From 6ddbb36c97910ed0890f47e128c9841d27f318b3 Mon Sep 17 00:00:00 2001 From: weisj Date: Thu, 25 Jun 2020 12:27:21 +0200 Subject: [PATCH] Check for possible null rect. --- .../weisj/darklaf/ui/text/DarkTextFieldUI.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index 0e4a64f3..78ad0af9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -143,13 +143,16 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh @Override protected Rectangle getVisibleEditorRect() { Rectangle rect = super.getVisibleEditorRect(); - FontMetrics fm = SwingUtilities2.getFontMetrics(editor, editor.getFont()); - int asc = fm.getMaxAscent(); - Insets ins = editor.getInsets(); - int height = editor.getHeight() - ins.top - ins.bottom; - rect.y = ins.top + (height - asc) / 2; - rect.y -= fm.getDescent() / 2; - adjustTextRect(getComponent(), rect); + System.out.println(editor); + if (rect != null) { + FontMetrics fm = SwingUtilities2.getFontMetrics(editor, editor.getFont()); + int asc = fm.getMaxAscent(); + Insets ins = editor.getInsets(); + int height = editor.getHeight() - ins.top - ins.bottom; + rect.y = ins.top + (height - asc) / 2; + rect.y -= fm.getDescent() / 2; + adjustTextRect(getComponent(), rect); + } return rect; }