Java tutorial
import java.awt.event.ActionEvent; import javax.swing.JOptionPane; import javax.swing.JTextField; public class Main { public static void main(String[] a) { JTextField jTextField1 = new JTextField(); jTextField1.setText("java2s.com"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action"); } }); JOptionPane.showMessageDialog(null, jTextField1); } }