如何停止 jButton 操作?

How can I stop jButton action?

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//codes for initializing & calculating value of a  
if(a==1){
//if this condition is true jButton action will Continue 
//jButton action code ......}
else{
//if this condition is false jButton action will stop.

如果一个值不等于 1 ,我只想停止 jButton1 的动作。我不想停止整个代码并重新运行 jButton1 的操作。当 a 得到 1 时。我该怎么做?

private void JButton1ActionPerformed( java.awt.event.ActionEvent evt )
{
    if( count == 1 )
       PerformAction()

    else return; //line is optional
}

只需将所有 ActionPerformed 代码放在 if 语句下,然后 return out(不需要)不执行它。