Forums Register Login

JMenuItem text problem

+Pie Number of slices to send: Send
Hello there,

I have a JMenuBar, with several JMenu's containing JMenuItem's.

As an example...

Save________S
Close________C
Exit_________F1

I will have spaces though, not underscores.
I'm struggling to get the letters to line up with the Font I'm using.
Not sure which one it is.

I can solve this using Monospaced Font, but it looks bad, and I would rather avoid it.
Is there another way I can get all the words lined up to the left, and the keys representing them lined up to the right?

Thanks for any help

[ August 28, 2007: Message edited by: colin shuker ]
[ August 28, 2007: Message edited by: colin shuker ]
+Pie Number of slices to send: Send
Arent you using Mnemonics and Accelerators? In that case you dont need to explicitly do the alignment.
+Pie Number of slices to send: Send
Wow...

Didn't know you could do that, thanks

I looked briefly at the methods in JMenuItem, I must have overlooked this setAccelerator method.

The great thing is... I don't need to use KeyListener's or KeyBinding's,
the key presses will just automatically link the to JMenuItems action.
This is a much better way of doing it, I'm glad I asked now.

Thanks
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 759 times.
Similar Threads
Crazy Tables
help needed with jsp:getProperty
problem with spacing of text in JTextArea
Access Counts in JSP
HTML might not be in right section??
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:14:59.