FreeHEP API
Version current

org.freehep.swing
Class JDirectoryChooser

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byorg.freehep.swing.JDirectoryChooser
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JDirectoryChooser
extends JComponent

A class which allows a user to select directories or files, similar to JFileChooser, except that it display files as a tree, and is better suited to selecting directories than the current file chooser (see java bug id 4239219). TODO: Understand issue with moving mouse between double clicks (seems like MOUSE_PRESSED and MOUSE_RELEASED events are generated, but not MOUSE_CLICKED) See Bug ID 4218549

Version:
$Id: JDirectoryChooser.java,v 1.8 2004/02/27 18:35:47 tonyj Exp $
Author:
Tony Johnson (tony_johnson@slac.stanford.edu)
See Also:
Serialized Form
Source Code:
JDirectoryChooser.java

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int APPROVE_OPTION
           
static int CANCEL_OPTION
           
static int DIRECTORIES_ONLY
           
static int FILES_AND_DIRECTORIES
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
JDirectoryChooser()
          Create a JDirectoryChooser with the default FileSystemView
JDirectoryChooser(File currentDirectory)
          Create a JDirectoryChooser with the default FileSystemView
JDirectoryChooser(File currentDirectory, FileSystemView view)
          Create a JDirectoryChooser
JDirectoryChooser(FileSystemView view)
          Create a JDirectoryChooser
JDirectoryChooser(String currentDirectory)
          Create a JDirectoryChooser with the default FileSystemView
JDirectoryChooser(String currentDirectory, FileSystemView view)
          Create a JDirectoryChooser
 
Method Summary
 void addNotify()
           
 String getDialogTitle()
          Gets the string that goes in the FileChooser's titlebar
 FileFilter getFileFilter()
          Get the current file filter
 int getFileSelectionMode()
          Test the file selection mode
 FileView getFileView()
          Returns the current file view.
 File getSelectedFile()
          Returns the currently selected file (or the first selected file if multiple files are selected)
 File[] getSelectedFiles()
          Returns a list of selected files if the filechooser is set to allow multi-selection.
 boolean isFileHidingEnabled()
          Test if file hiding is enabled
 boolean isMultiSelectionEnabled()
          Returns true if multi-file selection is enabled.
static void main(String[] argv)
           
 void setCurrentDirectory(File dir)
          Set the directory to which the tree is to open
 void setDialogTitle(String dialogTitle)
          Sets the string that goes in the FileChooser window's title bar
 void setFileFilter(FileFilter fileFilter)
          Set a filter to control which files are displayed in the tree
 void setFileHidingEnabled(boolean hide)
          Select whether to show "hidden" files in the tree
 void setFileSelectionMode(int mode)
          Set the file selection mode.
 void setFileView(FileView fileView)
          Sets the file view to used to retrieve UI information, such as the icon that represents a file or the type description of a file.
 void setMultiSelectionEnabled(boolean enable)
          Sets the filechooser to allow multiple file selections.
protected  void setup(FileSystemView view)
           
 int showDialog(Component parent)
          Popup up a modal dialog containing the JDirectoryChooser
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APPROVE_OPTION

public static final int APPROVE_OPTION
See Also:
Constant Field Values

CANCEL_OPTION

public static final int CANCEL_OPTION
See Also:
Constant Field Values

DIRECTORIES_ONLY

public static final int DIRECTORIES_ONLY
See Also:
Constant Field Values

FILES_AND_DIRECTORIES

public static final int FILES_AND_DIRECTORIES
See Also:
Constant Field Values
Constructor Detail

JDirectoryChooser

public JDirectoryChooser()
Create a JDirectoryChooser with the default FileSystemView


JDirectoryChooser

public JDirectoryChooser(File currentDirectory)
Create a JDirectoryChooser with the default FileSystemView

Parameters:
currentDirectory - The directory to which the tree is initially set

JDirectoryChooser

public JDirectoryChooser(String currentDirectory)
Create a JDirectoryChooser with the default FileSystemView

Parameters:
currentDirectory - The directory to which the tree is initially set

JDirectoryChooser

public JDirectoryChooser(File currentDirectory,
                         FileSystemView view)
Create a JDirectoryChooser

Parameters:
currentDirectory - The directory to which the tree is initially set
view - The FileSystemView to use

JDirectoryChooser

public JDirectoryChooser(String currentDirectory,
                         FileSystemView view)
Create a JDirectoryChooser

Parameters:
currentDirectory - The directory to which the tree is initially set
view - The FileSystemView to use

JDirectoryChooser

public JDirectoryChooser(FileSystemView view)
Create a JDirectoryChooser

Parameters:
view - The FileSystemView to use
Method Detail

addNotify

public void addNotify()

setCurrentDirectory

public void setCurrentDirectory(File dir)
Set the directory to which the tree is to open


setFileFilter

public void setFileFilter(FileFilter fileFilter)
Set a filter to control which files are displayed in the tree


getFileFilter

public FileFilter getFileFilter()
Get the current file filter

Returns:
The current FileFilter or null if none set

setFileHidingEnabled

public void setFileHidingEnabled(boolean hide)
Select whether to show "hidden" files in the tree

Parameters:
hide - True if hidden files should not be shown

isFileHidingEnabled

public boolean isFileHidingEnabled()
Test if file hiding is enabled

Returns:
true if file hiding is enabled
See Also:
setFileHidingEnabled(boolean)

setFileSelectionMode

public void setFileSelectionMode(int mode)
Set the file selection mode. Valid modes are

Parameters:
mode - either DIRECTORIES_ONLY or FILES_AND_DIRECTORIES (the default)
See Also:
JFileChooser.setFileSelectionMode(int)

getFileSelectionMode

public int getFileSelectionMode()
Test the file selection mode

Returns:
The current file selection mode
See Also:
setFileSelectionMode(int)

setMultiSelectionEnabled

public void setMultiSelectionEnabled(boolean enable)
Sets the filechooser to allow multiple file selections.


isMultiSelectionEnabled

public boolean isMultiSelectionEnabled()
Returns true if multi-file selection is enabled.


getSelectedFile

public File getSelectedFile()
Returns the currently selected file (or the first selected file if multiple files are selected)


getSelectedFiles

public File[] getSelectedFiles()
Returns a list of selected files if the filechooser is set to allow multi-selection.


setup

protected void setup(FileSystemView view)

updateUI

public void updateUI()

showDialog

public int showDialog(Component parent)
Popup up a modal dialog containing the JDirectoryChooser

Parameters:
parent - The parent of the dialog box
Returns:
either CANCEL_OPTION or JAPPROVE_OPTION
See Also:
JFileChooser.showDialog(java.awt.Component, java.lang.String)

setDialogTitle

public void setDialogTitle(String dialogTitle)
Sets the string that goes in the FileChooser window's title bar


getDialogTitle

public String getDialogTitle()
Gets the string that goes in the FileChooser's titlebar


setFileView

public void setFileView(FileView fileView)
Sets the file view to used to retrieve UI information, such as the icon that represents a file or the type description of a file.


getFileView

public FileView getFileView()
Returns the current file view.


main

public static void main(String[] argv)
                 throws Exception
Throws:
Exception

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.