diff --git a/src/Partie1Exo2.java b/src/Partie1Exo2.java new file mode 100755 index 0000000000000000000000000000000000000000..d8908de45607e55d1e346c1772e5e576acf577f0 --- /dev/null +++ b/src/Partie1Exo2.java @@ -0,0 +1,91 @@ + +import java.awt.event.*; +import javax.swing.*; +import java.awt.*; +import com.sun.xml.internal.ws.api.server.Container; + + + +public class Partie1Exo2 extends JFrame +{ + //JLabel label ; + public Partie1Exo2(){ + super("Partie1, Exercice2"); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setVisible(true); + + JButton button1 = new JButton("Rouge"); + JButton button2 = new JButton("Blue"); + JButton button3 = new JButton("Quitter"); + JLabel label = new JLabel("Exemple"); + JPanel panel = new JPanel(); + + java.awt.Container con = getContentPane(); + + con.setLayout(new BorderLayout()); + panel.setLayout(new FlowLayout()); + + + panel.add(button1); panel.add(button2); panel.add(button3); + + + con.add(label, BorderLayout.NORTH); + + con.add(panel,BorderLayout.CENTER); + + + button1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + label.setForeground(Color.RED); + } + }); + button2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + label.setForeground(Color.blue); + } + }); + button3.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + + + + + + + + + + + + + + pack(); + + + } + + + + + public static void main(String[] args) { + + SwingUtilities.invokeLater(() -> gui()); + + + } + private static void gui() { + // thread: GUI + new Partie1Exo2(); + } + +} +