tags:

views:

18

answers:

1

I am creating an options dialog using JOptionPane.showOptionDialog(...)

When I click one of the buttons added to this dialog, I need a label to apear underneath on the dialog (and this label should be scrollable if necessary). I have written event handlers for the buttons, but I am not sure how to get this label to appear on the dialog.

Any help would be great.

Update: I realized that it would be ok if I somehow called JOptionPane.showOptionDialog(...) with an initial message, and then when one of the buttons was clicked I would change the message. Is this possible?

+1  A: 

JOptionPane static methods are only shortcuts to easily create a dialog with option buttons and a fixed message. If you check the source from it, you will see that all is wrapped in this purpose. It's only a convenience class over a frequent use case of dialogs.

The suggestion from comment is correct, if you want more than this, you will have to create your own JDialog, as it will be easier than trying to change something from this generated dialog.

Edit: You can create your own JDialog yourself, using layout managers. A more simple way, suggested as well in the previous link, is to use a GUI builder, like the one included in Netbeans.

Gnoupi
Thanks. Could you provide an example on how to create a custom JDialog (or point me to a good source)? Seaching google has just gotten me confused.
llm