• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

menu behaviour when resizing windows in Swing

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hoping to get some suggestions or pointers.
How do I make the menubar behave like MS windows fashion, when the window is resized. Perhaps one of the following behaviour.
1. A scroll arrow thing appears, if all the menus cannot be displayed - IE
2. The menu's wrap into the next row - Visual InterDev, Notepad
3. or even, only the left-most menus are displayed, if there is not enough room.
I have looked at Javadocs and java sources, the only way seems to be to pass the menubar your own layout manager object(GridbagLayout is probabely most appropriate), but that is gonna be a bit of a hassle, i want to leave that as the last choice.
Would Eclipse's SWT library be better at this kind of thing?
thanks
Sandeep
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this code will place the menus starting on the left side. each item will keep its size even when the window is resized. the right most menus will disappear if the window gets to small.

how to make the JMenuBar have more lines or diplay a scrollpane want work without subclassing it, I think. at least not the scrollpane solution as JFrame wants a JMenuBar as argument.
chantal
[ October 17, 2002: Message edited by: Chantal Ackermann ]
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chantal,
Unfortunately, that did not solve my problem. If i set the layout to FlowLayout, it messes up the appearance of the menubar(The bottom border does not appear properly), and leaves too much space between menus(even when i specify the horizontal gap to be 0).
I might have to look at subclassing one of the classes in javax.swing.plaf.basic that provide the UI to a menubar.
sunny
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found it on sun's bug parade
http://developer.java.sun.com/developer/bugParade/bugs/4099794.html
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic