tags:

views:

74

answers:

3
A: 

Well, the menu width is automatically adjusted to the width of the longest text. Why would you want the menu to be wider than necessary?

If you must, you should be able to use setMinimumSize() to force a minimum width.

Michael Borgwardt
or for that matter, why should DOS ever need more than 640k of memory
Zak
I dont want to use numbers to achive this. i am looking for a layout solution.
iEisenhower
Why would you want the menu to be wider than necessary: if you look at windows all menu items have space around them. makes it look nicer.
iEisenhower
@Zak: that comparison makes more sense whatsoever. Letting the width auto-adjust does not impose a restriction on how wide it can get when necessary.
Michael Borgwardt
@ikurtz: if you look at windows, most menus have more entires, some of which are longer, thus the auto-adjusted width is larger. But the actual space before and after the longest entry is only slightly larger than in your app.
Michael Borgwardt
A: 

Menus as such looks good anyway. But if really need to have a hack, here it is Get ready for some real quick n dirty hack.

private static final SPACES="   ";
JMenu _Game = new JMenu(SPACES + "Game" + SPACES);
JMenuItem _New = new JMenuItem(SPACES + "New" + SPACES);
JMenuItem _Exit = new JMenuItem(SPACES + "Exit" + SPACES);
JMenu _Turn = new JMenu(SPACES + "Turn" + SPACES);
JMenuItem _Red = new JMenuItem(SPACES + "Red" + SPACES);
JMenuItem _Yellow = new JMenuItem(SPACES + "Yellow" + SPACES);
ring bearer
i posted this solution above already!
iEisenhower
A: 

EDIT: Solved!

JMenuItem _New = new JMenuItem("New        "); 

just add spaces as needed! simple.

this is a hack and not a pretty one but havent come across others yet.

iEisenhower