JFormDesigner 5.0.4 Runtime API

com.jformdesigner.model
Class FormContainer

java.lang.Object
  extended by com.jformdesigner.model.FormObject
      extended by com.jformdesigner.model.FormComponent
          extended by com.jformdesigner.model.FormContainer
All Implemented Interfaces:
FormSelectable
Direct Known Subclasses:
FormRoot, FormWindow

public class FormContainer
extends FormComponent

A form container represents a java.awt.Container in the form model. In addition to the inherited functionality, it has a form layout manager and a list of child form components. The relationship between FormContainer, FormLayoutManager and FormLayoutConstraints is the same as in Swing. The form container has a form layout manager. The form layout manager holds the form constrains for the children of the form container.

Take a look at the example source code (FormSaverExamples.java) for details.

Example using JGoodies FormLayout:

   FormLayoutManager layout = new FormLayoutManager(FormLayout.class);
   layout.setProperty("$columnSpecs", "default, labelcompgap, default:grow");
   layout.setProperty("$rowSpecs", "default, linegap, default");

   FormContainer panel = new FormContainer("javax.swing.JPanel", layout);
   panel.setName("this");
   panel.setProperty("$size", new Dimension(300, 200)); // size in design view

   // create "name" label
   FormComponent nameLabel = new FormComponent("javax.swing.JLabel");
   nameLabel.setName("nameLabel");
   nameLabel.setProperty("text", "Name:");

   // add "name" label to panel
   FormLayoutConstraints cons = new FormLayoutConstraints( CellConstraints.class );
   cons.setPropertyInt("gridX", 1);
   cons.setPropertyInt("gridY", 1);
   panel.add(nameLabel, cons);

   // create "name" text field
   FormComponent nameField = new FormComponent("javax.swing.JTextField");
   nameField.setName("nameField");
   nameField.setPropertyInt("columns", 20);

   // add "name" text field to panel
   cons = new FormLayoutConstraints( CellConstraints.class );
   cons.setPropertyInt("gridX", 3);
   cons.setPropertyInt("gridY", 1);
   panel.add(nameField, cons);
 


Field Summary
static java.lang.String FIELD_MENU_BAR
           
 
Fields inherited from class com.jformdesigner.model.FormComponent
FIELD_NAME
 
Fields inherited from class com.jformdesigner.model.FormObject
NULL_VALUE
 
Constructor Summary
FormContainer(java.lang.String className)
          Constructs a form container for the specified class.
FormContainer(java.lang.String className, FormLayoutManager layout)
          Constructs a form container for the specified class and form layout manager.
 
Method Summary
 boolean accept(FormComponentVisitor visitor)
          Accepts the given visitor.
 void add(FormComponent comp)
          Adds a form component to the end of this form container.
 void add(FormComponent comp, FormLayoutConstraints constraints)
          Adds a form component to the end of this form container and sets the specified constraints in the form layout manager of this container.
 void add(FormComponent comp, FormLayoutConstraints constraints, int index)
          Adds a form component to this form container at the specified position and sets the specified constraints in the form layout manager of this container.
 void add(FormComponent comp, int index)
          Adds a form component to this form container at the specified position.
 java.lang.Object clone()
          Clones this form container.
 FormComponent getComponent(int index)
          Returns the form component at index.
 int getComponentCount()
          Returns the number of form components in this form container.
 int getComponentIndex(FormComponent comp)
          Returns the index of comp in this form container; or -1 if the form component is not a child of this form container.
 FormComponent[] getComponents()
          Returns all form components in this form container.
 FormLayoutManager getLayout()
          Returns the form layout manager used by this form container.
 FormContainer getMenuBar()
          Returns the menu bar of this form container.
 FormComponent[] getMenuBarAndComponents()
          Returns the menu bar and all form components in this form container.
 FormContainer getMenuBarOwner()
          Returns the owner of a menu bar.
 void remove(FormComponent comp)
          Removes the specified form component from this form container.
 void remove(int index)
          Removes the form component at the specified index from this form container.
 void remove(java.lang.String name)
          Removes the form component with the specified name from this form container.
 void removeAll()
          Removes add children from this form container.
 void setLayout(FormLayoutManager layout)
          Sets the form layout manager for this form container.
 void setMenuBar(FormContainer menuBar)
          Sets the menu bar of this form container.
 
