java.awt

Class FileDialog

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class FileDialog
    extends Dialog
    The FileDialog class displays a dialog window from which the user can select a file.

    Since it is a modal dialog, when the application calls its show method to display the dialog, it blocks the rest of the application until the user has chosen a file.

    Since:
    JDK1.0
    See Also:
    Window.show(), Serialized Form
    • Field Detail

      • LOAD

        public static final int LOAD
        This constant value indicates that the purpose of the file dialog window is to locate a file from which to read.
        See Also:
        Constant Field Values
      • SAVE

        public static final int SAVE
        This constant value indicates that the purpose of the file dialog window is to locate a file to which to write.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FileDialog

        public FileDialog(Frame parent)
        Creates a file dialog for loading a file. The title of the file dialog is initially empty. This is a convenience method for FileDialog(parent, "", LOAD).
        Parameters:
        parent - the owner of the dialog
        Since:
        JDK1.1
      • FileDialog

        public FileDialog(Frame parent,
                  String title)
        Creates a file dialog window with the specified title for loading a file. The files shown are those in the current directory. This is a convenience method for FileDialog(parent, title, LOAD).
        Parameters:
        parent - the owner of the dialog
        title - the title of the dialog
      • FileDialog

        public FileDialog(Frame parent,
                  String title,
                  int mode)
        Creates a file dialog window with the specified title for loading or saving a file.

        If the value of mode is LOAD, then the file dialog is finding a file to read, and the files shown are those in the current directory. If the value of mode is SAVE, the file dialog is finding a place to write a file.

        Parameters:
        parent - the owner of the dialog
        title - the title of the dialog
        mode - the mode of the dialog; either FileDialog.LOAD or FileDialog.SAVE
        Throws:
        IllegalArgumentException - if an illegal file dialog mode is supplied
        See Also:
        LOAD, SAVE
      • FileDialog

        public FileDialog(Dialog parent)
        Creates a file dialog for loading a file. The title of the file dialog is initially empty. This is a convenience method for FileDialog(parent, "", LOAD).
        Parameters:
        parent - the owner of the dialog
        Throws:
        IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
        IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
        Since:
        1.5
        See Also:
        GraphicsEnvironment.isHeadless()
      • FileDialog

        public FileDialog(Dialog parent,
                  String title)
        Creates a file dialog window with the specified title for loading a file. The files shown are those in the current directory. This is a convenience method for FileDialog(parent, title, LOAD).
        Parameters:
        parent - the owner of the dialog
        title - the title of the dialog; a null value will be accepted without causing a NullPointerException to be thrown
        Throws:
        IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
        IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
        Since:
        1.5
        See Also:
        GraphicsEnvironment.isHeadless()
      • FileDialog

        public FileDialog(Dialog parent,
                  String title,
                  int mode)
        Creates a file dialog window with the specified title for loading or saving a file.

        If the value of mode is LOAD, then the file dialog is finding a file to read, and the files shown are those in the current directory. If the value of mode is SAVE, the file dialog is finding a place to write a file.

        Parameters:
        parent - the owner of the dialog
        title - the title of the dialog; a null value will be accepted without causing a NullPointerException to be thrown
        mode - the mode of the dialog; either FileDialog.LOAD or FileDialog.SAVE
        Throws:
        IllegalArgumentException - if an illegal file dialog mode is supplied;
        IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
        IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
        Since:
        1.5
        See Also:
        GraphicsEnvironment.isHeadless(), LOAD, SAVE
    • Method Detail

      • getMode

        public int getMode()
        Indicates whether this file dialog box is for loading from a file or for saving to a file.
        Returns:
        the mode of this file dialog window, either FileDialog.LOAD or FileDialog.SAVE
        See Also:
        LOAD, SAVE, setMode(int)
      • setMode

        public void setMode(int mode)
        Sets the mode of the file dialog. If mode is not a legal value, an exception will be thrown and mode will not be set.
        Parameters:
        mode - the mode for this file dialog, either FileDialog.LOAD or FileDialog.SAVE
        Throws:
        IllegalArgumentException - if an illegal file dialog mode is supplied
        Since:
        JDK1.1
        See Also:
        LOAD, SAVE, getMode()
      • getDirectory

        public String getDirectory()
        Gets the directory of this file dialog.
        Returns:
        the (potentially null or invalid) directory of this FileDialog
        See Also:
        setDirectory(java.lang.String)
      • setDirectory

        public void setDirectory(String dir)
        Sets the directory of this file dialog window to be the specified directory. Specifying a null or an invalid directory implies an implementation-defined default. This default will not be realized, however, until the user has selected a file. Until this point, getDirectory() will return the value passed into this method.

        Specifying "" as the directory is exactly equivalent to specifying null as the directory.

        Parameters:
        dir - the specified directory
        See Also:
        getDirectory()
      • getFile

        public String getFile()
        Gets the selected file of this file dialog. If the user selected CANCEL, the returned file is null.
        Returns:
        the currently selected file of this file dialog window, or null if none is selected
        See Also:
        setFile(java.lang.String)
      • getFiles

        public File[] getFiles()
        Returns files that the user selects.

        If the user cancels the file dialog, then the method returns an empty array.

        Returns:
        files that the user selects or an empty array if the user cancels the file dialog.
        Since:
        1.7
        See Also:
        setFile(String), getFile()
      • setFile

        public void setFile(String file)
        Sets the selected file for this file dialog window to be the specified file. This file becomes the default file if it is set before the file dialog window is first shown.

        Specifying "" as the file is exactly equivalent to specifying null as the file.

        Parameters:
        file - the file being set
        See Also:
        getFile(), getFiles()
      • setMultipleMode

        public void setMultipleMode(boolean enable)
        Enables or disables multiple file selection for the file dialog.
        Parameters:
        enable - if true, multiple file selection is enabled; false - disabled.
        Since:
        1.7
        See Also:
        isMultipleMode()
      • isMultipleMode

        public boolean isMultipleMode()
        Returns whether the file dialog allows the multiple file selection.
        Returns:
        true if the file dialog allows the multiple file selection; false otherwise.
        Since:
        1.7
        See Also:
        setMultipleMode(boolean)
      • getFilenameFilter

        public FilenameFilter getFilenameFilter()
        Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
        Returns:
        this file dialog's filename filter
        See Also:
        FilenameFilter, setFilenameFilter(java.io.FilenameFilter)
      • setFilenameFilter

        public void setFilenameFilter(FilenameFilter filter)
        Sets the filename filter for this file dialog window to the specified filter. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
        Parameters:
        filter - the specified filter
        See Also:
        FilenameFilter, getFilenameFilter()
      • paramString

        protected String paramString()
        Returns a string representing the state of this FileDialog window. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
        Overrides:
        paramString in class Dialog
        Returns:
        the parameter string of this file dialog window

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/awt/filedialog.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut