JOptionPane.YES_OPTION ==每个按钮上的ENTER [英] JOptionPane.YES_OPTION == ENTER on each button
本文介绍了JOptionPane.YES_OPTION ==每个按钮上的ENTER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的选项对话框:
I have a option dialog like this:
String[] options = ["Yes", "No"]; //button names
int n = JOptionPane.showOptionDialog(singleFrameService.getFrame(),
"Some Question?",
"",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, //do not use a custom Icon
options, //the titles of buttons
options[0]); //default button title
//if press yes
if (n == JOptionPane.YES_OPTION){
//make some if pressed Yes
}
当我使用鼠标并按是/否"-一切正常时... 但是,当我开始使用键盘时,请按TAB键转到否"按钮,然后按Enter-工作是"选项
When I used mouse and press Yes/No - all work fine... But when I start use keyboard, press TAB to go to "No" button, and then press ENTER - work "Yes" option
推荐答案
这一切都取决于外观,即AFAIK.在您的L& F中,"Enter"表示按默认按钮"(是).按下聚焦按钮可能是通过按下空格键来完成的.
It all depends on the look 'n feel, AFAIK. In your L&F, "Enter" means "press the default button" (which is Yes). Pressing the focused button is probably done by pressing the space bar.
这篇关于JOptionPane.YES_OPTION ==每个按钮上的ENTER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文