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.
我正在制作一个桌面应用程序。在爪哇。其中,一个人将首先浏览一个pdf或txt,然后其内容将显示在TextArea中。所以,我希望没有人可以编辑 TextArea 中的内容。那么,当一个人点击浏览按钮时,我们怎样才能使 TextArea 不可点击呢?
创建新的 JTextField 或 JTextArea
JTextField field = new JTextField("Read Only JTextField Example"); // for JTextArea: JTextArea field = new JTextArea();
要使 JTextField 只读或不可编辑使用,请使用 false 参数 void setEditable(boolean editable) 方法。
field.setEditable(false);