com.jeta.open.gui.framework
Class JETAPanel

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 com.jeta.open.gui.framework.JETAPanel
All Implemented Interfaces:
JETAContainer, ComponentFinder, SwingComponentSupport, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
FormPanel

public class JETAPanel
extends JPanel
implements JETAContainer, SwingComponentSupport

A panel that supports locating components by name as well as supporting the JETA controller/validation framework. Before adding components to this panel, you should call Component.setName(java.lang.String). Components with unique names can be accessed using the component getter methods in this class. JETAPanel works with JETAController. Both classes follow the Model-View-Controller architecture where JETAPanel is the view and JETAController is the controller. Event handlers and listeners should be declared in a JETAController derived class while view and layout code should be confined to JETAPanel instances.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
JETAPanel()
          ctor
JETAPanel(ComponentFinder finder)
          ctor
JETAPanel(LayoutManager layout)
          ctor
 
Method Summary
protected  ComponentFinder createComponentFinder()
          Creates a component finder that is used to locate child components in this panel by name.
 void enableComponent(String commandId, boolean bEnable)
          Enables/Disables the component associated with the given name.
 Collection getAllNamedComponents()
          Recursively searches an associated parent container for all components that are named.
 boolean getBoolean(String compName)
          Returns the selected state of the AbstractButton that has the given name.
 AbstractButton getButton(String compName)
          Returns the button that is contained in this panel and has the given name.
 JCheckBox getCheckBox(String compName)
          Returns the JCheckBox that is contained in this panel and has the given name.
 JComboBox getComboBox(String compName)
          Returns the JComboBox that is contained in this panel and has the given name.
 Component getComponentByName(String componentName)
          Locates the first component found in this container hierarchy that has the given name.
protected  ComponentFinder getComponentFinder()
          Returns the component finder associated with this panel
 Collection getComponentsByName(String compName)
          Locates all components found in this container hierarchy that has the given name.
 JETAController getController()
          Return the controller object that handles events for this panel.
 int getInteger(String compName, int defaultValue)
          Locates the JTextField that has the given component name.
 JLabel getLabel(String compName)
          Returns the JLabel that is contained in this panel and has the given name.
 JList getList(String compName)
          Returns the JList that is contained in this panel and has the given name.
 JPanel getPanel(String compName)
          Returns the JPanel that is contained in this panel and has the given name.
 JProgressBar getProgressBar(String compName)
          Returns JProgressBar that is contained in this panel and has the given name.
 JRadioButton getRadioButton(String compName)
          Returns the JRadioButton that is contained in this panel and has the given name.
 Object getSelectedItem(String compName)
          Returns the selected item from the JList or JComboBox that has the given name.
 JSpinner getSpinner(String compName)
          Returns JSpinner that is contained in this panel and has the given name.
 JTabbedPane getTabbedPane(String compName)
          Returns the JTabbedPane that is contained in this panel and has the given name.
 JTable getTable(String compName)
          Returns the JTable that is contained in this panel and has the given name.
 String getText(String compName)
          Returns the text property from a Component.
 JTextComponent getTextComponent(String compName)
          Returns the JTextComponent that is contained in this panel and has the given name.
 JTextField getTextField(String compName)
          Returns the JTextField that is contained in this panel and has the given name.
 JTree getTree(String compName)
          Returns the JTree that is contained in this panel and has the given name.
 UIDirector getUIDirector()
          Returns the UIDirector for this container.
 boolean isSelected(String compName)
          Return the selected state of the AbstractButton that has the given name.
 void removeDescendent(String compName)
          Locates the component with the given name and removes it from its parent.
static void removeFromParent(Component comp)
          Helper method that removes a component from its parent container.
 void reset()
          Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.
protected  void setComponentFinder(ComponentFinder finder)
          Sets the component finder associated with this panel
 void setController(JETAController controller)
          Sets the main controller that will handle events for this panel.
 void setSelected(String compName, boolean sel)
          Sets the selected attribute for the AbstractButton with the given name.
 void setSelectedItem(String compName, Object value)
          Sets the selected item in a JComboBox that has the given name.
 void setText(String compName, String txt)
          Sets text property for the Component with the given name.
 void setUIDirector(UIDirector director)
          Sets the UIDirector for this panel.
 void setVisible(String compName, boolean bVisible)
          Shows/Hides the component with the given name.
 void updateComponents()
          This is a helper method that simply forwards the call to the controller for this view (which forwards the call to the UIDirector if one exists)
 void updateComponents(EventObject evt)
          This is a helper method that simply forwards the call to the controller for this view (which forwards the call to the UIDirector if one exists)
 
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, getBaseline, getBaselineResizeBehavior, 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, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 

Constructor Detail

JETAPanel

public JETAPanel()
ctor


JETAPanel

public JETAPanel(LayoutManager layout)
ctor


JETAPanel

public JETAPanel(ComponentFinder finder)
ctor

