How to get a color from the user as a String
and use it in a method that accepts Color enum
values?
The idea is to get a color that the user ch
I would create a Map
and populate it with what String
color names map to which Color
objects. You can use java.awt.Color's own static Color constants, e.g. colorMap.put("BLACK", Color.BLACK);
, or you can insert your own mappings. Then you can take the user input and perform a lookup with get
to get the proper Color
object needed.