Article View: borland.public.jbuilder.java.swing
Article #7979Re: JPanel and BoxLayout
From: Greg Hamer
Date: Fri, 17 Nov 2000 00:00
Date: Fri, 17 Nov 2000 00:00
99 lines
4441 bytes
4441 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_0060_01C050AB.B6087090
Content-Type: text/plain;
charset="big5"
Content-Transfer-Encoding: quoted-printable
I think that you can use the method Container.add(Component,int) method =
that takes the component and its index. The index would be the position =
at which to insert the component. So to add 'b' between an existing 'a' =
and 'c' would be panel.add(b,1);
"Betty" <cutepang@net.polyu.edu.hk> wrote in message =
news:39D7049B.41D3CF38@net.polyu.edu.hk...
Here is my pseudo code...Construct the Layout=20
JPanel panel =3D new JPanel();=20
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_Axis));=20
JButton a =3D new JButton("A");=20
JButton b =3D new JButton("B");=20
JButton c =3D new JButton("C");=20
panel.add(a);=20
panel.add(b);=20
panel.add(c);=20
-------------------------------------------=20
In my program, I allow user to remove button from the Panel thru' some =
selecting in the comboBox.=20
I know how to remove Button from the Panel and I can add back the =
button into the panel.=20
However, if my panel have Button A and Button C, I want to add the =
Button B between Button A and Button C.=20
I don't know how to do it. I have tried to remove the Button C and =
add the Button B and C but it doesn't work.=20
In my JPanel, I must use the BoxLayout, how can I add a button B =
between Button A and Button C.=20
Thanks=20
Betty=20
=20
=20
=20
=20
=20
------=_NextPart_000_0060_01C050AB.B6087090
Content-Type: text/html;
charset="big5"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dbig5" http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I think that you can use the method=20
Container.add(Component,int) method that takes the component and its =
index. The=20
index would be the position at which to insert the component. So to add =
'b'=20
between an existing 'a' and 'c' would be panel.add(b,1);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV>"Betty" <<A=20
=
href=3D"mailto:cutepang@net.polyu.edu.hk">cutepang@net.polyu.edu.hk</A>&g=
t;=20
wrote in message <A=20
=
href=3D"news:39D7049B.41D3CF38@net.polyu.edu.hk">news:39D7049B.41D3CF38@n=
et.polyu.edu.hk</A>...</DIV><B>Here=20
is my pseudo code...Construct the Layout</B> <BR>JPanel panel =3D new =
JPanel();=20
<BR>panel.setLayout(new BoxLayout(panel, BoxLayout.Y_Axis)); =
<BR>JButton a =3D=20
new JButton("A"); <BR>JButton b =3D new JButton("B"); <BR>JButton c =
=3D new=20
JButton("C"); <BR>panel.add(a); <BR>panel.add(b); <BR>panel.add(c);=20
<BR>------------------------------------------- <BR>In my program, I =
allow=20
user to remove button from the Panel thru' some selecting in the =
comboBox.=20
<BR>I know how to remove Button from the Panel and I can add back the =
button=20
into the panel. <BR>However, if my panel have Button A and Button C, I =
want to=20
add the Button B between Button A and Button C. <BR>I don't know how =
to do=20
it. I have tried to remove the Button C and add the Button B and =
C but=20
it doesn't work. <BR>In my JPanel, I must use the BoxLayout, how can I =
add a=20
button B between Button A and Button C.=20
<P>Thanks <BR>Betty <BR> <BR> <BR> <BR> =
<BR> =20
</P></BLOCKQUOTE></FONT></DIV></BODY></HTML>
------=_NextPart_000_0060_01C050AB.B6087090--
Technical Details
Message-ID:
<3a15c051$1_2@dnews>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<39D7049B.41D3CF38@net.polyu.edu.hk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,84cd158c560f7f30,start X-Google-Attributes: gid111d45,public From: "Greg Hamer" <ghamer@troikanetworks.com> Subject: Re: JPanel and BoxLayout Date: 2000/11/17 Message-ID: <3a15c051$1_2@dnews> X-Deja-AN: 694930398 References: <39D7049B.41D3CF38@net.polyu.edu.hk> Content-Type: multipart/alternative; boundary="----=_NextPart_000_0060_01C050AB.B6087090" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Trace: 17 Nov 2000 15:33:37 -0800, 12.31.172.193 MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing