import java.awt.*;
import java.awt.event.*;

class ExCard extends Frame implements ActionListener {
    CardLayout index = new CardLayout();
    Panel boite = new Panel(index);
    Button deb, suiv, prec, der, show; 
    
    ExCard() {
        super("Cartes...");
        boite.setFont(new Font("Helvetica", Font.PLAIN, 24));
        boite.add("Une", new Button("une"));
        boite.add("Deux", new Button("deux"));
        boite.add("Trois", new Button("trois"));
        boite.add("Central", new Button("quatre"));
        boite.add("Cinq", new Button("cinq"));
        boite.add("Six", new Button("six"));

        Panel commandes = new Panel(new GridLayout(1,0));
        commandes.setFont(new Font("Helvetica", Font.PLAIN, 12));        
        commandes.add(deb = new Button("Debut"));
        deb.addActionListener(this);
        commandes.add(suiv = new Button("Suivant"));
        suiv.addActionListener(this);
        commandes.add(prec = new Button("Precedent"));
        prec.addActionListener(this);
        commandes.add(der = new Button("Fin"));
        der.addActionListener(this);
        commandes.add(show = new Button("Milieu"));
        show.addActionListener(this);
        add(boite,BorderLayout.CENTER);
        add(commandes,BorderLayout.SOUTH);
    }
    public void actionPerformed (ActionEvent e) {
        Button b = (Button) e.getSource();
        if (b == deb) index.first(boite); 
        else if (b == suiv) index.next(boite); 
        else if (b == prec) index.previous(boite); 
        else if (b == der) index.last(boite); 
        else if (b == show) index.show(boite,"Central"); 
    }   
    public static void main(String args[]) {
      ExCard e = new ExCard();
     e.addWindowListener(new Fermeur());
     e.setSize(350,200);
     e.setVisible(true);
    }
}
class Fermeur extends WindowAdapter {
    public void windowClosing(WindowEvent e) { 
        System.exit(0);
    }
}

