JDK-4201962 : Focus problems of JInternalFrames in a JDesktopPane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.6,1.2.0,1.2.2,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-01-09
  • Updated: 2000-10-23
  • Resolved: 2000-10-23
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 01/09/99


import javax.swing.*;
import java.awt.event.*;
import java.beans.*;

public class SwingTest extends JFrame{

	public SwingTest(){
		super("test");
		addWindowListener(new ExitHandler());
		setSize(300, 300);

		JDesktopPane dtp=new JDesktopPane();
		setLayeredPane(dtp);

		JInternalFrame if1=new JInternalFrame("f1", true, true, true, true);
		if1.setSize(150, 150);
		try{
			if1.setSelected(false);
		}
		catch(PropertyVetoException pve){
			pve.printStackTrace();
		}
		if1.show();

		JInternalFrame if2=new JInternalFrame("f2", true, true, true, true);
		if2.setSize(150, 150);
		try{
			if2.setSelected(true);
		}
		catch(PropertyVetoException pve){
			pve.printStackTrace();
		}
		if2.show();

		dtp.add(if1, JDesktopPane.DEFAULT_LAYER, 1);
		dtp.add(if2, JDesktopPane.DEFAULT_LAYER, 0);

		show();
	}

	public static void main(String args[]){
		new SwingTest();
	}
}

class ExitHandler extends WindowAdapter implements WindowListener{
	public void windowClosing(WindowEvent we){
		JFrame f=(JFrame)we.getSource();
		System.exit(0);
	}
}//end of source code


//Description
//
//When I try to load two JInternalFrames into a JFrame containing a 
//JDesktopPanel to hold them, both JInternalFrames start up having 
//the focus. The only way to get the focus onto one JInternalFrame 
//only is to iconify and then deiconify the two JInternalFrames. After
//this procedure the two frames behave as expected: clicking one moves 
//the focus and brings the frame to front. However, iconifying or 
//closing the frame that has the focus does still not result in the 
//other frame gaining the focus.
(Review ID: 48791)
======================================================================

Name: krT82822			Date: 06/12/99


We are using the Windows look and feel.  Under SWING 1.0.2 if a 
JInternalFrame (JIF) was closed, the previous JIF would become
the selected JIF.  When we switched to SWING 1.1 (and also in 
1.1.1 beta 1) the behavior changed.

Now when a JIF is closed, focus/selection seems to revert to the
first JIF opened.  For example: 3 JIF's are created and added
to the JDesktopPane of a JFrame.  As each is added, we perform a
moveToFront(), and a setSelected() so that the new JIF's are "on
top" and enabled.  After the third one is opened, the app. will 
look something like this...
 _______________________________________
|_|_______________________________|_|_|_|
|   ________________                    |
|  |________________|                   |
|  |    ____________|_____              |
|  | 1 |__________________|             |
|  |   |    ______________|___          |
|  |   | 2 |__________________|         |
|  |   |   |                  |         |
|  |___|   | 3                |         |
|      |   |                  |         |
|      |___|                  |         |
|          |                  |         |
|          |__________________|         |
|_______________________________________|

Now if we close JIF 3, and I would expect JIF 2 to be selected...
Instead, JIF 1 is brought to the front and selected.

The behavior is not consistent with the MDI Look and Feel that is
supposed to be provided by the WindowsLookAndFeel PLAF.

What's happening here???
(Review ID: 54440)
======================================================================

Name: skT88420			Date: 08/06/99


1. Run SwingSet on Window95.
2. Select Options Motif Look & Feel.
3. Select Internal Frame tab.
4. Press Make button twice.
5. 2 internal frames titled "Internal Frame 1" and 
   "Internal Frame 2" are displayed.
   "Internal Frame 2" is on top of "Internal Frame 1" and 
   "Internal Frame 2" is highlighted.
6. Iconify only "Internal Frame 2".
7. Deconify the icon corresponding to "Internal Frame 2".
8. Restored "Internal Frame 2" is covered by "Internal
   Frame 1".
(Review ID: 93601)
======================================================================

Name: skT88420			Date: 01/18/2000


java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

Problems occur when adding a JInternalFrame to a JDesktopPane when that desktop
pane has some iconified JInternalFrames. (PROBLEM 2 of 2)

The deiconified frames to be will be placed at the back of the z order (though
in the same layer) and clicking the title bar will not bring them to the front.

Reproducing the bug:  Start the SwingSet demo, click the Internal Frame tab.
Make a minimizable frame, then minimize it.  Make another frame.  Then
deiconify the first frame.  Try to bring this frame to front by clicking it -
you can't.

(Another bug report will be filed for a similar bug where the deiconified
frames are always selected when deiconified.)
(Review ID: 100099)
======================================================================

Comments
EVALUATION This report ended up a conglamoration of bug reports, some of which have been fixed, and others duplicated in other reports. I need to go through the individual reports added to this one, and figure out what other bug they refer to, or file a separate bug for them. Please try hard not to collapse unrelated bugs. hania.gajewska@Eng 1999-09-16 Name: apR10133 Date: 10/11/2000 The bug is not reproducible after the focus management enhancements. ###@###.### ======================================================================
11-06-2004

WORK AROUND Name: krT82822 Date: 06/12/99 Currently, we have supplanted the WindowsDesktopManager of the WindowsLookAndFeel PLAF with our own. In the switchFrame() method we changed if (next) { nextIndex = currentIndex + 1; if (nextIndex == count) { nextIndex = 0; } } else { nextIndex = currentIndex - 1; if (nextIndex == -1) { nextIndex = count - 1; } } to if (next) { nextIndex = currentIndex; // + 1; if (nextIndex == count) { nextIndex = 0; } } else { nextIndex = currentIndex - 1; if (nextIndex == -1) { nextIndex = count - 1; } } This causes other problems...like throwing control focus out-of-whack. I need to look at it closer when (if) I get time. (Review ID: 54440) ====================================================================== Name: skT88420 Date: 08/06/99 None. (Review ID: 93601) ======================================================================
11-06-2004