🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Best way to auto-format buttons and such inside a JPanel.

#893
From: John McGrath [TeamB]
Date: Sun, 07 Nov 2004 23:52
25 lines
1957 bytes
On 11/6/2004 at 11:48:24 PM, Innominate Innominate wrote:

> I'm trying to add a number of simple Swing elements to a JPanel 
> that is using a GridLayout. When I add a JComboBox to the panel, 
> the box is sized so as to entirely fill its portion of the grid.
> Is there a setting I can make so that the box's size can be 
> determined, probably at runtime, in an appropriate way, given
> the font in use at the time?

A GridLayout always lays out each child component at the same size.
You could place a panel in the grid, and your component in the panel, 
so that the panel's layout would determine the size and placement of
the component within the grid cell.

You might also want to look at other layouts, such as GridBagLayout.  
It  has the features that you are asking for.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <xn0dphnkf8ocbk002@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <418da914$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,923035278953d9b1
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "John McGrath  [TeamB]" <ng-b@JPMcGrath.net>
Subject: Re: Best way to auto-format buttons and such inside a JPanel.
Newsgroups: borland.public.jbuilder.java.swing
References: <418da914$1@newsgroups.borland.com>
User-Agent: XanaNews/1.16.4.6
Message-ID: <xn0dphnkf8ocbk002@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:00000036
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 141.158.57.49
Date: 7 Nov 2004 16:52:29 -0700
X-Trace: newsgroups.borland.com 1099875149 141.158.57.49 (7 Nov 2004 16:52:29 -0700)
Lines: 25
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!border2.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail