• Post Reply Bookmark Topic Watch Topic
  • New Topic

frame.setMenuBar(mb);  RSS feed

 
Urs Waefler
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have two very simple files. This is the source code:

1)

import java.awt.*;

public class EinfacheGui{

public static void main (String[] args){

Frame frame = new Frame("Urs");
frame.setSize(300,300);
frame.setVisible(true);
frame.setMenuBar(mb);

}
}

2)

import java.awt.*;

class MenuBarX{

MenuBar mb = new MenuBar();

}

I can not compile the EinfacheGui.java. I get this message:
cannot find symbol
symbol variable mb
...

I understand the message. But how can I solve this problem?

Urs
 
Campbell Ritchie
Sheriff
Posts: 55366
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have declared the mb variable in the MenuBarX class and tried to use it in the EinfacheGui class.

Suggest you add a get method to the MenuBarX class; then you can say
"frame.setMenuBar(new MenuBarX.getMB());"

It seems a rather roundabout way to set up a MenuBar. And why aren't you using Swing?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!