how to create yes to all option in dialog box through swing
I want to create a dialog box which contain four button
- yes
- no
- yes to all 开发者_如何学编程
- cancel
I'm able to create dialog but I am unable to add action in yes to all button.
Object[] options = {"Yes", "No", "Yes To All", "Cancel"};
int n = JOptionPane.showOptionDialog(MainGui.appView, "file "+tempFile+
"exits.\n Do you wish to overwrite?", "Question",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
null, options, options[2]);
Check for value of n
. It will be as follows:
n --> button
-----------
0 --> Yes
1 --> No
2 --> Yes to all
3 --> Cancel
You can switch over n
and do action respectively.
精彩评论