Pirkid

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2896
    David
    Participant

    This is random spam forum so w/e

    How do you make this more efficient? :/ I’m not that far ahead yet, but I just lol’d when I was making this at first.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;

    public class Clicker extends JFrame {
    JButton plus = new JButton(“Click me!”);
    JButton plus1 = new JButton(“Click me too!”);
    JButton plus2 = new JButton(“Heck, why not. Click me as well!”);
    JButton plus3 = new JButton(“Keep going! You’re almost there!”);
    JButton plus4 = new JButton(“Just a few more! Keep clicking!”);
    JButton plus5 = new JButton(“CLICK ME! :D”);
    JButton plus6 = new JButton(“Well, that was awkward. Click me to kill the program.”);
    int count = 0;
    JTextField countTimes = new JTextField(“0”,20);

    Clicker() {
    super(“Click on Me”);
    setSize(300,300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FlowLayout lulz = new FlowLayout();
    setLayout(lulz);

    add(plus);
    plus.addActionListener(new Clicked());
    setVisible(true);
    }

    class Clicked implements ActionListener {
    public void actionPerformed(ActionEvent a) {
    add(plus1);
    plus1.addActionListener(new Clicked1());
    plus.setEnabled(false);
    setVisible(true);
    }
    }

    class Clicked1 implements ActionListener {
    public void actionPerformed(ActionEvent b) {
    add(plus2);
    plus1.setEnabled(false);
    plus2.addActionListener(new Clicked2());
    setVisible(true);
    }
    }

    class Clicked2 implements ActionListener {
    public void actionPerformed(ActionEvent c) {
    add(plus3);
    plus2.setEnabled(false);
    plus3.addActionListener(new Clicked3());
    setVisible(true);
    }
    }

    class Clicked3 implements ActionListener {
    public void actionPerformed(ActionEvent d) {
    add(plus4);
    plus3.setEnabled(false);
    plus4.addActionListener(new Clicked4());
    setVisible(true);
    }
    }

    class Clicked4 implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    add(plus5);
    plus5.addActionListener(new Clicked5());
    plus4.setEnabled(false);
    setVisible(true);
    }
    }

    class Clicked5 implements ActionListener {
    public void actionPerformed(ActionEvent f) {
    add(countTimes);
    countTimes.setEnabled(false);
    count++;
    String lol = String.valueOf(count);
    String lolz = lol + ” – You’ll need 60 clicks. :)”;
    countTimes.setText(lolz);
    setVisible(true);

    if (count >= 60) {
    countTimes.setText(“Congratulations! You WINNNNNNNN!”);
    add(plus6);
    plus5.setEnabled(false);
    plus6.addActionListener(new Clicked6());
    setVisible(true);
    }
    }
    }

    class Clicked6 implements ActionListener {
    public void actionPerformed(ActionEvent g) {
    setVisible(false);
    }
    }

    public static void main(String[] args) {
    Clicker cl = new Clicker();
    }

    }

    #12254
    MasterCheeze
    Participant

    Get rid of the two smiley faces for starters.

    #12267
    David
    Participant

    Those are messages. The thing works, I just want it to be more efficient. 🙁

    #12262
    Jil
    Participant

    Don’t use Java? 🙂

    #7602
    David
    Participant

    LOL Annona you’re funny.

    Not.

    🙁

    Seriously? =(

    #7600
    Jil
    Participant

    What is all that supposed to do anyway?

    #7590
    David
    Participant

    Oh, eum, it’s pointless really. Basically, er, it sets up a regular screen with a button that says “click me!”

    When you click on that, another button appears that says, click me too!

    So on and so on,

    Then there’s a challenge, where you have to do 60 clicks, once you do that, another button says
    “Well, that was awkward. Click me to kill the application.”

    And when you click that, it’s over.

    Yeah. I was testing to see if I could make an infinite loop of buttons, like clicking one would make another in an infinite loop, but I don’t know how. XD I had to make each button separately.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.