com.jeta.forms.components.panel
Class FormPanel

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
                      extended by com.jeta.forms.components.panel.FormPanel
All Implemented Interfaces:
JETAContainer, ComponentFinder, SwingComponentSupport, ImageObserver, MenuContainer, Serializable, Accessible

public class FormPanel
extends JETAPanel

This is the main panel class used to load and view a form during runtime. Usage:

 FormPanel panel = new FormPanel("com/mycorp/app/gui/login/loginView.jfrm");
 
It assumed that all form files are located in your classpath.

You should only use the published APIs to programmatically add, remove, or access Swing Components from a form. If you need to programmatically change a form, you use a FormAccessor, see getFormAccessor(String). If you pass a valid form name, this method will return a FormAccessor instance. Use FormAccessors to access the FormLayout or to add, remove, change, or enumerate components in the underlying container.

 
 FormPanel myform = new FormPanel( "test.jfrm" ); // where the main form in
 test.jfrm is named "settings" FormAccessor form_accessor =
 (FormAccessor)myform.getFormAccessor( "settings" ); // adds a component at
 column 2 and row 5 form_accessor.addBean( new JButton("Test"), new
 CellConstraints( 2, 5 ) );
 
 // or replace the component named 'wizard.view' with a different
 component. FormPanel wiz_view = new FormPanel( "pane2.jfrm" );
 form_accessor.replaceBean( "wizard.view", wiz_view );
 
 
 
 // use FormAccessor to iterate over components in a form as well
 Iterator iter = formaccessor.beanIterator(); while( iter.hasNext() ) {
 Component comp = (Component)iter.next(); if ( comp instanceof FormAccessor ) {
 // found a nested form. // if this iterator is nested, the next
 call to next() will // return components in the nested form. }
 else { // found a standard Java Bean } }
 
 

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
FormPanel(FormComponent fc)
          FormPanel constructor.
FormPanel(InputStream istream)
          FormPanel constructor.
FormPanel(String formPath)
          FormPanel constructor.
 
Method Summary
protected  void addForm(FormComponent form, LayoutManager layout, Object constraints)
          Adds the form to this panel using the given layout manager and constraints
 void applyComponentOrientation(ComponentOrientation orientation)
           
 Iterator beanIterator(boolean nested)
          Returns an iterator for a collection of Java Beans (java.awt.Component objects) contained by this form and its nested forms.
 Object get(String objName)
          Returns the user object associated with the given name.
 FormAccessor getFormAccessor()
          Return an instance of a FormAccessor that is associated with the top-most form in this panel (recall that a form can have nested forms).
 FormAccessor getFormAccessor(String compName)
          Return an instance of a FormAccessor that has the given name.
 Container getFormContainer()
          Returns the parent container that contains the top-level form in this panel.
 void put(String objName, Object obj)
          Puts the given object into the user objects map.
 void revalidate()
          Revalidates this panel.
 void setFocusTraversalPolicy(FocusTraversalPolicy policy)
          Sets the focus traversal policy for this panel.
 void updateFocusPolicy()
          If this form panel contains a form with a custom focus policy, you should call updateFocusPolicy whenever you programatically add or remove components from the form or any nested forms.
 void updateUI()
          Override so we can update the underlying FormComponent
 
Methods inherited from class com.jeta.open.gui.framework.JETAPanel
createComponentFinder, enableComponent, getAllNamedComponents, getBoolean, getButton, getCheckBox, getComboBox, getComponentByName, getComponentFinder, getComponentsByName, getController, getInteger, getLabel, getList, getPanel, getProgressBar, getRadioButton, getSelectedItem, getSpinner, getTabbedPane, getTable, getText, getTextComponent, getTextField, getTree, getUIDirector, isSelected, removeDescendent, removeFromParent, reset, setComponentFinder, setController, setSelected, setSelectedItem, setText, setUIDirector, setVisible, updateComponents, updateComponents
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
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, 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, 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, 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

FormPanel

public FormPanel(String formPath)
FormPanel constructor. Loads the form from the given path. This constructor does not throw an exception if the form resource cannot be found. Instead, it will display an error message in the panel.

Parameters:
formPath - the path to the form file. This path can be absolute or relative to the classpath.

FormPanel

public FormPanel(InputStream istream)
          throws FormException
FormPanel constructor. Creates a FormPanel using the given InputStream. The InputStream must reference a valid underlying .jfrm.

Throws:
FormException - if any type of I/O error occurs or the input stream is not a valid form file.

FormPanel

public FormPanel(FormComponent fc)
FormPanel constructor. Creates a FormPanel using the given FormComponent as the content.

Method Detail

addForm

protected void addForm(FormComponent form,
                       LayoutManager layout,
                       Object constraints)
Adds the form to this panel using the given layout manager and constraints


beanIterator

public Iterator beanIterator(boolean nested)
Returns an iterator for a collection of Java Beans (java.awt.Component objects) contained by this form and its nested forms. Only components that occupy a cell in the grid on the form are returned - not children of those components. So, if you have a Java Bean that has several child components, only the Java Bean will be returned and not its children. This iterator is fail-fast. If any components are added or removed by invoking the underlying FormAccessors at any time after the Iterator is created, the iterator will throw a ConcurrentModificationException. If nested is set to true, then the iterator will fail if components are added to any FormAccessor in the form hierarchy. If nested if false, the iterator will fail only if modifications are made to the Form associated with the current FormAccessor. You may safely call remove on the iterator if you want to remove the component from the form.

Returns:
an iterator to a collection of components (java.awt.Component objects) contained by this form.

get

public Object get(String objName)
Returns the user object associated with the given name. This method does not return a Swing component (use instead JETAPanel.getComponentByName(java.lang.String)). Rather, this method returns any user object that was associated with this panel by calling put(String,Object). Null is returned if the object does not exist.


getFormContainer

public Container getFormContainer()
Returns the parent container that contains the top-level form in this panel. You should rarely have to call this method. Note that a better and safer solution is to name the form in the builder and call getFormAccessor(String)


getFormAccessor

public FormAccessor getFormAccessor()
Return an instance of a FormAccessor that is associated with the top-most form in this panel (recall that a form can have nested forms). Use FormAccessors if you want to programmatically change the underlying FormLayout and/or container.

Returns:
the FormAccessor associated with the topmost form in this panel.

getFormAccessor

public FormAccessor getFormAccessor(String compName)
Return an instance of a FormAccessor that has the given name. This is the same name you gave to the form (either the main form or nested forms) in the designer. Use FormAccessors if you want to programmatically change the underlying FormLayout and/or container.

Parameters:
compName - the name of the form to retrieve.
Returns:
the FormAccessor associated with the named form. Null is returned if component cannot be found with the given name or if the component is not a FormAccessor object.

put

public void put(String objName,
                Object obj)
Puts the given object into the user objects map. If an object already exists for the given name, it is overwritten. Objects can be retrieved from the map by calling get( String )

Parameters:
objName - the name of the object
obj - the object

revalidate

public void revalidate()
Revalidates this panel.

Overrides:
revalidate in class JComponent

applyComponentOrientation

public void applyComponentOrientation(ComponentOrientation orientation)
Overrides:
applyComponentOrientation in class Container

setFocusTraversalPolicy

public void setFocusTraversalPolicy(FocusTraversalPolicy policy)
Sets the focus traversal policy for this panel. Only call this if you wish to override the default handling provided by the form.

Overrides:
setFocusTraversalPolicy in class Container

updateFocusPolicy

public void updateFocusPolicy()
If this form panel contains a form with a custom focus policy, you should call updateFocusPolicy whenever you programatically add or remove components from the form or any nested forms. If a custom focus policy was not assigned in the Form Designer, then this method is not needed.


updateUI

public void updateUI()
Override so we can update the underlying FormComponent

Overrides:
updateUI in class JPanel


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