问题
After reading through all the Dialog tutorials for a while, there seems to be no apparent way to do this. The closest thing seems to be JOptionPane.showOptionDialog
, but I am limited by the optionType
parameter here.
EDIT: I figured out the problem, but have a new one. It seems that the options
parameter being specified in showOptionDialog
needs to be fairly simple objects (strings or just 'objects', not JButton
or the like). I was trying to put an array of custom-factory-created JButtons here, because they have a special rollover icon that I want to be using. What happens, though, is that clicking on any of these buttons does not cause the dialog to close (and thus, execution continues blocking on the dialog). So I have updated my question in the headline.
Put more succinctly -- the question is, how do I override JOptionPane.showOptionDialog(args)
to get the button customization I'm looking for? Or do I even need to do that?
Please and thanks! -B.
回答1:
This Java doc should help you create your own dialogs, or customize existing ones: How To Make Dialogs and if thats not what you want then maybe creating a JDialog
, adding the necessary components and buttons and making it visible would do the trick :)
来源:https://stackoverflow.com/questions/11145507/how-do-i-create-a-joptionpane-showoptiondialog-box-in-java-swing-with-custom-j