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

Focus is set incorrectly to parent of component on which requestFocus() is calle

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • linux_2.4

      Focus is incorrectly redirected to parent component instead to component on which requestFocus() was called.

      It is possible to see this behaviour when Editor window is selected and other window was selected before.

      This behaviour can be observer in JDK 1.4.0-beta-b63.
      In JDK 1.3.0 and JDK 1.3.1-rc2-b23 the same code works correctly.

      We have JComponent containing JEditorPane, requestFocus() is called on JEditorPane but focus is set to JComponent.

      More info: This bug also causes behaviour described in bug #4454403 and it is more urgent because it limits using Netbeans IDE even more.

      Steps to reproduce:
      1.Get development build of Netbeans IDE from http://www.netbeans.org/downloads.html (build 182 or later)
      2.Start Netbeans IDE in MDI mode and open any java source code.
      3.Make sure that Source Editor has keyboard focus - you can edit source.
      4.Select Explorer frame by mouse and select back Source Editor frame - now you see editor does not have keyboard focus.

      I added debug prints into CloneableEditor.processFocusEvent (subclass of JComponent) and QuietEditorPane.processFocusEvent (subclass of JEditorPane).
      requestFocus is called on QuietEditorPane when Source Editor frame is selected QuietEditorPane receives FOCUS_GAINED but after it it receives FOCUS_LOST and CloneableEditor receives FOCUS_GAINED. So instead of QuietEditorPane CloneableEditor gets focus. CloneableEditor is parent of QuietEditorPane in hiearchy (not direct). Hiearchy list (JavaEditorComponent is actually subclass of CloneableEditor; InternalFrameTypeImpl is subclass of JInternalFrame) gained by getParent().

      (NOTE: In this list P00 is child of P01 in hiearchy!!)

      P00:class org.openide.text.QuietEditorPane
      P01:class javax.swing.JViewport
      P02:class javax.swing.JScrollPane
      P03:class javax.swing.JPanel
      P04:class javax.swing.JPanel
      P05:class org.netbeans.modules.java.JavaEditor$JavaEditorComponent
      P06:class org.netbeans.core.windows.frames.PerimeterPane
      P07:class org.netbeans.core.windows.frames.SplitContainerImpl
      P08:class javax.swing.JLayeredPane
      P09:class javax.swing.JRootPane
      P10:class org.netbeans.core.windows.frames.InternalFrameTypeImpl
      P11:class javax.swing.JDesktopPane
      P12:class javax.swing.JViewport
      P13:class javax.swing.JScrollPane
      P14:class org.netbeans.core.windows.frames.DesktopPane

      I am investigating it further if I am able to identify it better. Anyway the same code works OK with JDK 1.3.0. If I find out anything new I let you know.

      Additional info: I added log from Netbeans IDE with some comments, please look at it, maybe it helps to find what is wrong.

      More details:
      I checked Netbeans dev build 184 with JDK-1.4.0-beta-b63, Linux 2.4.1 (RH 6.2 with Gnome WM) and it works fine - I can open file without any problem. What do you mean by 'latest AWT workspace'?

      IDE startup log:
      Setting up this user for the IDE...
      -- System info ----------------------------------------------------------------
        Product Version = NetBeans IDE, Development Version (Build 184)
        IDE Versioning = IDE/1 spec=1.7 impl=184
        Operating System = Linux version 2.4.1 running on i386
        Java; VM; Vendor = 1.4.0-beta; Java HotSpot(TM) Client VM 1.4.0-beta-b63; Sun Microsystems Inc.
        Java Home = /usr/java/jdk1.4/jre
        System Locale = en_US
        Home Dir; Current Dir = /home/ms124458; /mnt/local/mslama/netbeans_dev184
        IDE Install; User Dir = /mnt/local/mslama/netbeans_dev184; /home/ms124458/local/nbtest
        CLASSPATH = /mnt/local/mslama/netbeans_dev184/lib/patches/openide-compat.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/jaxp.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/jh.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/parser.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/regexp.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/rmi-ext.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/sax2.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/servlet.jar:/mnt/local/mslama/netbeans_dev184/lib/ext/xerces.jar:/mnt/local/mslama/netbeans_dev184/lib/core.jar:/mnt/local/mslama/netbeans_dev184/lib/openide-fs.jar:/mnt/local/mslama/netbeans_dev184/lib/openide-nodes.jar:/mnt/local/mslama/netbeans_dev184/lib/openide-util.jar:/mnt/local/mslama/netbeans_dev184/lib/openide.jar:/usr/java/jdk1.4/lib/dt.jar:/usr/java/jdk1.4/lib/htmlconverter.jar:/usr/java/jdk1.4/lib/tools.jar

      I stay today longer so we can communicate better. I will try to create simple standalone application to reproduce this behaviour - however I cannot say now if I will be successful.

      More details steps in Netbeans:
      1.After you start fresh build (empty user directory, user directory is set in bin/runide.sh - at beginning of script variable userdir - make sure you delete content of user directory) select MDI mode.
      2.In Explorer Filesystems tab by default there is node sampledir containing some java samples. Expand it and go to examples -> colorpicker folder.
      3. You will see ColorPreview and ColorPreviewBeanInfo java source nodes besides other nodes. Double click on ColorPreviewBeanInfo node. It will open Source Editor with this java source. Now you can check behaviour mentioned above with wrong focus by selecting Explorer and Source Editor frames by mouse. Beware: If you select second time Source Editor frame and QuietEditorPane did not have focus before it gets into infinite loop and you must kill IDE.

            dmendenhsunw David Mendenhall (Inactive)
            mslamasunw Marek Slama (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: