Hello Dani-Web participants,

I have an problem, I currently have simulation that runs fine in console, and now our teacher wants us to put it into a GUI type format. The problem that I am having is that the cancel button and close (X) button does not work what so ever. (JOptionPane.showinputdialog has to be in this format for now). So what could be the possible solution? The simulation works fine in the GUI. Also the Window is not suppose to close either I want the window to stay open until I press cancel or something like "q" to quit.

Any ideas?

Also if need be I can include the code. (also I am a beginner as well).

Thanks for any info that is given.

Hello Dani-Web participants,

I have an problem, I currently have simulation that runs fine in console, and now our teacher wants us to put it into a GUI type format. The problem that I am having is that the cancel button and close (X) button does not work what so ever. (JOptionPane.showinputdialog has to be in this format for now). So what could be the possible solution? The simulation works fine in the GUI. Also the Window is not suppose to close either I want the window to stay open until I press cancel or something like "q" to quit.

Any ideas?

Also if need be I can include the code. (also I am a beginner as well).

Thanks for any info that is given.

I also need to add that this code is wrapped in a while loop, which I think is the reason it continues and continues and continues.

int returnVal = JOptionPane.showConfirmDialog(display,
                    "Bla Bla Bla Text");
            if (returnVal == JOptionPane.OK_OPTION) {
                field1.setText("SELECTED - OK btn");
            } else if (returnVal == JOptionPane.NO_OPTION) {
                field1.setText("SELECTED - NO btn");
            } else if (returnVal == JOptionPane.CANCEL_OPTION) {
                field1.setText("SELECTED - Cancel btn");
            } else if (returnVal == JOptionPane.CLOSED_OPTION) {
                field1.setText("SELECTED - Close btn");
            }
This article has been dead for over six months. Start a new discussion instead.