Im having a lot of trouble trying to figure out something that seems like it would be easy.
For my final project I have to create a GUI application. I got it set up and working where when you click the button it will display some text depending on what button you press.
What I'm trying to figure out is how to make it where when you click a button, a seperate new GUI window will open.
When i add my code and click the button, it just adds the new buttons onto the GUI I already have open and everytime you click it, it adds more.
This is not what i want!
Here is an example of my working code to display the text.
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// Get the action command.
String actionCommand = e.getActionCommand();
// Determine which button was clicked and display
// a message.
if (actionCommand.equals("Button 1"))
{
JOptionPane.showMessageDialog(null, "You clicked " +
"the first button.");
}
else if (actionCommand.equals("Button 2"))
{
JOptionPane.showMessageDialog(null, "You clicked " +
"the second button.");
}
else if (actionCommand.equals("Button 3"))
{
JOptionPane.showMessageDialog(null, "You clicked " +
"the third button.");
}
Instead of it saying "You clicked the first button" when i click button 1, I want it to open up a new GUI.
How can I do this??
Thanks guys and sorry Im such a noob!