同じイベントに 2 つのアクションを実行させようとしている場合は、次の方法を試すことができます。
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
}
}
新しいプログラマーとして、これが機能する理由を理解する必要があります。
コードには無限の可能性があります。これを見ると、これまでに使用した多くのループ、スイッチ、およびその他のステートメントを組み込むことができることに注意してください。この場合、JButton をクリックしたときの動作を変更する条件を選択しています。
上達すると、本質的に Java に組み込まれたスレッドであるスレッドとイベントについて学び、さらに多くのことができるようになります。
良い仕事を続けて、難しい問題をあきらめないでください:D.