1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
package language;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class toto extends JFrame implements ActionListener
{
JButton voc, verbe;
Container c;
Rectangle rec;
JPanel j1,j2;
JButton b1,b2;
int num1=2;
public toto()
{
c = getContentPane();
setLayout(null);
b1 = new JButton("ok");
b2 = new JButton("souk");
j1 = new JPanel();
j1.setBounds(0, 85, 600, 40);
j2 = new JPanel();
j2.setBounds(0, 60, 600, 480);
verbe = new JButton("bouton1");
verbe.setBounds(150, 0, 150, 30);
verbe.addActionListener(this);
voc = new JButton("bouton2");
voc.setBounds(300, 0, 150, 30);
voc.addActionListener(this);
j1.add(b1);
j2.add(b2);
c.add(voc);
c.add(verbe);
Jbinit();
}
public void Jbinit()
{
j1.hide();
j2.hide();
if (num1 == 2)
{
j1.show();
}
if (num1 == 3)
{
j2.show();
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == voc)
{
num1 = 3;
this.Jbinit();
this.repaint();
}
}
public static void main(String[] args) {
JFrame page = new toto();
page.setBounds(400, 60, 600, 650);
page.setResizable(false);
page.setVisible(true);
}
} |
Partager