< prev index next >

src/java.desktop/share/classes/java/awt/FileDialog.java

Print this page

        

*** 30,44 **** import java.io.ObjectInputStream; import java.io.File; import sun.awt.AWTAccessor; /** ! * The <code>FileDialog</code> class displays a dialog window * from which the user can select a file. * <p> * Since it is a modal dialog, when the application calls ! * its <code>show</code> method to display the dialog, * it blocks the rest of the application until the user has * chosen a file. * * @see Window#show * --- 30,44 ---- import java.io.ObjectInputStream; import java.io.File; import sun.awt.AWTAccessor; /** ! * The {@code FileDialog} class displays a dialog window * from which the user can select a file. * <p> * Since it is a modal dialog, when the application calls ! * its {@code show} method to display the dialog, * it blocks the rest of the application until the user has * chosen a file. * * @see Window#show *
*** 59,72 **** * dialog window is to locate a file to which to write. */ public static final int SAVE = 1; /* ! * There are two <code>FileDialog</code> modes: <code>LOAD</code> and ! * <code>SAVE</code>. * This integer will represent one or the other. ! * If the mode is not specified it will default to <code>LOAD</code>. * * @serial * @see getMode() * @see setMode() * @see java.awt.FileDialog#LOAD --- 59,72 ---- * dialog window is to locate a file to which to write. */ public static final int SAVE = 1; /* ! * There are two {@code FileDialog} modes: {@code LOAD} and ! * {@code SAVE}. * This integer will represent one or the other. ! * If the mode is not specified it will default to {@code LOAD}. * * @serial * @see getMode() * @see setMode() * @see java.awt.FileDialog#LOAD
*** 74,95 **** */ int mode; /* * The string specifying the directory to display ! * in the file dialog. This variable may be <code>null</code>. * * @serial * @see getDirectory() * @see setDirectory() */ String dir; /* * The string specifying the initial value of the * filename text field in the file dialog. ! * This variable may be <code>null</code>. * * @serial * @see getFile() * @see setFile() */ --- 74,95 ---- */ int mode; /* * The string specifying the directory to display ! * in the file dialog. This variable may be {@code null}. * * @serial * @see getDirectory() * @see setDirectory() */ String dir; /* * The string specifying the initial value of the * filename text field in the file dialog. ! * This variable may be {@code null}. * * @serial * @see getFile() * @see setFile() */
*** 116,126 **** /* * The filter used as the file dialog's filename filter. * The file dialog will only be displaying files whose * names are accepted by this filter. ! * This variable may be <code>null</code>. * * @serial * @see #getFilenameFilter() * @see #setFilenameFilter() * @see FileNameFilter --- 116,126 ---- /* * The filter used as the file dialog's filename filter. * The file dialog will only be displaying files whose * names are accepted by this filter. ! * This variable may be {@code null}. * * @serial * @see #getFilenameFilter() * @see #setFilenameFilter() * @see FileNameFilter
*** 171,181 **** private static native void initIDs(); /** * Creates a file dialog for loading a file. The title of the * file dialog is initially empty. This is a convenience method for ! * <code>FileDialog(parent, "", LOAD)</code>. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be --- 171,181 ---- private static native void initIDs(); /** * Creates a file dialog for loading a file. The title of the * file dialog is initially empty. This is a convenience method for ! * {@code FileDialog(parent, "", LOAD)}. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be
*** 190,200 **** /** * 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 ! * <code>FileDialog(parent, title, LOAD)</code>. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be --- 190,200 ---- /** * 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 ! * {@code FileDialog(parent, title, LOAD)}. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be
*** 209,222 **** /** * Creates a file dialog window with the specified title for loading * or saving a file. * <p> ! * If the value of <code>mode</code> is <code>LOAD</code>, then the * file dialog is finding a file to read, and the files shown are those * in the current directory. If the value of ! * <code>mode</code> is <code>SAVE</code>, the file dialog is finding * a place to write a file. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's --- 209,222 ---- /** * Creates a file dialog window with the specified title for loading * or saving a file. * <p> ! * If the value of {@code mode} is {@code 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 ! * {@code mode} is {@code SAVE}, the file dialog is finding * a place to write a file. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's
*** 224,234 **** * displayed. * * @param parent the owner of the dialog * @param title the title of the dialog * @param mode the mode of the dialog; either ! * <code>FileDialog.LOAD</code> or <code>FileDialog.SAVE</code> * @exception IllegalArgumentException if an illegal file * dialog mode is supplied * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE */ --- 224,234 ---- * displayed. * * @param parent the owner of the dialog * @param title the title of the dialog * @param mode the mode of the dialog; either ! * {@code FileDialog.LOAD} or {@code FileDialog.SAVE} * @exception IllegalArgumentException if an illegal file * dialog mode is supplied * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE */
*** 239,264 **** } /** * Creates a file dialog for loading a file. The title of the * file dialog is initially empty. This is a convenience method for ! * <code>FileDialog(parent, "", LOAD)</code>. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @exception java.lang.IllegalArgumentException if the <code>parent</code>'s ! * <code>GraphicsConfiguration</code> * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if <code>parent</code> ! * is <code>null</code>; this exception is always thrown when ! * <code>GraphicsEnvironment.isHeadless</code> ! * returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.5 */ public FileDialog(Dialog parent) { this(parent, "", LOAD); --- 239,264 ---- } /** * Creates a file dialog for loading a file. The title of the * file dialog is initially empty. This is a convenience method for ! * {@code FileDialog(parent, "", LOAD)}. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @exception java.lang.IllegalArgumentException if the {@code parent}'s ! * {@code GraphicsConfiguration} * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if {@code parent} ! * is {@code null}; this exception is always thrown when ! * {@code GraphicsEnvironment.isHeadless} ! * returns {@code true} * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.5 */ public FileDialog(Dialog parent) { this(parent, "", LOAD);
*** 266,294 **** /** * 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 ! * <code>FileDialog(parent, title, LOAD)</code>. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @param title the title of the dialog; a <code>null</code> value * will be accepted without causing a ! * <code>NullPointerException</code> to be thrown ! * @exception java.lang.IllegalArgumentException if the <code>parent</code>'s ! * <code>GraphicsConfiguration</code> * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if <code>parent</code> ! * is <code>null</code>; this exception is always thrown when ! * <code>GraphicsEnvironment.isHeadless</code> ! * returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.5 */ public FileDialog(Dialog parent, String title) { this(parent, title, LOAD); --- 266,294 ---- /** * 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 ! * {@code FileDialog(parent, title, LOAD)}. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @param title the title of the dialog; a {@code null} value * will be accepted without causing a ! * {@code NullPointerException} to be thrown ! * @exception java.lang.IllegalArgumentException if the {@code parent}'s ! * {@code GraphicsConfiguration} * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if {@code parent} ! * is {@code null}; this exception is always thrown when ! * {@code GraphicsEnvironment.isHeadless} ! * returns {@code true} * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.5 */ public FileDialog(Dialog parent, String title) { this(parent, title, LOAD);
*** 296,332 **** /** * Creates a file dialog window with the specified title for loading * or saving a file. * <p> ! * If the value of <code>mode</code> is <code>LOAD</code>, then the * file dialog is finding a file to read, and the files shown are those * in the current directory. If the value of ! * <code>mode</code> is <code>SAVE</code>, the file dialog is finding * a place to write a file. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @param title the title of the dialog; a <code>null</code> value * will be accepted without causing a ! * <code>NullPointerException</code> to be thrown * @param mode the mode of the dialog; either ! * <code>FileDialog.LOAD</code> or <code>FileDialog.SAVE</code> * @exception java.lang.IllegalArgumentException if an illegal * file dialog mode is supplied; ! * @exception java.lang.IllegalArgumentException if the <code>parent</code>'s ! * <code>GraphicsConfiguration</code> * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if <code>parent</code> ! * is <code>null</code>; this exception is always thrown when ! * <code>GraphicsEnvironment.isHeadless</code> ! * returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @since 1.5 */ --- 296,332 ---- /** * Creates a file dialog window with the specified title for loading * or saving a file. * <p> ! * If the value of {@code mode} is {@code 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 ! * {@code mode} is {@code SAVE}, the file dialog is finding * a place to write a file. * <p> * <strong>Note:</strong> Some platforms may not support * showing the user-specified title in a file dialog. * In this situation, either no title will be displayed in the file dialog's * title bar or, on some systems, the file dialog's title bar will not be * displayed. * * @param parent the owner of the dialog ! * @param title the title of the dialog; a {@code null} value * will be accepted without causing a ! * {@code NullPointerException} to be thrown * @param mode the mode of the dialog; either ! * {@code FileDialog.LOAD} or {@code FileDialog.SAVE} * @exception java.lang.IllegalArgumentException if an illegal * file dialog mode is supplied; ! * @exception java.lang.IllegalArgumentException if the {@code parent}'s ! * {@code GraphicsConfiguration} * is not from a screen device; ! * @exception java.lang.IllegalArgumentException if {@code parent} ! * is {@code null}; this exception is always thrown when ! * {@code GraphicsEnvironment.isHeadless} ! * returns {@code true} * @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @since 1.5 */
*** 351,362 **** super.setTitle(title); } /** ! * Constructs a name for this component. Called by <code>getName()</code> ! * when the name is <code>null</code>. */ String constructComponentName() { synchronized (FileDialog.class) { return base + nameCounter++; } --- 351,362 ---- super.setTitle(title); } /** ! * Constructs a name for this component. Called by {@code getName()} ! * when the name is {@code null}. */ String constructComponentName() { synchronized (FileDialog.class) { return base + nameCounter++; }
*** 380,407 **** /** * Indicates whether this file dialog box is for loading from a file * or for saving to a file. * * @return the mode of this file dialog window, either ! * <code>FileDialog.LOAD</code> or ! * <code>FileDialog.SAVE</code> * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @see java.awt.FileDialog#setMode */ public int getMode() { return mode; } /** ! * Sets the mode of the file dialog. If <code>mode</code> is not ! * a legal value, an exception will be thrown and <code>mode</code> * will not be set. * * @param mode the mode for this file dialog, either ! * <code>FileDialog.LOAD</code> or ! * <code>FileDialog.SAVE</code> * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @see java.awt.FileDialog#getMode * @exception IllegalArgumentException if an illegal file * dialog mode is supplied --- 380,407 ---- /** * Indicates whether this file dialog box is for loading from a file * or for saving to a file. * * @return the mode of this file dialog window, either ! * {@code FileDialog.LOAD} or ! * {@code FileDialog.SAVE} * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @see java.awt.FileDialog#setMode */ public int getMode() { return mode; } /** ! * Sets the mode of the file dialog. If {@code mode} is not ! * a legal value, an exception will be thrown and {@code mode} * will not be set. * * @param mode the mode for this file dialog, either ! * {@code FileDialog.LOAD} or ! * {@code FileDialog.SAVE} * @see java.awt.FileDialog#LOAD * @see java.awt.FileDialog#SAVE * @see java.awt.FileDialog#getMode * @exception IllegalArgumentException if an illegal file * dialog mode is supplied
*** 419,446 **** } /** * Gets the directory of this file dialog. * ! * @return the (potentially <code>null</code> or invalid) ! * directory of this <code>FileDialog</code> * @see java.awt.FileDialog#setDirectory */ public String getDirectory() { return dir; } /** * Sets the directory of this file dialog window to be the ! * specified directory. Specifying a <code>null</code> 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, <code>getDirectory()</code> * will return the value passed into this method. * <p> * Specifying "" as the directory is exactly equivalent to ! * specifying <code>null</code> as the directory. * * @param dir the specified directory * @see java.awt.FileDialog#getDirectory */ public void setDirectory(String dir) { --- 419,446 ---- } /** * Gets the directory of this file dialog. * ! * @return the (potentially {@code null} or invalid) ! * directory of this {@code FileDialog} * @see java.awt.FileDialog#setDirectory */ public String getDirectory() { return dir; } /** * Sets the directory of this file dialog window to be the ! * specified directory. Specifying a {@code 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, {@code getDirectory()} * will return the value passed into this method. * <p> * Specifying "" as the directory is exactly equivalent to ! * specifying {@code null} as the directory. * * @param dir the specified directory * @see java.awt.FileDialog#getDirectory */ public void setDirectory(String dir) {
*** 451,464 **** } } /** * Gets the selected file of this file dialog. If the user ! * selected <code>CANCEL</code>, the returned file is <code>null</code>. * * @return the currently selected file of this file dialog window, ! * or <code>null</code> if none is selected * @see java.awt.FileDialog#setFile */ public String getFile() { return file; } --- 451,464 ---- } } /** * Gets the selected file of this file dialog. If the user ! * selected {@code CANCEL}, the returned file is {@code null}. * * @return the currently selected file of this file dialog window, ! * or {@code null} if none is selected * @see java.awt.FileDialog#setFile */ public String getFile() { return file; }
*** 590,605 **** peer.setFilenameFilter(filter); } } /** ! * Reads the <code>ObjectInputStream</code> and performs * a backwards compatibility check by converting ! * either a <code>dir</code> or a <code>file</code> ! * equal to an empty string to <code>null</code>. * ! * @param s the <code>ObjectInputStream</code> to read */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); --- 590,605 ---- peer.setFilenameFilter(filter); } } /** ! * Reads the {@code ObjectInputStream} and performs * a backwards compatibility check by converting ! * either a {@code dir} or a {@code file} ! * equal to an empty string to {@code null}. * ! * @param s the {@code ObjectInputStream} to read */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject();
*** 612,626 **** file = null; } } /** ! * Returns a string representing the state of this <code>FileDialog</code> * 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 ! * <code>null</code>. * * @return the parameter string of this file dialog window */ protected String paramString() { String str = super.paramString(); --- 612,626 ---- file = null; } } /** ! * Returns a string representing the state of this {@code 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 ! * {@code null}. * * @return the parameter string of this file dialog window */ protected String paramString() { String str = super.paramString();
< prev index next >