Results 1 to 3 of 3

Thread: zorder

  1. #1
    aznboarder is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default zorder

    Hello,

    I have two components in a JFrame that I want to switch between by using the getContentPane().setComponentZOrder. I have a button on each component where the onclick ActionEvent is to pull the other Component to the top, so when I'm viewing component1, I call getContentPane().setComponentZOrder(component2, 1) when I click the button. However, this doesn't bring component2 to the top, it actually doesn't do anything. I tried setting component0 to 0, and component2 to 1, but that doesn't work either. I also tried calling the repaint() method on the contentpane, and that doesn't do anything either.

    Setting the zorder on the component should move the components back and forth right? Am I doing something wrong??

    Java Code:
        private void analyzeButtonAction(ActionEvent actionEvent) 
        {
        	getContentPane().setComponentZOrder(_createDatasetComponent, 0);
        	getContentPane().setComponentZOrder(_testLabel, 1);
        	getContentPane().repaint();
        }

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

    Default

    Are you sure that you don't want to use a CardLayout here? This would allow you to easily swap components without fuss.

  3. #3
    aznboarder is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

Posting Permissions

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