TextFieldTestFrame

package ch.usi.inf.sape.gui.test.app;
 
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
import javax.swing.JTextField;
import javax.swing.JFrame;
 
 
/**
 * Test GUI capture and replay tools for their ability to handle operations on a text field.
 * 
 * See our AST'10 paper "Automating Performance Testing of Interactive Java Applications".
 * 
 * Copyright (c) 2010 - Sape Research Group, University of Lugano
 */
public final class TextFieldTestFrame extends JFrame {
 
	public TextFieldTestFrame() {
		super("TextFieldTestFrame");
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		final JTextField tf = new JTextField();
		add(tf, BorderLayout.CENTER);
 
		tf.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent ev) {
				System.out.println("You submitted: "+tf.getText());
			}
		});
 
		tf.addMouseListener(new MouseAdapter() {
			public void mouseReleased(final MouseEvent ev) {
				if (tf.getSelectedText()!=null) {
					System.out.println("You selected: "+tf.getSelectedText());
				}
			}
		});
 
		tf.addKeyListener(new KeyAdapter() {	
			public void keyTyped(final KeyEvent ev) {
				System.out.println("You typed: "+ev.getKeyChar());
			}
		});
 
		setSize(300, 300);
		setVisible(true);
	}
 
 
	public static void main(final String[] args) {
		new TextFieldTestFrame();
	}
 
}