Article View: borland.public.jbuilder.java.swing
Article #239Re: Swing Problem
From: Paul Nichols[TeamB]
Date: Sat, 10 Mar 2007 23:34
Date: Sat, 10 Mar 2007 23:34
36 lines
2363 bytes
2363 bytes
marcellovin.martinelli@gmail.com wrote:
> no layout
> i add components in this way
> jPanel.add(component_name,null);
>
> and then sets position with
> component_name.setBounds(x,y,width,height);
>
> that's way changing screen resolution all mess:P
>
> thx for your tip :p
>
Yes, this will NEVER work. Resolutions and screens change dramatically
across different Operating Systems. They even change on the same OS with
different video cards and screen resolutions.
You need to use a layout manager, if you want an XPlatform application.
Which one you use is up to you, but for most, I generally follow the
following pattern.
Frame Layouts: Layout type BorderLayout
JPanel1 added to frame as BorderLayout.NORTH
JPanel2 added to frame as BorderLayout.CENTER
JPanel3 added to fram as BorderLayout.SOUTH
Inside JPanel1, add another Panel. Set it to GirdBagLayout, You can
design using null for layoyt, but change the inner panel to JPanel1 to
GridbagLayout internally. This way the JPanel1 will retain NORTH
Locations within the ContentPane of the JFrame.
Do the same for all other Panels. This makes your application or applet
pretty portable across platforms. Easy to say, hard to teach online.
Look as Paul F. stated at the Layout Tutorials.
Technical Details
Message-ID:
<45f3405d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<1173199960.373362.108200@n33g2000cwc.googlegroups.com> <45f1f240$1@newsgroups.borland.com> <1173550242.640624.75120@30g2000cwc.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,aa9305e806396af8 X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 10 Mar 2007 18:34:21 -0500 From: "Paul Nichols[TeamB]" <paul@comp.net> User-Agent: Thunderbird 1.5.0.9 (X11/20070104) MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing Subject: Re: Swing Problem References: <1173199960.373362.108200@n33g2000cwc.googlegroups.com> <45f1f240$1@newsgroups.borland.com> <1173550242.640624.75120@30g2000cwc.googlegroups.com> In-Reply-To: <1173550242.640624.75120@30g2000cwc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 76.97.213.175 Message-ID: <45f3405d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1173569629 76.97.213.175 (10 Mar 2007 15:33:49 -0800) Lines: 37 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail