Key « JOptionPane « Java Swing Q&A





1. Setting Mnemonics and Hot Keys for a JOptionPane Dialog    stackoverflow.com

Is it possible to assign hotkeys and mnemonics to the buttons in a JOptionPane Dialog? I'd like to be able, in a JOptionPane generated message dialog with the options Yes, ...

2. Java JOptionPane.showConfirmDialog hot key    stackoverflow.com

I am displaying a confirmation dialog in Java using JOptionPane.showConfirmDialog. The dialog shows a Yes No confirmation to the user. This is called as follows:

int result = JOptionPane.showConfirmDialog(sessionObjects.getActiveComponent(), 
 ...

4. keyboard usage of a JOptionPane    coderanch.com

Which Look And Feel are you using? I seem to recall a "feature" of the Java Look And Feel that caused the return key to always press the default button in an option pane, and not the one that currently has the focus. I think the Windows Look And Feel has the behavior you are expecting. Also, this might have been ...

5. mnemonci keys in JoptionPane    coderanch.com

9. Set mnemonic key for JOptionPane.showOptionDialog    coderanch.com

import java.awt.event.*; import javax.swing.*; class Testing { public Testing() { JButton b1 = new JButton("OK"); JButton b2 = new JButton("Cancel"); b1.setMnemonic(KeyEvent.VK_O); b2.setMnemonic(KeyEvent.VK_C); JButton[] options = {b1,b2}; b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.out.println("OK"); } }); b2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.out.println("Cancel"); } }); JOptionPane.showOptionDialog(null, "", "",-1,2,null, options, options[0]); System.exit(0); } public static void main(String[] args){new Testing();} }





10. JOptionPane KeyEvent    java-forums.org