• 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

menu behaviour when resizing windows in Swing

 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found it on sun's bug parade
http://developer.java.sun.com/developer/bugParade/bugs/4099794.html
 
Normally trees don't drive trucks. Does this tiny ad have a license?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic