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

an Action.TEXT property should be added

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • None
    • 1.4.0, 1.4.2
    • client-libs
    • generic, x86
    • generic, windows_xp

    Description

      Name: jl125535 Date: 03/17/2004


      A DESCRIPTION OF THE REQUEST :
      When using JButton directly, you can set the name and the text properties to different values. E.g.:

      JButton button = new JButton();
      button.setName("MyButton");
      button.setText("MijnKnop");

      This is usefull for i18n. I can keep the name of the button constant, so I can refer to it always, and just have the text changed depending on the locale.

      When using an Action, the Action.NAME property sets the text property of JButton, not the name property of JButton.

      JUSTIFICATION :
      This is useful in a i18n environment especially when using the abbot library with actions (see http://abbot.sourceforge.net/ - it's an extention to JUnit for GUI testing). The abbot library uses the name to find the actual JButton to click on, so I want to keep this name the same across locales. I want to be able to define both properties in the Action.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Action.NAME should set the name property of a JButton
      a new property Action.TEXT should be added to set the text property of the JButton.

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

      /**
       *
       *
       */
      public class ButtonActionTest
      {
      public static void main( String[] args )
      {
      JButton button1 = new JButton("i18n version of Copy");
      button1.setName("Copy");
      System.out.println( "button 1 text: " + button1.getText() );
      System.out.println( "button 1 name: " + button1.getName() );

      JButton button2 = new JButton(new MyCopyAction());
      System.out.println( "button 2 text: " + button2.getText() );
      System.out.println( "button 2 name: " + button2.getName() );

      }

      private static class MyAction extends AbstractAction
      {
      public MyAction()
      {
      super( "Copy" ); //sets text property in reality
                               // This block is what I want
                               //putValue( Action.TEXT, "i18n version of Copy" );
                               //putValue( Action.NAME, "Copy" );

      }

      public void actionPerformed( ActionEvent e )
      {
      //Do something here
      }
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      call setName on the JButton you made using the Action
      (Incident Review ID: 240287)
      ======================================================================

      Attachments

        Activity

          People

            Unassigned Unassigned
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: