Class FolderDialog

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class FolderDialog
    extends java.awt.FileDialog
    A folder dialog is a modal file dialog to specially select a folder on disk. This class takes advantage of a little know trick in Apple's VMs to show a real folder dialog, with a Choose button and all. However, there is no such thing on other platforms, where this class employs the usual kludge which is to show a Save dialog. If you would rather use the Swing JFileChooser, go right ahead. Based on: MRJ Adapter 1.2, Modified by Joseph A. Huwaldt
    Version:
    January 1, 2024
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.BaselineResizeBehavior
    • Field Summary

      • Fields inherited from class java.awt.FileDialog

        LOAD, SAVE
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      FolderDialog​(java.awt.Frame parent)
      Construct a folder dialog with the given parent frame.
      FolderDialog​(java.awt.Frame parent, java.lang.String title)
      Construct a folder dialog with the given parent frame and title.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDirectory()
      Get the directory of this file dialog.
      java.lang.String getFile()
      Get the file of this file dialog, which in the case of this class, is always an empty string ("") unless the user has canceled where the return value will be null.
      void setMode​(int mode)
      Set the mode of the dialog.
      void setVisible​(boolean visible)
      Shows or hides this Dialog depending on the value of parameter 'visible'.
      • Methods inherited from class java.awt.FileDialog

        addNotify, getFilenameFilter, getFiles, getMode, isMultipleMode, setDirectory, setFile, setFilenameFilter, setMultipleMode, setTitle
      • Methods inherited from class java.awt.Dialog

        getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setUndecorated, show, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FolderDialog

        public FolderDialog​(java.awt.Frame parent)
        Construct a folder dialog with the given parent frame.
        Parameters:
        parent - the parent frame
      • FolderDialog

        public FolderDialog​(java.awt.Frame parent,
                            java.lang.String title)
        Construct a folder dialog with the given parent frame and title.
        Parameters:
        parent - the parent frame
        title - the title of the dialog
    • Method Detail

      • getFile

        public java.lang.String getFile()
        Get the file of this file dialog, which in the case of this class, is always an empty string ("") unless the user has canceled where the return value will be null.
        Overrides:
        getFile in class java.awt.FileDialog
        Returns:
        an empty string if a directory was selected, or null
      • getDirectory

        public java.lang.String getDirectory()
        Get the directory of this file dialog.
        Overrides:
        getDirectory in class java.awt.FileDialog
        Returns:
        the directory of the dialog, or null
      • setMode

        public void setMode​(int mode)
        Set the mode of the dialog. This method is overriden because it doesn't make sense in the context of an application dialog to allow selection of the mode. It will throw an error if you try to call it.
        Overrides:
        setMode in class java.awt.FileDialog
        Parameters:
        mode - the mode
      • setVisible

        public void setVisible​(boolean visible)
        Shows or hides this Dialog depending on the value of parameter 'visible'. Since the dialog is modal, this method will not return until either the user dismisses the dialog or you make it invisible yourself via setVisible(false) or dispose().
        Overrides:
        setVisible in class java.awt.Dialog