🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#901
From: Inominate Inominate
Date: Tue, 16 Nov 2004 02:02
32 lines
2512 bytes
John McGrath [TeamB] wrote:
> 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: <41995fb6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.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
Date: Mon, 15 Nov 2004 21:02:32 -0500
From: Inominate Inominate <innominatetwice@_no_spam_yahoo.com>
Reply-To:  innominatetwice@_no_spam_yahoo.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Best way to auto-format buttons and such inside a JPanel.
References: <418da914$1@newsgroups.borland.com> <xn0dphnkf8ocbk002@newsgroups.borland.com>
In-Reply-To: <xn0dphnkf8ocbk002@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.168.64.28
Message-ID: <41995fb6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100570550 24.168.64.28 (15 Nov 2004 18:02:30 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail