如何在JTextPane中获取当前的html元素(标记)? [英] How to get current html element(tag) in JTextPane?

查看:93
本文介绍了如何在JTextPane中获取当前的html元素(标记)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java程序在所见即所得HTML编辑器中进行操作.我需要当我在段落元素上单击鼠标时,它应该在JOption对话框中显示

标记.请告诉我我该怎么做?

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?

推荐答案

例如,请参见此 http://java-sl. com/JEditorPaneStructureTool.html

简单来说,您可以使用getParagraphElement()方法获取HTMLDocument并获取段落.使用JEditorPaneviewToModel()方法来获取插入点的插入符号.

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.

这篇关于如何在JTextPane中获取当前的html元素(标记)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