I am creating a graphical interface for my program. When I press the start button, I want it to call another program.
Below is my listerner code:
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==startButton)
?????
}
}
What should I do? I intend to call another Java file (Start.java).
If you want to create a new Start instance there, you could do that:
Or if you already have a reference to an existing Start object, then simply call its methods. A caveat, if any of Start’s methods take a long time to complete or are resource hogs, you’ll want to do them in a background thread such as supplied by a SwingWorker object.
Note that my answer is quite general and perhaps a bit vague on the details, but I cannot supply any finer grained details until you tell us a lot more about the structure of your program, your classes, and your specific problem here.