1
2 import org.swixml.SwingEngine;
3
4 import javax.swing.*;
5 import java.awt.*;
6 import java.awt.event.ActionEvent;
7
8
16public class Cards {
17
18 private static final String DESCRIPTOR = "xml/cards.xml";
19 private SwingEngine swix = new SwingEngine( this );
20
21
22 public JPanel pnl;
23
24 private Cards() throws Exception {
25 swix.render( Cards.DESCRIPTOR ).setVisible( true );
26 this.showAction.actionPerformed( null );
27 }
28
29
30 public Action nextAction = new AbstractAction() {
31 public void actionPerformed( ActionEvent e ) {
32 CardLayout cl = (CardLayout) ( pnl.getLayout() );
33 cl.next( pnl );
34 }
35 };
36
37
38 public Action showAction = new AbstractAction() {
39 public void actionPerformed( ActionEvent e ) {
40 CardLayout cl = (CardLayout) ( pnl.getLayout() );
42 if (e!=null) {
43 cl.show( pnl, e.getActionCommand() );
44 }
45 }
46 };
47
48 public static void main( String[] args ) {
49 try {
50 new Cards();
51 } catch (Exception e) {
52 System.err.println( e.getMessage() );
53 }
54 }
55
56}
57