默认的似乎没有这个功能
你需要自己 extends 一个 JDialog 达到这种方法
BTW: 这种一闪而过的东西要快捷健干嘛?

解决方案 »

  1.   

    如果extends JDialog,我算白问了
      

  2.   

    这样做试试:
    JButton okButton = (JButton)optionpane.getComponent( index );//想要设置助记符的按钮然后在okButton.setMnemonic(...);
      

  3.   

    谢 tomcatjava(小鱼儿) 的提示

    JButton ok = new JButton("是[Y]");
    ok.setMnemonic('Y');
    JButton ca = new JButton("否[N]");
    ca.setMnemonic('N');
    Object[] opts = new Object[2];
    opts[0] = ok;
    opts[1] = ca;
    JOptionPane.showOptionDialog(null, "OptionPane Demo", "demo",
    JOptionPane.DEFAULT_OPTION,
    JOptionPane.WARNING_MESSAGE, null,
    opts,
    opts[0]) ;问题解决了,哎!也怪自己太粗心,人家那个参数设计为Object[]又不是String[].