Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从包含人名列表的文本区域生成一个可点击事件。当我们单击某个名称时,它必须调用一个方法(该方法会从 XML 文件中显示该人的详细信息)。
这可能与文本区域?我听说过JTextPane,但我需要其他选择。
JTextPane
是的,这是可能的。使用viewToModel()方法获取点击点的偏移量。然后使用UtilitiestogetWordStart/getWordEnd方法获取点击的名称。然后只需将名称传递给所需的函数。
viewToModel()
Utilities
getWordStart/getWordEnd