-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
6
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
As originally requested 8 years ago in bug #4226498, there needs to be a reasonable and convenient way to set the color of the text used to paint the string in a JProgressBar.
I feel it is fair to request a re-review of this decision, as quite a time period has passed and three versions of the JDK have gone by...
JUSTIFICATION :
8 years have passed since this request was made and I think it is time that it be re-examined.
The initial response was two-pronged and I believe each tine to be flawed.
1. You could set the all-encompassing UIManager default property values before creating the progress bar.
FLAW: If the Look & Feel is switched and the UIs are reinstalled, the defaults will now affect ALL progress bars. If you have two or more bars of different colors, it may not be possible to find a neutral color that looks good in both. Obviously many applications have multiple progress bars, or even progress bars whose color changes over time depending on the value of the bar.
2. There is a desire not to expose this feature for the sake of aesthetics.
FLAW: Where do you draw the line? Is this argument valid for JButtons? JLabels? The coloring API is exposed in countless Swing widgets; yet, this one is somehow special. I would like to understand what makes it unique among all other components in that it cannot have its coloring API exposed. Furthermore, even with the advent of Synth, which was explicitly designed to allow aesthetics to be enhanced, there is still no good solution for this!
It is unacceptable for the "workaround" to be "create a new ProgressBarUI" class. This is a simple, obvious operation that should not be problematic to implement nor to access consistently. The standard behavior of allowing a UIResource-derived object to be set for the color is already in-place because of Synth, so I see absolutely no reason at all why the fix cannot be made.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JProgressBar should allow per-instance setting of its painted string color in the same manner as all other JComponents.
ACTUAL -
JProgressBar does not allow per-instance setting of the painted string color.
---------- BEGIN SOURCE ----------
No test case applies to this request.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workaround #1: Create a new class that extends JProgressBar, override paintComponent, copy & paste string-positioning code from the JDK source, and add a simple "setTextForeground(java.awt.Color)" method.
Workaround #2: Create a new ProgressBarUI class. Override the defaults table and expose the String value in some manner, i.e. a setter method on the UI class or a property lookup on the JComponent's per-instance properties table.
Workaround #3: Create an entirely new class and reimplement all of the JProgressBar logic, this time with String color accessible.
As originally requested 8 years ago in bug #4226498, there needs to be a reasonable and convenient way to set the color of the text used to paint the string in a JProgressBar.
I feel it is fair to request a re-review of this decision, as quite a time period has passed and three versions of the JDK have gone by...
JUSTIFICATION :
8 years have passed since this request was made and I think it is time that it be re-examined.
The initial response was two-pronged and I believe each tine to be flawed.
1. You could set the all-encompassing UIManager default property values before creating the progress bar.
FLAW: If the Look & Feel is switched and the UIs are reinstalled, the defaults will now affect ALL progress bars. If you have two or more bars of different colors, it may not be possible to find a neutral color that looks good in both. Obviously many applications have multiple progress bars, or even progress bars whose color changes over time depending on the value of the bar.
2. There is a desire not to expose this feature for the sake of aesthetics.
FLAW: Where do you draw the line? Is this argument valid for JButtons? JLabels? The coloring API is exposed in countless Swing widgets; yet, this one is somehow special. I would like to understand what makes it unique among all other components in that it cannot have its coloring API exposed. Furthermore, even with the advent of Synth, which was explicitly designed to allow aesthetics to be enhanced, there is still no good solution for this!
It is unacceptable for the "workaround" to be "create a new ProgressBarUI" class. This is a simple, obvious operation that should not be problematic to implement nor to access consistently. The standard behavior of allowing a UIResource-derived object to be set for the color is already in-place because of Synth, so I see absolutely no reason at all why the fix cannot be made.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JProgressBar should allow per-instance setting of its painted string color in the same manner as all other JComponents.
ACTUAL -
JProgressBar does not allow per-instance setting of the painted string color.
---------- BEGIN SOURCE ----------
No test case applies to this request.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Workaround #1: Create a new class that extends JProgressBar, override paintComponent, copy & paste string-positioning code from the JDK source, and add a simple "setTextForeground(java.awt.Color)" method.
Workaround #2: Create a new ProgressBarUI class. Override the defaults table and expose the String value in some manner, i.e. a setter method on the UI class or a property lookup on the JComponent's per-instance properties table.
Workaround #3: Create an entirely new class and reimplement all of the JProgressBar logic, this time with String color accessible.
- relates to
-
JDK-4226498 JProgressBar has no method to set String color
- Closed