void () { boolean enabled = isEnabled(); if (enabled && myEditable) { myTextField.setEnabled(true); myTextField.setToolTipText(UIBundle.message("color.panel.select.color.tooltip.text")); } else { myTextField.setEnabled(false); myTextField.setToolTipText(null); } Color color = enabled ? myColor : null; if (color != null) { myTextField.setText(StringUtil.toUpperCase(ColorUtil.toHex(color))); } else { myTextField.setText(null); color = getBackground(); } myTextField.setBackground(color); myTextField.setSelectedTextColor(color); if (color != null) { int gray = (int)(0.212656 * color.getRed() + 0.715158 * color.getGreen() + 0.072186 * color.getBlue()); int delta = gray < 0x20 ? 0x60 : gray < 0x50 ? 0x40 : gray < 0x80 ? 0x20 : gray < 0xB0 ? -0x20 : gray < 0xE0 ? -0x40 : -0x60; gray += delta; color = new Color(gray, gray, gray); myTextField.setDisabledTextColor(color); myTextField.setSelectionColor(color); gray += delta; color = new Color(gray, gray, gray); myTextField.setForeground(color); } }