🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#900
From: Innominate Twice
Date: Mon, 15 Nov 2004 03:35
29 lines
2365 bytes
"John McGrath  [TeamB]" <ng-b@JPMcGrath.net> wrote in message news:<xn0dphnkf8ocbk002@newsgroups.borland.com>...
> 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.

Okay, I added a Grid layout, with 2 columns to my panel. Then I added
JPanels to 6 grid areas and a GridBag layout to each. To test this, I
added a JComboBox to a few of the panels. The combo box formatted
nicely w/o any difficulty and appeared the same when I executed the
program as it did when I designed it.

Thank You. I've been hearing about GridBag layouts and that they
should be used with nested layouts but I also heard that they were
difficult for beginners to work with. This is encouraging.

Thanks again,
Technical Details
Message-ID: <7fa560d5.0411141935.2a0d9568@posting.google.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail
References: <418da914$1@newsgroups.borland.com> <xn0dphnkf8ocbk002@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
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail
From: innominatetwice@yahoo.com (Innominate Twice)
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Best way to auto-format buttons and such inside a JPanel.
Date: 14 Nov 2004 19:35:06 -0800
Organization: http://groups.google.com
Lines: 29
Message-ID: <7fa560d5.0411141935.2a0d9568@posting.google.com>
References: <418da914$1@newsgroups.borland.com> <xn0dphnkf8ocbk002@newsgroups.borland.com>
NNTP-Posting-Host: 24.168.64.28
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1100489707 15168 127.0.0.1 (15 Nov 2004 03:35:07 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 15 Nov 2004 03:35:07 +0000 (UTC)