Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane and JMenuBar are incompatible?

 
Rick Gentry
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a JFrame with a JScrollPane set as its container. After I do that my JMenuBar will no longer pull down it's menus. Are they incompatible or is there something I've overlooked?
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though in the example is not shown. Are you adding any awt component to the JScrollPane?
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shouldn't be a problem. Does it work if you comment out the :
frame.setContentPane(new JScrollPane());
line ?
 
Rick Gentry
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose, yes, I've got a bunch of stuff in the scrollpane that shows up just fine. There's so much that it takes up the entire frame minus the menubar and requires a scrollpane to fit all of it. Hence my choice of using a scrollpane.
Don, yeah it worked fine before I put in the scroll pane. I've got a suspision (sp?) that the menus are pulling down behind the scrollpane. I can click on them and they select as they're susposed to but the menu isn't there.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there are heavyweight components inside the JScrollPane they will overlap the expanded lightweigth menus.
 
Rick Gentry
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how do I fix that so that the menu's are heavier?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this fixes it - add this code at the beginning of your application:



This makes all popup menus use heavyweight components, so they will appear above any other heavyweight components you may be using.

(And check out the article - "Mixing Heavy and Light Components")
 
Rick Gentry
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you thank you thank, that's beautiful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic