Class InterFormContainer

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class InterFormContainer extends Container

A container that allows you to use the same component on multiple forms. This is most useful for adding a global footer or sidebar that appears on multiple forms, or even the whole app. For example, the Twitter app has tabs for "Home", "Search", "Messages", etc.. that are always shown in the app, and are fixed in place, even between forms. This container allows you to achieve a similar thing with Codename One apps.

Note that the InterFormContainer object itself cannot be added to multiple forms. You need to create two InterFormContainer instances that share the same content.

  • Constructor Details

    • InterFormContainer

      public InterFormContainer(Component content)

      Creates an interform container with the provided content.

      Parameters
      • content: The component that is to be shared across multiple forms.
  • Method Details

    • findCommonContainers

      public static Map<InterFormContainer, InterFormContainer> findCommonContainers(Component root1, Component root2)

      Finds common InterFormContainers in two different component trees.

      Parameters
      • root1: The root of the first component tree to search.

      • root2: The root of the second component tree to search.

      Returns
      Returns:
      A Map that maps an InterFormContainer from the first tree to its corresponding container from the second tree.
    • inject

      public static InterFormContainer inject(String selector, Container root, Component content)

      Injects the given "content" as an InterFormContainer inside the component hierarchy rooted at "root"

      Parameters
      • selector: A selector to identify the component to add the container to. See ComponentSelector.

      • root: The root container serving as a starting point for the selector search.

      • content: The content to inject.

      Returns

      The InterFormContainer that was injected, or null if the selector didn't match any containers.

    • initComponent

      protected void initComponent()
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • findPeer

      public InterFormContainer findPeer(Component root)

      Finds any InterformContainer instances in the UI hierarchy rooted at root that contains the same content as this container.

      Parameters
      • root: A component/container whose UI hierarchy is to be searched.
      Returns

      An InterFormContainer with the same content as this container, or null if none is found.

    • paint

      public void paint(Graphics g)

      This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

      Parameters
      • g: the component graphics
      Specified by:
      paint in interface Animation
      Overrides:
      paint in class Container
    • calcPreferredSize

      protected Dimension calcPreferredSize()

      Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

      Returns

      the calculated preferred size based on component content

      Overrides:
      calcPreferredSize in class Container