import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class UsersApplet extends JApplet
	implements ActionListener
{
	private JLabel userLabel;
	private JLabel pwdLabel;
	private JTextField userTextField;
	private JTextField passwordTextField;
	private JButton signinButton;
	private JButton cancelButton;

	public void init()
	{
		Container contentPane = getContentPane();
		contentPane.setLayout(new FlowLayout());

		//User name components
		userLabel = new JLabel("User Name: ");
		contentPane.add(userLabel);
		userTextField = new JTextField(30);
		contentPane.add(userTextField);

		//Password components
		pwdLabel = new JLabel("Password: ");
		contentPane.add(pwdLabel);
		passwordTextField = new JTextField(30);
		contentPane.add(passwordTextField);

		//Buttons
		signinButton = new JButton("Sign In Now!");
		contentPane.add(signinButton);
		signinButton.addActionListener(this);

		cancelButton = new JButton("Cancel");
		contentPane.add(cancelButton);
		cancelButton.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		String actionCommand = e.getActionCommand();

		if(actionCommand.equals("Sign In Now!"))
		{
			JOptionPane.showMessageDialog(null,
				"User name " + userTextField.getText() +
				"\nPassword " + passwordTextField.getText());
			userTextField.setText(" ");
			passwordTextField.setText(" ");
		}
		else if(actionCommand.equals("Cancel"))
		{
			userTextField.setText(" ");
			passwordTextField.setText(" ");
		}
	}
}