开发者

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

开发者 https://www.devze.com 2023-03-20 14:01 出处:网络
I want to create a dialog box which contain four button yes no yes to all开发者_如何学编程 cancel

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

精彩评论

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