Methods inherited from class com.jformdesigner.model.FormComponent
addEvent, addEvent, auxiliary, getAuxiliaryPropertyBoolean, getAuxiliaryPropertyInt, getAuxiliaryPropertyString, getClassName, getConstraints, getEvent, getEventCount, getEvents, getModel, getName, getParent, hasAuxiliary, removeEvent, removeEvent, setName, toString
 
Methods inherited from class com.jformdesigner.model.FormObject
getProperties, getProperty, getProperty, getPropertyBoolean, getPropertyBoolean, getPropertyCount, getPropertyDouble, getPropertyDouble, getPropertyInt, getPropertyInt, getPropertyNames, getPropertyString, getPropertyString, getReferenceCount, properties, propertyNames, setProperty, setProperty, setProperty, setPropertyBoolean, setPropertyBoolean, setPropertyDouble, setPropertyDouble, setPropertyInt, setPropertyInt, setPropertyString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_MENU_BAR

public static final java.lang.String FIELD_MENU_BAR
See Also:
Constant Field Values
Constructor Detail

FormContainer

public FormContainer(java.lang.String className)
Constructs a form container for the specified class.


FormContainer

public FormContainer(java.lang.String className,
                     FormLayoutManager layout)
Constructs a form container for the specified class and form layout manager.

Method Detail

clone

public java.lang.Object clone()
Clones this form container.

Overrides:
clone in class FormComponent

getLayout

public FormLayoutManager getLayout()
Returns the form layout manager used by this form container.


setLayout

public void setLayout(FormLayoutManager layout)
Sets the form layout manager for this form container.


getComponentCount

public int getComponentCount()
Returns the number of form components in this form container.


getComponent

public FormComponent getComponent(int index)
Returns the form component at index.


getComponents

public FormComponent[] getComponents()
Returns all form components in this form container.


getComponentIndex

public int getComponentIndex(FormComponent comp)
Returns the index of comp in this form container; or -1 if the form component is not a child of this form container.


add

public void add(FormComponent comp)
Adds a form component to the end of this form container.


add

public void add(FormComponent comp,
                int index)
Adds a form component to this form container at the specified position.


add

public void add(FormComponent comp,
                FormLayoutConstraints constraints)
Adds a form component to the end of this form container and sets the specified constraints in the form layout manager of this container.


add

public void add(FormComponent comp,
                FormLayoutConstraints constraints,
                int index)
Adds a form component to this form container at the specified position and sets the specified constraints in the form layout manager of this container.

Parameters:
comp - The form component to be added.
constraints - The form layout constraints for the form component.
index - The position in the container's list at which to insert the component; or -1 to insert at the end

remove

public void remove(FormComponent comp)
Removes the specified form component from this form container.


remove

public void remove(int index)
Removes the form component at the specified index from this form container.


remove

public void remove(java.lang.String name)
Removes the form component with the specified name from this form container.


removeAll

public void removeAll()
Removes add children from this form container.


getMenuBar

public FormContainer getMenuBar()
Returns the menu bar of this form container.

Since:
2.0

setMenuBar

public void setMenuBar(FormContainer menuBar)
Sets the menu bar of this form container.

Since:
2.0

getMenuBarOwner

public FormContainer getMenuBarOwner()
Returns the owner of a menu bar.

Since:
2.0

accept

public boolean accept(FormComponentVisitor visitor)
Accepts the given visitor. The visitor's FormComponentVisitor.visit(com.jformdesigner.model.FormComponent) is called with this form container, with the menu bar of this form container and with all children of this form container.

Overrides:
accept in class FormComponent
Parameters:
visitor - The visitor.
Returns:
The result of FormComponentVisitor.visit(com.jformdesigner.model.FormComponent).
Since:
3.0

getMenuBarAndComponents

public FormComponent[] getMenuBarAndComponents()
Returns the menu bar and all form components in this form container.

Since:
2.0

JFormDesigner 5.0.4 Runtime API

Copyright (C) 2004-2012 FormDev Software GmbH. All rights reserved.