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

RFE: Cannot set some AWT properties until peer has been created

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.0.2, 1.1.6
    • client-libs
    • tiger
    • generic, sparc
    • generic, solaris_2.5



      Name: rlT66838 Date: 07/26/99


      Certain properties on AWT components cannot be
      set until the peer has been created. An example
      is the caretPosition property of the TextField.

      Code to reproduce:

      >>>
      TextField tf1 = new TextField() ;
      tf1.setText( "qwerty" ) ;
      tf1.setCaretPosition( 2 ) ;
      <<<

      The following exception report appears on Windows
      NT 4.0:

      >>>
      java.awt.IllegalComponentStateException: Cannot set caret position until after the peer has been created
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.RuntimeException.<init>(Compiled Code)
              at java.lang.IllegalStateException.<init>(IllegalStateException.java:56)
              at java.awt.IllegalComponentStateException.<init>(IllegalComponentStateException.java:53)
              at java.awt.TextComponent.setCaretPosition(TextComponent.java:350)
              at MyClass.<init>(MyClass.java:33)
              at MyClass.main(MyClass.java:68)
      <<<

      Surely these properties could, like the text
      property, be stored away by the TextField object
      and passed over to the peer when the latter is
      created?

      This would not only make code easier to write and
      to understand, but would also help when trying
      to generate code from bean-building applications
      (eg. the BeanBox).

      Because nothing in the bean spec allows bean-
      builders to find out whether a particular
      property has any restrictions on when it can be
      set, properties which cannot be set until the
      peer has been created cannot be handled gracefully
      by bean-builders which use code generation.
      (Review ID: 35386)
      ======================================================================

            uwesunw Uwe Uwe (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: