Generic Environment GUI Class Library

Class EnvFileChooser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JFileChooser
                          |
                          +--EnvFileChooser
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class EnvFileChooser
extends javax.swing.JFileChooser

Environment-Based Applications:
An EnvFileChooser is a JFileChooser subclass that adds some specialized behavior for opening and saving environment data files. The additional features allow for filtering to just ".dat" files, an alert that confirms before overwriting an existing file, and an accessory panel on the open dialog for choosing which bounded/unbounded class to use for the new environment.

This class is a slightly modified version of the College Board's Marine Biology Simulation EnvFileChooser class (see www.collegeboard.com/ap/students/compsci/). Like the MBS version, this version will look in the MBSFactory for lists of the available bounded and unbounded representations. This version, however, does not require applications to use MBSFactory if the only environment representations available are BoundedEnv and UnboundedEnv.

Version:
1 December 2002
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFileChooser
javax.swing.JFileChooser.AccessibleJFileChooser
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  EnvChoiceComboBox boundedChooser
           
protected  java.lang.Class defaultBounded
           
protected  java.lang.Class defaultUnbounded
           
protected static java.lang.String ENV_EXT
           
protected  javax.swing.JPanel openAccessory
           
protected  EnvChoiceComboBox unboundedChooser
           
 
Fields inherited from class javax.swing.JFileChooser
ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY, accessibleContext, ACCESSORY_CHANGED_PROPERTY, APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY, APPROVE_BUTTON_TEXT_CHANGED_PROPERTY, APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY, APPROVE_OPTION, APPROVE_SELECTION, CANCEL_OPTION, CANCEL_SELECTION, CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY, CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY, CUSTOM_DIALOG, DIALOG_TITLE_CHANGED_PROPERTY, DIALOG_TYPE_CHANGED_PROPERTY, DIRECTORIES_ONLY, DIRECTORY_CHANGED_PROPERTY, ERROR_OPTION, FILE_FILTER_CHANGED_PROPERTY, FILE_HIDING_CHANGED_PROPERTY, FILE_SELECTION_MODE_CHANGED_PROPERTY, FILE_SYSTEM_VIEW_CHANGED_PROPERTY, FILE_VIEW_CHANGED_PROPERTY, FILES_AND_DIRECTORIES, FILES_ONLY, MULTI_SELECTION_ENABLED_CHANGED_PROPERTY, OPEN_DIALOG, SAVE_DIALOG, SELECTED_FILE_CHANGED_PROPERTY, SELECTED_FILES_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
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
EnvFileChooser()
          Creates a new EnvFileChooser.
 
Method Summary
 void approveSelection()
          Called when the user hits the approve button (Save/Open) to confirm the selected file is acceptable.
 java.lang.Class boundedClass()
          Returns the bounded environment class selected on the open accessory.
protected  void makeOpenAccessory()
          Builds the open accessory with combo boxes for choosing the bounded and unbounded environment classes.
 int showOpenDialog(java.awt.Component parent)
          Brings up a modal file chooser dialog allowing the user to choose the environment file.
 int showSaveDialog(java.awt.Component parent)
          Brings up a modal file chooser dialog allowing the user to save to an environment file.
 java.lang.Class unboundedClass()
          Returns the unbounded environment class selected on the open accessory.
 
Methods inherited from class javax.swing.JFileChooser
accept, addActionListener, addChoosableFileFilter, cancelSelection, changeToParentDirectory, ensureFileIsVisible, fireActionPerformed, getAcceptAllFileFilter, getAccessibleContext, getAccessory, getApproveButtonMnemonic, getApproveButtonText, getApproveButtonToolTipText, getChoosableFileFilters, getControlButtonsAreShown, getCurrentDirectory, getDescription, getDialogTitle, getDialogType, getFileFilter, getFileSelectionMode, getFileSystemView, getFileView, getIcon, getName, getSelectedFile, getSelectedFiles, getTypeDescription, getUI, getUIClassID, isAcceptAllFileFilterUsed, isDirectorySelectionEnabled, isFileHidingEnabled, isFileSelectionEnabled, isMultiSelectionEnabled, isTraversable, paramString, removeActionListener, removeChoosableFileFilter, rescanCurrentDirectory, resetChoosableFileFilters, setAcceptAllFileFilterUsed, setAccessory, setApproveButtonMnemonic, setApproveButtonMnemonic, setApproveButtonText, setApproveButtonToolTipText, setControlButtonsAreShown, setCurrentDirectory, setDialogTitle, setDialogType, setFileFilter, setFileHidingEnabled, setFileSelectionMode, setFileSystemView, setFileView, setMultiSelectionEnabled, setSelectedFile, setSelectedFiles, setup, showDialog, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENV_EXT

protected static final java.lang.String ENV_EXT

openAccessory

protected javax.swing.JPanel openAccessory

boundedChooser

protected EnvChoiceComboBox boundedChooser

unboundedChooser

protected EnvChoiceComboBox unboundedChooser

defaultBounded

protected java.lang.Class defaultBounded

defaultUnbounded

protected java.lang.Class defaultUnbounded
Constructor Detail

EnvFileChooser

public EnvFileChooser()
Creates a new EnvFileChooser. The default starting directory will be the "DataFiles" subdirectory on the current working directory.
Method Detail

makeOpenAccessory

protected void makeOpenAccessory()
Builds the open accessory with combo boxes for choosing the bounded and unbounded environment classes.

showOpenDialog

public int showOpenDialog(java.awt.Component parent)
Brings up a modal file chooser dialog allowing the user to choose the environment file.
Overrides:
showOpenDialog in class javax.swing.JFileChooser
Parameters:
parent - the parent of the dialog
Returns:
the return state of the dialog once finished

boundedClass

public java.lang.Class boundedClass()
Returns the bounded environment class selected on the open accessory.
Returns:
the selected bounded environment class

unboundedClass

public java.lang.Class unboundedClass()
Returns the unbounded environment class selected on the open accessory.
Returns:
the selected unbounded environment class

showSaveDialog

public int showSaveDialog(java.awt.Component parent)
Brings up a modal file chooser dialog allowing the user to save to an environment file.
Overrides:
showSaveDialog in class javax.swing.JFileChooser
Parameters:
parent - the parent of the dialog
Returns:
the return state of the dialog once finished

approveSelection

public void approveSelection()
Called when the user hits the approve button (Save/Open) to confirm the selected file is acceptable. Overrides the JFileChooser to confirm overwrite if choosing a file that already exists for a save action.
Overrides:
approveSelection in class javax.swing.JFileChooser

Generic Environment GUI Class Library

Copyright© 2003 Alyce Brady