IcanGui
Class GuiFileDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by IcanGui.GuiFileDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class GuiFileDialog
extends java.awt.Dialog
implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.ItemListener

Display a file dialog and return a filename for loading or saving data.

Since:
1.0;
Version:
1.1.6;
Updated by Louis Handler on Dec 29, 2005, 11:39 EST (1.1.6).
Updated by Louis Handler on Jul 18, 2005, 08:05 EDT (1.1.5).
Updated by Louis Handler on May 6, 2005, 09:54 EDT (1.1.2).
Updated by Louis Handler on May 3, 2005, 10:23 EDT (1.1.1).
Updated by Louis Handler on Jan 3, 2005, 09:01 EST (1.1.0).
Updated by Louis Handler on Sep 10, 2003, 10:37 EDT.
Updated by Louis Handler on Sep 8, 2003, 08:30 EDT.
Updated by Louis Handler on Sep 8, 2003, 08:13 EDT.
Updated by Louis Handler on Jul 27, 2000, 11:53 EDT.
Updated by Louis Handler on Mar 28, 2000, 13:10 EST.
Updated by Louis Handler on Mar 13, 2000, 13:55 EST.
Updated by Louis Handler on Feb 22, 2000, 14:54 EST.
Updated by Louis Handler on Dec 3, 1999, 09:52 EST.
Updated by Louis Handler on Feb 8, 1999, 08:30 EST.
Updated by Matthew Der on Jul 29, 1998.
Updated by Louis Handler on Jul 27, 1998, 09:13 EDT.
Updated by Louis Handler on Jul 21, 1998, 07:50 EDT.
Updated by Matthew Der on Jul 6, 1998.
Updated by Matthew Der on Jun 23, 1998.
Updated by Louis Handler on Jun 18, 1998.
Author:
Louis Handler
See Also:
Dialog, FileDialog, Serialized Form

Nested Class Summary
(package private)  class GuiFileDialog.Madapter
          Mouse Adapter Inner Class
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String ACCEPTABLE
          Acceptable characters in a file name.
private  java.awt.Button bCancel
          Cancel button closes this window without doing anything.
private  java.awt.Button bDoit
          Button to load the selected file or Button to save the data into the selected file.
private  java.awt.Button bHelp
          Help button generates a message to help decide what to do.
private static java.lang.String DIRECTORY_FILE
          File containing directory on WWW server.
private  java.awt.TextField entry
          TextField to hold file name from which to load data or to which to save data.
private  java.util.Vector fileListVector
          List of file names from which to choose.
private  java.lang.String fileName
          Chosen file name.
private  java.lang.String filter
          String to use as file name filter.
private  boolean firstRun
          Variable to test for the first time the frame is displayed.
private  java.awt.List flist
          List of file names from which to choose.
private  java.awt.Label fnsv
          Label of component describing the file to be saved.
private static java.lang.String HTTP
          Start of a URL (HTTP).
private  int loadOrSave
          FileDialog purpose: LOAD or SAVE.
private  java.lang.String nDirectory
          Web Server data Directory URL beginning with "http:".
private  boolean newFocus
          First time switch used to set the focus on the first time.
private static int NHTTP
          Number of characters to compare for start of URL (HTTP).
private  int oldIndex
          Old Index
private  java.lang.String title
          Title at top of window frame.
private  GuiFileDialog windowFileName
          Instance of this class.
private  IcanFrame windowFrameParent
          IcanFrame of parent.
 
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
GuiFileDialog(IcanFrame parent, java.lang.String title, java.lang.String nDirectory, java.lang.String filter, java.lang.String initFileName, int loadOrSave)
          Constructor creates a File Dialog window.
 
Method Summary
 boolean acceptF(java.lang.String fnm)
          Test for file name of the given format where there should be one asterisk (*) in the filter to be tested against.
 void actionPerformed(java.awt.event.ActionEvent evt)
          Determine the type of event and dispatch to the current class' method to handle that type of event.
 java.lang.String[] getAclRead()
          Get list of directories from ~/.hotjava.properties file corresponding to property "acl.read".
 java.lang.String[] getAclWrite()
          Get list of directories from ~/.hotjava.properties file corresponding to property "acl.write".
 java.lang.String getFile()
          Return chosen file name.
 java.lang.String getName()
          Get class name.
 void helpMe()
          Display help message.
 void helpMe(java.awt.Component target)
          Display help message.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          Detect when an item state has changed.
 void keyPressed(java.awt.event.KeyEvent evt)
          Perform Key Press
 void keyReleased(java.awt.event.KeyEvent evt)
          Detect when a key has been released.
 void keyTyped(java.awt.event.KeyEvent evt)
          Perform Key Typed
 void readFileNames(java.io.BufferedReader dbin)
          Read list of file names.
 void readFileNamesLocal()
          Get list of file names, which match the given filter, in allowed directories, on local machine, if possible.
 java.util.Properties readHotjavaProperties()
          Get list of properties from ~/.hotjava.properties file.
 void remove()
          Dispose of any components required before disposing of parent.
 void setFile(java.lang.String lastFileName)
          Set initital value of file name from last file name opened and read or written, then modified by the current file name filter's extension.
 void setFocusToEntry()
          Set focus to TextField, if defined.
 int writeFileName(java.lang.String fileName, java.lang.String fileTitle)
          Open the file containing the file list and append the specified file name.
 
