Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MenuBar & Listener Compile errors

 
capp luckett
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
Could anyone give me a had with 4 compile errors, please.
I think 144 has to do with "{" being out of place but could
not find it. I think that 123 errors because I am not extending
JFrame but I might be able to do a MyFrame.setJMenuBar..., ?
Thanks
Capp
======= errors ===
MyBar.java:144: ';' expected
Class MenuListenerClass implements ActionListener
^
MyBar.java:123: cannot resolve symbol
symbol : method setJMenuBar (javax.swing.JMenuBar)
location: class MyBar
setJMenuBar(menuBar); //set the meubar for the JFrame
^
MyBar.java:125: cannot resolve symbol
symbol : class MenuListenerClass location: class MyBar
MenuListenerClass themenus = new MenuListenerClass(this);
^
MyBar.java:125: cannot resolve symbol
symbol : class MenuListenerClass
location: class MyBar
MenuListenerClass themenus = new MenuListenerClass(this);
^
==== errors end ===

 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Capp,
I don't really know what you are trying to do but it looks terrible. The first error is easy to fix because "Class" is not a reserved word in java but "class" is. If you are coming from a Windows background keep in mind that Java is case sensitive just like UNIX is.
You seem to be creating a customized MenuBar. If that is the case then you can't use setJMenuBar from inside of it. That method is to be used by the JFrame that wants to use your customized MenuBar. That means that in your code the call should be moved to your main method:
myframe.setJMenuBar( new MyBar() );
Another error you have is that you are trying to call your constructor from within an actionPerformed method. In java you can't directly call any constructor you must use the new operator.
This is where I get lost because why would a MenuListener want to keep creating new MenuBars everytime any menu item is chosen?
Regards,
Manfred.
 
capp luckett
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
It helps a lot!!
I see my problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic