I need to create a JOptionPane.showInputDialog with a selection list and just an 'OK' button. I can find examples for just an 'OK' button and a selection list but not both.
Is there a version of the constants in JOptionPane which allows an OK button on its own? Have a look; I couldn't find it. I presume the method you want is showInputDialog()? I didn't see an overloading which seems to match what you are asking for.
Why do you need a selection dialog that has no "Cancel" button? It can be very frustrating for the user if there is no "Cancel" (suppose the user popped up the question by mistake, or needs more information before she can make the correct choice)?
Anyway, if you do make a dialog with no "Cancel" button, what do you expect to happen if the user closes the window using the border "X" button?
In this particular case the user MUST make a selection (even if it is to accept the default) to proceed. The 'X' will be disabled. As for unintentionally getting into this pane (probably not really possible in the context of the process), the cancel opportunity occurred earlier in a different dialog. Also this is a non-destructive dialog until the user returns to the parent and saves.
I looked at JList first but I'm not sure it will accomplish what I want. I will have to look at it again and think about it. It also seems substantially more complicated to implement to get what I need. In any case I am gathering that there is no way to remove the 'Cancel' button or the unwanted TextField when using showInputDialog.
Dennis Putnam wrote:It also seems substantially more complicated to implement to get what I need.
Its not.
Dennis Putnam wrote:In any case I am gathering that there is no way to remove the 'Cancel' button or the unwanted TextField when using showInputDialog.
Addition to Maneesh's hint: you can also pass an array of JRadioButton as the message argument. But don't forget to iterate over the array and add them to a ButtonGroup first.
luck, db
There are no new questions, but there may be new answers.