从JLabel中选择文本? [英] Selecting text from a JLabel?
本文介绍了从JLabel中选择文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从JLabel中选择文本?如果没有,那么最好的替代控件是什么,以及它如何配置为像JLabel一样?
Is it possible to enable the selection of text from a JLabel? If not, what's the best alternative control to use, and how can it be configured to appear like a JLabel?
推荐答案
JTextField不允许像JLabel这样的html格式的文本。如果你想要可选择的html文本,你可以尝试将JTextPane设置为html格式:
A JTextField doesn't allow html-formatted text like a JLabel. If you want selectable html text you could alternatively try a JTextPane set to html formatting:
JTextPane f = new JTextPane();
f.setContentType("text/html"); // let the text pane know this is what you want
f.setText("<html>Hello World</html>"); // showing off
f.setEditable(false); // as before
f.setBackground(null); // this is the same as a JLabel
f.setBorder(null); // remove the border
这篇关于从JLabel中选择文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文