JDK-4885827 : JButton not updated when client property "hideActionText" changes.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.1_06,1.4.1,1.4.1_03,1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-07-01
  • Updated: 2005-08-26
  • Resolved: 2005-08-26
Related Reports
Duplicate :  
Description
Name: jk109818			Date: 07/01/2003


FULL PRODUCT VERSION :
java version "1.4.1_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)

FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

A DESCRIPTION OF THE PROBLEM :
Setting the client property "hideActionText" after a JButton has already been configured via an action will have no effect on the visibility of the button text.  AbstractButton should listen to changes of this property and update the button text appropriately.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the sample program (change the icon image to any icon on your system)


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Only the icon should be visible on the button.
ACTUAL -
Both the icon and the text are visible.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.net.URL;

import javax.swing.*;

public class Test
{
    public static final int STR_LEN = 10000;

    public static void main( String[] args )
    {
        try {
            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
            JDialog dialog = new JDialog( (Frame) null, true );
            JButton button = new JButton( new TestAction() );
            button.putClientProperty( "hideActionText", Boolean.TRUE );
            dialog.getContentPane().add( button );
            dialog.pack();
            dialog.show();
        }
        catch ( Exception e ) {
            e.printStackTrace();
        }
        finally {
            System.exit( 0 );
        }
    }

    static class TestAction extends AbstractAction
    {
        public TestAction() {
            putValue( NAME, "Test" );

            URL resourceURL = Test.class.getResource( "com/requisite/gui/graphics/help16.gif" );
            Icon icon = new ImageIcon( resourceURL );
            putValue( SMALL_ICON, icon );
        }

        public void actionPerformed( ActionEvent e )
        {
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
The work around is to create the button this way:

JButton button = new JButton();
button.putClientProperty( "hideActionText", Boolean.TRUE );
button.setAction( new TestAction() );
(Review ID: 189430) 
======================================================================

Comments
EVALUATION This is being fixed as part of 4133141, refer to it for details and status.
26-08-2005

EVALUATION Name: ibR10256 Date: 12/10/2003 BasicButtonListener receives property change events but doesn't process hideActionText property change. This should be fixed. ###@###.### 2003-12-10 ======================================================================
10-12-2003