-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b07
-
x86
-
windows_xp
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2141730 | 6u1 | Mike Bronson | P4 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b95, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In some cases, the first element of JDesktopPane.getAllFrames array is an iconified internal frame. This leads to this iconified internal frame to be selected ( get the focus ) and be displayed in front of another expanded internal frames.
It seems that the internal frames array returned by getAllFrames is even more mangled as it does not respect the order in witch the frames were focused.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test. Then:
1. Minimize 'Frame 5', 'Frame 4', 'Frame 3', 'Frame 2' in this order ( let 'Frame 1' expanded ).
2. Expand back 'Frame 5'.
3. Minimize again 'Frame 5'.
All this time watch the console to see the result of the desktop.getAllFrames array.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After step 3, the selected frame should be 'Frame 1' ( the only expanded frame )
ACTUAL -
Instead, the focus is set to 'Frame 4' wich is iconified.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package bugs;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
public class InternalFramesBug {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("Mustang Internal Frames Bug");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JDesktopPane desktop = new JDesktopPane();
InternalFramesBug.populate(desktop);
frame.add(desktop);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds((screen.width-400)/2,(screen.height-400)/2,400,400);
frame.setVisible(true);
try {
desktop.getAllFrames()[0].setSelected(true);
} catch (Exception e) {
// ignore ?
}
}
});
}
public static void populate(final JDesktopPane desktop) {
for (int i = 0; i < 5; i++) {
JInternalFrame jif = new JInternalFrame("Frame "+(i+1), true, true, true, true);
jif.setBounds(20*(i%10), 20*(i%10), 200, 100);
desktop.add(jif);
jif.setVisible(true);
jif.addInternalFrameListener(new InternalFrameAdapter() {
@Override
public void internalFrameIconified(InternalFrameEvent arg0) {
// TODO Auto-generated method stub
for (JInternalFrame frame : desktop.getAllFrames()) {
System.out.println(frame.getTitle()+" "+frame.isIcon());
}
System.out.println("-----------");
}
});
}
}
}
---------- END SOURCE ----------
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b95)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b95, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
In some cases, the first element of JDesktopPane.getAllFrames array is an iconified internal frame. This leads to this iconified internal frame to be selected ( get the focus ) and be displayed in front of another expanded internal frames.
It seems that the internal frames array returned by getAllFrames is even more mangled as it does not respect the order in witch the frames were focused.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test. Then:
1. Minimize 'Frame 5', 'Frame 4', 'Frame 3', 'Frame 2' in this order ( let 'Frame 1' expanded ).
2. Expand back 'Frame 5'.
3. Minimize again 'Frame 5'.
All this time watch the console to see the result of the desktop.getAllFrames array.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After step 3, the selected frame should be 'Frame 1' ( the only expanded frame )
ACTUAL -
Instead, the focus is set to 'Frame 4' wich is iconified.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package bugs;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
public class InternalFramesBug {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("Mustang Internal Frames Bug");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JDesktopPane desktop = new JDesktopPane();
InternalFramesBug.populate(desktop);
frame.add(desktop);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds((screen.width-400)/2,(screen.height-400)/2,400,400);
frame.setVisible(true);
try {
desktop.getAllFrames()[0].setSelected(true);
} catch (Exception e) {
// ignore ?
}
}
});
}
public static void populate(final JDesktopPane desktop) {
for (int i = 0; i < 5; i++) {
JInternalFrame jif = new JInternalFrame("Frame "+(i+1), true, true, true, true);
jif.setBounds(20*(i%10), 20*(i%10), 200, 100);
desktop.add(jif);
jif.setVisible(true);
jif.addInternalFrameListener(new InternalFrameAdapter() {
@Override
public void internalFrameIconified(InternalFrameEvent arg0) {
// TODO Auto-generated method stub
for (JInternalFrame frame : desktop.getAllFrames()) {
System.out.println(frame.getTitle()+" "+frame.isIcon());
}
System.out.println("-----------");
}
});
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-2141730 First element of JDesktopPane.getAllFrames is an iconified internal frame
- Resolved