home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / awt / FileDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  2.4 KB  |  82 lines

  1. package java.awt;
  2.  
  3. import java.awt.peer.FileDialogPeer;
  4. import java.io.FilenameFilter;
  5.  
  6. public class FileDialog extends Dialog {
  7.    public static final int LOAD = 0;
  8.    public static final int SAVE = 1;
  9.    int mode;
  10.    String dir;
  11.    String file;
  12.    FilenameFilter filter;
  13.  
  14.    public FileDialog(Frame parent, String title) {
  15.       this(parent, title, 0);
  16.    }
  17.  
  18.    public FileDialog(Frame parent, String title, int mode) {
  19.       super(parent, title, true);
  20.       this.mode = mode;
  21.       ((Container)this).setLayout((LayoutManager)null);
  22.    }
  23.  
  24.    public synchronized void addNotify() {
  25.       super.peer = ((Window)this).getToolkit().createFileDialog(this);
  26.       if (super.peer != null) {
  27.          super.addNotify();
  28.       }
  29.  
  30.    }
  31.  
  32.    public int getMode() {
  33.       return this.mode;
  34.    }
  35.  
  36.    public String getDirectory() {
  37.       return this.dir;
  38.    }
  39.  
  40.    public void setDirectory(String dir) {
  41.       this.dir = dir;
  42.       if (super.peer != null) {
  43.          ((FileDialogPeer)super.peer).setDirectory(dir);
  44.       }
  45.  
  46.    }
  47.  
  48.    public String getFile() {
  49.       return this.file;
  50.    }
  51.  
  52.    public void setFile(String file) {
  53.       this.file = file;
  54.       if (super.peer != null) {
  55.          ((FileDialogPeer)super.peer).setFile(file);
  56.       }
  57.  
  58.    }
  59.  
  60.    public FilenameFilter getFilenameFilter() {
  61.       return this.filter;
  62.    }
  63.  
  64.    public void setFilenameFilter(FilenameFilter filter) {
  65.       this.filter = filter;
  66.       FileDialogPeer peer = (FileDialogPeer)super.peer;
  67.       if (peer != null) {
  68.          peer.setFilenameFilter(filter);
  69.       }
  70.  
  71.    }
  72.  
  73.    protected String paramString() {
  74.       String str = super.paramString();
  75.       if (this.dir != null) {
  76.          str = str + ",dir= " + this.dir;
  77.       }
  78.  
  79.       return str + (this.mode == 0 ? ",load" : ",save");
  80.    }
  81. }
  82.