| Author |
'class' or interface expected error
|
Clare Wright
Greenhorn
Joined: Jun 06, 2006
Posts: 11
|
|
Howdy, Would appreciate some help on the code below. I thought this error was brought on by missing braces etc - the compiler doesn't seem to like the Panel center = new Panel(); line. By importing java.applet.Applet I thought it would work fine. import java.awt.*; import java.applet.Applet; public class NestedPanels extends Applet { public NestedPanels () { Panel center = new Panel(); //error happening here // error is: 'class' or 'interface' expected Panel panel = new Panel(); center.setLayout(new BorderLayout()); center.add("South", new Button("south")); center.add("North", new Button("north")); center.add("East", new Button("east")); center.add("West", new Button("west")); center.add("Center", new Button("center")); Panel south = new Panel(); south.setLayout(new FlowLayout()); south.add(new Button("Help")); choice = new Choice(); choice.addItem("one"); choice.addItem("two"); choice.addItem("three"); choice.addItem("four"); choice.addItem("five"); south.add(choice); messageBar = new Label("This is a message bar."); south.add(messageBar); setLayout(new BorderLayout()); add("North", new Button("North")); add("East", new Button("East")); add("West", new Button("West")); add("South", south); add("Center", center); } protected Label messageBar; protected Choice choice; } Thanks.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Did you make a Panel.java file ? Maybe it conflicts with the API's Panel class. [ July 26, 2006: Message edited by: Satou kurinosuke ]
|
[My Blog]
All roads lead to JavaRanch
|
 |
Clare Wright
Greenhorn
Joined: Jun 06, 2006
Posts: 11
|
|
|
Found the problem. Ingeniously I had another Panel.java file in the directory - bad move I have learnt from this mistake.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
This answers my question
|
 |
Clare Wright
Greenhorn
Joined: Jun 06, 2006
Posts: 11
|
|
Yip! You were exactly correct!
|
 |
 |
|
|
subject: 'class' or interface expected error
|
|
|