-
Bug
-
Resolution: Fixed
-
P4
-
6u12, 7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2169701 | 6u12 | Anthony Petrov | P2 | Closed | Fixed | b02 |
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b22)
Java HotSpot(TM) Client VM (build 11.0-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Service Pack 2
A DESCRIPTION OF THE PROBLEM :
JDK 7 supports mixing of heavyweight and lightweight components (currently based on isOpaque() return value of lightweight components). That feature does not seem to work for children of GlassPane. See the test program.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute the following program.
2. Drop down the menu
3. Observer how the drop down Menu, JInternalFrame and the heavyweight button get painted.
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
public class TestFrame {
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu menu = new JMenu("Menu");
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menuBar.add(menu);
// LAYERED PANE SECTION
// JLayeredPane layeredPane = frame.getRootPane().getLayeredPane();
// JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true);
// internalFrame.setBounds(50, 50, 200, 100);
// internalFrame.setVisible(true);
// layeredPane.add(internalFrame, JLayeredPane.PALETTE_LAYER);
// GLASSPANE PANE SECTION
JPanel glassPane = (JPanel) frame.getRootPane().getGlassPane();
glassPane.setVisible(true);
glassPane.setLayout(null);
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true);
internalFrame.setBounds(50, 0, 200, 100);
internalFrame.setVisible(true);
glassPane.add(internalFrame);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new Button("Heavyweight Button"));
frame.setSize(400, 400);
frame.setVisible(true);
}
}
If you comment out the GLASSPANE SECTION and uncomment the LAYERED PANE section and then execute the program that works well.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect to see the full JInternalFrame.
ACTUAL -
The JInternalFrame is being clicpped by the HeavyWeight button.
If you want to use the glasspane for what it is intended for this is a huge problem.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
mport java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
public class TestFrame {
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu menu = new JMenu("Menu");
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menu.add(new JMenuItem("Menu Item"));
menuBar.add(menu);
// LAYERED PANE SECTION
// JLayeredPane layeredPane = frame.getRootPane().getLayeredPane();
// JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true);
// internalFrame.setBounds(50, 50, 200, 100);
// internalFrame.setVisible(true);
// layeredPane.add(internalFrame, JLayeredPane.PALETTE_LAYER);
// GLASSPANE PANE SECTION
JPanel glassPane = (JPanel) frame.getRootPane().getGlassPane();
glassPane.setVisible(true);
glassPane.setLayout(null);
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true);
internalFrame.setBounds(50, 0, 200, 100);
internalFrame.setVisible(true);
glassPane.add(internalFrame);
Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new Button("Heavyweight Button"));
frame.setSize(400, 400);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
- backported by
-
JDK-2169701 Mixing of heavyweight/lightweight components does not wrk with GlassPane childre
- Closed
- duplicates
-
JDK-6768307 PIT : JComboBox's popup gets hidden below the heavy weight (AWT ) button
- Closed
-
JDK-2169232 PIT : JComboBox's popup gets hidden below the heavy weight (AWT ) button
- Closed
- relates to
-
JDK-6981919 Lightweight component in GlassPane is not redrawn over heavyweight component during move.
- Closed
-
JDK-6776743 Lightweight components must be counted as opaque rectangles for the purposes of hw/lw mixing
- Closed
-
JDK-6779670 Recursive procedures in the HW/LW Mixing code must traverse parent containers
- Closed
-
JDK-6778882 InternalFrame within glass pane goes below a heavy weight component
- Closed
-
JDK-6797195 Forward-port enhancements for hw/lw mixing from 6u12 to 7
- Closed