Problem with Java panels

Discussion in 'Java' started by Lukasz Huculak, May 19, 2004.

  1. I want to write application with few tabbed panels each with split
    panel inside. Some of those split panels should share the same panel
    as in code below.
    //----------------//
    JTabbedPane tabbed = new JTabbedPane();

    JSplitPane split1 = new JSplitPane();
    JSplitPane split2 = new JSplitPane();

    JPanel panel1 = new JPanel()
    JPanel panel2 = new JPanel();
    JPanel panel3 = new JPanel();

    split1.setLeftComponent(panel1);
    split1.setRightComponent(panel2);

    split2.setLeftComponent(panel2);
    split2.setRightComponent(panel3);

    tabbed.addTab("1",split1);
    tabbed.addTab("2",split2);
    //------------------------//

    Unfortunately in split1 panel I cannot see panel2 but only panel1. In
    split2 panel it all works fine. Why it doesn't work?

    --
    Lukasz Huculak
    Lukasz Huculak, May 19, 2004
    #1
    1. Advertising

  2. Lukasz Huculak wrote:

    > I want to write application with few tabbed panels each with split
    > panel inside. Some of those split panels should share the same panel
    > as in code below.
    > //----------------//
    > JTabbedPane tabbed = new JTabbedPane();
    >
    > JSplitPane split1 = new JSplitPane();
    > JSplitPane split2 = new JSplitPane();
    >
    > JPanel panel1 = new JPanel()
    > JPanel panel2 = new JPanel();
    > JPanel panel3 = new JPanel();
    >
    > split1.setLeftComponent(panel1);
    > split1.setRightComponent(panel2);
    >
    > split2.setLeftComponent(panel2);
    > split2.setRightComponent(panel3);
    >
    > tabbed.addTab("1",split1);
    > tabbed.addTab("2",split2);
    > //------------------------//
    >
    > Unfortunately in split1 panel I cannot see panel2 but only panel1. In
    > split2 panel it all works fine. Why it doesn't work?
    >


    You can't add the same component (in your case panel2) to different
    containers (split1 and split2) at the same time. From the moment you add
    panel2 to split2, it is removed from split1.

    --
    Kind regards,
    Christophe Vanfleteren
    Christophe Vanfleteren, May 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Nunciato

    Problem with Validation Using Panels

    Chris Nunciato, Jul 1, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    325
    Chris Nunciato
    Jul 1, 2003
  2. Chad A. Beckner
    Replies:
    2
    Views:
    565
    Chad A. Beckner
    Jun 18, 2004
  3. Eva
    Replies:
    1
    Views:
    318
    Andrew Thompson
    Jan 21, 2005
  4. Replies:
    2
    Views:
    416
  5. Andrea Gasperi

    AjaxControlToolkit problem with modal panels

    Andrea Gasperi, Nov 18, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    328
    Allen Chen [MSFT]
    Nov 27, 2008
Loading...

Share This Page