void (Component component, boolean enabled) { if (component.isEnabled() == enabled) return; component.setEnabled(enabled); if (component instanceof JPanel) { final Border border = ((JPanel)component).getBorder(); if (border instanceof TitledBorder) { Color color; color = enabled ? component.getForeground() : NamedColorUtil.getInactiveTextColor(); ((TitledBorder)border).setTitleColor(color); } } else if (component instanceof JLabel label) { Color color = NamedColorUtil.getInactiveTextColor(); @NonNls String changeColorString = "<font color=#" + colorToHex(color) + ">"; @NonNls String text = label.getText(); if (text != null && text.startsWith("<html>")) { if (StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && enabled) { text = "<html>" + text.substring(("<html>" + changeColorString).length()); } else if (!StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && !enabled) { text = "<html>" + changeColorString + text.substring("<html>".length()); } label.setText(text); } } else if (component instanceof JTable) { TableColumnModel columnModel = ((JTable)component).getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableCellRenderer cellRenderer = columnModel.getColumn(0).getCellRenderer(); if (cellRenderer instanceof Component) { enableComponent((Component)cellRenderer, enabled); } } } }