-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.4.2
-
x86
-
windows_2000
Name: gm110360 Date: 04/23/2004
FULL PRODUCT VERSION :
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
I have placed a JPanel into JColorChooser using the
setPreviewPanel(JComponent) method.
Whenever the JColorChooser is resized, the JPanel gains an extra 10 pixels in height, and 26 pixels in width.
I have managed to work around this for the moment by overriding the getPreferredSize() method in the JPanel class, and making it return a constant value.
I think there is a bug in the layout class used by the JColorChooser to layout the position of the preview panel.
This problem does not occur in java 1.3.1-b24
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the supplied test code and resize the window by dragging an edge a few times.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The preview panel stays a constant size when the window is resized. At least it does in java 1.3.1-b24
ACTUAL -
The preview panel will gain an extra 10 pixels of height and 26 pixels of width each time the window is resized.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package testcolorchooser;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame
{
private JPanel contentPane;
private BorderLayout borderLayout1 = new BorderLayout();
private JColorChooser jColorChooser1 = new JColorChooser();
private JPanel myPreviewPanel = new JPanel();
//Construct the frame
public Frame1()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
contentPane.add(jColorChooser1, BorderLayout.CENTER);
myPreviewPanel.setBackground(Color.cyan);
myPreviewPanel.setSize(200,50);
myPreviewPanel.setPreferredSize(new Dimension(200,50));
jColorChooser1.setPreviewPanel(myPreviewPanel);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
//Main method
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{
e.printStackTrace();
}
Frame1 frame = new Frame1();
frame.validate();
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Override the setPreferredSize() method of the JComponent being used as a custom preview panel so that it returns a constant value
Release Regression From : 1.3.1
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Incident Review ID: 250200)
======================================================================
- relates to
-
JDK-5029286 REGRESSION: JColorChooser.setPreviewPanel() does not show custom preview panel
- Closed