I just want the actionPerformed
event method to be used once. For example: I'm trying to get two values from one textfield.
public void actionPerformed(ActionEvent ev){
String whatever = tf.getText();
if(whatever.equalsIgnoreCase("good"){
inout.append("blahh");
//and then I'm trying to get a new value from the user without it resetting.
}
If you are trying to make the same event execute two actions then you could try the following:
int choice = 0;
public void actionPerformed(ActionEvent ev){
if ( choice == 0 ) {
String whatever = tf.getText();
if(whatever.equalsIgnoreCase("good"){
inout.append("blahh");
...
choice++;
}// end first action
else if ( choice == 1 ) {
//Second action
//Your code for what happens the second time would go here
choice++;
} else {
//you can do this forever
}
}
As a new programmer you should understand why this works:
There is endless posibility for code. By seeing this you should note that you can incorperate many of the loops, switches, and other statements you've used leading up to this. In this case I'm making a condition choice that changes what happens when you click your JButton.
When you get better you will learn about threads and Events, that in essence are threads built into Java, and you will be able to do a lot more.
Keep up the good work and never give up on a hard problem :D.