Method Detail

createComponentFinder

protected ComponentFinder createComponentFinder()
Creates a component finder that is used to locate child components in this panel by name.


enableComponent

public void enableComponent(String commandId,
                            boolean bEnable)
Enables/Disables the component associated with the given name.

Specified by:
enableComponent in interface JETAContainer
Specified by:
enableComponent in interface SwingComponentSupport
Parameters:
commandId - the name of the component to enable/disable
bEnable - true/false to enable/disable

getBoolean

public boolean getBoolean(String compName)
Returns the selected state of the AbstractButton that has the given name. If a component is found with the given name and that component is not an AbstractButton, then false is returned.

Specified by:
getBoolean in interface SwingComponentSupport
Returns:
the selected state of the named AbstractButton.

getButton

public AbstractButton getButton(String compName)
Returns the button that is contained in this panel and has the given name. If the component is not found nor is an AbstractButton, null is returned.

Specified by:
getButton in interface SwingComponentSupport
Returns:
the named AbstractButton

getCheckBox

public JCheckBox getCheckBox(String compName)
Returns the JCheckBox that is contained in this panel and has the given name. If the component is not found nor is a JCheckBox, null is returned.

Specified by:
getCheckBox in interface SwingComponentSupport
Returns:
the named JCheckBox

getComboBox

public JComboBox getComboBox(String compName)
Returns the JComboBox that is contained in this panel and has the given name. If the component is not found nor is a JComboBox, null is returned.

Specified by:
getComboBox in interface SwingComponentSupport
Returns:
the named JComboBox

getComponentByName

public Component getComponentByName(String componentName)
Locates the first component found in this container hierarchy that has the given name. This will recursively search into child containers as well. If no component is found with the given name, null is returned.

Specified by:
getComponentByName in interface JETAContainer
Specified by:
getComponentByName in interface ComponentFinder
Parameters:
componentName - the name of the component to search for
Returns:
the named component

getComponentFinder

protected ComponentFinder getComponentFinder()
Returns the component finder associated with this panel

Returns:
the component finder associated with this panel

getComponentsByName

public Collection getComponentsByName(String compName)
Locates all components found in this container hierarchy that has the given name. This will recursively search into child containers as well. This method is useful for frame windows that can have multiple components with the same name. For example, a menu item and toolbar button for the same command would have the same name.

Specified by:
getComponentsByName in interface JETAContainer
Specified by:
getComponentsByName in interface ComponentFinder
Parameters:
compName - the name of the components to search for
Returns:
a collection of Component objects that have the given name.
See Also:
objects that have the given name.

getAllNamedComponents

public Collection getAllNamedComponents()
Recursively searches an associated parent container for all components that are named. An empty collection is returned if no names components exist.

Specified by:
getAllNamedComponents in interface ComponentFinder
Returns:
a collection of all named Component objects.

getController

public JETAController getController()
Return the controller object that handles events for this panel. This framework assumes that all event listeners will be declared in a JETAController; however, this is not strictly required.

Returns:
the controller that will handle events for this panel

getInteger

public int getInteger(String compName,
                      int defaultValue)
Locates the JTextField that has the given component name. The text in the field is converted to an integer and returned. If the text cannot be converted to an integer or the component is not a JTextField, the defaultValue is returned.

Specified by:
getInteger in interface SwingComponentSupport
Parameters:
compName - the JTextField to find.
defaultValue - the value to return if the component is not a JTextField or the text in the field is not an integer.
Returns:
the text converted to an integer.

getLabel

public JLabel getLabel(String compName)
Returns the JLabel that is contained in this panel and has the given name. If the component is not found nor is a JLabel, null is returned.

Specified by:
getLabel in interface SwingComponentSupport
Returns:
the named JLabel.

getList

public JList getList(String compName)
Returns the JList that is contained in this panel and has the given name. If the component is not found nor is a JList, null is returned.

Specified by:
getList in interface SwingComponentSupport
Returns:
the named JList

getPanel

public JPanel getPanel(String compName)
Returns the JPanel that is contained in this panel and has the given name. If the component is not found nor is a JPanel, null is returned.

Specified by:
getPanel in interface SwingComponentSupport
Returns:
the named JPanel

getProgressBar

public JProgressBar getProgressBar(String compName)
Returns JProgressBar that is contained in this panel and has the given name. If the component is not found nor is a JProgressBar, null is returned.

Specified by:
getProgressBar in interface SwingComponentSupport
Returns:
the named JProgressBar.

getRadioButton

public JRadioButton getRadioButton(String compName)
Returns the JRadioButton that is contained in this panel and has the given name. If the component is not found nor is a JRadioButton, null is returned.

Specified by:
getRadioButton in interface SwingComponentSupport
Returns:
the named JRadioButton

getSelectedItem

public Object getSelectedItem(String compName)
Returns the selected item from the JList or JComboBox that has the given name. If a list or combo is not found with the name, null is returned.

