Results 1 to 3 of 3
Thread: zorder
- 03-28-2009, 02:24 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
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(); }
-
Are you sure that you don't want to use a CardLayout here? This would allow you to easily swap components without fuss.
- 03-30-2009, 06:55 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks