File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JEditorPane html getCaretPosition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JEditorPane html getCaretPosition" Watch "JEditorPane html getCaretPosition" New topic

JEditorPane html getCaretPosition

John Carver

Joined: Mar 14, 2005
Posts: 3
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

Joined: Aug 20, 2004
Posts: 138
Hi John,

Try the following code.
jEditorPane1.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent 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


Download Java GUI Builder, <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: JEditorPane html getCaretPosition
jQuery in Action, 3rd edition