Here you can find the source of invert(Color color)
public static Color invert(Color color)
//package com.java2s; //License from project: LGPL import java.awt.Color; public class Main { public static Color invert(Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()); }//from w w w. ja v a2 s.c o m public static String invert(String color) { return colorToHexString(invert(hexStringToColor(color))); } public static String colorToHexString(Color color) { String hexString = Integer.toHexString(color.getRGB() & 0x00ffffff); while (hexString.length() < 6) { hexString = "0" + hexString; } return "#" + hexString; } public static Color hexStringToColor(String hexString) { return Color.decode(hexString); } }