File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JScrollPane and JMenuBar are incompatible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane and JMenuBar are incompatible?" Watch "JScrollPane and JMenuBar are incompatible?" New topic
Author

JScrollPane and JMenuBar are incompatible?

Rick Gentry
Ranch Hand

Joined: Dec 14, 2002
Posts: 63
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

Joined: Jul 03, 2001
Posts: 2120
Though in the example is not shown. Are you adding any awt component to the JScrollPane?


SCJP2. Please Indent your code using UBB Code
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
shouldn't be a problem. Does it work if you comment out the :
frame.setContentPane(new JScrollPane());
line ?
Rick Gentry
Ranch Hand

Joined: Dec 14, 2002
Posts: 63
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

Joined: Jul 03, 2001
Posts: 2120
If there are heavyweight components inside the JScrollPane they will overlap the expanded lightweigth menus.
Rick Gentry
Ranch Hand

Joined: Dec 14, 2002
Posts: 63
So how do I fix that so that the menu's are heavier?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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")


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Rick Gentry
Ranch Hand

Joined: Dec 14, 2002
Posts: 63
Thank you thank you thank, that's beautiful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JScrollPane and JMenuBar are incompatible?