home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / sun / awt / win32 / MFileDialogPeer.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  2.7 KB  |  91 lines

  1. /*
  2.  * @(#)MFileDialogPeer.java    1.16 96/04/24 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19. package sun.awt.win32;
  20.  
  21. import java.awt.*;
  22. import java.awt.peer.*;
  23. import java.io.FilenameFilter;
  24.  
  25. public class MFileDialogPeer extends MDialogPeer implements FileDialogPeer {
  26.     native void pCreate(MComponentPeer parent,
  27.     int mode, String title, String file);
  28.  
  29.     void create(MComponentPeer parent) {
  30.         FileDialog target = (FileDialog)this.target;
  31.  
  32.         pCreate(parent, target.getMode(), target.getTitle(), target.getFile());
  33.     }
  34.  
  35.     public MFileDialogPeer(FileDialog target) {
  36.     super(target);
  37.  
  38.     FileDialog    fdialog = (FileDialog)target;
  39.     String        dir = fdialog.getDirectory();
  40.  
  41.     if (dir != null) {
  42.         setDirectory(dir);
  43.     }
  44.     }
  45.     native void        pShow();
  46.     native void        pHide();
  47.     public void        handleSelected(String file) {
  48.     int    index = file.lastIndexOf('\\');
  49.  
  50.     String dir;
  51.     if (index == -1) {
  52.         dir = ".\\";
  53.         ((FileDialog)target).setFile(file);
  54.     } else {
  55.         dir = file.substring(0, index+1);
  56.         ((FileDialog)target).setFile(file.substring(index+1));
  57.     }
  58.     ((FileDialog)target).setDirectory(dir);
  59.     }
  60.     public void        handleCancel() {
  61.     ((FileDialog)target).setFile(null);
  62.     }
  63.     public void        handleQuit() {
  64.     handleCancel();
  65.     hide();
  66.     }
  67.     public native void    setDirectory(String dir);
  68.     public native void    setFile(String file);
  69.     public void        setFilenameFilter(FilenameFilter filter) {
  70.         // Not implemented for 1.0
  71.     }
  72.     public void pReshape(int x, int y, int width, int height) {
  73.         // Not implemented for 1.0
  74.     }
  75.     public void pSetTitle(String title) {
  76.         // Not implemented for 1.0
  77.     }
  78.     public void setResizable(boolean resizable) {
  79.         // Not implemented for 1.0
  80.     }
  81.  
  82.     public void setInsets(Insets i) {
  83.         insets = i;
  84.     }
  85.  
  86.     // avoid MDialogPeer's modality support.
  87.     public void show() {
  88.         pShow();
  89.     }
  90. }
  91.