@@ -0,0 +1,2278 @@
+/**%0A * @(#)TextFieldTest.java%0A *%0A *%0A * @author%0A * @version 1.00 2014/7/14%0A */%0Aimport java.awt.*;%0Aimport java.awt.event.*;%0Aimport javax.swing.*;%0A%0Apublic class TextFieldTest extends JFrame %7B%0A%09private JTextField tField1, tField2, tField3;%0A%09private JPasswordField pField;%0A%0A%09//GUI section%0A    public TextFieldTest() %7B%0A    %09super (%22Test out JTextField and JPasswordField%22);%0A%0A    %09Container container = getContentPane();%0A    %09container.setLayout( new FlowLayout());%0A%0A    %09//tField with default size%0A    %09tField1 = new JTextField(10);%0A    %09container.add(tField1);%0A%0A    %09//tField with default text%0A    %09tField2 = new JTextField(%22Enter something here%22);%0A    %09container.add(tField2);%0A%0A    %09//20 visible element - no event handler%0A    %09tField3 = new JTextField(%22Uneditable text field%22, 20);%0A    %09tField3.setEditable(false);%0A    %09container.add(tField3);%0A%0A    %09//pField with default text%0A    %09pField = new JPasswordField(%22Hidden text%22);%0A    %09container.add(pField);%0A%0A    %09//register event handlers%0A    %09TextFieldHandler handler = new TextFieldHandler();%0A    %09tField1.addActionListener(handler);%0A    %09tField2.addActionListener(handler);%0A    %09tField3.addActionListener(handler);%0A    %09pField.addActionListener(handler);%0A%0A    %09setSize( 350, 125);%0A    %09setVisible(true);%0A    %7D%0A%0A    public static void main (String%5B%5D args) %7B%0A    %09TextFieldTest app = new TextFieldTest();%0A    %09app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A    %7D%0A%0A    //private inner class for event handling%0A    private class TextFieldHandler implements ActionListener %7B%0A%0A    %09//process textfield events%0A    %09public void actionPerformed(ActionEvent event) %7B%0A%0A    %09%09String string = %22%22;%0A%0A    %09%09//user pressed enter in tField1%0A    %09%09if (event.getSource() == tField1)%0A    %09%09%09string = %22tField1: %22 + event.getActionCommand();%0A%0A    %09%09//user pressed enter in tField2%0A    %09%09else if (event.getSource() == tField2)%0A    %09%09%09string = %22tField2: %22 + event.getActionCommand();%0A%0A    %09%09//user pressed enter in tField3%0A    %09%09else if (event.getSource() == tField3)%0A    %09%09%09string = %22tField3: %22 + event.getActionCommand();%0A%0A    %09%09//user pressed enter in tField1%0A    %09%09else if (event.getSource() == pField) %7B%0A%0A    %09%09%09string = %22pField: %22 + new String(pField.getPassword() );%0A    %09%09%7D%0A%0A    %09%09JOptionPane.showMessageDialog( null, string);%0A    %09%7D%0A    %7D%0A%0A%7D%0A

Create TextFieldTest.java