beowulf.gui
Class JNode.PropertiesWindow

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended bybeowulf.gui.JNode.PropertiesWindow
All Implemented Interfaces:
Accessible, ActionListener, EventListener, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants
Enclosing class:
JNode

public class JNode.PropertiesWindow
extends JFrame
implements ActionListener

This class is a specialized JFrame and will display all relevant properties of a JNode when the "show properties" option in a JNode's popup menu is selected. The indicated properties can also be changed from within this window. Whether or not a property is 'relevant' is determined by the code in .setupFields(). If a subclass of JNode wishes to add more fields to this list, the subclass should also contain an inner class definition of a subclass of the PropertiesWindow (mirroring the JNode's architecture). The subclass should override the .setupFields() method in PropertiesWindow (see that method for details). All of the other work will be taken care of. Only integers, booleans, Strings, and doubles can currently be shown/edited in the PropertiesWindow class.

The overridden version of .setupFields() must

  • Call super.setupFields()
  • Use designated static fields (JNode.PropertiesWindow.INT_TYPE, etc.) to indicate the type of a field. This is so that the PropertiesWindow can correctly infer what type of input component to use.
  • Place all accessors in the JNode.PropertiesWindow.accessors array, all modifiers in the JNode.PropertiesWindow.modifiers array, all labels to appear in the input component in the JNode.PropertiesWindow.fieldNames array, and all types in the JNode.PropertiesWindow.fieldTypes array.
  • The ith accessor must correspond to the ith modifier, the ith field name, and the ith field type.
  • After calling super.setupFields(), the accessors, modifiers, fieldNames, and fieldTypes arrays will have values. These values must be preserved. The call must be made before the subclass puts any values into those arrays as well, since the super.setupFields() call will obliterate any values in those arrays.


    Version:
    1.0 - Feb 18, 2004
    Author:
    Andy Scukanec - (ags at cs dot cornell dot edu)
    See Also:
    Serialized Form

    Nested Class Summary
     
    Nested classes inherited from class javax.swing.JFrame
    JFrame.AccessibleJFrame
     
    Nested classes inherited from class java.awt.Frame
    Frame.AccessibleAWTFrame
     
    Nested classes inherited from class java.awt.Window
    Window.AccessibleAWTWindow
     
    Nested classes inherited from class java.awt.Container
    Container.AccessibleAWTContainer
     
    Nested classes inherited from class java.awt.Component
    Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
     
    Field Summary
    protected  Method[] accessors
              Holds a list of accessors for fields that should be visible in the properties window.
    static String BOOL_TYPE
              A string used to indicate that a field is of type 'boolean'.
    protected static String CANCEL_BUTTON_TEXT
              Indicates the Cancel button was pressed.
    static String DOUBLE_TYPE
              A string used to indicate that a field is of type 'double'.
    protected  JComponent[] fieldEntrys
              Holds a list of JComponents used for displaying current values of fields to be modified, and for receiving input to modify those same fields.
    protected  String[] fieldNames
              Holds a list of names of fields that will appear in the properties window.
    protected  String[] fieldTypes
              Holds a list of string indicating the type of each field.
    static String INT_TYPE
              A string used to indicate that a field is of type 'int'.
    protected  Method[] modifiers
              Holds a list of modifiers for fields that should be visible in the properties window.
    protected  boolean neverShownBefore
              Holds a flag indicating whether or not this window has been shown before.
    protected static String OK_BUTTON_TEXT
              Indicates the Ok button was pressed.
    static String STRING_TYPE
              A string used to indicate that a field is of type 'String'.
     
    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, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, 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
    JNode.PropertiesWindow()
              Basic constructor used to do the initial setup.
     
    Method Summary
     void actionPerformed(ActionEvent ae)
               
    protected  void cancelButtonPressed()
              If the cancel button is pressed, this method will be called and the window will simply hide itself, and save none of the values.
    protected  JComponent makeBottomPanel()
              Returns the JComponent holding the ok and cancel buttons.
    protected  JComponent makeCenterPanel()
              This method simply creates a panel of input/output components for all requested fields.
    protected  void okButtonPressed()
              If the ok button is pressed, this method will be called and the window will hide itself after attempting to set the values of all of the fields listed in the window.
    protected  void setupFields()
              This method is called from the constructor only and should be overridden by all subclasses of this class.
     void show()
               
     
    Methods inherited from class javax.swing.JFrame
    addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
     
    Methods inherited from class java.awt.Frame
    addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
     
    Methods inherited from class java.awt.Window
    addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, 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, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, 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
    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface java.awt.MenuContainer
    getFont, postEvent
     

    Field Detail

    OK_BUTTON_TEXT

    protected static final String OK_BUTTON_TEXT
    Indicates the Ok button was pressed.

    See Also:
    Constant Field Values

    CANCEL_BUTTON_TEXT

    protected static final String CANCEL_BUTTON_TEXT
    Indicates the Cancel button was pressed.

    See Also:
    Constant Field Values

    INT_TYPE

    public static final String INT_TYPE
    A string used to indicate that a field is of type 'int'.

    See Also:
    Constant Field Values

    STRING_TYPE

    public static final String STRING_TYPE
    A string used to indicate that a field is of type 'String'.

    See Also:
    Constant Field Values

    BOOL_TYPE

    public static final String BOOL_TYPE
    A string used to indicate that a field is of type 'boolean'.

    See Also:
    Constant Field Values

    DOUBLE_TYPE

    public static final String DOUBLE_TYPE
    A string used to indicate that a field is of type 'double'.

    See Also:
    Constant Field Values

    accessors

    protected Method[] accessors
    Holds a list of accessors for fields that should be visible in the properties window.


    modifiers

    protected Method[] modifiers
    Holds a list of modifiers for fields that should be visible in the properties window.


    fieldNames

    protected String[] fieldNames
    Holds a list of names of fields that will appear in the properties window.


    fieldTypes

    protected String[] fieldTypes
    Holds a list of string indicating the type of each field.


    fieldEntrys

    protected JComponent[] fieldEntrys
    Holds a list of JComponents used for displaying current values of fields to be modified, and for receiving input to modify those same fields.


    neverShownBefore

    protected boolean neverShownBefore
    Holds a flag indicating whether or not this window has been shown before.

    Constructor Detail

    JNode.PropertiesWindow

    public JNode.PropertiesWindow()
    Basic constructor used to do the initial setup.

    Method Detail

    setupFields

    protected void setupFields()
    This method is called from the constructor only and should be overridden by all subclasses of this class. Overriding this class will allow the subclass to indicate which extra fields the subclass contains should be shown. In overriding this method, super.setupFields() should always be called, and the values in accessors, modifiers, fieldNames, and fieldTypes should not be obliterated but saved and copied into the new arrays.


    makeCenterPanel

    protected JComponent makeCenterPanel()
    This method simply creates a panel of input/output components for all requested fields.

    Returns:
    The JComponent holding all of the I/O components.

    makeBottomPanel

    protected JComponent makeBottomPanel()
    Returns the JComponent holding the ok and cancel buttons.

    Returns:
    The JComponent holding the ok and cancel buttons.

    show

    public void show()

    actionPerformed

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

    cancelButtonPressed

    protected void cancelButtonPressed()
    If the cancel button is pressed, this method will be called and the window will simply hide itself, and save none of the values.


    okButtonPressed

    protected void okButtonPressed()
    If the ok button is pressed, this method will be called and the window will hide itself after attempting to set the values of all of the fields listed in the window. A failure for one field will not cascade to other fields, but will be isolated to that particular field. Failures could occur for a number of reasons - poorly formatted numbers, incorrectly set up reflection mechanisms by subclasses, etc.