Browse Source

Fixed colours of labels not updating when theme is changed.

pull/109/head
weisj 5 years ago
parent
commit
5f934d4356
  1. 14
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java
  3. 5
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java
  4. 6
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java
  5. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties
  6. 2
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

14
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(); protected static final DarkLabelUI darkLabelUI = new DarkLabelUI();
private final Color inactiveForeground; private Color inactiveForeground;
private final Color cellForegroundNoFocus; private Color cellForegroundNoFocus;
protected Rectangle paintIconR = new Rectangle(); protected Rectangle paintIconR = new Rectangle();
protected Rectangle paintTextR = new Rectangle(); protected Rectangle paintTextR = new Rectangle();
public DarkLabelUI() { public DarkLabelUI() {
inactiveForeground = UIManager.getColor("Label.inactiveForeground"); installUI(null);
cellForegroundNoFocus = UIManager.getColor("Label.cellForegroundNoFocus");
} }
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
return darkLabelUI; 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 @Override
public void paint(final Graphics g, final JComponent c) { public void paint(final Graphics g, final JComponent c) {

2
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 javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.Arrays;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
@ -610,7 +609,6 @@ public class DarkScrollBarUI extends BasicScrollBarUI {
} }
private void resetThumbAnimator() { private void resetThumbAnimator() {
System.out.println(Arrays.toString(Thread.currentThread().getStackTrace()));
resetAnimators(thumbFadeinAnimator, thumbFadeoutAnimator, mouseOverThumb, thumbAlpha, MAX_THUMB_ALPHA); resetAnimators(thumbFadeinAnimator, thumbFadeoutAnimator, mouseOverThumb, thumbAlpha, MAX_THUMB_ALPHA);
} }

5
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.ComponentUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel; import javax.swing.table.TableColumnModel;
import java.awt.*; import java.awt.*;
@ -42,7 +43,6 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
protected Color borderColor; protected Color borderColor;
protected Color background; protected Color background;
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
return new DarkTableHeaderUI(); return new DarkTableHeaderUI();
} }
@ -56,7 +56,8 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
headerHeight = HEADER_HEIGHT; headerHeight = HEADER_HEIGHT;
} }
header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, headerHeight))); 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(); DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer();
renderer.setHorizontalAlignment(SwingConstants.LEADING); renderer.setHorizontalAlignment(SwingConstants.LEADING);
} }

6
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java

@ -130,6 +130,12 @@ public class DarkTableUI extends DarkTableUIBridge {
return false; return false;
} }
@Override
public void installUI(final JComponent c) {
super.installUI(c);
}
@Override @Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties

@ -61,3 +61,5 @@ Table.rowHeight = 22
#Icons #Icons
Table.ascendingSortIcon = menu/up.svg[themed](8,16) Table.ascendingSortIcon = menu/up.svg[themed](8,16)
Table.descendingSortIcon = menu/down.svg[themed](8,16) Table.descendingSortIcon = menu/down.svg[themed](8,16)
Table.naturalSortIcon = empty(8,16)

2
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() { private WindowListener createWindowListener() {
return new WindowsTitlePane.WindowHandler(); return new WindowsTitlePane.WindowHandler();
} }
private PropertyChangeListener createWindowPropertyChangeListener() { private PropertyChangeListener createWindowPropertyChangeListener() {
return new PropertyChangeHandler(); return new PropertyChangeHandler();
} }

Loading…
Cancel
Save