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
|
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class ButtonPanel extends JPanel implements ActionListener{
private JButton BoutonOK;
private JButton BoutonQuitter;
public ButtonPanel() {
BoutonOK = new JButton("OK");
BoutonQuitter = new JButton("Quitter");
add(BoutonOK);
add(BoutonQuitter);
BoutonOK.addActionListener(this);
BoutonQuitter.addActionListener(this);
}
public void actionPerformed(ActionEvent evt)
{
Object source = evt.getSource();
Color color = getBackground();
if (source == BoutonOK) System.out.print("HELLO WORLD");
if (source == BoutonQuitter) System.exit(0);
setBackground(color);
repaint();
}
}
class ButtonFrame extends JFrame
{ public ButtonFrame()
{ setTitle("Simplification de fonction booléenne");
setSize(300, 200);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
} );
Container contentPane = getContentPane();
contentPane.add(new ButtonPanel());
}
}
public class IG{
}
} |
Partager