--- old/src/java.desktop/share/classes/javax/swing/colorchooser/ColorPanel.java 2019-05-20 08:21:14.000000000 -0700 +++ new/src/java.desktop/share/classes/javax/swing/colorchooser/ColorPanel.java 2019-05-20 08:21:12.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,10 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import javax.swing.ButtonGroup; +import javax.swing.DefaultButtonModel; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -40,7 +41,7 @@ import javax.swing.JSpinner.DefaultEditor; @SuppressWarnings("serial") // Superclass is not serializable across versions -final class ColorPanel extends JPanel implements ActionListener { +final class ColorPanel extends JPanel implements ItemListener { private final SlidingSpinner[] spinners = new SlidingSpinner[5]; private final float[] values = new float[this.spinners.length]; @@ -73,7 +74,7 @@ add(button, gbc); group.add(button); button.setActionCommand(Integer.toString(i)); - button.addActionListener(this); + button.getModel().addItemListener(this); this.spinners[i] = new SlidingSpinner(this, button); } else { @@ -106,14 +107,20 @@ this.model = model; } - public void actionPerformed(ActionEvent event) { - try { - this.z = Integer.parseInt(event.getActionCommand()); - this.y = (this.z != 2) ? 2 : 1; - this.x = (this.z != 0) ? 0 : 1; - getParent().repaint(); - } - catch (NumberFormatException exception) { + @Override + public void itemStateChanged(ItemEvent e) { + if(e.getStateChange() == ItemEvent.SELECTED) { + if (e.getSource() instanceof DefaultButtonModel) { + DefaultButtonModel model = (DefaultButtonModel) e.getSource(); + try { + this.z = Integer.parseInt(model.getActionCommand()); + this.y = (this.z != 2) ? 2 : 1; + this.x = (this.z != 0) ? 0 : 1; + getParent().repaint(); + } + catch (NumberFormatException exception) { + } + } } }