The first case:
if(loginF.getText()=="root" && passwordF.getText() == "root"); Here we have if statement with an empty statement as it's contained Statement. so we are not allowed to call else any more; and in all case the cod:
#
{
#
mb = new MenuBar(this);
#
mb.setBackground(java.awt.Color.white);
#
this.setJMenuBar(mb);
#
this.validate();
#
this.repaint();
#
setBounds(400, 400, 600, 500);
#
setVisible(true);
#
}
The second the block above doesn't excecute because the condition:
loginF.getText()=="root" && passwordF.getText() == "root" because the condition doesn't stisfied.
Now tell me witch of the two if own the else clause?
//This code is from the java language specification
if (door.isOpen())
if (resident.isVisible())
resident.greet("Hello!");
else door.bell.ring(); Hope it helps.