问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/10533940/how-to-get-current-html-elementtag-in-jtextpane