Hello Group,
i need a little help here:
i have a JFrame with two buttons which are in JPanel1, what i want is
to put another JPanel2 in a JFrame on buttonAction, under the first
panel (JPanel1).
That second panel (JPanel2) have some buttons and textFields in it...
i try with :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
this.getContentPane().add(jPanel2);
pack();
setVisible(true);
}
i also try to put jPanel2 in some empty jPanel3 which is under jPanel1
on the JFrame with:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
jPanel3.add(jPanel2);
jPanel3.setVisible(true);
jPanel3.repaint();
}
but that doesn't work... any idea what shall i do...
thanks
Andrew Thompson - 04 Jul 2008 11:24 GMT
>...
> but that doesn't work... any idea what shall i do...
Try giving the codes amphetamines in their daily grit.
If that fails, I suggest posting an SSCCE.
<http://pscode.org/sscce.html>
> thanks
No worries.
--
Andrew Thompson
http://pscode.org/
RedGrittyBrick - 04 Jul 2008 15:07 GMT
> Hello Group,
> i need a little help here:
[quoted text clipped - 30 lines]
> but that doesn't work... any idea what shall i do...
> thanks
Post an SSCCE (http://sscce.org/)
In one application (an error dialogue with a "show details" button), I
add the second panel at the same time I add the first and just turn it's
visibility on or off. I also have to re pack() the container as I resize
the second panel to suit it's current contents.
It depends partly on what Layout Manager your JFrame's Content Pane is
using. Hence the need for an SSCCE.

Signature
RGB
caultonpos - 07 Jul 2008 06:47 GMT
> Hello Group,
> i need a little help here:
[quoted text clipped - 30 lines]
> but that doesn't work... any idea what shall i do...
> thanks
Here is what I would do
a) Take your frame
b) Add the 'parent' panel with BorderLayout
c) Add a Panel1 with constraint 'center'
d) On click add panel2 to the 'parent' panel with constraint 'south' -
maybe call revalidate on it