Advertisement
Guest User

Untitled

a guest
Oct 19th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. package projet2;
  2.  
  3. import javax.swing.JButton;
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import java.awt.Color;
  7. import java.awt.GridLayout;
  8.  
  9. public class Fenetre extends JFrame {
  10.  
  11. // CardLayout cl = new CardLayout();
  12.  
  13. public Fenetre(){
  14.  
  15. // JButton bouton = new JButton("Ceci est un bouton");
  16. GridLayout gl = new GridLayout();
  17. gl.setColumns(1);
  18. gl.setRows(3);
  19. gl.setHgap(5);
  20. gl.setVgap(5);
  21.  
  22. this.setLayout(gl);
  23. this.setTitle("Fenêtre");
  24. this.setSize(400, 500);
  25. this.setLocationRelativeTo(null);
  26. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27. this.setVisible(true);
  28.  
  29. JPanel card1 = new JPanel();
  30. card1.setBackground(Color.blue);
  31.  
  32. JPanel card2 = new JPanel();
  33. card2.setBackground(Color.red);
  34.  
  35. JPanel card3 = new JPanel();
  36. card3.setBackground(Color.green);
  37.  
  38. JPanel pan = new JPanel();
  39. pan.setBackground(Color.ORANGE);
  40. this.setContentPane(pan);
  41. this.setVisible(true);
  42. this.getContentPane().add(new Bouton("1", Color.white, Color.black, Color.red));
  43. this.getContentPane().add(new Bouton("2", Color.cyan, Color.magenta, Color.yellow));
  44. this.getContentPane().add(new JButton("3"));
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement