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

微笑、不失礼 提交于 2020-01-05 04:33:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!