Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6298940
Votes 0
Synopsis AbstractButton.setModel doesn't fully update mnemonic
Category java:classes_swing
Reported Against
Release Fixed mustang(b50), 5.0u6(b03) (Bug ID:2128825)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 19-JUL-2005
Description
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.
  xxxxx@xxxxx   2005-07-19 20:33:37 GMT
Work Around
N/A
Evaluation
Need more investigation whether take mnemonic from new model or not
Posted Date : 2005-08-02 17:24:20.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang