Browse Source

Fixed possible NPE.

pull/127/head
weisj 5 years ago
parent
commit
2cd80fdbcc
  1. 17
      core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java

17
core/src/main/java/com/github/weisj/darklaf/components/border/DarkBorders.java

@ -27,13 +27,16 @@ import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
public final class DarkBorders {
public static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap = new WeakHashMap<>();
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap = new WeakHashMap<>();
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap =
Collections.synchronizedMap(new WeakHashMap<>());
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap =
Collections.synchronizedMap(new WeakHashMap<>());
public static Border createLineBorder(final int top, final int left, final int bottom, final int right) {
@ -45,14 +48,16 @@ public final class DarkBorders {
final Map<WeakLineBorder, WeakReference<WeakLineBorder>> map, final String key) {
WeakLineBorder border = new WeakLineBorder(top, left, bottom, right);
if (map.containsKey(border)) {
return map.get(border).get();
} else {
WeakReference<WeakLineBorder> ref = map.get(border);
if (ref != null) {
WeakLineBorder b = ref.get();
if (b != null) return b;
}
}
border.setColor(UIManager.getColor(key));
map.put(border, new WeakReference<>(border));
return border;
}
}
public static Border createWidgetLineBorder(final int top, final int left, final int bottom, final int right) {
return createBorder(top, left, bottom, right, lineWidgetBorderMap, "borderSecondary");

Loading…
Cancel
Save