FileDocCategorySizeDatePackage
JavaChooserWithPreview.javaAPI DocExample827Sun Mar 28 19:08:36 BST 1999None

JavaChooserWithPreview

public class JavaChooserWithPreview extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    
    JFileChooser fc = new JFileChooser();
    fc.addChoosableFileFilter(new JavaFilter());
    fc.setAccessory(new TextPreview(fc));
    int result = fc.showOpenDialog(new JFrame());
    if (result == JFileChooser.APPROVE_OPTION) {
      try {
        File f = fc.getSelectedFile();
        if (f != null) {
          FileInputStream fin = new FileInputStream(f);
          StreamCopier.copy(fin, System.out);
          fin.close();
        }
      }
      catch (IOException e) {
        System.err.println(e);
      }
      
    }
    
    System.exit(0);