如何使JTextArea不可选

Rad*_*ad1 6 java swing

我想显示一个textarea来描述一个节点的价值(一个图形项目),但每当我选择文本它变得凌乱,所以我希望它是无法切割的!这是代码:

public class TransparentTextArea extends JTextArea {

String texte;

public TransparentTextArea(String texte) {
    this.setLineWrap(true);
    this.setWrapStyleWord(true);
    this.texte = texte;
    this.setBackground(new Color(255, 0, 9, 0));
    this.setFont(new Font("Serif", Font.ITALIC, 24));
    this.setEditable(false);
    this.setText(texte);
    this.setSize(new Dimension(200,100 ));
  } 
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Ste*_*dis 17

这是一个老问题,但对于那些仍在关心的人来说,禁用JTextArea它并不是很有帮助,主要是因为前景的灰色.最好的办法是使荧光笔无效:

setHighlighter(null)
Run Code Online (Sandbox Code Playgroud)