按钮点击导致另一个按钮触发

button click causing another button to trigger

我正在做一个需要用户登录的项目。我的 GUI 有 loginquit 和下面的 ATM 小键盘。 numpad0-9clearok。单击 ok 按钮后,我想使用 ok 按钮触发登录。我有办法这样做吗?

for (int i = 0; i < 10; i++)
{
    if (e.getSource() == keypad[i])
    {
        //Edit the input display
        passINPUT = passINPUT + i;
        pass.setText(passINPUT);
    }
}

if(e.getSource() == clear){
    passINPUT = "";
    pass.setText(passINPUT);       
}

if(e.getSource() == OK){}

我想通了!解决方案是使用

buttonName.doClick();