Browse Source

Check for possible null rect.

pull/189/head
weisj 4 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
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;
}

Loading…
Cancel
Save