@SuppressWarnings( "FormatString" ) // Error Prone
		private static String color2hex( Color color ) {
			int rgb = color.getRGB();
			boolean hasAlpha = color.getAlpha() != 255;

			boolean useShortFormat =
				(rgb & 0xf0000000) == (rgb & 0xf000000) << 4 &&
				(rgb & 0xf00000) == (rgb & 0xf0000) << 4 &&
				(rgb & 0xf000) == (rgb & 0xf00) << 4 &&
				(rgb & 0xf0) == (rgb & 0xf) << 4;

			if( useShortFormat ) {
				int srgb = ((rgb & 0xf0000) >> 8) | ((rgb & 0xf00) >> 4) | (rgb & 0xf);
				return String.format( hasAlpha ? "#%03X%X" : "#%03X", srgb, (rgb >> 24) & 0xf );
			} else
				return String.format( hasAlpha ? "#%06X%02X" : "#%06X", rgb & 0xffffff, (rgb >> 24) & 0xff );
		}
Creates a UI defaults inspector panel that can be embedded into any window.
flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatUIDefaultsInspector.java