Enabling a jbutton at startup

72 views Asked by At

I have a login form and a mainform. In the mainform I have a disabled JButton. I want to enable that JButton only if the username that I get from the login form is "admin". I have a singleton controller instantiated in both forms. I do something like

if(controller.admin=="admin"){jbutton.setEnabled(true)};

but I’m new to swing and I don't know where to use this code. I tried using it in the mainform's constructor but it didn't work.

1

There are 1 answers

0
Sriram S On
   if((controller.admin).equals("admin"))
  {
 jbutton.setEnabled(true);
  }

this is the correct code .please describe the questions with code