简体   繁体   English

禁用在Java中启用JButton

[英]Disable enable JButton in Java

I have a problem I'm trying to disable JButton with setEnabled(false) like this: 我有一个问题我试图用setEnabled(false)禁用JButton,如下所示:

ButtonNewCustomer.setEnabled(false);

But this didn't work so then I imported the Applet packages, but still not working, then I discovered that I also needed to use extends Applet in the class, but the problem is that I'm already using extends for other things like this: 但这没有用,所以我导入了Applet包,但仍然没有工作,然后我发现我还需要在类中使用扩展Applet,但问题是我已经在使用扩展来处理其他类似的事情了:

public class GUI4EX extends JFrame implements ActionListener {
...
}

I have tried to add Applet, but this dont't work! 我试图添加Applet,但这不行! Is there a way to solve this? 有办法解决这个问题吗? Thanks! 谢谢!

EDIT: It's working know! 编辑:它的工作知道! The problem was a misspelling of the buttonNewCustomer. 问题是buttonNewCustomer的拼写错误。 The first letter 'b' was 'B'. 第一个字母'b'是'B'。 Sorry! 抱歉! And thanks for the help! 谢谢你的帮助!

使用setEnabled(true)启用按钮...

在设置框架的可见性之前,请确保禁用/启用按钮。

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

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