Advertisement
Guest User

Test.java

a guest
Nov 20th, 2019
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.awt.event.ActionListener;
  2. import java.awt.event.ActionEvent;
  3.  
  4. import javax.swing.JFrame;
  5. import javax.swing.JButton;
  6. import javax.swing.JLabel;
  7.  
  8. public class Test
  9. {
  10. public static void main(String[] args)
  11. {
  12. JFrame frame = new JFrame("Example Program");
  13. JLabel label = new JLabel("0");
  14. JButton button = new JButton("Click me");
  15.  
  16. frame.setSize(400, 400);
  17. label.setBounds(50, 50, 150, 30);
  18. button.setBounds(100, 100, 150, 30);
  19.  
  20. frame.add(label);
  21. frame.add(button);
  22.  
  23. frame.setLayout(null);
  24. frame.setVisible(true);
  25. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  26.  
  27. button.addActionListener(new ActionListener()
  28. {
  29. public void actionPerformed(ActionEvent e)
  30. {
  31. int x = 0;
  32.  
  33. while (x <= 10000000)
  34. {
  35. String x_string = Integer.toString(x);
  36. label.setText(x_string);
  37. x++;
  38. }
  39.  
  40. } // end actionPerformed method
  41.  
  42. }); // end actionListener
  43.  
  44. } // end main method
  45.  
  46. } // end class Test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement