[英]Why is my JTextField in JFrame not working?
Simple question. 简单的问题。 I've been trying to block/disable my textfield in my JFrame, but unfortunately it just doesn't work!
我一直试图在我的JFrame中阻止/禁用我的文本字段,但不幸的是它只是不起作用!
Suppose the name of my disable textfield is "fnTxt", so in the code I wrote fnTxt.setEnabled(false);
假设我的禁用文本字段的名称是“fnTxt”,所以在代码中我写了
fnTxt.setEnabled(false);
. 。 And when I run it, nothing happen!
当我运行它时,什么都没发生! The textfield is still able to be click/fill.
该文本字段仍然可以单击/填充。
Am I doing it wrong or it's something else? 我做错了还是别的什么?
setEnabled works fine for what it is meant for. setEnabled可以正常工作。 But I assume you want to make it invisible, for that you simple have to use
fnTxt.setVisible(false);
但是我假设你想让它变得不可见,因为你必须使用
fnTxt.setVisible(false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.