Results 1 to 3 of 3
  1. #1
    uzipaz is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Default a jpanel within a jpanel

    Hello everyone,
    I have a desktop application project in which I added buttons with functionalities to it. So, they all are contained in a single JPanel, now whenever I push a certain, I have a further data to gather from the user, In that JPanel where the button is located, I have inserted another JPanel where I want my respective fields to be displayed according to the button I pressed in the main JPanel.....

    Now, my problem is that I cannot get to display that inner JPanel that I have made separately as a class,
    In my main JPanel where my buttons are located I have written an 'actionPerformed' function for that button so that I can add the respective new JPanel...
    Java Code:
    EditProfile editprofile = new EditProfile(); // editprofile is the JPanel I want to add in the main JPanel
    editprofile.setVisible(true);
    this.innerPanel.add(editprofile); // innerpanel is the panel where my respecitve panels that I want to add will be displayed
    this.innerPanel.validate();
    this.innerPanel.repaint();
    this.validate(); // this is the Panel where my buttons are located
    this.repaint();
    When I execute the code, and click on the respective button, the inner JPanel(EditProfile) does'nt display itself....
    Can someone help me what I am doing wrong here???
    Thanks for the help.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: a jpanel within a jpanel

    This is possibly a layout issue -- that you're adding the new component to a container whose layout doesn't play nice with adding things like this -- but it's difficult to tell based on what you've posted. Better to create a small compilable and runnable program that demonstrates your problem, an SSCCE, and posting it here.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: a jpanel within a jpanel

    Also, there's no rule against using correct capitalization in the subject line. Please do so in future.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Change JPanel text of Parent JPanel from JDialog
    By bikashlama in forum AWT / Swing
    Replies: 7
    Last Post: 12-09-2011, 03:47 AM
  2. Adding a jpanel to a customized Jpanel Class
    By trishtren in forum AWT / Swing
    Replies: 7
    Last Post: 04-05-2011, 06:52 PM
  3. Placing a new JPanel over a paint overriden JPanel
    By Tanshaydar in forum AWT / Swing
    Replies: 4
    Last Post: 12-08-2010, 06:00 PM
  4. Replies: 3
    Last Post: 04-20-2009, 11:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •