• 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

JMenuItem with Null Layout

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:



 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic