Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+6 votes

I have the color picker on the GUI, but the value keeps coming back as null. So how do I get the color value that the user puts in.

asked ago in CSC 305 Fall 2024 by (4.2k points)

1 Answer

+5 votes
 
Best answer

I don't know if this is the best way to do it, but what I did is I created a variable in the figure class for the color as well as a setter method. Then I added a listener to the color picker which got the prototype to clone for each shape tool, and then I set the color to the color picker's color. Then the last thing I did, was in the draw method of the figure class, I added the line g.setStroke(color); before the drawShape method call.

answered ago by (2.2k points)
selected ago by
...