Home › Forums › The Train Wreck and Forum Games › Pirkid
- This topic has 6 replies, 3 voices, and was last updated 15 years, 8 months ago by
David.
-
AuthorPosts
-
19 June 2009 at 01:28 #2896
David
ParticipantThis 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();
}}
19 June 2009 at 03:23 #12254MasterCheeze
ParticipantGet rid of the two smiley faces for starters.
19 June 2009 at 19:13 #12267David
ParticipantThose are messages. The thing works, I just want it to be more efficient. 🙁
20 June 2009 at 01:51 #12262Jil
ParticipantDon’t use Java? 🙂
20 June 2009 at 01:55 #7602David
ParticipantLOL Annona you’re funny.
Not.
🙁
Seriously? =(
20 June 2009 at 01:56 #7600Jil
ParticipantWhat is all that supposed to do anyway?
20 June 2009 at 01:59 #7590David
ParticipantOh, 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.
-
AuthorPosts
- You must be logged in to reply to this topic.