Article View: borland.public.jbuilder.java.swing
Article #12251An interesting menu Challenge
From: kerbel
Date: Fri, 05 Feb 1999 00:00
Date: Fri, 05 Feb 1999 00:00
30 lines
1553 bytes
1553 bytes
Here is an interesting question about effective menu display in Swing: I am trying to display a list of menu items with their corresponding descriptions on the right hand side of the menu. The problem is how to align the descriptions on the right hand side. I cannot seem to find any method which lets you align subsections of a JMenuItem in Swing, so I've adopted the following method: * get the string width (using FontMetrics) of the longest item * loop through all the menu items and while the length of the LHS OF each one is less than the length of the longest one - pad it with spaces. This gives me a pretty good display, however, the right hand descriptions are not 100% aligned as it's not an exact technique. I'm trying to display something like: Menu ITEMA DescripA ITEMB DescripB ITEMC DescripC Can anyone come up with a more effective solution? TIA Uri Kerbel -- uri@kalbi.demon.co.uk www.kalbi.demon.co.uk (Java applets/utilities) --
Technical Details
Message-ID:
<36baec13.15061669@news.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,2343da4b71e3228d,start X-Google-Attributes: gid111d45,public From: kerbel@kalbi.demon.co.uk Subject: An interesting menu Challenge Date: 1999/02/05 Message-ID: <36baec13.15061669@news.demon.co.uk> X-Deja-AN: 440978362 X-NNTP-Posting-Host: kalbi.demon.co.uk:158.152.128.133 X-Trace: news.demon.co.uk 918220149 nnrp-06:19347 NO-IDENT kalbi.demon.co.uk:158.152.128.133 Reply-To: kerbel@kalbi.demon.co.uk Newsgroups: borland.public.jbuilder.java.swing X-Complaints-To: abuse@demon.net