problems with a cardlayout.

Discussion in 'Java' started by steve, Nov 21, 2004.

  1. steve

    steve Guest

    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
     
    steve, Nov 21, 2004
    #1
    1. Advertising

  2. steve

    steve Guest

    On Sun, 21 Nov 2004 09:54:42 +0800, steve wrote
    (in article <>):

    > Hi,


    <SNIP>

    fixed.
    stray initialization call drifted into a loop.

    This is one of several times where im sure Jalopy , has moved code about.
     
    steve, Nov 21, 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. Lee Fesperman

    CardLayout on JRE 1.4.2

    Lee Fesperman, Jul 4, 2003, in forum: Java
    Replies:
    0
    Views:
    379
    Lee Fesperman
    Jul 4, 2003
  2. BG

    cardlayout problem

    BG, Jul 30, 2003, in forum: Java
    Replies:
    0
    Views:
    411
  3. AJ
    Replies:
    2
    Views:
    366
    Wilhelm Stockhammer
    Jan 10, 2004
  4. roadkill
    Replies:
    7
    Views:
    657
    roadkill
    Jan 9, 2005
  5. Replies:
    1
    Views:
    468
    markspace
    Sep 24, 2012
Loading...

Share This Page