开发者

how to create yes to all option in dialog box through swing

I want to create a dialog box which contain four button

  1. yes
  2. no
  3. yes to all
  4. 开发者_如何学编程
  5. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