JDK-4254005 : JTextField gets no focus in JWindow
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0,1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-07-14
  • Updated: 2000-10-23
  • Resolved: 2000-10-23
Related Reports
Duplicate :  
Duplicate :  
Description

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)
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 07/14/99 Do not use JDK version since 1.1.7, use JDK 1.1.6 or earlier versions only. ====================================================================== Name: skT88420 Date: 07/14/99 Do not use JDK 1.1.7 or later, use only JDK 1.1.6 or earlier. (Review ID: 85574) ======================================================================
11-06-2004

EVALUATION This occurs in 1.3, but its a focus problem and not a text problem. I'm passing this along. timothy.prinzing@eng 1999-09-07 I am guessing this is an awt bug having to do with the whole Window focus mess, but I won't reassign until looking at this further. The title claims that this is a duplicate of 4193062, which it is not, so I am changing the title to avoid confusion. hania.gajewska@Eng 1999-09-16 Name: pzR10082 Date: 10/23/2000 This bug has disappeared in Merlin after focus changes. However, test should be slightly modified in order to work. It uses JWindow with null owner, and such JWindows are always non-focusable. If the window has a real parent, textfields are quite focusable: Frame f = new Frame(); JWindow window = new JWindow(f); ###@###.### 2000-10-23 ======================================================================
23-10-2000