import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame; 
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;

public class evehand1 extends JFrame{	//extends for inheritance
private JTextField item1;
private JTextField item2;
private JTextField item3;
private JPasswordField password;

public evehand1(){
	super("The Title");
	setLayout(new FlowLayout());
	item1=new JTextField(10);
	add(item1);
	
	item2= new JTextField("Enter text here");
	add(item2);
	
	item3= new JTextField("uneditable",20);
	item3.setEditable(false);
	add(item3);
	
	password = new JPasswordField("mypass");
	add(password);
	
	thehandler handler = new thehandler();
	item1.addActionListener(handler);
	item2.addActionListener(handler);
	item3.addActionListener(handler);
	password.addActionListener(handler);
}

		public class thehandler implements ActionListener{
			public void actionPerformed(ActionEvent event){
				String temp="";
				if(event.getSource()==item1)
					temp= String.format("field 1: %s" ,  event.getActionCommand());
				else if(event.getSource()==item2)
					temp=String.format("field 2: %s", event.getActionCommand());
				else if(event.getSource()==item3)
					temp=String.format("field 3: %s", event.getActionCommand());
				else if(event.getSource()==password)
					temp=String.format("password field is: %s" , event.getActionCommand());
				
				JOptionPane.showMessageDialog(null, temp);
				
			}
		}

}