-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.1
-
x86
-
windows_2000
Name: jk109818 Date: 08/28/2002
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
AND
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
sun's TechTip
http://developer.java.sun.com/developer/JDCTechTips/2001/tt1
220.html
shows how to create modal or semi-modal internal frames
using a glassPane. If a JComboBox is added to the internal
frame, the following behavior is observed:
- JDK1.3.1, JDK1.4.0/1.4.1Beta with a Look And Feel
different from "Windows": Only the portion of the combo box
list falling outside of the internal frame bounds is
visible.
- JDK1.4.0/1.4.1Beta with Window with Windows Look And
Feel: The JCombo list is visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the attached application (which is derived from
Sun's example) passing "Windows" as argument.
2. Click on "Open"
3. Open the combo list: everything looks ok.
4. repeat the same operation passing "CDE/Motif"
or "Metal". the list is partially invisible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
The combo should work fine with all look and feels, or Sun
should provide a working tip.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Modal {
static class ModalAdapter
extends InternalFrameAdapter {
Component glass;
public ModalAdapter(Component glass) {
this.glass = glass;
// Associate dummy mouse listeners
// Otherwise mouse events pass through
MouseInputAdapter adapter =
new MouseInputAdapter(){};
glass.addMouseListener(adapter);
glass.addMouseMotionListener(adapter);
}
public void internalFrameClosed(
InternalFrameEvent e) {
glass.setVisible(false);
}
}
public static void main(String args[]) {
System.out.println("Installed lookAndFeels:");
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
for(int i=0; i<lafInfo.length; i++) {
System.out.println(lafInfo[i].getName());
}
String lookAndFeel = null;
if (args.length>0)
lookAndFeel = args[0];
initLookAndFeel(lookAndFeel);
final JFrame frame = new JFrame(
"Modal Internal Frame");
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
final JDesktopPane desktop = new JDesktopPane();
ActionListener showModal =
new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Manually construct a message frame popup
JOptionPane optionPane = new JOptionPane();
optionPane.setMessage("Hello, World");
optionPane.setMessageType(
JOptionPane.INFORMATION_MESSAGE);
// JInternalFrame modal = optionPane.
// createInternalFrame(desktop, "Modal");
JInternalFrame modal = new JInternalFrame
("test", true, true, true);
JPanel jp = (JPanel )modal.getContentPane();
JComboBox jcb = new JComboBox(new String[]{"choice
a", "choice b"});
jp.setLayout(new BorderLayout());
jp.add(jcb,BorderLayout.NORTH);
jp.add(new JTextArea(),BorderLayout.CENTER);
// create opaque glass pane
JPanel glass = new JPanel();
glass.setOpaque(false);
// Attach modal behavior to frame
modal.addInternalFrameListener(
new ModalAdapter(glass));
// Add modal internal frame to glass pane
glass.add(modal);
// Change glass pane to our panel
frame.setGlassPane(glass);
// Show glass pane, then modal dialog
modal.setVisible(true);
glass.setVisible(true);
System.out.println("Returns immediately");
}
};
JInternalFrame internal =
new JInternalFrame("Opener");
desktop.add(internal);
JButton button = new JButton("Open");
button.addActionListener(showModal);
Container iContent = internal.getContentPane();
iContent.add(button, BorderLayout.CENTER);
internal.setBounds(25, 25, 200, 100);
internal.setVisible(true);
Container content = frame.getContentPane();
content.add(desktop, BorderLayout.CENTER);
frame.setSize(500, 300);
frame.setVisible(true);
}
private static void initLookAndFeel(String lookAndFeel) {
String lookAndFeelClassName = null;
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels
();
for(int i=0; i<lafInfo.length; i++) {
if (lafInfo[i].getName().equals(lookAndFeel)) {
lookAndFeelClassName = lafInfo[i].getClassName();
}
}
if (lookAndFeelClassName == null)
System.err.println("No class found for lookAndFeel: "+ lookAndFeel);
try {
UIManager.setLookAndFeel(lookAndFeelClassName);
} catch (ClassNotFoundException e) {
System.err.println("Couldn't find class for specified look and feel:"
+ lookAndFeel);
System.err.println("Did you include the L&F library in the class
path?");
System.err.println("Using the default look and feel.");
} catch (UnsupportedLookAndFeelException e) {
System.err.println("Can't use the specified look and feel ("
+ lookAndFeel
+ ") on this platform.");
System.err.println("Using the default look and feel.");
} catch (Exception e) {
System.err.println("Couldn't get specified look and feel ("
+ lookAndFeel
+ "), for some reason.");
System.err.println("Using the default look and feel.");
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
use non-modal or non internal modal windows, but this is
really annoying.
(Review ID: 158607)
======================================================================
- duplicates
-
JDK-4707111 JPopupMenus in JFileChooser() don't display properly when added to a glass Pane
-
- Open
-