Utilisation des onglets

/*

 * JTabbedPaneExemple.java
 *
 * Created on April 6, 2008, 9:21 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package exemple;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
/**

 *
 * @author gmonard
 */
public class JTabbedPaneExemple extends JFrame implements ActionListener
{
    JButton ok1;
    JButton ok2;
    JButton ok3;
    JTextField partir1;
    JTextField partir2;
    JTextField partir3;

    /** Creates a new instance of JTabbedPaneExemple */
    public JTabbedPaneExemple()
    {
        super("Exemple de JTabbedPane");
        this.setSize(300,200);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panneau1 = new JPanel();
        JPanel panneau2 = new JPanel();
        JPanel panneau3 = new JPanel();

        JTabbedPane onglets = new JTabbedPane();
        onglets.addTab("Il court,", panneau1);
        onglets.addTab("il court,", panneau2);
        onglets.addTab("le furet ...", panneau3);

        BoxLayout agencement1 = new BoxLayout(panneau1, BoxLayout.Y_AXIS);
        panneau1.setLayout(agencement1);
        BoxLayout agencement2 = new BoxLayout(panneau2, BoxLayout.Y_AXIS);
        panneau2.setLayout(agencement2);
        BoxLayout agencement3 = new BoxLayout(panneau3, BoxLayout.Y_AXIS);
        panneau3.setLayout(agencement3);

        partir1 = new JTextField("",20);
        partir2 = new JTextField("",20);
        partir3 = new JTextField("",20);
        partir1.setEditable(false);
        partir2.setEditable(false);
        partir3.setEditable(false);
        ok1 = new JButton("Quitter");
        ok2 = new JButton("Quitter");
        ok3 = new JButton("Quitter");
        ok1.addActionListener(this);
        ok2.addActionListener(this);
        ok3.addActionListener(this);
        panneau1.add(partir1);
        panneau1.add(ok1);
        panneau2.add(partir2);
        panneau2.add(ok2);
        panneau3.add(partir3);
        panneau3.add(ok3);


        this.add(onglets);
        this.setVisible(true);
    }

    public void actionPerformed(ActionEvent evenement)
    {
        Object source = evenement.getSource();
        if (source == ok1)
        {
            partir1.setText("Perdu ...");
        }
        else if (source == ok2)
        {
            partir2.setText("Essayez encore ...");
        }
        else if (source == ok3)
        {
            this.dispose();
        }
        else
        {
            // rien
        }
    }

    public static void main(String[] arguments)
    {
        new JTabbedPaneExemple();
    }

}