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

text appears in toolbar button after Action.putValue(Action.NAME, ...)

    XMLWordPrintable

Details

    • beta
    • generic, sparc
    • generic, solaris_2.6

    Description



      Name: rmT116609 Date: 11/21/2000


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


      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      /**
       * JDK 1.3 does not show Action text in toolbar icon initially, but will after
      putValue(Action.NAME, ...).
       *
       * @version $Revision: 1.1 $, $Date: 2000/11/21 01:16:36 $
       * @author Andrew Chen
       */
      public class Bug extends JFrame {
          private final Icon UNDO = new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Undo16.gif"));
          private final Icon REDO = new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Redo16.gif"));

          /**
           * @version $Revision: 1.1 $, $Date: 2000/11/21 01:16:36 $
           * @author Andrew Chen
           */
          public class Undo extends AbstractAction {
              private boolean undo = true;

              public Undo() {
                  putValue(Action.NAME, "Undo");
                  putValue(Action.SMALL_ICON, UNDO);
                  }

              public void actionPerformed(ActionEvent event) {
                  undo = !undo;
                  // now, 'Undo' or 'Re-Do' will appear in toolbar button
                  putValue(Action.NAME, undo ? "Undo" : "Re-Do");
                  putValue(Action.SMALL_ICON, undo ? UNDO : REDO);
                  }
              }

          public Bug() {
              Action undo = new Undo();

              JToolBar toolbar = new JToolBar();
              toolbar.add(undo);

              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(toolbar, BorderLayout.NORTH);
              pack();
              }

          public static void main(String[] argv) {
              JFrame f = new Bug();
              f.setVisible(true);
              }
          }


      % javac Bug.java
      % java Bug

      Initially, toolbar Undo button has no text, but text shows once clicking on it.
      (Review ID: 112630)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              apikalev Andrey Pikalev
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: