🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JFrame default size

#9533
From: Paul Furbacher [TeamB]
Date: Thu, 09 Mar 2000 00:00
26 lines
1860 bytes
Steve Davis wrote:
> 
> I have a simple application that was created using the Application Wizard.
> It has one JFrame that uses XYLayout.  When I first created the application,
> I set the frame size in XYLayout to be (300,300), and the application ran
> fine (Frame opened with size 300,300).  Now that I have added a few
> components, the Frame is opening with a size of (0,0) when I start the
> application.  I can get around this problem by using the statement
> "frame.setSize(300,300)" after the statement "frame.setVisible(true)" in the
> application constructor.  But I should not have to do this, and the initial
> application worked correctly.
> 
> Has anyone else encountered this problem and know how to fix it, since the
> frame opened fine before I started adding components?

You want to call "frame.pack()" prior to calling "frame.show()".

Then, soon after that, you'll want to start becoming familiar with
layout managers -- most importantly, GridBagLayout.  It's tough, 
but by becoming proficient using the GridBagLayout (and never
using the XYLayout except when initially placing components onto
a panel) you will save tons of headaches later, and may even get
compliments for nice looking panels and frames. 


Paul Furbacher (TeamB)
Technical Details
Message-ID: <38C7CA48.53834431@home.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8a3n1q$5474@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c93b64284dafe2d7
X-Google-Attributes: gid111d45,public
From: "Paul Furbacher [TeamB]" <pnf@home.com>
Subject: Re: JFrame default size
Date: 2000/03/09
Message-ID: <38C7CA48.53834431@home.com>
X-Deja-AN: 595204445
Content-Transfer-Encoding: 7bit
References: <8a3n1q$5474@bornews.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Reply-To: pnf@home.com
Newsgroups: borland.public.jbuilder.java.swing