JDK-4380468 : JColorChooser's HSB panel sometimes displays 1 RGB digit
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-10-18
  • Updated: 2001-01-17
  • Resolved: 2001-01-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Description

Name: rmT116609			Date: 10/18/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

1. Run the SwingSet2 demo.
2. Click the JColorChooser demo button (3rd one).
3. Click any of the color buttons.
4. Click the HSB tab.
5. Click in the lower left corner of the gradient
   palette in order to select a color such that
   all three RGB values are single digit colors
   (such as 0, 0, 0 or 5, 3, 1).
6. Click another tab, then click back to the HSB tab.
7. Now click the lighter colors that should have
   2 and 3 digit RGB values. The bug is that only
   the last digit of their values show.

Explanation:

DefaultHSBChooserPanel uses a layout class called
SmartGridLayout to lay out the RGB part. It does so
on tab changes and apparently focus events. The problem
is that once it has layed out the RGB text fields for
a single digit, they will only become wide enough for
more digits if layed out again. Simply clicking
colors on the gradient palette does not cause a layout.
Therefore, the text fields remain too small until
a layout causing event occurs.
(Review ID: 109782) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
24-08-2004

EVALUATION Name: apR10133 Date: 12/19/2000 The problem is in class colorchooser/DefaultHSBChooserPanel.java I guess we should make the RGB fields with a fixed width, but not to revalidate it every time. ###@###.### ======================================================================
24-08-2004

WORK AROUND Name: rmT116609 Date: 10/18/2000 The JColorChooser and related code is not very easily extended. Most members, functions, and classes are protected from outside use. It does many other things that are undesirable (or are bugs) and requires extraordinary workarounds due to its closed coding. This problem can be worked around easily but it is not elegant. Simply create the below class and add it as a ChangeListener to the JColorChooser within a class where chooser is set to the JColorChooser instance (or modify this listener to accept and save the JColorChooser in its constructor): private class HSBBugFix implements ChangeListener { public void stateChanged(ChangeEvent e) { chooser.revalidate(); } } This causes a layout every time the color changes from a gradient click or drag. ======================================================================
24-08-2004

SUGGESTED FIX Name: apR10133 Date: 12/19/2000 ------- DefaultHSBChooserPanel.java ------- *** /tmp/deQzkK_ Tue Dec 19 19:41:32 2000 --- DefaultHSBChooserPanel.java Tue Dec 19 19:40:27 2000 *************** *** 307,319 **** JPanel panel = new JPanel(new SmartGridLayout(2,3)); Color color = getColorFromModel(); ! redField = new JTextField( String.valueOf(color.getRed()) ); redField.setEditable(false); ! greenField = new JTextField(String.valueOf(color.getGreen()) ); greenField.setEditable(false); ! blueField = new JTextField( String.valueOf(color.getBlue()) ); blueField.setEditable(false); String redString = UIManager.getString("ColorChooser.hsbRedText"); --- 307,319 ---- JPanel panel = new JPanel(new SmartGridLayout(2,3)); Color color = getColorFromModel(); ! redField = new JTextField( String.valueOf(color.getRed()), 3 ); redField.setEditable(false); ! greenField = new JTextField(String.valueOf(color.getGreen()), 3 ); greenField.setEditable(false); ! blueField = new JTextField( String.valueOf(color.getBlue()), 3 ); blueField.setEditable(false); String redString = UIManager.getString("ColorChooser.hsbRedText"); ###@###.### ======================================================================
24-08-2004