krut.KRUT_GUI
Class SaveFileChooser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by krut.KRUT_GUI.SaveFileChooser
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class SaveFileChooser
extends javax.swing.JPanel
implements java.awt.event.ActionListener

This class is a JPanel used to handle the file names of the save files. The SaveFileChooser is displayed by the KrutSettings class, and communicates with the user through the KrutSettings window. The SaveFileChooser contains several methods for handling the changing of save file names, including filterFile, which should be called any time a save file name is changed.

See Also:
Serialized Form

Nested Class Summary
 class SaveFileChooser.SaveFileFilter
          A FileFilter for the FileChooser.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 java.io.File audioFile
          The file for the audio (wav).
 java.awt.GridBagConstraints gridBagConstraints
           
 java.io.File imageFile
          The file for the screenshot (jpg).
 KrutSettings myKrutSettings
          This is used to change the textfields for the save files in the KrutSettings object.
 OutputText myOutput
          An OutputText object that the current class can use to create output.
 java.io.File videoFile
          The file for the movie (mov).
 
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
SaveFileChooser()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          A file type button has been clicked by the user.
protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
          Returns an ImageIcon, or null if the path was invalid.
 java.io.File filterFile(java.io.File f)
          Checks if a file exist, and if files should not be overwritten.
 java.lang.String getExtension(java.io.File f)
          Retrieve the file extension of a file.
 java.lang.String getFileWithoutExtension(java.io.File f)
          Returns a file name minus the extension
 java.io.File getNextFile(java.io.File f)
          This can be used directly to change a file for another file with the same name, but a higher index number.
 void init(java.io.File startImage, java.io.File startAudio, java.io.File startVideo)
          This method is called to initiate the SaveFileChooser.
 java.io.File selectFile(java.io.File currentFile)
          Displays a file chooser, asking the user to select a file.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

imageFile

public java.io.File imageFile
The file for the screenshot (jpg).


audioFile

public java.io.File audioFile
The file for the audio (wav).


videoFile

public java.io.File videoFile
The file for the movie (mov).


myOutput

public OutputText myOutput
An OutputText object that the current class can use to create output.


gridBagConstraints

public java.awt.GridBagConstraints gridBagConstraints

myKrutSettings

public KrutSettings myKrutSettings
This is used to change the textfields for the save files in the KrutSettings object. In the original program there were no such textfields. They were added in the KrutSettings window to avoid large changes to the SaveFileChooser window.

Constructor Detail

SaveFileChooser

public SaveFileChooser()
Method Detail

init

public void init(java.io.File startImage,
                 java.io.File startAudio,
                 java.io.File startVideo)
This method is called to initiate the SaveFileChooser.

Parameters:
startImage - The initial save file for the screenshot.
startAudio - The initial save file for the audio.
startVideo - The initial save file for the movie.

getExtension

public java.lang.String getExtension(java.io.File f)
Retrieve the file extension of a file.

Parameters:
f - A file with an extension.
Returns:
A String containing the extension of the file.

getFileWithoutExtension

public java.lang.String getFileWithoutExtension(java.io.File f)
Returns a file name minus the extension

Parameters:
f - The file
Returns:
A String containing the file nane minus the file extension

getNextFile

public java.io.File getNextFile(java.io.File f)
This can be used directly to change a file for another file with the same name, but a higher index number. This method is a direct alternative to the filterFile() method. This method is used by the filterFile() method, as well as the restoreGUI() method in Run_KRUT.

Parameters:
f - The file to check.
Returns:
A new file with the next index number, irregardless of whether such a file already exists or not.

filterFile

public java.io.File filterFile(java.io.File f)
Checks if a file exist, and if files should not be overwritten. If true, another file is returned with the same file name, but a higher number.

Parameters:
f - The file to check.
Returns:
A new file that does not exist.

selectFile

public java.io.File selectFile(java.io.File currentFile)
Displays a file chooser, asking the user to select a file. Returns a file with a proper extension. jpg-files are automatically approved. Other file types are compared to the file extension in the global parameter myExtension, and are accepted if they are a match. If a file is not accepted, the extension in the global parameter myExtension is added to the file name, after which the file is returned.

Parameters:
currentFile - The save file.
Returns:
The save file with a proper extension. null if the user did not choose a file (cancelled).

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
A file type button has been clicked by the user. This method determines which button, and then calls the selectFile method to open a FileChooser for the appropriate file type.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The ActionEvent.

createImageIcon

protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path was invalid.