JDK-6253913 : Reg. TextField in a Window having an iconified frame as parent behaves improperly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-04-12
  • Updated: 2011-01-19
  • Resolved: 2005-08-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b49Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
I have a TextFied in a window having an iconified frame as parent. The frame is in iconified state and the window is visible when the application is lauched. When the TextField is clicked, it gains focus and text can be entered in the TextField. Now click on a native window, so that it gains focus and then click on the TextField. The TextField gains focus but on entering some text, the text does not appear on the TextField. 

This is reproducible from mustang b27. Not reproducible on tiger b64. This occurs only on Windows platform.

To reproduce:
1. Run the attached code.
2. Click on the text field and enter some text. It could be seen that the text appears on the text field.
3. Click on a native window so that the text field loses focus.
4. Now click on the TextField and enter some text. If the text does not appear, bug is reproduced.
###@###.### 2005-04-12 12:56:08 GMT

Comments
SUGGESTED FIX ------- Dialog.java ------- *** /tmp/sccs.AEayH0 Wed Jul 27 16:31:09 2005 --- Dialog.java Wed Jul 27 16:22:36 2005 *************** *** 896,907 **** modalBlocker.toFront(); } setLocationByPlatform(false); for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = (Window) (((WeakReference) ! (ownedWindowList.elementAt(i))).get()); if ((child != null) && child.showWithParent) { child.show(); child.showWithParent = false; } // endif } // endfor --- 896,906 ---- modalBlocker.toFront(); } setLocationByPlatform(false); for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = ownedWindowList.elementAt(i).get(); if ((child != null) && child.showWithParent) { child.show(); child.showWithParent = false; } // endif } // endfor ------- Window.java ------- *** /tmp/sccs.Crayz0 Wed Jul 27 16:31:08 2005 --- Window.java Wed Jul 27 16:28:33 2005 *************** *** 167,177 **** * A vector containing all the windows this * window currently owns. * @since 1.2 * @see #getOwnedWindows */ ! transient Vector ownedWindowList = new Vector(); private transient WeakReference weakThis; transient boolean showWithParent; /** --- 167,178 ---- * A vector containing all the windows this * window currently owns. * @since 1.2 * @see #getOwnedWindows */ ! transient Vector<WeakReference<Window>> ownedWindowList = ! new Vector<WeakReference<Window>>(); private transient WeakReference weakThis; transient boolean showWithParent; /** *************** *** 604,620 **** SunToolkit.closeSplashScreen(); } Dialog.checkShouldBeBlocked(this); super.show(); locationByPlatform = false; for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = (Window) (((WeakReference) ! (ownedWindowList.elementAt(i))).get()); ! if ((child != null) && child.showWithParent) { ! child.show(); ! child.showWithParent = false; ! } // endif } // endfor if (!isModalBlocked()) { updateChildrenBlocking(); } } --- 605,625 ---- SunToolkit.closeSplashScreen(); } Dialog.checkShouldBeBlocked(this); super.show(); locationByPlatform = false; + boolean isFrameOrDialog = (this instanceof Frame || + this instanceof Dialog); for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = ownedWindowList.elementAt(i).get(); ! if ((child != null) && child.showWithParent) { ! child.show(); ! child.showWithParent = false; ! } // endif ! if (isFrameOrDialog && (child != null)) { ! updateChildFocusableWindowState(child); ! } } // endfor if (!isModalBlocked()) { updateChildrenBlocking(); } } *************** *** 625,634 **** --- 630,651 ---- postWindowEvent(WindowEvent.WINDOW_OPENED); state |= OPENED; } } + static private void updateChildFocusableWindowState(Window w) { + if (w.isShowing()) { + ((WindowPeer)w.getPeer()).updateFocusableWindowState(); + } + for (int i = 0; i < w.ownedWindowList.size(); i++) { + Window child = w.ownedWindowList.elementAt(i).get(); + if (child != null) { + updateChildFocusableWindowState(child); + } + } + } + synchronized void postWindowEvent(int id) { if (windowListener != null || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 || Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) { WindowEvent e = new WindowEvent(this, id); *************** *** 648,659 **** */ @Deprecated public void hide() { synchronized(ownedWindowList) { for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = (Window) (((WeakReference) ! (ownedWindowList.elementAt(i))).get()); if ((child != null) && child.visible) { child.hide(); child.showWithParent = true; } } --- 665,675 ---- */ @Deprecated public void hide() { synchronized(ownedWindowList) { for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = ownedWindowList.elementAt(i).get(); if ((child != null) && child.visible) { child.hide(); child.showWithParent = true; } } *************** *** 987,998 **** int fullSize = ownedWindowList.size(); int realSize = 0; Window fullCopy[] = new Window[fullSize]; for (int i = 0; i < fullSize; i++) { ! fullCopy[realSize] = (Window) (((WeakReference) ! (ownedWindowList.elementAt(i))).get()); if (fullCopy[realSize] != null) { realSize++; } } --- 1003,1013 ---- int fullSize = ownedWindowList.size(); int realSize = 0; Window fullCopy[] = new Window[fullSize]; for (int i = 0; i < fullSize; i++) { ! fullCopy[realSize] = ownedWindowList.elementAt(i).get(); if (fullCopy[realSize] != null) { realSize++; } } *************** *** 2186,2197 **** s.writeObject(null); synchronized (ownedWindowList) { for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = (Window) (((WeakReference) ! (ownedWindowList.elementAt(i))).get()); if (child != null) { s.writeObject(ownedWindowK); s.writeObject(child); } } --- 2201,2211 ---- s.writeObject(null); synchronized (ownedWindowList) { for (int i = 0; i < ownedWindowList.size(); i++) { ! Window child = ownedWindowList.elementAt(i).get(); if (child != null) { s.writeObject(ownedWindowK); s.writeObject(child); } } ------- XWindowPeer.java ------- *** /tmp/sccs.HQaOQ0 Wed Jul 27 16:31:10 2005 --- XWindowPeer.java Wed Jul 27 14:19:53 2005 *************** *** 261,273 **** * - Java window is non-focusable * - Java window is simple Window(not Frame or Dialog) */ boolean isNativelyNonFocusableWindow() { if (XToolkit.isToolkitThread()) { - return isSimpleWindow() || !isFocusableWindow(); - } else { return isSimpleWindow() || !cachedFocusableWindow; } } public void handleWindowFocusInSync(long serial) { --- 261,273 ---- * - Java window is non-focusable * - Java window is simple Window(not Frame or Dialog) */ boolean isNativelyNonFocusableWindow() { if (XToolkit.isToolkitThread()) { return isSimpleWindow() || !cachedFocusableWindow; + } else { + return isSimpleWindow() || !isFocusableWindow(); } } public void handleWindowFocusInSync(long serial) { *************** *** 1236,1246 **** XToolkit.removeEventDispatcher(XToolkit.getDefaultRootWindow(), rootPropertyEventDispatcher); rootPropertyEventDispatcher = null; } } ! public void updateFocusableWindowState() {} XAtom XA_NET_WM_STATE; XAtomList net_wm_state; public XAtomList getNETWMState() { if (net_wm_state == null) { --- 1236,1251 ---- XToolkit.removeEventDispatcher(XToolkit.getDefaultRootWindow(), rootPropertyEventDispatcher); rootPropertyEventDispatcher = null; } } ! public void updateFocusableWindowState() { ! // Though, this might not be called on Toolkit ! if (!XToolkit.isToolkitThread()) { ! cachedFocusableWindow = isFocusableWindow(); ! } ! } XAtom XA_NET_WM_STATE; XAtomList net_wm_state; public XAtomList getNETWMState() { if (net_wm_state == null) {
27-07-2005

EVALUATION Iconified state doesn't matter here. The problem appears when a Window is shown before its parent. In this case its focusability state is set to false as its decorated parent is not yet shown. Its state is not updated then.
25-07-2005