Advertisement
Guest User

Javadoc

a guest
Feb 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. package mastermind;
  2.  
  3.  
  4. import java.awt.BorderLayout;
  5. import java.awt.FlowLayout;
  6. import java.awt.GridLayout;
  7.  
  8. import javax.swing.JButton;
  9. import javax.swing.JLabel;
  10. import javax.swing.JPanel;
  11. import javax.swing.JTextField;
  12. import javax.swing.SwingConstants;
  13.  
  14. public class VueMastermind extends JPanel {
  15.  
  16. public VueMastermind()
  17. {
  18. this.setLayout(new BorderLayout());
  19.  
  20. //Partie haute de l'interface
  21. {
  22. JPanel haut = new JPanel();
  23. haut.setLayout(new FlowLayout());
  24. JLabel label_couleurs = new JLabel("Couleurs: ");
  25. haut.add(label_couleurs);
  26. //Boutons de la partie haute de l'interface
  27. {
  28. JPanel hautBoutons = new JPanel();
  29. hautBoutons.setLayout(new GridLayout(1, 6));
  30. for(int i=0; i<6; i++)
  31. {
  32. hautBoutons.add(new JButton());
  33. }
  34. haut.add(hautBoutons);
  35. }
  36.  
  37. this.add(haut, BorderLayout.NORTH);
  38. }
  39.  
  40. //Milieu de l'interface
  41. {
  42. JPanel milieu = new JPanel();
  43. milieu.setLayout(new GridLayout(10, 2));
  44.  
  45. //Boucle de lignes
  46. for(int i = 0; i<10; i++)
  47. {
  48. //Boutons
  49. {
  50. JPanel btns = new JPanel();
  51. btns.setLayout(new GridLayout(1, 4));
  52.  
  53. for(int j=0; j<4; j++)
  54. {
  55. btns.add(new JButton());
  56. }
  57.  
  58. milieu.add(btns);
  59. }
  60. //Compteurs
  61. {
  62. JPanel cmpts = new JPanel();
  63. cmpts.setLayout(new GridLayout(2, 2));
  64.  
  65. //Labels
  66. {
  67. JLabel tmp;
  68. tmp = new JLabel("BP");
  69. tmp.setHorizontalAlignment(SwingConstants.CENTER);
  70. cmpts.add(tmp);
  71. tmp = new JLabel("MP");
  72. tmp.setHorizontalAlignment(SwingConstants.CENTER);
  73. cmpts.add(tmp);
  74. }
  75. //Champs de texte
  76. {
  77. for(int j=0; j<2; j++)
  78. {
  79. JTextField tmp = new JTextField();
  80. tmp.setEditable(false);
  81. cmpts.add(tmp);
  82. }
  83. }
  84. milieu.add(cmpts);
  85. }
  86. }
  87. this.add(milieu, BorderLayout.CENTER);
  88. }
  89.  
  90. //Partie basse de l'interface
  91. {
  92. JPanel bas = new JPanel();
  93. bas.setLayout(new GridLayout(1, 2));
  94. //Partie boutons
  95. {
  96. JPanel btns = new JPanel();
  97. btns.setLayout(new GridLayout(1, 4));
  98.  
  99. for(int i=0; i<4; i++)
  100. {
  101. btns.add(new JButton());
  102. }
  103.  
  104. bas.add(btns);
  105. }
  106. //Partie Valider
  107. {
  108. bas.add(new JButton("Valider"));
  109. }
  110. this.add(bas, BorderLayout.SOUTH);
  111. }
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement