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

+9 votes

I have tried a few things to change the color with a color picker, but the only way I was able to change any color was if I had a static Color variable in the Figure class (which then of course changed every shape to that color every time). I am confused about where to actually put in the color, since we are technically cloning figures instead of actually constructing new ones. I am assuming I should use g.setStroke(), but that is only relevant when you actually draw something new... so I don't know how to make that work with the cloning functionality.

asked in CSC 305 Fall 2024 by (4.5k points)

1 Answer

+7 votes

The simplest solution is probably to:

  1. pass the ColorPicker object into the each of the CreationTool objects when you create them, and then
  2. after newFigure has been cloned within the CreationTool's mouse handling method, you can call setColor(...) method on that specific Figure object to change to the color that you can get by querying the ColorPicker.

Hope that helps!

answered by (4.9k points)
...