• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenuBar object not visible in JFrame

 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I' currently wrking on BeatBox application from Head First Java. I made a jpanel the pane of the frame & when i try to add a JMenuBar object to that it is not getting displayed when i run the code.
When i add a menuBar directly to the JFrame object it is visible & working fine but not incase when added to JPanel.

 
Tom Storm
Ranch Hand
Posts: 31
IntelliJ IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I haven't run the code but the way you add a menu bar is with setJMenuBar and not with add. I think it should be background.setJMenuBar(menubar);
Hope it helps.
 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tom .. I dint just noticed that i made that silly mistake....
 
Tom Storm
Ranch Hand
Posts: 31
IntelliJ IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!