I have java program with interface created using Java Swing. The interface contains a JButton
. I want to add Action
to that button so that it should execute another Java program which I specify.
How to do that?
I have java program with interface created using Java Swing. The interface contains a JButton
. I want to add Action
to that button so that it should execute another Java program which I specify.
How to do that?
Try this:
yourButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Process proc = Runtime.getRuntime().exec("java -jar A.jar");
} catch (IOException ex) {
}
}
});