Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JEditorPane html getCaretPosition

 
John Carver
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to make an simple HTML editor and I'm having a problem with determining if the text is bold at the caret posistion in a JEditorPane. Is there an easy way of determining this?
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Try the following code.
-------------------
jEditorPane1.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e)
{
jEditorPane1_caretUpdate(e);
}

});
...
...
private void jEditorPane1_caretUpdate(CaretEvent e)
{
System.out.println("\njEditorPane1_caretUpdate(CaretEvent e) called.");
System.out.println(">>" + "location:" + e.getDot() + ";\tthe location of other end of the logical selection:" + e.getMark());
// TODO: Add any handling code here

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic