-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
---
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
---
java version "1.4.2_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
---
java version "1.3.1_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_16-b06)
Java HotSpot(TM) Client VM (build 1.3.1_16-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Linux 2.6.16-1.2069_FC4smp #1 SMP Tue Mar 28 12:47:32 EST 2006 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The popup in a JComboBox fails to appear under some conditions.
- setLightWeightPopupEnabled(true) (which seems to be the default)
The behavior varies depending on JPanel nesting levels and selected Layout Managers, which provided code will demonstrate.
The code has been tested under Windows XP with Java 1.5.0_06, 1.4.2 and 1.3.1 and under Linux with Java 1.5.0_06 with identical result.
It doesn't seem to be depending on the Look&Feel since the behavior is the same both when using Metal and Windows.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.UIManager;
/** */
public class TestDialog
extends JDialog
{
public TestDialog(Frame owner, boolean modal)
{
super(owner, "", modal);
init();
}
private void init()
{
JRootPane root = this.getRootPane();
root.setLayout(new BorderLayout());
// Using this call ONLY will cause neither JComboBox to work correctly.
// root.add(this.getEntryPanel(), BorderLayout.CENTER);
// Using these calls will stop one JComboBox to work correctly.
root.add(this.getCenterPanel(), BorderLayout.CENTER);
root.add(this.getBottomPanel(), BorderLayout.SOUTH);
this.setSize(new Dimension(640, 480));
this.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent e)
{
System.exit(0);
}
});
}
private JPanel getBottomPanel()
{
JPanel jp1 = new JPanel();
jp1.setLayout(new FlowLayout());
jp1.add(this.getButton());
return jp1;
}
private JPanel getCenterPanel()
{
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
jp.add(getEntryPanel(), BorderLayout.SOUTH);
return jp;
}
private JPanel getEntryPanel()
{
JPanel jp = new JPanel();
jp.setLayout(new FlowLayout());
// Does work as expected.
{
JComboBox tagType = new JComboBox(new String[]
{
"a",
"b",
"c"
});
jp.add(tagType);
}
// Does not work as expected.
{
JComboBox tagType = new JComboBox(new String[]
{
"a",
"b"
});
jp.add(tagType);
}
return jp;
}
private JButton getButton()
{
JButton button = new JButton();
// comment button.setText() will make the bug disappear.
button.setText("OK");
return button;
}
/**
* @param args
*/
public static void main(String [] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
TestDialog td=new TestDialog(null, false);
td.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use setLightWeightPopupEnabled(false) on all JComboBoxes.
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
---
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
---
java version "1.4.2_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
---
java version "1.3.1_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_16-b06)
Java HotSpot(TM) Client VM (build 1.3.1_16-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Linux 2.6.16-1.2069_FC4smp #1 SMP Tue Mar 28 12:47:32 EST 2006 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The popup in a JComboBox fails to appear under some conditions.
- setLightWeightPopupEnabled(true) (which seems to be the default)
The behavior varies depending on JPanel nesting levels and selected Layout Managers, which provided code will demonstrate.
The code has been tested under Windows XP with Java 1.5.0_06, 1.4.2 and 1.3.1 and under Linux with Java 1.5.0_06 with identical result.
It doesn't seem to be depending on the Look&Feel since the behavior is the same both when using Metal and Windows.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.UIManager;
/** */
public class TestDialog
extends JDialog
{
public TestDialog(Frame owner, boolean modal)
{
super(owner, "", modal);
init();
}
private void init()
{
JRootPane root = this.getRootPane();
root.setLayout(new BorderLayout());
// Using this call ONLY will cause neither JComboBox to work correctly.
// root.add(this.getEntryPanel(), BorderLayout.CENTER);
// Using these calls will stop one JComboBox to work correctly.
root.add(this.getCenterPanel(), BorderLayout.CENTER);
root.add(this.getBottomPanel(), BorderLayout.SOUTH);
this.setSize(new Dimension(640, 480));
this.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent e)
{
System.exit(0);
}
});
}
private JPanel getBottomPanel()
{
JPanel jp1 = new JPanel();
jp1.setLayout(new FlowLayout());
jp1.add(this.getButton());
return jp1;
}
private JPanel getCenterPanel()
{
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
jp.add(getEntryPanel(), BorderLayout.SOUTH);
return jp;
}
private JPanel getEntryPanel()
{
JPanel jp = new JPanel();
jp.setLayout(new FlowLayout());
// Does work as expected.
{
JComboBox tagType = new JComboBox(new String[]
{
"a",
"b",
"c"
});
jp.add(tagType);
}
// Does not work as expected.
{
JComboBox tagType = new JComboBox(new String[]
{
"a",
"b"
});
jp.add(tagType);
}
return jp;
}
private JButton getButton()
{
JButton button = new JButton();
// comment button.setText() will make the bug disappear.
button.setText("OK");
return button;
}
/**
* @param args
*/
public static void main(String [] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Throwable e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
TestDialog td=new TestDialog(null, false);
td.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use setLightWeightPopupEnabled(false) on all JComboBoxes.