|
Quick Lists
|
|
Bug ID:
|
6297220
|
|
Votes
|
0
|
|
Synopsis
|
JFileChooser.setApproveButtonMnemonic() does not set the mnemonic key
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
|
|
Release Fixed
|
|
|
State
|
3-Accepted,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
|
|
Submit Date
|
15-JUL-2005
|
|
Description
|
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
customer Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The JFileChooser.setApproveButtonMnemonic() seems not to work as expected ...
Please run the example provided below
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Component;
import java.awt.Container;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFileChooser;
public class FileChooserBug {
public static void main(String[] args) {
new FileChooserBug().showGUI();
}
public void showGUI() {
JFileChooser jFsChooser = new JFileChooser();
jFsChooser.setApproveButtonText("Add");
jFsChooser.setApproveButtonMnemonic(KeyEvent.VK_A);
System.out.println(jFsChooser.getApproveButtonMnemonic());
jFsChooser.showOpenDialog(null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
private void bugFix(Component comp) {
if (comp instanceof Container) {
Component[] c = ((Container) comp).getComponents();
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof JButton) {
JButton btn = ((JButton) c[i]);
String txt = btn.getText();
if (txt != null)
if (txt.equals("Add"))
btn.setMnemonic(KeyEvent.VK_A);
}
bugFix(c[i]);
}
}
}
xxxxx@xxxxx 2005-07-15 07:26:29 GMT
|
|
Work Around
|
N/A
|
|
Evaluation
|
According to the following code in MetalFileChooserUI.java, Metal doesn't use mnemonics for these buttons:
private void doApproveButtonMnemonicChanged(PropertyChangeEvent e) {
// Note: Metal does not use mnemonics for approve and cancel
}
Either this should be changed, or the docs should be brought in line to mention that the use of mnemonics is L&F dependent.
xxxxx@xxxxx 2005-07-15 17:25:03 GMT
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |