-1
ボタンをクリックするとmain()を再実行し、プログラムを再起動するプログラムが必要ですが、やり方には固執していますそれ。私は実際にこれを行うことが可能かどうかわかりません。誰かが私を助けてくれることを願っている。ありがとうございました。Javaのボタンをクリックするとメインメソッドを再実行するUIを作成する
package tst;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
public class callMain {
private JButton buttons;
public static void main(String[] args) {
System.out.println("how are you");
}
public callMain() {
JButton button = new JButton("btn");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// I want to rerun the program
}
});
}
' JButton':あなたはcallMainクラスである場合、
あるいはさらに簡単に'? – Jerry06
http://www.javatpoint.com/java-awtとhttp://www.javatpoint.com/event-handling-in-javaをお読みください –
@ Jerry06指摘してくれてありがとうございます。私はコードハのいくつかの詳細をスキップしました。 – alex007