001: package org.netbeans.jemmy.testing;
002:
003: import java.awt.*;
004:
005: import java.awt.event.*;
006:
007: import java.io.*;
008:
009: import javax.swing.*;
010:
011: import javax.swing.filechooser.*;
012:
013: import org.netbeans.jemmy.explorer.*;
014: import org.netbeans.jemmy.operators.*;
015:
016: public class Application_031 extends TestFrame {
017:
018: JTextField tf;
019: JButton btn;
020: JFileChooser chooser;
021:
022: public Application_031() {
023: super ("Application_031");
024:
025: tf = new JTextField("");
026: btn = new JButton("...");
027: chooser = new JFileChooser();
028: chooser.setCurrentDirectory(new File(System
029: .getProperty("user.dir")));
030: chooser
031: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
032: btn.addActionListener(new ActionListener() {
033: public void actionPerformed(ActionEvent e) {
034: tf.setText("");
035: org.netbeans.jemmy.JemmyProperties.getCurrentOutput()
036: .printLine("In actionPerformed");
037: int respond = chooser.showDialog(btn, "---");
038: org.netbeans.jemmy.JemmyProperties.getCurrentOutput()
039: .printLine("Out actionPerformed");
040: org.netbeans.jemmy.JemmyProperties.getCurrentOutput()
041: .printLine("");
042: if (respond == JFileChooser.APPROVE_OPTION) {
043: if (chooser.getSelectedFile() != null) {
044: tf.setText(chooser.getSelectedFile()
045: .getAbsolutePath());
046: } else {
047: tf.setText("");
048: }
049: }
050: }
051: });
052: chooser.addChoosableFileFilter(new NoDirFilter());
053: chooser.addChoosableFileFilter(new NothingFilter());
054: chooser.addChoosableFileFilter(new NoFileFilter());
055: chooser
056: .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
057: getContentPane().setLayout(new BorderLayout());
058: getContentPane().add(btn, BorderLayout.EAST);
059: getContentPane().add(tf, BorderLayout.CENTER);
060:
061: setSize(400, 100);
062: }
063:
064: public static void main(String[] argv) {
065: Application_031 app = new Application_031();
066: app.show();
067: }
068:
069: class NoFileFilter extends javax.swing.filechooser.FileFilter {
070: public NoFileFilter() {
071: super ();
072: }
073:
074: public boolean accept(File f) {
075: return (f.isDirectory());
076: }
077:
078: public String getDescription() {
079: return ("No file");
080: }
081: }
082:
083: class NoDirFilter extends javax.swing.filechooser.FileFilter {
084: public NoDirFilter() {
085: super ();
086: }
087:
088: public boolean accept(File f) {
089: return (!f.isDirectory());
090: }
091:
092: public String getDescription() {
093: return ("No directory");
094: }
095: }
096:
097: class NothingFilter extends javax.swing.filechooser.FileFilter {
098: public NothingFilter() {
099: super ();
100: }
101:
102: public boolean accept(File f) {
103: return (false);
104: }
105:
106: public String getDescription() {
107: return ("Nothing");
108: }
109: }
110:
111: }
|