import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

        // Display a JTextField and JPasswordField.
        // When the Login button is pressed, retrieve the
        // text they both contain.
class SwingTextFrame1 extends JFrame {
    public SwingTextFrame1() {
        final int width = 300, height = 100;
        setSize(width,height);
        Container contents = getContentPane();

        // Place both fields in a vertical box.
        Box box = Box.createVerticalBox();
        final JTextField name = new JTextField("guest",10);
        name.setHorizontalAlignment(JTextField.LEFT);
        final JPasswordField password = new JPasswordField(10);
        box.add(name);
        box.add(password);
        contents.add(box,"Center");

        // Display the contents of the fields when a button is pressed.
        JButton login = new JButton("Login");
        login.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                System.out.println("Name = "+name.getText());
                String pwd = new String(password.getPassword());
                System.out.println("Password = "+pwd);
                System.exit(0);
            }
        });
        contents.add(login,"South");
        pack();
    }
}
