diff --git a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java index f113a047..161e9c98 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/text/SearchTextField.java @@ -27,6 +27,8 @@ package com.github.weisj.darklaf.components.text; import javax.swing.*; import javax.swing.text.Document; +import com.github.weisj.darklaf.ui.text.DarkTextFieldUI; + public class SearchTextField extends JTextField { public static final int SEARCH = 0; @@ -57,7 +59,7 @@ public class SearchTextField extends JTextField { */ public SearchTextField(final Document doc, final String text, final int columns) { super(doc, text, columns); - putClientProperty("JTextField.variant", "search"); + putClientProperty(DarkTextFieldUI.KEY_VARIANT, DarkTextFieldUI.VARIANT_SEARCH); addActionListener(e -> { SearchListener[] list = listenerList.getListeners(SearchListener.class); SearchEvent evt = new SearchEvent(SearchTextField.this, SEARCH, "search", getText()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java index 55d5755e..f2a78b8f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java @@ -61,7 +61,7 @@ public class DarkListUI extends DarkListUIBridge { @Override protected void installDefaults() { super.installDefaults(); - list.putClientProperty(KEY_ALTERNATE_ROW_COLOR, UIManager.getBoolean("List.alternateRowColor")); + PropertyUtil.installBooleanProperty(list, KEY_ALTERNATE_ROW_COLOR, "List.alternateRowColor"); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java index 59c3392f..4f4ce2b1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java @@ -28,7 +28,6 @@ import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; @@ -78,9 +77,7 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { @Override protected void uninstallDefaults() { super.uninstallDefaults(); - if (header.getBorder() instanceof UIResource) { - LookAndFeel.uninstallBorder(header); - } + LookAndFeel.uninstallBorder(header); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index bb134d97..3c17e611 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -204,10 +204,9 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener { LookAndFeel.installProperty(table, "rowHeight", ROW_HEIGHT_FALLBACK); } table.setDefaultEditor(Object.class, new DarkTableCellEditor()); - table.putClientProperty(KEY_RENDER_BOOLEAN_AS_CHECKBOX, - UIManager.getBoolean("Table.renderBooleanAsCheckBox")); - table.putClientProperty(KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Table.booleanRenderType")); - table.putClientProperty(KEY_ALTERNATE_ROW_COLOR, UIManager.getBoolean("Table.alternateRowColor")); + PropertyUtil.installBooleanProperty(table, KEY_RENDER_BOOLEAN_AS_CHECKBOX, "Table.renderBooleanAsCheckBox"); + PropertyUtil.installBooleanProperty(table, KEY_ALTERNATE_ROW_COLOR, "Table.alternateRowColor"); + PropertyUtil.installProperty(table, KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Table.booleanRenderType")); setupRendererComponents(table); borderColor = UIManager.getColor("TableHeader.borderColor"); selectionFocusBackground = UIManager.getColor("Table.focusSelectionBackground"); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index 02195337..243c404c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -51,7 +51,6 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh protected static final String KEY_PREFIX = "JTextField."; public static final String KEY_VARIANT = KEY_PREFIX + "variant"; public static final String KEY_SHOW_CLEAR = KEY_PREFIX + "showClear"; - public static final String KEY_KEEP_SELECTION_ON_FOCUS_LOST = KEY_PREFIX + "keepSelectionOnFocusLost"; public static final String KEY_FIND_POPUP = KEY_PREFIX + "Search.FindPopup"; public static final String VARIANT_SEARCH = "search"; protected static Icon clear; @@ -264,8 +263,6 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh @Override protected void installDefaults() { super.installDefaults(); - editor.putClientProperty(KEY_KEEP_SELECTION_ON_FOCUS_LOST, - UIManager.getBoolean("TextField.keepSelectionOnFocusLost")); arcSize = UIManager.getInt("TextField.arc"); borderSize = UIManager.getInt("TextField.borderThickness"); searchArcSize = UIManager.getInt("TextField.searchArc"); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index f2d5bc79..7af8d860 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -108,7 +108,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi editor.setBorder(null); } if (editor != null) { - editor.putClientProperty(KEY_ROUNDED_SELECTION, UIManager.getBoolean("TextComponent.roundedSelection")); + PropertyUtil.installBooleanProperty(editor, KEY_ROUNDED_SELECTION, "TextComponent.roundedSelection"); } disabledColor = UIManager.getColor(getPropertyPrefix() + ".disabledBackground"); inactiveColor = UIManager.getColor(getPropertyPrefix() + ".inactiveBackground"); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index a60538a6..7466fb8d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -168,11 +168,10 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { collapsedSelected = UIManager.getIcon("Tree.collapsed.selected.unfocused.icon"); collapsedFocus = UIManager.getIcon("Tree.collapsed.unselected.focused.icon"); collapsed = UIManager.getIcon("Tree.collapsed.unselected.unfocused.icon"); - tree.putClientProperty(DarkTreeUI.KEY_RENDER_BOOLEAN_AS_CHECKBOX, - UIManager.getBoolean("Tree.renderBooleanAsCheckBox")); - tree.putClientProperty(DarkTreeUI.KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Tree.booleanRenderType")); - tree.setShowsRootHandles(true); - tree.putClientProperty(KEY_LINE_STYLE, UIManager.getString("Tree.defaultLineStyle")); + PropertyUtil.installBooleanProperty(tree, KEY_RENDER_BOOLEAN_AS_CHECKBOX, "Tree.renderBooleanAsCheckBox"); + PropertyUtil.installProperty(tree, KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Tree.booleanRenderType")); + PropertyUtil.installProperty(tree, KEY_LINE_STYLE, UIManager.getString("Tree.defaultLineStyle")); + LookAndFeel.installProperty(tree, JTree.SHOWS_ROOT_HANDLES_PROPERTY, true); } @Override diff --git a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java index ac3cb55d..5cf1e1c9 100644 --- a/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java +++ b/utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java @@ -31,6 +31,16 @@ import javax.swing.*; public class PropertyUtil { + public static void installProperty(final JComponent c, final String key, final Object value) { + if (c.getClientProperty(key) == null) { + c.putClientProperty(key, value); + } + } + + public static void installBooleanProperty(final JComponent c, final String key, final String valueKey) { + installProperty(c, key, UIManager.getBoolean(valueKey)); + } + public static boolean getBooleanProperty(final Component c, final String property) { return getBooleanProperty(c, property, false); }