I need a program that when I click the button, it will rerun the main(),aka, restart the program, but I am stuck on how to do it. I actually do not know if it is possible to do this. Hope someone could help me out. Thank you.
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
withoutcontainer
?