Search code examples
javajbutton

button click causing another button to trigger


I am working on a project that requires a user to login. The GUI I have has login, quit and an ATM numpad below that. The numpad has 0-9, clear and ok. I would like to use the ok button to trigger login once ok button is clicked. Is there a way for me to do so?

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){}

Solution

  • I figured it out! The solution is to use

    buttonName.doClick();