Beispiel #1
0
 private Point getCaretLocation() {
   Point loc = new Point();
   TextAreaPainter painter = textArea.getPainter();
   FontMetrics fm = painter.getFontMetrics();
   int offsetY = fm.getHeight() - COMPOSING_UNDERBAR_HEIGHT;
   int lineIndex = textArea.getCaretLine();
   loc.y = lineIndex * fm.getHeight() + offsetY;
   int offsetX = textArea.getCaretPosition() - textArea.getLineStartOffset(lineIndex);
   loc.x = textArea.offsetToX(lineIndex, offsetX);
   return loc;
 }
Beispiel #2
0
 private Rectangle getCaretRectangle(int x, int y) {
   TextAreaPainter painter = textArea.getPainter();
   Point origin = painter.getLocationOnScreen();
   int height = painter.getFontMetrics().getHeight();
   return new Rectangle(origin.x + x, origin.y + y, 0, height);
 }