aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes MenuBar & Listener Compile errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MenuBar & Listener Compile errors" Watch "MenuBar & Listener Compile errors" New topic
Author

MenuBar & Listener Compile errors

capp luckett
Ranch Hand

Joined: Dec 07, 2000
Posts: 33
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 ===


flodin
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Dec 07, 2000
Posts: 33
Thanks.
It helps a lot!!
I see my problems.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MenuBar & Listener Compile errors