Advertisement
Guest User

SSPViewer

a guest
Oct 25th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. package p3;
  2.  
  3. //import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.FlowLayout;
  6. //import java.awt.GridLayout;
  7. //import java.util.Random;
  8. import java.util.Random;
  9.  
  10. import javax.swing.JLabel;
  11. //import javax.swing.JPanel;
  12.  
  13. public class SSPViewer extends JLabel {
  14. private JLabel lblWin = new JLabel("Först till 3 vinner!");
  15. private JLabel lblHum = new JLabel("Human");
  16. private JLabel xxx = new JLabel(" ");
  17. private JLabel lblHumScore = new JLabel("0");
  18. private JLabel lblHumWep = new JLabel("vapen");
  19. private JLabel lblCump = new JLabel("Computer");
  20. private JLabel lblCumpScore = new JLabel("0");
  21. private JLabel lblCumpWep = new JLabel("Vapen");
  22. // public Object humanChoice;
  23.  
  24. public static int STEN = 0, SAX = 1, PÅSE = 2;
  25.  
  26. public SSPViewer() {
  27. setPreferredSize(new Dimension(200, 200));
  28. lblWin.setPreferredSize(new Dimension(200, 50));
  29. setLayout(new FlowLayout());
  30.  
  31. add(lblWin);
  32. add(xxx);
  33. add(lblHum);
  34. add(lblHumScore);
  35. add(lblHumWep);
  36.  
  37. add(lblCump);
  38. add(lblCumpScore);
  39. add(lblCumpWep);
  40.  
  41. }
  42.  
  43. public void setVapen(String vapen) {
  44. lblHumWep.setText(vapen);
  45. }
  46.  
  47. public void setNbr(int sel) {
  48. Random random = new Random();
  49.  
  50. int select = random.nextInt(3);
  51.  
  52. if (select == 0) {
  53. System.out.println("0");
  54. lblCumpWep.setText("påse");
  55. } else if (select == 1) {
  56. System.out.println("1");
  57. lblCumpWep.setText("sax");
  58. } else if (select == 2) {
  59. System.out.println("2");
  60. lblCumpWep.setText("Sten");
  61. }
  62. }
  63.  
  64. //
  65. // public void setChange(String string) {
  66. // System.out.println("wazzzaaappp");
  67. // lblCumpWep.setText("dddd");
  68. // System.out.println("broooor");
  69. // }
  70. }
  71. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement