mdh.hephaestus2.gamelib
Class FileBrowser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--mdh.hephaestus2.gamelib.FileBrowser
All Implemented Interfaces:
Accessible, ActionListener, EventListener, FocusListener, ImageObserver, ItemListener, KeyListener, MenuContainer, Serializable

public class FileBrowser
extends Dialog
implements ActionListener, KeyListener, ItemListener, FocusListener

A cross-platform file dialog.

Author:
Copyright © 2001 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
static int LOAD
           
static int SAVE
           
 
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
FileBrowser(Frame frame, String title, int type, File startdir)
          Creates a new FileBrowser.
 
Method Summary
 boolean acceptExtension(String name)
           
 void actionPerformed(ActionEvent ae)
           
 void addNotify()
           
 void focusGained(FocusEvent fe)
           
 void focusLost(FocusEvent fe)
           
 File getFile()
           
 boolean getFilesFirst()
           
 void itemStateChanged(ItemEvent ie)
           
 void keyPressed(KeyEvent ke)
           
 void keyReleased(KeyEvent ke)
           
 void keyTyped(KeyEvent ke)
           
static void main(String[] args)
           
 Choice makeChoice()
          Creates a drop-down choice with sane colors.
 TextField makeTextField(String text, int minlen)
          Creates a text field with sane colors.
 Panel makeWhitePanel(Component comp)
          Creates a black-on-white panel with a single component maximized in it.
 void setExtensions(String[] exts)
           
 void setFilesFirst(boolean f)
           
 void setPosition()
          Called automatically by setVisible().
 void setShowHidden(boolean s)
           
 void show()
          Centers the dialog over the parent frame
 
Methods inherited from class java.awt.Dialog
dispose, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, 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, getBackground, 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, getMouseWheelListeners, getName, 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, isOpaque, 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, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOAD

public static final int LOAD
See Also:
Constant Field Values

SAVE

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

FileBrowser

public FileBrowser(Frame frame,
                   String title,
                   int type,
                   File startdir)
Creates a new FileBrowser.

Parameters:
frame - Parent frame.
title - Title of the dialog.
type - LOAD or SAVE.
startdir - Initial directory; user.dir is used if startdir is null.
Method Detail

main

public static void main(String[] args)
                 throws IOException
IOException

makeChoice

public Choice makeChoice()
Creates a drop-down choice with sane colors.


makeTextField

public TextField makeTextField(String text,
                               int minlen)
Creates a text field with sane colors. The width of the field is 'minlen' or the length of the text, whichever is longer. Null text is treated as "".


makeWhitePanel

public Panel makeWhitePanel(Component comp)
Creates a black-on-white panel with a single component maximized in it.


acceptExtension

public boolean acceptExtension(String name)

actionPerformed

public void actionPerformed(ActionEvent ae)
Specified by:
actionPerformed in interface ActionListener

addNotify

public void addNotify()
Overrides:
addNotify in class Dialog

getFile

public File getFile()

getFilesFirst

public boolean getFilesFirst()

itemStateChanged

public void itemStateChanged(ItemEvent ie)
Specified by:
itemStateChanged in interface ItemListener

keyPressed

public void keyPressed(KeyEvent ke)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent ke)
Specified by:
keyTyped in interface KeyListener

setExtensions

public void setExtensions(String[] exts)

setFilesFirst

public void setFilesFirst(boolean f)

setPosition

public void setPosition()
Called automatically by setVisible().


setShowHidden

public void setShowHidden(boolean s)

show

public void show()
Centers the dialog over the parent frame

Overrides:
show in class Dialog

focusGained

public void focusGained(FocusEvent fe)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent fe)
Specified by:
focusLost in interface FocusListener