JDK-4227768 : Z-ordering of Windows Look-and-Feel JInternalFrames
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.6,1.2.0,1.2.1,1.2.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-04-08
  • Updated: 2000-05-02
  • Resolved: 2000-05-02
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.
Other
1.4.0 betaFixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Description

Name: krT82822			Date: 04/07/99


Z-ordering of JInternalFrame "MDI" windows under Windows look-and-feel doesn't work properly. To see the problem, simply 

1. run SwingSet under Windows look-and-feel.
2. create a few internal frame windows (say "Internal Frame 1" through "Internal Frame 4".
3. close the most recently created window ("Internal Frame 4").
4. Internal Frame 3 (the next frame in the stack) should then be on top, but instead Internal Frame 1 pops up! This is NOT the case with Java look-and-feel: only Windows look-and-feel.

It seems you are simply keeping internal frames in a list and if any internal frame is closed, the oldest frame created is shown.

This may seem like a trivial problem, but my users really hate this "feature". When you close a window, the next window in the stack should open.
(Review ID: 56491) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

EVALUATION Indeed, the internal frames seem to get activated in seemingly random order. hania.gajewska@Eng 1999-09-16 Name: keC97670 Date: 04/10/2000 We can remove remapping of the actions that switch to next and previous frame in WindowsDesktopPaneUI and leave the original from BasicDesktopPaneUI. Also the wrong activation in BasicDesktopPaneUI is fixed (third file) ======================================================================
11-06-2004

WORK AROUND Name: krT82822 Date: 04/07/99 I could try to maintain the correct stack myself. ======================================================================
11-06-2004

SUGGESTED FIX Name: keC97670 Date: 04/10/2000 The following changes (diffs -C) should be applied. ------- BasicDesktopPaneUI.java ------- *** /tmp/dS0ayHt Mon Apr 10 14:33:59 2000 --- BasicDesktopPaneUI.java Mon Apr 10 14:33:31 2000 *************** *** 431,441 **** } /* ! * Handles navigating to the next internal frame. */ ! protected class NavigateAction extends AbstractAction { public void actionPerformed(ActionEvent e) { ! // navigate to the next frame verifyFramesCache(); selectedIndex++; if (selectedIndex >= framesCache.size()) { --- 431,441 ---- } /* ! * Handles navigating to the previous internal frame. */ ! protected class PreviousAction extends AbstractAction { public void actionPerformed(ActionEvent e) { ! // navigate to the previous frame verifyFramesCache(); selectedIndex++; if (selectedIndex >= framesCache.size()) { *************** *** 468,478 **** } /* ! * Handles navigating to the previous internal frame. */ ! private class PreviousAction extends AbstractAction { public void actionPerformed(ActionEvent e) { ! // navigate to the previous internal frame verifyFramesCache(); selectedIndex--; if (selectedIndex < 0) { --- 468,478 ---- } /* ! * Handles navigating to the next internal frame. */ ! private class NavigateAction extends AbstractAction { public void actionPerformed(ActionEvent e) { ! // navigate to the next internal frame verifyFramesCache(); selectedIndex--; if (selectedIndex < 0) { ------- WindowsDesktopManager.java ------- *** /tmp/dZlaWFt Mon Apr 10 14:24:48 2000 --- WindowsDesktopManager.java Mon Apr 10 14:23:46 2000 *************** *** 52,75 **** * We preserve the creation order so that "next" and "previous" * frame actions make sense. */ - Vector childFrames = new Vector(1); - - public void closeFrame(JInternalFrame f) { - if (f == currentFrame) { activateNextFrame(); } - childFrames.removeElement(f); - super.closeFrame(f); - } - public void activateFrame(JInternalFrame f) { try { super.activateFrame(f); ! // If this is the first activation, add to child list. ! if (childFrames.indexOf(f) == -1) { ! childFrames.addElement(f); ! } ! ! if (currentFrame != null && f != currentFrame) { // If the current frame is maximized, transfer that // attribute to the frame being activated. if (currentFrame.isMaximum() && --- 52,62 ---- * We preserve the creation order so that "next" and "previous" * frame actions make sense. */ public void activateFrame(JInternalFrame f) { try { super.activateFrame(f); ! if (currentFrame != null && f != currentFrame) { // If the current frame is maximized, transfer that // attribute to the frame being activated. if (currentFrame.isMaximum() && *************** *** 90,156 **** } catch (PropertyVetoException e) {} } - private void switchFrame(boolean next) { - if (currentFrame == null) { - // initialize first frame we find - if (initialFrame != null) - activateFrame(initialFrame); - return; - } - - int count = childFrames.size(); - if (count <= 1) { - // No other child frames. - return; - } - - int currentIndex = childFrames.indexOf(currentFrame); - if (currentIndex == -1) { - // should never happen... - return; - } - - int nextIndex; - if (next) { - nextIndex = currentIndex + 1; - if (nextIndex == count) { - nextIndex = 0; - } - } else { - nextIndex = currentIndex - 1; - if (nextIndex == -1) { - nextIndex = count - 1; - } - } - JInternalFrame f = (JInternalFrame)childFrames.elementAt(nextIndex); - activateFrame(f); - currentFrame = f; - } - - /** - * Activate the next child JInternalFrame, as determined by - * the frames' Z-order. If there is only one child frame, it - * remains activated. If there are no child frames, nothing - * happens. */ - public void activateNextFrame() { - switchFrame(true); - } - - /** same as above but will activate a frame if none - * have been selected - */ - public void activateNextFrame(JInternalFrame f){ - initialFrame = f; - switchFrame(true); - } - - /** - * Activate the previous child JInternalFrame, as determined by - * the frames' Z-order. If there is only one child frame, it - * remains activated. If there are no child frames, nothing - * happens. - */ - public void activatePreviousFrame() { - switchFrame(false); - } } --- 77,80 ---- ------- WindowsDesktopPaneUI.java ------- *** /tmp/dgQaiGt Mon Apr 10 14:29:04 2000 --- WindowsDesktopPaneUI.java Mon Apr 10 11:33:52 2000 *************** *** 41,47 **** } } ! void switchFrame(boolean next) { WindowsDesktopManager dm = (WindowsDesktopManager)desktop.getDesktopManager(); if (dm == null) { --- 41,47 ---- } } ! /* void switchFrame(boolean next) { WindowsDesktopManager dm = (WindowsDesktopManager)desktop.getDesktopManager(); if (dm == null) { *************** *** 53,67 **** dm.activatePreviousFrame(); } } ! protected void installKeyboardActions() { super.installKeyboardActions(); ActionMap map = SwingUtilities.getUIActionMap(desktop); ! if (map != null) { map.put("selectNextFrame", new SwitchFrameAction(true)); map.put("selectPreviousFrame", new SwitchFrameAction(false)); } ! // Request focus if it isn't set. if(!desktop.requestDefaultFocus()) { desktop.requestFocus(); --- 53,67 ---- dm.activatePreviousFrame(); } } ! */ protected void installKeyboardActions() { super.installKeyboardActions(); ActionMap map = SwingUtilities.getUIActionMap(desktop); ! /* if (map != null) { map.put("selectNextFrame", new SwitchFrameAction(true)); map.put("selectPreviousFrame", new SwitchFrameAction(false)); } ! */ // Request focus if it isn't set. if(!desktop.requestDefaultFocus()) { desktop.requestFocus(); *************** *** 69,75 **** } ! class SwitchFrameAction extends AbstractAction { boolean direction; SwitchFrameAction(boolean direction) { --- 69,75 ---- } ! /* class SwitchFrameAction extends AbstractAction { boolean direction; SwitchFrameAction(boolean direction) { *************** *** 80,84 **** switchFrame(direction); } } ! } --- 80,84 ---- switchFrame(direction); } } ! */} ======================================================================
11-06-2004