简体   繁体   English

setEnabled(false)之后,jTextArea背景不变

[英]jTextArea background not changing after setEnabled(false)

i have set setEnabled(false) for my jTextArea in a netbeans. 我在netbeans中为我的jTextArea设置了setEnabled(false)。 The textarea is disabled but its background colour is not changing from white to a 'grayish' as expected. 文本区域被禁用,但是其背景颜色没有从白色变为预期的“灰色”。 This only happens if i run my project from main class. 仅当我从主类运行项目时,才会发生这种情况。 It changes the background colour to a 'grayish' while running from the jForm containing the textArea. 从包含textArea的jForm运行时,它将背景颜色更改为“灰色”。 Why is this? 为什么是这样?

You would need to make the code followed by jTextArea1.setBackground(Color.GREY); 您需要先编写代码,然后是jTextArea1.setBackground(Color.GREY);。 So it will look like this. 因此它将看起来像这样。

jTextArea1.setEnabled(false); jScrollPane1.setEnabled(false);
jTextArea1.setBackground(Color.GREY);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM