• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MenuBar & Listener Compile errors

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
It helps a lot!!
I see my problems.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic