The Artima Developer Community
Sponsored Link

Java Answers Forum
beginner's problem

3 replies on 1 page. Most recent reply: Apr 7, 2003 2:27 PM by Anil

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
johnny

Posts: 2
Nickname: drinker
Registered: Apr, 2003

beginner's problem Posted: Apr 6, 2003 8:14 PM
Reply to this message Reply
Advertisement
Dear all,

i'm a junior java programmer,
and i get a programming problem occur in compile time,
the program has two file call fatherFrame.java and
sonFrame, these file as follow:
/*
fatherFrame.java
*/
import javax.swing.*;

public class fatherFrame {
JFrame f = new JFrame("father");

fatherFrame() {
sonFrame cf = new sonFrame();

f.setSize(640, 480);
f.getContentPane().setLayout(null);
f.getContentPane().add(cf);

f.show();
}
public static void main(String[] args) {
fatherFrame runMain = new fatherFrame();
}
}

/*
sonFrame.java
*/
import javax.swing.*;

public class sonFrame {
sonFrame() {

JInternalFrame cf = new JInternalFrame("son",false,true,false,true);
cf.setSize(300,300);

cf.show();
}
}

error message:
fatherFrame.java:11: cannot resolve symbol
symbol : method add (sonFrame)
location: class java.awt.Container
f.getContentPane().add(cf);
^
my java compile is 1.4 and how to solve this problem?
thank you


Johnny


Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: beginner's problem Posted: Apr 6, 2003 10:30 PM
Reply to this message Reply
Why don't you have both the programs into "Packages" and then import sonFrame into the fatherFrame. Which should solve your problem

johnny

Posts: 2
Nickname: drinker
Registered: Apr, 2003

Re: beginner's problem Posted: Apr 7, 2003 2:08 AM
Reply to this message Reply
Why bundle with compiler the demo program doesn't
use import?

Anil

Posts: 1
Nickname: boney
Registered: Apr, 2003

Re: beginner's problem Posted: Apr 7, 2003 2:27 PM
Reply to this message Reply
add method of java.awt.Container requires argument of type Component . If your sonFrame class extends java.awt.Component the compilation problem should be solved.

Flat View: This topic has 3 replies on 1 page
Topic: Console mode clear screen... Previous Topic   Next Topic Topic: java GUI

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use