Fog Creek Software
Discussion Board




Swing JMenu thingy...

I've been trying to find a solution to this problem: i.e: get all the text  on my menu:  http://www.geocities.com/kzhiwei_2000/file-menu.gif  nicely aligned to increase readability.

I've tried adding spaces but the alignment is off and I hate ugly stuff.

Anybody care to give some help? Besides stuff like ditching Swing and switching to WxWindows? =)

Wei
Monday, January 13, 2003

Your link produced a 404, so I couldn't see what you meant. I've done plenty of GUI applications with JMenus, and I don't see any problem with the alignment.

John Webber
Monday, January 13, 2003

There's some junk at the end of the url which you should remove.  The proper link should be:
http://www.geocities.com/kzhiwei_2000/file-menu.gif

Apparently he wants all the text to line up properly.

Tj
Monday, January 13, 2003

How about having a completely transparent icon of the same size as your other icons for those menu items without displayable icons?

Yves
Monday, January 13, 2003

Geocities is fascinating, it will only show you a .gif if the referrer is from Geocities.

Anyway, there are two easy ways that strike me.  Unfortunately I don't have Gimp on this machine or even java 1.4, so I can't test this right now.

a) Put in blank (alpha 0) icons.  Then make the policy that all images must be cropped to the same size.

b) v1.4 has the JMenuItem.setIconTextGap(int) method.  You could enforce things so that whenever you add an item to the menu, it will set the gap between the icons and text, according to whatever item has the widest icon.

Please tell me if I'm not being clear.

Tj
Monday, January 13, 2003

Check this out and you will be enlightened.
Of course, you'll have to pay but it's worth the price.

http://www.jgoodies.com/products/index.html

Philippe Back
Monday, January 13, 2003

Even with a sample screenshot

http://www.jgoodies.com/freeware/looksdemo/images/looksdemo.png

Philippe Back
Monday, January 13, 2003

Tj: the link seems to work fine even at home now... hmmm strange. well anyway, yeah i wanted the text to line-up straight... that's the way it's done in commercial programs like Jcreator or .NET yah...

Yves/Tj: i think the alpha thingy is a great idea! i didn't think of it though... =)

Phillip: ah jgoodies is really good... i've seen it and oh my... it's the cost though... i've in my final diploma year and my team we're just attached out so cost is a factor... zero if possible if ya know what i mean... heh =)

Wei
Monday, January 13, 2003

*  Recent Topics

*  Fog Creek Home