Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. public void setBoutons(Piece[] bloc)
  2. {
  3. this.piece1 = bloc[0];
  4. this.piece2 = bloc[1];
  5. this.piece3 = bloc[2];
  6.  
  7. this.nompiece1 = piece1.getNom();
  8. this.nompiece2 = piece2.getNom();
  9. this.nompiece3 = piece3.getNom();
  10.  
  11. //System.out.println(nompiece1);
  12.  
  13. this.bouton1.setActionCommand(this.nompiece1);
  14. this.bouton2.setActionCommand(this.nompiece2);
  15. this.bouton3.setActionCommand(this.nompiece3);
  16.  
  17. this.couleur1 = piece1.getCouleur();
  18. this.couleur2 = piece2.getCouleur();
  19. this.couleur3 = piece3.getCouleur();
  20.  
  21. this.disposition1 = piece1.getDisposition();
  22. this.disposition2 = piece2.getDisposition();
  23. this.disposition3 = piece3.getDisposition();
  24.  
  25. }
  26.  
  27. Client exception: java.lang.NullPointerException
  28. java.lang.NullPointerException
  29. at Fenetre.setBoutons(Fenetre.java:174)
  30. at Fenetre.<init>(Fenetre.java:60)
  31. at Client.main(Client.java:22)
  32.  
  33. import java.awt.BorderLayout;
  34. import java.awt.Color;
  35. import java.awt.Dimension;
  36. import java.awt.FlowLayout;
  37. import java.awt.GridLayout;
  38. import java.awt.event.ActionEvent;
  39. import java.awt.event.ActionListener;
  40. import java.rmi.RemoteException;
  41. import javax.swing.JButton;
  42. import javax.swing.JFrame;
  43. import javax.swing.JLabel;
  44. import javax.swing.JPanel;
  45.  
  46. public class Fenetre extends JFrame implements ActionListener{
  47. private JButton[][] cases;
  48. private JButton bouton1;
  49. private JButton bouton2;
  50. private JButton bouton3;
  51. private String nompiece1;
  52. private String nompiece2;
  53. private String nompiece3;
  54. private Color couleur1;
  55. private Color couleur2;
  56. private Color couleur3;
  57. private byte[][] disposition1;
  58. private byte[][] disposition2;
  59. private byte[][] disposition3;
  60. private Piece piece1;
  61. private Piece piece2;
  62. private Piece piece3;
  63. private byte p1;
  64. private byte p2;
  65. private byte p3;
  66. private Interface ninja;
  67. private JPanel grille;
  68. private JPanel zonepieces;
  69. private JPanel zonedroite;
  70. private JPanel zonehaut;
  71. private JLabel pseudo;
  72. private JLabel score;
  73.  
  74.  
  75. public Fenetre(Interface uneinterface)
  76. {
  77. this.ninja = uneinterface;
  78. try
  79. {
  80. Piece[] unpool = ninja.PoolPieces();
  81. this.setBoutons(unpool);
  82. }
  83. catch (RemoteException e)
  84. {
  85. e.printStackTrace();
  86. }
  87.  
  88. this.p1 = 0;
  89. this.p2 = 0;
  90. this.p3 = 0;
  91.  
  92. this.cases = new JButton[10][10];
  93. this.grille = new JPanel();
  94. this.zonepieces = new JPanel();
  95. this.zonedroite = new JPanel();
  96. this.zonehaut = new JPanel();
  97. this.grille.setLayout(new GridLayout(10, 10, 2, 2));
  98.  
  99. for(int j = 0; j<10; j++)
  100. {
  101. for(int i = 0; i<10; i++)
  102. {
  103. this.cases[j][i] = new JButton(" ");
  104. this.cases[j][i].addActionListener(this);
  105. this.cases[j][i].setActionCommand(""+j+i);
  106. this.cases[j][i].setBackground(Color.gray);
  107. this.grille.add(cases[j][i]);
  108. }
  109. }
  110.  
  111. this.bouton1 = new JButton();
  112. this.bouton1.addActionListener(this);
  113. this.bouton1.setBackground(Color.WHITE);
  114.  
  115. this.bouton2 = new JButton();
  116. this.bouton2.addActionListener(this);
  117. this.bouton2.setBackground(Color.WHITE);
  118.  
  119. this.bouton3 = new JButton();
  120. this.bouton3.addActionListener(this);
  121. this.bouton3.setBackground(Color.WHITE);
  122.  
  123. this.zonepieces.setLayout(new FlowLayout());
  124. this.zonepieces.add(bouton1);
  125. this.zonepieces.add(bouton2);
  126. this.zonepieces.add(bouton3);
  127. this.pseudo = new JLabel("Pseudo");
  128. this.zonehaut.add(pseudo);
  129. this.score = new JLabel("Score");
  130. this.zonedroite.add(score);
  131.  
  132. add(grille, BorderLayout.CENTER);
  133. add(zonepieces, BorderLayout.SOUTH);
  134. add(zonedroite, BorderLayout.EAST);
  135. add(zonehaut, BorderLayout.NORTH);
  136.  
  137. this.setTitle("1010");
  138. this.setSize(700, 700);
  139. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  140. this.setLocationRelativeTo(null);
  141. this.setVisible(true);
  142.  
  143. }
  144.  
  145. public void setBoutons(Piece[] bloc)
  146. {
  147. this.piece1 = bloc[0];
  148. this.piece2 = bloc[1];
  149. this.piece3 = bloc[2];
  150.  
  151. this.nompiece1 = piece1.getNom();
  152. this.nompiece2 = piece2.getNom();
  153. this.nompiece3 = piece3.getNom();
  154.  
  155. //System.out.println(nompiece1);
  156.  
  157. this.bouton1.setActionCommand(this.nompiece1);
  158. this.bouton2.setActionCommand(this.nompiece2);
  159. this.bouton3.setActionCommand(this.nompiece3);
  160.  
  161. this.couleur1 = piece1.getCouleur();
  162. this.couleur2 = piece2.getCouleur();
  163. this.couleur3 = piece3.getCouleur();
  164.  
  165. this.disposition1 = piece1.getDisposition();
  166. this.disposition2 = piece2.getDisposition();
  167. this.disposition3 = piece3.getDisposition();
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement