/** * Set the dot according to the currently visible screen window. #param * percentFromWindowTop percentage giving the distance of the caret from the * top of the currently visible window. */ public void adjustCaret(int percentFromWindowTop) { JTextComponent c = component; if (c != null) { Rectangle bounds = getExtentBounds(); bounds.y += (percentFromWindowTop * bounds.height) / 100 - (percentFromWindowTop * lineHeight) / 100; try { int offset = ((BaseTextUI) c.getUI()).getPosFromY(bounds.y); if (offset >= 0) { caretSetDot(offset, null, SCROLL_SMALLEST); } } catch (BadLocationException e) { } } }
/** Set the dot according to the currently visible screen window. * #param percentFromWindowTop percentage giving the distance of the caret * from the top of the currently visible window. */ public void adjustCaret(int percentFromWindowTop) { JTextComponent c = component; if (c != null) { Rectangle bounds = getExtentBounds(); bounds.y += (percentFromWindowTop * bounds.height) / 100 - (percentFromWindowTop * lineHeight) / 100; try { int offset = ((BaseTextUI)c.getUI()).getPosFromY(bounds.y); if (offset >= 0) { caretSetDot(offset, null, SCROLL_SMALLEST); } } catch (BadLocationException e) { } } }