🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

stop a JComboBox from resizing?

#11442
From: Nick Jones
Date: Tue, 01 Jun 1999 00:00
25 lines
1701 bytes
I have a JComboBox in a GridBagLayout and I want to stop it from
resizing when I dynamically add large strings to its item list.

I tried overwriting the setBounds method so that the width could only be
set within an arbitrary limit, but I found that the popup list would
still expand to accommodate the full length of the new item, thus
messing up the appearance of my gui (although the string item would be
truncated and have ellipsis added, the width of the popup would still be
large enough to accommodate the untruncated string)

I altered my list renderer to only resize to an arbitrary limit and it
appeared to work : the combo box and the popup would correctly truncate
their strings and would appear to have a normal width.   But as soon as
I added a large string to the list of selection items, the GridBagLayout
that the combo box sat in would expand to the size of the 'imaginary
full width' popup, although the combo box and its visible popup were the
desired width.

I was wondering : Is there any way that I can control the width of the
combo box and its popup so that adding new items will not cause it to
expand the GridBagLayout column?

Thanks!

  Nick
Technical Details
Message-ID: <37530AFA.AEEEDDF4@alchemy.co.nz>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e67d828bd505966d,start
X-Google-Attributes: gid111d45,public
From: Nick Jones <n.jones@alchemy.co.nz>
Subject: stop a JComboBox from resizing?
Date: 1999/06/01
Message-ID: <37530AFA.AEEEDDF4@alchemy.co.nz>
X-Deja-AN: 484231320
Content-Transfer-Encoding: 7bit
Organization: Alchemy Group Limited
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing