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

BasicComboBoxEditor.setItem() works incorrectly.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: nkR10003 Date: 06/05/2001


      JavaDoc comments for method BasicComboBoxEditor.setItem(Object anObject) state:

      "Sets the item that should be edited. If anObject is an instance of
      java.lang.Number then the editor is constrained to only accept numerical
      values."

      Actually the editor accepts any value that starts with digit.

      Example below demonstrates this problem:
      ------------------example--------------------
      import javax.swing.plaf.basic.BasicComboBoxEditor;

      public class test {
          public static void main(String[] args) {
              BasicComboBoxEditor c = new BasicComboBoxEditor();
              Object number = new Integer(5);
              Object nonNumber = new String("5test");
              c.setItem(number);
              System.out.println("Editor configured to accept only numbers");
              c.setItem(nonNumber);
              if (c.getItem() != null
                      && c.getItem().equals(nonNumber)) {
                  System.out.println("value to set : " + nonNumber);
                  System.out.println("returned value: " + c.getItem());
                  System.out.println("Test failed");
              } else {
                  System.out.println("Test passed");
              }
          }
      }
      ------------------output---------------------
      Editor configured to accept only numbers
      value to set : 5test
      returned value: 5test
      Test failed
      ---------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            mdavidsosunw Mark Davidson (Inactive)
            Reporter:
            knasunw Kna Kna (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: