-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2
-
b50
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2128825 | 5.0u6 | Nishant Patel | P3 | Resolved | Fixed | b03 |
FULL PRODUCT VERSION :
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Linux localhost.localdomain 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When a button has its model set it does not correctly pick up the mnemonic from the model. The letter is highlighted (on appropriate PL&Fs), but is inoperable. Further resetting the mnemonic after the model is set still does not work. Actions are unaffected. The mistakes are obvious and trivially fixable from the source.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached program. Give the window focus and press Alt-P.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should show button pressed and write to standard out:
"What P is..."
This does happen when the button is pressed.
ACTUAL -
Does nothing. Sits there like a lemon.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;
class Mnemon {
public static void main(String[] args) {
JButton button = new JButton("P plz");
ButtonModel model = new DefaultButtonModel();
model.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.out.println("What P is...");
}
});
model.setMnemonic('P');
//button.setMnemonic(model.getMnemonic());
button.setModel(model);
JFrame frame = new JFrame("Button mnemonic test");
frame.getContentPane().add(button);
frame.pack();
frame.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
* Set the mnemonic *before* the model:
button.setMnemonic(model.getMnemonic());
button.setModel(model);
* Subclass the button and override setModel with:
public void setModel(ButtonModel model) {
this.setMntMnemonic(model.getMnemonic());
super.setModel(model);
}
* Use Action or other alternate mechanism.
###@###.### 2005-07-19 20:33:37 GMT
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Linux localhost.localdomain 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When a button has its model set it does not correctly pick up the mnemonic from the model. The letter is highlighted (on appropriate PL&Fs), but is inoperable. Further resetting the mnemonic after the model is set still does not work. Actions are unaffected. The mistakes are obvious and trivially fixable from the source.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached program. Give the window focus and press Alt-P.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should show button pressed and write to standard out:
"What P is..."
This does happen when the button is pressed.
ACTUAL -
Does nothing. Sits there like a lemon.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;
class Mnemon {
public static void main(String[] args) {
JButton button = new JButton("P plz");
ButtonModel model = new DefaultButtonModel();
model.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.out.println("What P is...");
}
});
model.setMnemonic('P');
//button.setMnemonic(model.getMnemonic());
button.setModel(model);
JFrame frame = new JFrame("Button mnemonic test");
frame.getContentPane().add(button);
frame.pack();
frame.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
* Set the mnemonic *before* the model:
button.setMnemonic(model.getMnemonic());
button.setModel(model);
* Subclass the button and override setModel with:
public void setModel(ButtonModel model) {
this.setMntMnemonic(model.getMnemonic());
super.setModel(model);
}
* Use Action or other alternate mechanism.
###@###.### 2005-07-19 20:33:37 GMT
- backported by
-
JDK-2128825 AbstractButton.setModel doesn't fully update mnemonic
-
- Resolved
-
- relates to
-
JDK-8342524 Use latch in AbstractButton/bug6298940.java instead of delay
-
- Resolved
-