Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.Component;
  3. import java.awt.Cursor;
  4. import java.awt.Frame;
  5. import java.awt.event.*;
  6. import java.awt.Color.*;
  7. import java.util.Random.*;
  8.  
  9. class Harald extends Thread implements ActionListener
  10. {
  11.  
  12. JFrame harald;
  13. JLabel Spiel;
  14. JTextArea Text;
  15. Cursor c;
  16. JComponent component;
  17. JButton butter;
  18. JButton butt;
  19. ActionEvent e;
  20. Windowlauscher amfenster;
  21.  
  22. public Harald()
  23. {
  24. Spiel = new JLabel("Hallo, Ich möchte ein Spiel mit dir Spielen. Spielst du mit mir ?") ;
  25. c = new Cursor(Cursor.CROSSHAIR_CURSOR);
  26. amfenster = new Windowlauscher();
  27. butter = new JButton ("JOO");
  28. butt = new JButton ("NÄH");
  29. harald = new JFrame("GUI NO.1");
  30. harald.setLayout(null);
  31. harald.setBounds(0, 0,1280, 995);
  32. Spiel.setBounds(420, 120, 450, 20);
  33. butter.setBounds(465, 200, 80, 80);
  34. butt.setBounds(645, 200, 80, 80);
  35. butter.addActionListener(this);
  36. butt.addActionListener(this);
  37. harald.addWindowListener(amfenster);
  38. harald.add(Spiel);
  39. harald.add(butter);
  40. harald.add(butt);
  41. harald.setResizable(false);
  42. harald.setVisible(true);
  43. }
  44.  
  45.  
  46. public void actionPerformed(ActionEvent e)
  47. {
  48. if(e.getSource()==butter)
  49. {
  50. harald.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
  51.  
  52. }
  53. if(e.getSource()==butt)
  54. {
  55. System.exit(0);
  56. }
  57.  
  58.  
  59. }
  60.  
  61.  
  62.  
  63. public void run()
  64. {
  65. for(int i = 0; i < 10; i++)
  66. {
  67. try
  68. {
  69. sleep(5000);
  70. }
  71. catch(InterruptedException e)
  72. {
  73.  
  74. }
  75.  
  76. }
  77. }
  78.  
  79.  
  80. public static void main(String[] args)
  81. {
  82.  
  83. Harald blub = new Harald();
  84. blub.run();
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement