I know this has been asked thousands of times, but I have never found an answer that works for me. I'm using Java IDE for Java Developers (Eclipse Kepler).
I need to have a JButton which by clicking it, it will close the JFrame that the button is on, and opens a new one that exists in a different class. I have this:
JButton button = new JButton("Click Me!");
add(button);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
}
});
}
I have no idea what to put after the actionPerformed. And frame.dispose(); does not work for me.
I'm asking, how do I close the JFrame with a JButton, and by clicking the same button it also opens a new class's JFrame?
Here's an example that may help: