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

/**
 * Define a simple window with 4 entry fields
 * This class is a subclass of JFrame
 * By instantiating Awindow4, we are instantiating a JFrame  
 */

public class Awindow4 extends JFrame 
{
    public static void main(String[] arguments) 
    {
        Awindow4 w = new Awindow4();            //instantiate an object of this class
						//therefore a new JFrame subclass
        w.create();
    }

    public void create()                	//create a window
    {
        this.setTitle("My first Entry Form");           //no need to say this.      
        this.setSize(260, 190);                         //set window size
        this.setLocation(120,80);                       //set window position
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);   //action when you press X
        this.setResizable(false);       		//make it not resizable

        //---------------------------------------------------------------------
        // Either get a reference to the contentPane, 
        // or create a new JPanel, and assign it to the contentPane 
        //---------------------------------------------------------------------

        Container pane = getContentPane();      //either get reference to contentPane
                                                //PS. JFrame defaults to BorderLayout

//      JPanel pane = new JPanel();             //or create a JPanel
//      setContentPane(pane);                   //and assign it to the contentPane
                                                //PS. JPanel defaults to FlowLayout

        FlowLayout flow = new FlowLayout();     //create a FlowLayout manager   
        pane.setLayout(flow);                   //use it to layout the panel
    
        Color c;                                //create a RGB color object
        Font  f;                                //create a Font object

        c = new Color(200,255,255);             //create an RGB color
        pane.setBackground(c);                  //set the background color

        JLabel         nameLabel = new JLabel("Username: ");    //define fields
        JTextField     username  = new JTextField(15);          //to be displayed
        JLabel         pswdLabel = new JLabel("Password: ");    //in window
        JPasswordField password  = new JPasswordField(15);
        JLabel         cmntLabel = new JLabel("Comments:");
        JTextArea      comments  = new JTextArea(4, 15);
        JButton        button    = new JButton("   ENTER   ");

        comments.setLineWrap(true);             //set line wrap
        comments.setWrapStyleWord(true);        //set word wrap

        c = new Color(250,200,150);             //define color      
        button.setBackground(c);                //set button background color
        c = new Color(50,100,150);      
        button.setForeground(c);                //set button foreground color

        f = new Font("Arial",Font.BOLD,12);     //PLAIN, ITALIC, BOLD
        button.setFont(f);                      //set button font
                
        pane.add(nameLabel);                    
        pane.add(username);             //add components
        pane.add(pswdLabel);            //to the window
        pane.add(password);
        pane.add(cmntLabel);
        pane.add(comments);
        pane.add(button);

        this.setVisible(true);          	//make the window visible
    						//must be after placing components
    }
}