tags:

views:

83

answers:

2

In my app, I've got a menu bar with a File menu. In the submenus, each JMenuItem is wasting a lot of white space to the left of the text for a checkbox (I think), even though I'm not including any JCheckBoxMenuItems.

I'm seeing lots of other java/swing apps who's menus don't waste this space. How do I do it in my app?

Menu screen shot

A: 

This may be a default for your chosen UIManager Look and Feel (L&F). You could try using put() to change it. This handy UIManager Defaults tool shows the effect of disparate Menu.margin values in various L&Fs.

trashgod
A: 

The issue is that the menu UI is deliberately lining up the text of all of your menu items. If none of your menu items had icons nor checkboxes, then none of them would have any space on the left for icons or checkboxes, either.

Personally, I wouldn't want to change this. If you did figure out a way get rid of the "wasted space" next to your menu items that don't have icons, then your menu would have a jagged appearance. If you changed this, then someone reading the menu would have to adjust to the fact that the left-hand baseline keeps changing as their eyes move down the menu list.

So, my advice would be either to get rid of all the icons or just to be happy that all of the menu items' text labels are vertically aligned with one another.

Joe Carnahan