Why can't I create a color in Java with the "new" keyword?
6 answers
Check this link Color (Java 2 Platform SE v1.4.2) .
If you want this code to work:
Color temp = new Color(foo.getBackground());
foo.getBackground () must return an integer. Since it returns a Color object, you have a type mismatch.
You can always do:
Color temp = new Color(foo.getbackground().getRGB());
or
Color color = foo.getBackground();
Color temp = new Color(color.getRed(), color.getGreen(), color.getBlue(),color.getAlpha());
+5