Guest User

Untitled

a guest
Dec 15th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.FlowLayout;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. import javax.swing.*;
  7. public class Clicker {
  8. private static boolean Stage = false;
  9. private static int Coins = 0;
  10. private static JButton button4;
  11. private static JFrame Shop;
  12. private static JFrame Clicker3;
  13. public static void main (String [] args){
  14. Clicker3 = new JFrame("Clicker");
  15. JButton button = new JButton("Click me");
  16. JButton button2 = new JButton("Shop");
  17. JPanel panel = new JPanel(new FlowLayout());
  18. JLabel label = new JLabel("Coins:"+ Coins);
  19. Clicker3.add(panel, BorderLayout.SOUTH);
  20. Clicker3.add(label, BorderLayout.NORTH);
  21. panel.add(button);
  22. panel.add(button2);
  23. Clicker3.setVisible(true);
  24. Clicker3.setSize(350, 350);
  25. button.addActionListener(new ActionListener(){
  26. public void actionPerformed(ActionEvent arg0) {
  27. if(Stage = true){
  28. Coins=Coins + 1;
  29. Update();
  30. }else{
  31. Coins=Coins +2;
  32. Update();
  33. }
  34.  
  35. }
  36.  
  37. private void Update() {
  38. label.setText("Coins:"+ Coins);
  39. }
  40.  
  41. });
  42. button2.addActionListener(new ActionListener(){
  43. public void actionPerformed(ActionEvent arg1){
  44. Shop = new JFrame("Shop");
  45. JPanel panel3 = new JPanel(new FlowLayout());
  46. button4 = new JButton("X2");
  47. panel3.add(button4);
  48. Shop.add(panel3, BorderLayout.CENTER);
  49. Shop.setVisible(true);
  50. Shop.setSize(350, 350);
  51. }
  52. });
  53. button4.addActionListener(new ActionListener(){
  54. public void actionPerformed(ActionEvent arg2){
  55. if (Coins !=100 | Coins > 100){
  56. Coins=Coins - 100;
  57. Stage = true;
  58. System.out.println("+");
  59. }else{
  60.  
  61. System.out.println("-");
  62. }
  63. }
  64. });
  65.  
  66. }
  67. }
Add Comment
Please, Sign In to add comment