ActionListener w/ Dialog
I've tried looking for this on Google, to no avail. Essentially, when someone presses the "Resize" button, I need a dialog to pop up saying "Increase by what factor?" with an input line. Obviously, the program needs to store this variable and use it later, so... how would I do this? So far, all I have is the very basic written for it.
This is in my CreateButtons method;
And this is in my actionPerformed method that catches the event;
JButton resizeButton = new JButton("Resize");
resizeButton.setBounds(1024, 584, BUTTON_WIDTH, BUTTON_HEIGHT);
It's an if-statement because I have about 10 other buttons that aren't relevant to this question., in case you were wondering. Thanks for any help! :)
String buttonText = e.getActionCommand();
//SOMETHING NEEDS TO GO HERE
You really don't want to have a "switch-board" action listener, but instead give each JButton or like group of buttons their own ActionListener.
Originally Posted by BariMutation
As to your question, I'd use one of the JOptionPane dialogs. The Swing tutorial and API will show you what you need to do to accomplish this.