I can't seem to get the circle to change color after the user picks a new color from the JColorChooser. any ideas?
package bouncer; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; public class Bouncer extends JComponent { private static final int FRAME_WIDTH = 300; private static final int FRAME_HEIGHT = 300; private static Color circleColor = (Color.RED); public void paintComponent(Graphics g) { Graphics g2 = (Graphics) g; g2.setColor(circleColor); g2.fillOval(130, 120, 10, 10); } public static void main(String[] args) { JFrame frame = new JFrame("Bouncing Ball"); frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JButton button = new JButton("Choose Color"); class AddColor implements ActionListener { @Override public void actionPerformed(ActionEvent event) { circleColor = JColorChooser.showDialog(null, "pick your color", circleColor); } } ActionListener listener = new AddColor(); button.addActionListener(listener); JPanel panel = new JPanel(); panel.add(button); frame.add(new Bouncer()); frame.add(panel, BorderLayout.SOUTH); } }