🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1105

Re: How to set width of JMenuItem on JMenuBar

#1105
From: John T. Dow
Date: Fri, 26 Mar 2004 20:16
37 lines
2375 bytes
pnichols wrote:
> John T. Dow wrote:
> 
> 
>>I posted this to the ide group but have received no answer. It's
>>possibly a swing question anyway.
>>
>>I need a menu choice on the default menu bar which when selected doesn't
>>cause a submenu to drop down but triggers its action immediately.
>>
>>The problem I'm having when I put a jMenuItem (not a jMenu) on the menu
>>bar is it is much wider than the other things on the bar, all of which
>>are jMenu.
>>
>>I don't see how to control the width of a jMenuItem on the bar.
>>
>>What am I missing?
>>
>>John
> 
> 
> It should auto-adjust to the font and text you are using.

No, it's much wider than it should be. (Following the text is a lot of 
empty space, all of which can be clicked with the mouse to trigger the 
action.)

I suspected that the menu item is looking at everything else on the bar 
and making itself just as wide as the widest (because menu items should 
be on menus, one above another), but that's not the case. It's much 
wider than any of the other menus on the bar.

Although it doesn't look good, it does what I want. Namely, click on it 
and the action is performed.

Perhaps another approach is to add a menu and then override its action, 
which is to do a popup menu.
Technical Details
Message-ID: <40648F8F.6050704@johntdow.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <406485B5.5090909@johntdow.com> <40648c35@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,318be48f988251ce
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2004-03-26 12:28:33 PST
Message-ID: <40648F8F.6050704@johntdow.com>
Date: Fri, 26 Mar 2004 15:16:15 -0500
From: "John T. Dow" <john@johntdow.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: How to set width of JMenuItem on JMenuBar
References: <406485B5.5090909@johntdow.com> <40648c35@newsgroups.borland.com>
In-Reply-To: <40648c35@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 4.15.244.46
X-Trace: newsgroups.borland.com 1080332188 4.15.244.46 (26 Mar 2004 12:16:28 -0800)
Lines: 38
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail