Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenuItem with Null Layout  RSS feed

 
Garrett Damato
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I want to say I accidentally hit "resolved" and this is not yet resolved :/ . I'm making my first ever applet and everything was going well until I tried making JMenuItems with a Null Layout. I need to make it so when you click on file,edit, or help, a bar comes down with the Menu Items on it (like the top of the screen when google chrome is open). Any help is appreciated Heres my Code:



 
Campbell Ritchie
Sheriff
Posts: 53742
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have taken the resolved flag off (I think ‍).
I shall go back and edit your code to add code tags and get rid of any lines too long and won't it look better

Why are you using null layouts? Why are you using applets? Nobody else uses them any more. I am not quite sure you have told us what the problem is. What happens and what did you want to happen?
You have put the setVisible method too early; move it to the very last line of the constructor. Don't use add for menu bars. Use the setJMenuBar method instead.

You say your class extends JApplet but you haven't used the applet‑specific methods like init.
 
Campbell Ritchie
Sheriff
Posts: 53742
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't add menu items to the frame or panel. Add them to a menu and add the menu to the menu bar. Read this part of the Java® Tutorials.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!