Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4885827

JButton not updated when client property "hideActionText" changes.

    XMLWordPrintable

Details

    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)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              svioletsunw Scott Violet (Inactive)
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: