gpt4 book ai didi

java - 如何在点击两次后禁用 JButton?

转载 作者:行者123 更新时间:2023-12-02 03:38:32 24 4
gpt4 key购买 nike

我想知道如果 JButton 被按下两次,按钮是否会自行禁用,换句话说,它会 .setEnabled(false);

这是我到目前为止的代码。我想要这样,如果 Respin 被按下两次,那么 btnRespin 将被设置为 false

      //This is the code for spinning the wheels once hold is pressed
if (event.getSource() == btnHold1 && "THIS IS WHERE I NEED THE CODE FOR IF THE BUTTON IS PUSHED TWICE")
{
counter = 0;
timer1.stop();
btnHold1.setEnabled(false);
}

最佳答案

您可以使用点击计数器

就像 int i = 0;并在每次点击时增加

并检查何时高于 1

关于java - 如何在点击两次后禁用 JButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37144811/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com