import squint.*;
import javax.swing.*;

/*
 * A friendly log in window that greets the user.  This
 * program illustrates how to use an accessor method to
 * ask an object for information.
 */
public class FriendlyLogInWindowWithPanels extends GUIManager {

    /*
     * The text field where the user types in the username.
     */
    private JTextField userId;

    // size of the program's window 
    private final int WINDOW_WIDTH = 200;
    private final int WINDOW_HEIGHT = 300;
    
    // size of input text fields 
    private final int FIELD_WIDTH = 8;
    
    public FriendlyLogInWindowWithPanels() {

        this.createWindow(WINDOW_WIDTH, WINDOW_HEIGHT);

        JPanel panel = new JPanel();
        panel.add(new JLabel("Username:"));
        userId = new JTextField(FIELD_WIDTH);
        panel.add(userId);
        contentPane.add(panel);

        panel = new JPanel();
        panel.add(new JLabel("Password:"));
        panel.add(new JPasswordField(FIELD_WIDTH));
        contentPane.add(panel);

        contentPane.add(new JButton("Authenticate"));
    
    }

    public void buttonClicked() {
        
        // Add welcome message based on user name.
        contentPane.add(new JLabel("Welcome " + userId.getText() + "."));
        contentPane.add(new JLabel("Your login is accepted."));
    }
}
