FileDialogTestFrame

package ch.usi.inf.sape.gui.test.app;
 
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
import javax.swing.JFileChooser;
import javax.swing.JFrame;
 
 
/**
 * Test GUI capture and replay tools for their ability to deal with file dialogs.
 * 
 * See our AST'10 paper "Automating Performance Testing of Interactive Java Applications".
 * 
 * Copyright (c) 2010 - Sape Research Group, University of Lugano
 */
public final class FileDialogTestFrame extends JFrame {
 
	private JFileChooser chooser;
 
 
	public FileDialogTestFrame() {
		super("FileDialogTestFrame");
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		chooser = new JFileChooser();
		addMouseListener(new MouseAdapter() {
			public void mousePressed(final MouseEvent ev) {
				final int result = chooser.showOpenDialog(ev.getComponent());
				if (result==JFileChooser.APPROVE_OPTION) {
					System.out.println("You chose to open the file: " +
							chooser.getSelectedFile().getName());
				}
			}
		});
 
		setSize(500, 500);
		setVisible(true);
		requestFocus();
	}
 
	public static void main(final String[] args) {
		new FileDialogTestFrame();
	}
 
}