com.bluemarsh.jswat.ui
Class MainWindow

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--com.bluemarsh.jswat.ui.MainWindow
All Implemented Interfaces:
javax.accessibility.Accessible, com.bluemarsh.config.ConfigureListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class MainWindow
extends javax.swing.JFrame
implements com.bluemarsh.config.ConfigureListener

This class implements the main window of the application.

Author:
Nathan Fiedler
See Also:
Serialized Form

Inner Class Summary
protected  class MainWindow.ActionChangedListener
          Watches for changes in the actions and deals with them by changing the corresponding menu items or toolbar buttons.
protected  class MainWindow.MainLayout
          Specialized layout for tracking the toolbar's placement.
 
Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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  javax.swing.JMenuBar menubar
          The menu bar.
protected  javax.swing.JToolBar toolbar
          The tool bar.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainWindow(java.lang.String title)
          Creates a new MainWindow objct and puts up the main window.
 
Method Summary
 void close()
          We have been asked to close down this window.
 void configurationChanged()
          Invoked whenever the preferences have changed.
protected  javax.swing.JMenu createMenu(java.lang.String key)
          Create a menu for the app.
protected  javax.swing.JMenuBar createMenubar()
          Create the menubar for the app.
protected  javax.swing.JMenuItem createMenuItem(java.lang.String cmd, com.bluemarsh.config.JConfigure config)
          This is the hook through which all menu items are created.
protected  javax.swing.JToolBar createToolbar()
          Create the toolbar.
protected  javax.swing.JButton createToolbarButton(java.lang.String key)
          Create a button to go inside of the toolbar.
protected  boolean hasComponent(java.awt.Component child)
          Tests if this container contains the given component.
protected  void resetShortcuts()
          Uses the configured shortcut settings to set all of the menu item accelerators.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

menubar

protected javax.swing.JMenuBar menubar
The menu bar.

toolbar

protected javax.swing.JToolBar toolbar
The tool bar.
Constructor Detail

MainWindow

public MainWindow(java.lang.String title)
Creates a new MainWindow objct and puts up the main window. Also creates a window listener to close the program when the close button is activated (using the ExitAction class).
Parameters:
title - title for the main window
Method Detail

close

public void close()
We have been asked to close down this window. Need to do a little clean up and then we will disappear and dispose of ourselves.

configurationChanged

public void configurationChanged()
Invoked whenever the preferences have changed. We take this opportunity to reset the shortcuts.
Specified by:
configurationChanged in interface com.bluemarsh.config.ConfigureListener

createMenu

protected javax.swing.JMenu createMenu(java.lang.String key)
Create a menu for the app. By default this pulls the definition of the menu from the associated resource file.
Parameters:
key - menu key in resource bundle
Returns:
menu built out

createMenubar

protected javax.swing.JMenuBar createMenubar()
Create the menubar for the app. By default this pulls the definition of the menu from the associated resource file.
Returns:
menu bar with menus built out

createMenuItem

protected javax.swing.JMenuItem createMenuItem(java.lang.String cmd,
                                               com.bluemarsh.config.JConfigure config)
This is the hook through which all menu items are created. Using the cmd string it finds the menu item label and image (if any) in the resource bundle.
Parameters:
cmd - action command string for this menu item; used to get the label and image.
config - reference to JConfigure for keyboard shortcuts.
Returns:
new menu item
See Also:
createMenu(java.lang.String)

createToolbar

protected javax.swing.JToolBar createToolbar()
Create the toolbar. By default this reads the resource file for the definition of the toolbar.
Returns:
new toolbar built out

createToolbarButton

protected javax.swing.JButton createToolbarButton(java.lang.String key)
Create a button to go inside of the toolbar. By default this will load an image resource. The image filename is relative to the classpath (including the '.' directory if its a part of the classpath), and may either be in a JAR file or a separate file.
Parameters:
key - key in resource bundle for tool
Returns:
new toolbar button

hasComponent

protected boolean hasComponent(java.awt.Component child)
Tests if this container contains the given component.
Parameters:
child - component to search for.
Returns:
true if the child is a member of this container.

resetShortcuts

protected void resetShortcuts()
Uses the configured shortcut settings to set all of the menu item accelerators. Called when the user has changed the keyboard shortcuts at runtime.