• Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving colors for repainting

 
Ricky Peddicord
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I can choose a color from a dropdown menu and then draw in that color and freely change to a different color, but when I resize the window and it repaints it, it changes all of it to the currently selected color instead of the various original colors that were on the original panel. How would I go about saving the colors I used so that they can show up when paintComponent is called?

Here is the code for the drawing/painting portion.

 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of declaring "list" as a collection of type Point, create a class that can save the coordinates, the shape type, and the color, and make "list" a collection of that class.

And instead of using a String for the shape type ("Oval", "Rectangle", etc.) think about using an enum or at least a set of static final int values named, for instance, OVAL and RECTANGLE, so that in your paintComponent method you can use
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quit cross posting: http://stackoverflow.com/questions/35788000/saving-colors-for-repainting

It is extremely frustrating to take the time to answer a question and then find out you already have the answer in your other question. We are not here to write the code for you.

It is up to you to read the comments and follow the examples and then modify your code appropriately.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!