• Post Reply Bookmark Topic Watch Topic
  • New Topic

The JEditorPane

 
Daniel Trebbien
Ranch Hand
Posts: 81
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After wrestling with all of the objects associated with a JEditorPane (Cursor, Document, Element, AttributeSet, ...) in order to find the location of the lowest pixel of the cursor, which depends on the font at the cursor, I started wondering if anyone has actually done something special/important/useful with this class (other than the default usages)?
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by D. Trebbien:
After wrestling with all of the objects associated with a JEditorPane (Cursor, Document, Element, AttributeSet, ...) in order to find the location of the lowest pixel of the cursor, which depends on the font at the cursor,


[edit: When you say Cursor I presume you mean Caret, since Cursor is independent of font. If not, please clarify.]

FYI, all Swing text components have Carets, not just JEditorPane. A simple way to get the lowest pixel of the Caret is

java.awt.Rectangle rect = (DefaultCaret)yourPane.getCaret();
int lowestCaretPosition = rect.y + rect.height;


with the proviso that this won't work if you are using a custom Caret that doesn't inherit from DefaultCaret.

I started wondering if anyone has actually done something special/important/useful with this class (other than the default usages)?


I'm not sure what you mean here. People have certainly done interesting things with JEditorPane, but I'm not sure what qualifies as default usage.
[ July 11, 2007: Message edited by: Brian Cole ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!