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

JTextField doesn't get focus or loses focus forever

    Details

    • Subcomponent:
    • Introduced In Version:
      7
    • Resolved In Build:
      b87
    • CPU:
      x86
    • OS:
      linux

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0_03"
        Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
        Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux Celsius 3.2.6 #1 SMP Wed Feb 15 12:04:35 CET 2012 i686 Intel(R) Pentium(R) D CPU 3.20GHz GenuineIntel GNU/Linux

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        XWindow manager: IceWM. No KDE, Gnome or such.

        A DESCRIPTION OF THE PROBLEM :
        1. A JTextField created as a child of the main JFrame _never_ gets the focus when the user clicks into it.

        2. A JTextField in a dynamically created JDialog loses the focus as soon as the cursor is moved out of the parent JFrame, and _never_ gets it back.

        No such problems on Windows XP!

        REGRESSION. Last worked in version 6u29

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Start attached test program.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Text field should gain focus when clicked into.
        ACTUAL -
        Text field gets focus once and then loses it forever, or doesn't get it at all.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;

        // Focus bug

        public class Focusbug
            extends JFrame
        {
            JDialog dia;

            Focusbug(String titel)
            {
                super(titel);
                setDefaultCloseOperation(EXIT_ON_CLOSE);

                dia = new JDialog(this);
                dia.setBounds(10, 10, 200,70);
                dia.add(new JTextField("One-way focus"));

                JButton start = new JButton("Create dialog");

                start.addActionListener(new ActionListener()
                {
                    public void actionPerformed(ActionEvent e)
                    {
                        dia.setVisible(true);
                    }
                });

                add(start, BorderLayout.NORTH);

                JPanel panel = new JPanel();

                panel.add(new JTextField("No focus here"));
                add(panel, BorderLayout.SOUTH);
            }
            
            static public void main(String[] args)
            {
                Focusbug focusbug = new Focusbug("Focusbug");

                focusbug.setBounds(100, 100, 250, 100);
                focusbug.setVisible(true);
            }
        }


        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ant Anton Tarasov
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: