Browse Source

Fixed NPE in ScrollLayoutManager when changing theme.

pull/75/head
weisj 5 years ago
parent
commit
760384d9ee
  1. 13
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java
  2. 5
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java

13
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollPaneUI.java

@ -126,8 +126,21 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI {
public void installUI(final JComponent x) {
super.installUI(x);
oldLayout = (ScrollPaneLayout) x.getLayout();
if (oldLayout instanceof ScrollLayoutManagerDelegate) {
oldLayout = ((ScrollLayoutManagerDelegate) oldLayout).getDelegate();
}
if (oldLayout != null) {
x.setLayout(new ScrollLayoutManagerDelegate(oldLayout) {
@Override
public void addLayoutComponent(final String name, final Component comp) {
if (name != null && name.toUpperCase().endsWith("CORNER")) {
Component oldComp = getDelegate().getCorner(name);
getDelegate().removeLayoutComponent(oldComp);
}
super.addLayoutComponent(name, comp);
}
@Override
public void layoutContainer(final Container parent) {
super.layoutContainer(parent);

5
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/ScrollLayoutManagerDelegate.java

@ -49,6 +49,11 @@ public class ScrollLayoutManagerDelegate extends ScrollPaneLayout {
delegate.addLayoutComponent(name, comp);
}
@Override
public void syncWithScrollPane(final JScrollPane sp) {
delegate.syncWithScrollPane(sp);
}
@Override
public void removeLayoutComponent(final Component comp) {
delegate.removeLayoutComponent(comp);

Loading…
Cancel
Save