Issue Details (XML | Word | Printable)

Key: SWINGX-1257
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Karl Schaefer
Reporter: leuski
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

JXColorSelectionButton incorrect colorchooser cancel behavior

Created: 21/Jan/10 02:09 PM   Updated: 10/Mar/11 11:45 AM   Resolved: 10/Mar/11 11:45 AM
Component/s: Misc Component
Affects Version/s: 1.6.1
Fix Version/s: 1.6.3

Time Tracking:
Not Specified


Operating System: All
Platform: Macintosh

Issuezilla Id: 1,257
Participants: Karl Schaefer and leuski

 Description  « Hide

The color chooser dialog in JXColorSelectionButton always remembers the very first color it was called
with. Lets say your button has a black background. Do this: click the button, dialog opens, select a
different color, e.g., red, click OK. Now, click the button again, dialog opens, click Cancel. The intended
behavior is for the background to stay red, but the button color REVERTS back to black.

The reason is that in JXColorSelectionButton.showDialog the cancel button ActionListener is instantiated
only once with the final oldColor set to the original background. That oldColor value never changes for
the actionListener.

private void showDialog() {
final Color oldColor = getBackground();

if (dialog == null) {
dialog = JColorChooser.createDialog(JXColorSelectionButton.this,
"Choose a color", true, getChooser(),
new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
Color color = getChooser().getColor();
if (color != null) { setBackground(color); }
new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { setBackground(oldColor); }
new ColorChangeListener(JXColorSelectionButton.this));



kenaiadmin made changes - 25/Jan/11 02:05 PM
Field Original Value New Value
issue.field.bugzillaimportkey 1257 85517
Karl Schaefer made changes - 28/Jan/11 12:56 PM
Affects Version/s 1.6.1 [ 13360 ]
Affects Version/s 1.6++ [ 13359 ]
Karl Schaefer added a comment - 10/Mar/11 11:45 AM

SWINGX-1257: Fixed issue with restoring color when dialog is canceled.


Committed revision 3949.

Karl Schaefer made changes - 10/Mar/11 11:45 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]