From 247690e3e5bf01ac2b1b28372a6663e4413d9830 Mon Sep 17 00:00:00 2001 From: weisj Date: Thu, 5 Mar 2020 22:16:03 +0100 Subject: [PATCH] Fixed NPE when accessing evt.getNewValue() on properChange-Events. Signed-off-by: weisj --- .../java/com/github/weisj/darklaf/ui/table/DarkTableUI.java | 4 ++-- .../weisj/darklaf/platform/macos/ui/MacOSTitlePane.java | 2 +- .../weisj/darklaf/platform/windows/ui/WindowsTitlePane.java | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) 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 b46054f1..23d8b014 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 @@ -51,10 +51,10 @@ public class DarkTableUI extends DarkTableUIBridge { private final PropertyChangeListener propertyChangeListener = e -> { String key = e.getPropertyName(); if ("showHorizontalLines".equals(key)) { - boolean b = (boolean) e.getNewValue(); + boolean b = Boolean.TRUE.equals(e.getNewValue()); table.setRowMargin(b ? 1 : 0); } else if ("showVerticalLines".equals(key)) { - boolean b = (boolean) e.getNewValue(); + boolean b = Boolean.TRUE.equals(e.getNewValue()); table.getColumnModel().setColumnMargin(b ? 1 : 0); } else if ("ancestor".equals(key)) { Object oldVal = e.getOldValue(); diff --git a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java index 815340b0..3f587544 100644 --- a/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java +++ b/macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java @@ -243,7 +243,7 @@ public class MacOSTitlePane extends CustomTitlePane { public void propertyChange(final PropertyChangeEvent pce) { String name = pce.getPropertyName(); if ("title".equals(name)) { - titleLabel.setText(pce.getNewValue().toString()); + titleLabel.setText(pce.getNewValue() == null ? "" : pce.getNewValue().toString()); repaint(); } } 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 b5775f31..00f505c1 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 @@ -771,7 +771,7 @@ public class WindowsTitlePane extends CustomTitlePane { getRootPane().repaint(); } } else if ("title".equals(name)) { - titleLabel.setText(pce.getNewValue().toString()); + titleLabel.setText(pce.getNewValue() == null ? "" : pce.getNewValue().toString()); repaint(); } else if ("componentOrientation".equals(name)) { revalidate(); @@ -782,6 +782,7 @@ public class WindowsTitlePane extends CustomTitlePane { repaint(); } else if ("background".equals(name) && pce.getNewValue() instanceof Color) { Color color = (Color) pce.getNewValue(); + if (color == null) return; JNIDecorationsWindows.setBackground(windowHandle, color.getRed(), color.getGreen(), color.getBlue()); } }