Heres my code
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Order extends Applet implements ActionListener
{
String password = "pword";
TextField txt1 = new TextField(10);
TextField txt2 = new TextField(10);
Button btn1 = new Button("Ok");
Button btn2 = new Button("Ok");
Label lbl1 = new Label("Choose Your Order");
Checkbox chk1 = new Checkbox("Value Meal #1: P25.00");
public void init()
{
add(new Label("Username: ",Label.LEFT));
add(txt1);
addNewLine();
add(new Label("Password: ",Label.LEFT));
add(txt2);
txt2.setEchoChar('*');
addNewLine();
add(btn1);
add(lbl1);
lbl1.setVisible(false);
add(chk1);
chk1.setVisible(false);
btn1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == btn1)
{
process();
}
}
public void process()
{
if(txt2.getText().equals(password))
{
lbl1.setVisible(true);
chk1.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"Invalid Password","Message",JOptionPane.INFORMATION_MESSAGE);
}
}
public void addHorizontalLine(Color c)
{
Canvas line = new Canvas( );
line.setSize(10000,1);
line.setBackground(c);
add(line);
}
public void addNewLine( )
{
addHorizontalLine(getBackground( ));
}
}
the problem is when I run the program and enter the password, lbl1 and chk1 should be visible but it stays invisible.