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

Window does not allow its children to get keyboard focus on Solaris

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.0, 1.1, 1.1.8
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      solaris_2.5, windows_nt

      Description

      I have tried it with both window focus policy (Point in window to make active and click in window to make active). The behaviour is very erratic. Sometimes
      it allows me to type a few characters.

      This bug is critical to my project. Since there are no workarounds
      for this problem, I think it correctly belongs in the P1/1 proirity.

      Please give me pointer to JavaSoft's criteria for bug prioritization.


      I have a JWindow that has a single child a JTextArea.
      This JTextArea never gets a keyboard focus, no matter what on Solaris.
      The bug seems to be both in Swing's JWindow and AWT's Window.

      This works fine on Win32.

      Here are the codes for both of them.

      /*
      File: JWindowBug.java
      Swing implementation
      */


      import com.sun.java.swing.*;

      import java.awt.Dimension;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.awt.event.*;
      import java.awt.Color;
      import java.awt.*;

      public class JWindowBug {

              public final JWindow window ;
              public final JButton button ;
              public final JTextArea text ;

          public JWindowBug() {
              JFrame frame = new JFrame("JWindowBug");
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}});

              window = new JWindow(frame);
              button = new JButton("Press Me");
              text = new JTextArea(10, 50);

              frame.getContentPane().add(button);
              window.getContentPane().setLayout(new BorderLayout());
              window.getContentPane().add( text, BorderLayout.CENTER);
              button.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ev) {
                      window.setSize(new Dimension(300, 200));
                      window.setLocation(button.getLocationOnScreen().x , button.getLocationOnScreen().y +
                               button.getSize().height);
                      window.setVisible(true);
                      text.grabFocus();
                      text.append("\n Hello there ");
                  }
              });

              frame.setSize(150, 150);
              frame.setLocation( new Point(150, 150));
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              new JWindowBug();
          }

      }


      /*
      File: WindowBug.java
      AWT implementation
      */

      import java.awt.Dimension;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.awt.event.*;
      import java.awt.Color;
      import java.awt.*;

      public class WindowBug {

              public final Window window ;
              public final Button button ;
              public final TextArea text ;

          public WindowBug() {
              Frame frame = new Frame("WindowBug");
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}});

              window = new Window(frame);
              button = new Button("Press Me");
              text = new TextArea(10, 50);

              frame.add(button);
              window.setLayout(new BorderLayout());
              window.add( text, BorderLayout.CENTER);
              button.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ev) {
                      window.setSize(new Dimension(300, 200));
                      window.setLocation(button.getLocationOnScreen().x , button.getLocationOnScreen().y +
                               button.getSize().height);
                      window.setVisible(true);
                      text.requestFocus();
                      text.append("\n Hello there ");
                  }
              });

              frame.setSize(150, 150);
              frame.setLocation( new Point(150, 150));
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              new WindowBug();
          }

      }




      Name: vi73552 Date: 05/26/99

      =20
      /*
      The following program demonstrate,=20
      that swing's JWindow has problem with focus handling.
      In the JFrame it is possible to "tab" between the components.
      In the JWindow this does not work properly.

      The problem exists both in "Swing 1.1" and "Swing 1.1.1 Beta 2".

      The test was performed under Windows NT with fixpak 3.


      */// File: Test.java

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

      public class Test {

      =09JTextField field1, field2, field3, field4;
      =09JFrame frame;
      =09JWindow window;
      =09JButton button1, button2;
      =09JPanel panel1, panel2;

      =09public Test() {
      =09=09field1 =3D new JTextField(10);
      =09=09field1.setText("field 1");
      =09=09field2 =3D new JTextField(10);
      =09=09field2.setText("field 2");
      =09=09field3 =3D new JTextField(10);
      =09=09field3.setText("field 3");
      =09=09field4 =3D new JTextField(10);
      =09=09field4.setText("field 4");
      =09=09panel1 =3D new JPanel();
      =09=09panel1.setLayout(new GridLayout(2, 1));
      =09=09panel1.add(field1);
      =09=09panel1.add(field2);
      =09=09panel2 =3D new JPanel();
      =09=09panel2.setLayout(new GridLayout(2, 1));
      =09=09panel2.add(field3);
      =09=09panel2.add(field4);
      =09=09button1 =3D new JButton("Press");
      =09=09button2 =3D new JButton("Don't Press");
      =09=09frame =3D new JFrame("Test");
      =09=09frame.getContentPane().add(panel1, "Center");
      =09=09frame.getContentPane().add(button1, "South");
      =09=09frame.pack();
      =09=09frame.setVisible(true);
      =09=09window =3D new JWindow(frame);
      =09=09window.getContentPane().add(panel2, "Center");
      =09=09window.getContentPane().add(button2, "South");
      =09=09ActionListener al =3D new ActionListener() {
      =09=09=09public void actionPerformed(ActionEvent ev) {
      =09=09=09=09window.pack();
      =09=09=09=09window.setLocation(200, 0);
      =09=09=09=09window.setVisible(true);
      =09=09=09}
      =09=09};
      =09=09button1.addActionListener(al);
      =09
      =09}
      =09
      =09public static void main(String[] args) {
      =09=09new Test();
      =09}

      }
      (Review ID: 83494)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                duke J. Duke (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: