aspose file tools
The moose likes Beginning Java and the fly likes 'class' or interface expected error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark " Watch " New topic
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
    
  11

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
    
  11

This answers my question
Clare Wright
Greenhorn

Joined: Jun 06, 2006
Posts: 11
Yip! You were exactly correct!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: 'class' or interface expected error
 
Similar Threads
Button trouble
Can't get an ActionListener to change a JLabel text
Urgent question . Please help
layout managers
scrollbars in a canvas-urgent