Rishi
Rishi

Reputation: 95

How to get current html element(tag) in JTextPane?

I am doing on WYSIWYG Html Editor using Java Program. I need When I click mouse on Paragraph element, It should be displays

tag in JOption dialog. Please advice me How can i do this?

Upvotes: 1

Views: 1243

Answers (1)

StanislavL
StanislavL

Reputation: 57381

See for example this one http://java-sl.com/JEditorPaneStructureTool.html

In simple words you can get your HTMLDocument and get paragraph using getParagraphElement() method. Use viewToModel() method of JEditorPane to get caret offet for the clicked point.

Upvotes: 5

Related Questions