problems with a cardlayout.

S

steve

Hi,

I have a jframe that adds a jpanel.

the jpanel holds a number of buttons at the bottom.
and above them a jpanel ,that is set to card layout.

final static String DISPLAYPANEL = "DispayNotes";
final static String EDITPANEL = "EditNotes";
JPanel container = new JPanel(new CardLayout());
JPanel Card1Root = new Card1();
JPanel Card2Root = new Card2();


in my init code i have

container.add(Card1Root, DISPLAYPANEL);
container.add(Card2Root, EDITPANEL);
this.setLayout(flowLayout1);
this.add(container, null);
this.add(buttonbox, null);


the switch cod is:

void showthecaf() {
// Card1Root.setVisible(false);
CardLayout cl = (CardLayout) (container.getLayout());

cl.show(container, EDITPANEL); //flip to the new screen
}

the problem is that whenever i switch to the second card, if i deselect the
window & reselect it
or drag another window over it,
then card 1 shows thru as well as card 2
if i then slightly re-size the window, then the display "rights" it's self
again.

but card 2 never shows thru on card 1.


the cards are setup as separate classes as in separate .jar files.

public class Card2 extends JPanel {}
public class Card1 extends JPanel {}

any ideas?

steve
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top