Methods inherited from class java.awt.Dialog
addNotify, getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, 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, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

windowFrameParent

private IcanFrame windowFrameParent
IcanFrame of parent.


windowFileName

private GuiFileDialog windowFileName
Instance of this class.


title

private java.lang.String title
Title at top of window frame.


nDirectory

private java.lang.String nDirectory
Web Server data Directory URL beginning with "http:".


fileName

private java.lang.String fileName
Chosen file name.


filter

private java.lang.String filter
String to use as file name filter. There should be one asterisk (*) within the string. Either the prefix or extension may be missing. Having an extension present is recommended.


loadOrSave

private int loadOrSave
FileDialog purpose: LOAD or SAVE. Must be set to either FileDialog.LOAD or FileDialog.SAVE.


fileListVector

private java.util.Vector fileListVector
List of file names from which to choose.


flist

private java.awt.List flist
List of file names from which to choose.


fnsv

private java.awt.Label fnsv
Label of component describing the file to be saved.


newFocus

private boolean newFocus
First time switch used to set the focus on the first time.


entry

private java.awt.TextField entry
TextField to hold file name from which to load data or to which to save data.


bDoit

private java.awt.Button bDoit
Button to load the selected file or Button to save the data into the selected file.


bCancel

private java.awt.Button bCancel
Cancel button closes this window without doing anything.


bHelp

private java.awt.Button bHelp
Help button generates a message to help decide what to do.


DIRECTORY_FILE

private static final java.lang.String DIRECTORY_FILE
File containing directory on WWW server.

See Also:
Constant Field Values

oldIndex

private int oldIndex
Old Index


firstRun

private boolean firstRun
Variable to test for the first time the frame is displayed. Used to set focus on entry.


ACCEPTABLE

private static final java.lang.String ACCEPTABLE
Acceptable characters in a file name.

See Also:
Constant Field Values

HTTP

private static final java.lang.String HTTP
Start of a URL (HTTP).

See Also:
Constant Field Values

NHTTP

private static final int NHTTP
Number of characters to compare for start of URL (HTTP).

Constructor Detail

GuiFileDialog

public GuiFileDialog(IcanFrame parent,
                     java.lang.String title,
                     java.lang.String nDirectory,
                     java.lang.String filter,
                     java.lang.String initFileName,
                     int loadOrSave)
Constructor creates a File Dialog window.

Parameters:
parent - Parent frame object.
title - Title at top of window frame.
nDirectory - Directory URL beginning with "http:".
filter - String to use as file name filter. There should be one asterisk (*) within the string. Either the prefix or extension may be missing. Having an extension present is recommended.
initFileName - Initital value of file name from last file name opened and read or written. Will be modified by the file name filter's extension.
loadOrSave - FileDialog purpose: LOAD or SAVE.
Method Detail

remove

public void remove()
Dispose of any components required before disposing of parent.


getFile

public java.lang.String getFile()
Return chosen file name.

Returns:
File name result.

setFile

public void setFile(java.lang.String lastFileName)
Set initital value of file name from last file name opened and read or written, then modified by the current file name filter's extension.

Parameters:
lastFileName - Last value of file name opened and read or written.

readFileNames

public void readFileNames(java.io.BufferedReader dbin)
                   throws java.io.IOException
Read list of file names. The format of the directory file is:

Parameters:
dbin - Buffered Reader.
Throws:
java.io.IOException - I/O error or any data formatting error.

readFileNamesLocal

public void readFileNamesLocal()
Get list of file names, which match the given filter, in allowed directories, on local machine, if possible.


readHotjavaProperties

public java.util.Properties readHotjavaProperties()
Get list of properties from ~/.hotjava.properties file.

Returns:
List of properties.

getAclRead

public java.lang.String[] getAclRead()
Get list of directories from ~/.hotjava.properties file corresponding to property "acl.read".

Returns:
List of directories.

getAclWrite

public java.lang.String[] getAclWrite()
Get list of directories from ~/.hotjava.properties file corresponding to property "acl.write".

Returns:
List of directories.

acceptF

public boolean acceptF(java.lang.String fnm)
Test for file name of the given format where there should be one asterisk (*) in the filter to be tested against.

Parameters:
fnm - File name string.
Returns:
True, if file matches filter; else, false.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Determine the type of event and dispatch to the current class' method to handle that type of event.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - Action event.

setFocusToEntry

public void setFocusToEntry()
Set focus to TextField, if defined.


itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
Detect when an item state has changed.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
evt - Item event.

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Detect when a key has been released. Detect Enter, F1, Tab, Shift+Tab, Up and Down Arrows, Alt+Right, Alt+Left.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
evt - Key event.

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Perform Key Press

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
evt - KeyEvent

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Perform Key Typed

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
evt - KeyEvent

helpMe

public void helpMe()
Display help message.


helpMe

public void helpMe(java.awt.Component target)
Display help message.

Parameters:
target - Component for which error/help message is displayed.

writeFileName

public int writeFileName(java.lang.String fileName,
                         java.lang.String fileTitle)
Open the file containing the file list and append the specified file name.

Parameters:
fileName - Name of file to add to file list.
Returns:
Number of items written; error if negative.
See Also:
readFileNames(BufferedReader)

getName

public java.lang.String getName()
Get class name.

Overrides:
getName in class java.awt.Component
Returns:
Class name.