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: 6182942
Votes 0
Synopsis JButton.isEnabled() return false however the button is enabled
Category java:classes_swing
Reported Against
Release Fixed mustang(b50)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 6343899
Submit Date 21-OCT-2004
Description
FULL PRODUCT VERSION :
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
If you create a JButton from an Action that is disabled and then you change the JButtons model to a new DefaultButtonModel() then the button appiers enabled, however, the buttons isEnabled() method returns false.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the snippet as is.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The buttons isEnabled() has to return true, when the button can be pressed (= is enabled)
ACTUAL -
The method return false.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import  java.awt.event.*;
import javax.swing.*;

public class MainClass {

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Action a = new AbstractAction("Button") {

      public void actionPerformed(ActionEvent e) {
        System.out.println(((JComponent)e.getSource()).isEnabled());
      }

      public void setEnabled(boolean b) {
        super.setEnabled(false);
      }
    };
    a.setEnabled(false);
    JButton bt = new JButton(a);
    frame.getContentPane().add(bt);
    bt.setModel(new DefaultButtonModel());
    frame.pack();
    frame.show();
  }
}
---------- END SOURCE ----------
  xxxxx@xxxxx   10/21/04 23:07 GMT

We have received a fix for this bug from java.net user thulin.
Attached is the contribution.txt
  xxxxx@xxxxx   2005-05-05 19:55:09 GMT
Work Around
N/A
Evaluation
Received a fix for this from java.net user thulin. Attached is the
contribution.txt
  xxxxx@xxxxx   2005-05-20 23:52:10 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang