This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

MenuBar & Listener Compile errors

 
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 ===

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!