Browse Source

Check for possible null rect.

pull/189/head
weisj 5 years ago
parent
commit
6ddbb36c97
  1. 17
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java

17
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java

@ -143,13 +143,16 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
@Override @Override
protected Rectangle getVisibleEditorRect() { protected Rectangle getVisibleEditorRect() {
Rectangle rect = super.getVisibleEditorRect(); Rectangle rect = super.getVisibleEditorRect();
FontMetrics fm = SwingUtilities2.getFontMetrics(editor, editor.getFont()); System.out.println(editor);
int asc = fm.getMaxAscent(); if (rect != null) {
Insets ins = editor.getInsets(); FontMetrics fm = SwingUtilities2.getFontMetrics(editor, editor.getFont());
int height = editor.getHeight() - ins.top - ins.bottom; int asc = fm.getMaxAscent();
rect.y = ins.top + (height - asc) / 2; Insets ins = editor.getInsets();
rect.y -= fm.getDescent() / 2; int height = editor.getHeight() - ins.top - ins.bottom;
adjustTextRect(getComponent(), rect); rect.y = ins.top + (height - asc) / 2;
rect.y -= fm.getDescent() / 2;
adjustTextRect(getComponent(), rect);
}
return rect; return rect;
} }

Loading…
Cancel
Save