Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2008

Tip: Looking for answers? Try searching our database.

JPanel in a JFrame???

Thread view: 
Luka - 04 Jul 2008 10:22 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.