From 5f934d43566062dbc44b8c9c35a1d0e78ef2b262 Mon Sep 17 00:00:00 2001 From: weisj Date: Mon, 16 Mar 2020 00:43:00 +0100 Subject: [PATCH] Fixed colours of labels not updating when theme is changed. --- .../github/weisj/darklaf/ui/label/DarkLabelUI.java | 14 ++++++++++---- .../darklaf/ui/scrollpane/DarkScrollBarUI.java | 2 -- .../weisj/darklaf/ui/table/DarkTableHeaderUI.java | 5 +++-- .../github/weisj/darklaf/ui/table/DarkTableUI.java | 6 ++++++ .../weisj/darklaf/properties/ui/table.properties | 2 ++ .../platform/windows/ui/WindowsTitlePane.java | 2 -- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java index c5ae2f62..8abe7162 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java @@ -45,20 +45,26 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener protected static final DarkLabelUI darkLabelUI = new DarkLabelUI(); - private final Color inactiveForeground; - private final Color cellForegroundNoFocus; + private Color inactiveForeground; + private Color cellForegroundNoFocus; protected Rectangle paintIconR = new Rectangle(); protected Rectangle paintTextR = new Rectangle(); public DarkLabelUI() { - inactiveForeground = UIManager.getColor("Label.inactiveForeground"); - cellForegroundNoFocus = UIManager.getColor("Label.cellForegroundNoFocus"); + installUI(null); } public static ComponentUI createUI(final JComponent c) { return darkLabelUI; } + @Override + public void installUI(final JComponent c) { + if (c != null) super.installUI(c); + //Ensure colors are up to date. + inactiveForeground = UIManager.getColor("Label.inactiveForeground"); + cellForegroundNoFocus = UIManager.getColor("Label.cellForegroundNoFocus"); + } @Override public void paint(final Graphics g, final JComponent c) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java index 0a3dbc1f..423e0713 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java @@ -34,7 +34,6 @@ import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicScrollBarUI; import java.awt.*; import java.awt.event.*; -import java.util.Arrays; /** * @author Konstantin Bulenkov @@ -610,7 +609,6 @@ public class DarkScrollBarUI extends BasicScrollBarUI { } private void resetThumbAnimator() { - System.out.println(Arrays.toString(Thread.currentThread().getStackTrace())); resetAnimators(thumbFadeinAnimator, thumbFadeoutAnimator, mouseOverThumb, thumbAlpha, MAX_THUMB_ALPHA); } 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 32519153..b754ba0b 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 @@ -29,6 +29,7 @@ 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; import javax.swing.table.TableColumnModel; import java.awt.*; @@ -42,7 +43,6 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { protected Color borderColor; protected Color background; - public static ComponentUI createUI(final JComponent c) { return new DarkTableHeaderUI(); } @@ -56,7 +56,8 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { headerHeight = HEADER_HEIGHT; } header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, headerHeight))); - if (header.getDefaultRenderer() instanceof DefaultTableCellRenderer) { + TableCellRenderer defaultRenderer = header.getDefaultRenderer(); + if (defaultRenderer instanceof DefaultTableCellRenderer) { DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer(); renderer.setHorizontalAlignment(SwingConstants.LEADING); } 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 976b0cd3..9a870e4e 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 @@ -130,6 +130,12 @@ public class DarkTableUI extends DarkTableUIBridge { return false; } + @Override + public void installUI(final JComponent c) { + super.installUI(c); + + } + @Override protected void installListeners() { super.installListeners(); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties index 1c885866..edb6d864 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties @@ -61,3 +61,5 @@ Table.rowHeight = 22 #Icons Table.ascendingSortIcon = menu/up.svg[themed](8,16) Table.descendingSortIcon = menu/down.svg[themed](8,16) +Table.naturalSortIcon = empty(8,16) + diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index f5f3fbe3..7b8dadf4 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -263,12 +263,10 @@ public class WindowsTitlePane extends CustomTitlePane { } } - private WindowListener createWindowListener() { return new WindowsTitlePane.WindowHandler(); } - private PropertyChangeListener createWindowPropertyChangeListener() { return new PropertyChangeHandler(); }