0

I'm interested in getting a list of the html elements in my JEditorPane that contain the selection. I think .getElementsAt a member of HTMLEditorKit.HTMLTextAction would be useful but I don't know how to implement it. I found the description at this link:

https://docs.oracle.com/javase/8/docs/api/javax/swing/text/html/HTMLEditorKit.HTMLTextAction.html#getElementsAt-javax.swing.text.html.HTMLDocument-int-

I'm new to Java. I have a JEditorPane called editArea_ and the code:

    HTMLDocument doc = (HTMLDocument) editArea_.getDocument();
    HTMLEditorKit ekit = (HTMLEditorKit) editArea_.getEditorKit();

    int selectStart = editArea_.getSelectionStart();

How would I implement this? I've tried

HTMLEditorKit.InsertHTMLTextAction.class.getElementsAt(doc, selectStart);

Thinking since it was a static class I should be able to invoke it like this but it doesnt work. Thanks for your help

Geoff L
  • 677
  • 4
  • 20

0 Answers0