Specified by:
getSelectedItem in interface SwingComponentSupport
Returns:
the selected item from the named JList or JComboBox.

getSpinner

public JSpinner getSpinner(String compName)
Returns JSpinner that is contained in this panel and has the given name. If the component is not found nor is a JSpinner, null is returned.

Specified by:
getSpinner in interface SwingComponentSupport
Returns:
the named JSpinner

getTable

public JTable getTable(String compName)
Returns the JTable that is contained in this panel and has the given name. If the component is not found nor is a JTable, null is returned.

Specified by:
getTable in interface SwingComponentSupport
Returns:
the named JTable

getTabbedPane

public JTabbedPane getTabbedPane(String compName)
Returns the JTabbedPane that is contained in this panel and has the given name. If the component is not found nor is a JTabbedPane, null is returned.

Specified by:
getTabbedPane in interface SwingComponentSupport
Returns:
the named JTabbedPane

getTextComponent

public JTextComponent getTextComponent(String compName)
Returns the JTextComponent that is contained in this panel and has the given name. If the component is not found nor is a JTextComponent, null is returned.

Specified by:
getTextComponent in interface SwingComponentSupport
Returns:
the named JTextComponent

getTextField

public JTextField getTextField(String compName)
Returns the JTextField that is contained in this panel and has the given name. If the component is not found nor is a JTextField, null is returned.

Specified by:
getTextField in interface SwingComponentSupport
Returns:
the named JTextField

getText

public String getText(String compName)
Returns the text property from a Component. If a component is not found with the given name or a component does not have a text property, then null is returned.

Specified by:
getText in interface SwingComponentSupport
Returns:
the text property.

getTree

public JTree getTree(String compName)
Returns the JTree that is contained in this panel and has the given name. If the component is not found nor is a JTree, null is returned.

Specified by:
getTree in interface SwingComponentSupport
Returns:
the named JTree

getUIDirector

public UIDirector getUIDirector()
Returns the UIDirector for this container. UIDirectors are part of this framework and are responsible for enabling/disabling components based on the program state. For example, menu items and toolbar buttons must be enabled or disabled depending on the current state of the frame window. UIDirectors handle this logic.

Specified by:
getUIDirector in interface JETAContainer
Returns:
the UIDirector

isSelected

public boolean isSelected(String compName)
Return the selected state of the AbstractButton that has the given name. If a component is found with the given name and that component is not an AbstractButton, then false is returned.

Specified by:
isSelected in interface SwingComponentSupport
See Also:
getBoolean(java.lang.String)

removeDescendent

public void removeDescendent(String compName)
Locates the component with the given name and removes it from its parent.

Parameters:
compName - the name of the component to locate.

removeFromParent

public static void removeFromParent(Component comp)
Helper method that removes a component from its parent container.

Parameters:
comp - the component to remove

reset

public void reset()
Description copied from interface: ComponentFinder
Tells the implementation that any cached components should be flushed and reloaded because the parent container might have changed.

Specified by:
reset in interface ComponentFinder

setComponentFinder

protected void setComponentFinder(ComponentFinder finder)
Sets the component finder associated with this panel


setUIDirector

public void setUIDirector(UIDirector director)
Sets the UIDirector for this panel.


setController

public void setController(JETAController controller)
Sets the main controller that will handle events for this panel.


setVisible

public void setVisible(String compName,
                       boolean bVisible)
Shows/Hides the component with the given name.

Specified by:
setVisible in interface SwingComponentSupport
Parameters:
compName - the name of the component to enable/disable
bVisible - show/hide the component/disable

setSelected

public void setSelected(String compName,
                        boolean sel)
Sets the selected attribute for the AbstractButton with the given name. If a component is found with the given name and that component is not an AbstractButton, this call is ignored.

Specified by:
setSelected in interface SwingComponentSupport
Parameters:
compName - the name of the AbstractButton whose selected attribute to set.
sel - the selected attribute to set

setSelectedItem

public void setSelectedItem(String compName,
                            Object value)
Sets the selected item in a JComboBox that has the given name. If a combo is not found with the name, no action is performed.

Specified by:
setSelectedItem in interface SwingComponentSupport

setText

public void setText(String compName,
                    String txt)
Sets text property for the Component with the given name. If no component is found or the Component does not have a text property, then this method is a no op.

Specified by:
setText in interface SwingComponentSupport
Parameters:
compName - the name of the JTextComponent whose text to set
txt - the text to set

updateComponents

public void updateComponents()
This is a helper method that simply forwards the call to the controller for this view (which forwards the call to the UIDirector if one exists)


updateComponents

public void updateComponents(EventObject evt)
This is a helper method that simply forwards the call to the controller for this view (which forwards the call to the UIDirector if one exists)



Copyright © 2005-2007 Jeff Tassin & Todd Viegut. All Rights Reserved.