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

JTextField gets no focus in JWindow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0, 1.2.2
    • client-libs



      Name: skT88420 Date: 07/14/99


      JWindow should be an alternative to JFrame for frameless window
      applications.
      Since jdk1.1.7 (include jdk1.2.2), the behavior of JTextField's
      in a JWindow or a Window has become strange: The JTextField does
      not obtain the standard focus caret (the blinked slash) on
      mouse clicks on it. Only after a switch to another window, it
      obtains the focus caret. However, there can be more than one
      focus carets on a single JWindow, if more than one such
      switches are done.

      This behavior is not observed with jdk1.1.5 or jdk1.1.6 with
      swing1.0.3.

      If one uses TextField instead of JTextField, then everything is
      normal.

      The following is the source code the demonstrate the behavior:

      --------------------------------------------

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

      public class FocusTest
      {
          public static void textFieldinWindow()
          {
              JWindow window = new JWindow();
              Container c = window.getContentPane();
              c.setLayout(null);
              window.setSize(300,200);
              window.setLocation(100, 100);
              JTextField field1 = new JTextField("strange bahavior");
              JTextField field2 = new JTextField("strange bahavior");
              c.add(field1);
              c.add(field2);
              field1.setBounds(20, 40, 100, 30);
              field2.setBounds(20, 100, 100, 30);
              
              window.setVisible(true);
          }

          // Thie method is used only for purpose of comparison
          public static void textFieldinFrame()
          {
              JFrame frame = new JFrame();
              Container c = frame.getContentPane();
              c.setLayout(null);
              frame.setSize(300,200);
              frame.setLocation(500, 100);
              JTextField field1 = new JTextField("correct behavior");
              JTextField field2 = new JTextField("correct behavior");
              c.add(field1);
              c.add(field2);
              field1.setBounds(20, 40, 100, 30);
              field2.setBounds(20, 100, 100, 30);
              
              frame.setVisible(true);
          }
          
          public static void main(String[] arg)
          {
              textFieldinWindow();
              textFieldinFrame(); // used for comparison only
          }
      }

      ------------------------------------------------------

      Compile information:

      >java -version
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      >java -fullversion
      java full version "JDK-1.2.2-W"
      (Review ID: 85573)
      ======================================================================

      Name: skT88420 Date: 07/14/99


      JWindow should be an alternative to JFrame for frameless window
      applications.
      Since jdk1.1.7 (include jdk1.2.2), the behavior of JTextField's
      in a JWindow or a Window has become strange: The JTextField does
      not obtain the standard focus caret (the blinked slash) on
      mouse clicks on it. Only after a switch to another window, it
      obtains the focus caret. However, there can be more than one
      focus carets on a single JWindow, if more than one such
      switches are done.

      This behavior is not observed with jdk1.1.5 or jdk1.1.6 with
      swing1.0.3.

      If one uses TextField instead of JTextField, then everything is
      normal.

      The following is the source code the demonstrate the behavior:

      --------------------------------------------

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

      public class FocusTest
      {
          public static void textFieldinWindow()
          {
              JWindow window = new JWindow();
              Container c = window.getContentPane();
              c.setLayout(null);
              window.setSize(300,200);
              window.setLocation(100, 100);
              JTextField field1 = new JTextField("strange bahavior");
              JTextField field2 = new JTextField("strange bahavior");
              c.add(field1);
              c.add(field2);
              field1.setBounds(20, 40, 100, 30);
              field2.setBounds(20, 100, 100, 30);
              
              window.setVisible(true);
          }

          // Thie method is used only for purpose of comparison
          public static void textFieldinFrame()
          {
              JFrame frame = new JFrame();
              Container c = frame.getContentPane();
              c.setLayout(null);
              frame.setSize(300,200);
              frame.setLocation(500, 100);
              JTextField field1 = new JTextField("correct behavior");
              JTextField field2 = new JTextField("correct behavior");
              c.add(field1);
              c.add(field2);
              field1.setBounds(20, 40, 100, 30);
              field2.setBounds(20, 100, 100, 30);
              
              frame.setVisible(true);
          }
          
          public static void main(String[] arg)
          {
              textFieldinWindow();
              textFieldinFrame(); // used for comparison only
          }
      }

      ------------------------------------------------------

      Compile information:

      >java -version
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      >java -fullversion
      java full version "JDK-1.2.2-W"
      (Review ID: 85574)
      ======================================================================

            hgajewsksunw Hania Gajewska (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: