can any1 tell mewhy this prog won't switch between card?
package j24work;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class testCard extends JFrame implements ActionListener {
JToolBar tool = new JToolBar();
JButton button1 = new JButton("Card1");
JButton button2 = new JButton("Card2");
JPanel cards;
JPanel card1 = new JPanel();
JPanel card2 = new JPanel();
public testCard() {
super("testing...");
setSize(300, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
BorderLayout flow = new BorderLayout();
pane.setLayout(flow);
button1.addActionListener(this);
button2.addActionListener(this);
cards = new JPanel(new CardLayout());
cards.add(card1, "Card1");
cards.add(card2, "Card2");
tool.add(button1);
tool.add(button2);
pane.add(tool, BorderLayout.NORTH);
pane.add(cards, BorderLayout.CENTER);
CardLayout c1 = (CardLayout)(cards.getLayout());
c1.show(cards, "Card1");
setContentPane(pane);
setVisible(true);
}
public void actionPerformed(ActionEvent evt) {
CardLayout c2 = (CardLayout)(cards.getLayout());
c2.show(cards, evt.getActionCommand());
}
public static void main(String[] args) {
testCard tc = new testCard();
}
}
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/beginnersclub/post?act=reply&messageNum=5598
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/