com.jmex.bui
Class BContainer

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.BContainer
Direct Known Subclasses:
BList, BScrollBar, BScrollingList, BScrollingList.BViewport, BScrollPane, BScrollPane.BViewport, BTabbedPane, BTextArea, BWindow

public class BContainer
extends BComponent

A user interface element that is meant to contain other interface elements.


Nested Class Summary
protected static interface BContainer.ChildOp
          Used in wasAdded() and wasRemoved().
 
Field Summary
protected  ArrayList<BComponent> _children
           
protected  BLayoutManager _layout
           
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
BContainer()
          Creates a container with no layout manager.
BContainer(BLayoutManager layout)
          Creates a container with the supplied layout manager.
 
Method Summary
 void add(BComponent child)
          Adds a child to this container.
 void add(BComponent child, Object constraints)
          Adds a child to this container with the specified layout constraints.
 void add(int index, BComponent child)
          Adds a child to this container at the specified position.
 void add(int index, BComponent child, Object constraints)
          Adds a child to this container at the specified position, with the specified layout constraints.
protected  void applyOperation(BContainer.ChildOp op)
          Applies an operation to all of our children.
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
 BComponent getComponent(int index)
          Returns the indexth component from this container.
 int getComponentCount()
          Returns the number of components contained in this container.
 int getComponentIndex(BComponent component)
          Returns the index of the specified component in this container or -1 if the component count not be found.
protected  String getDefaultStyleClass()
          Returns the default stylesheet class to be used for all instances of this component.
 BComponent getHitComponent(int mx, int my)
          Returns the component "hit" by the specified mouse coordinates which might be this component or any of its children.
 BLayoutManager getLayoutManager()
          Returns the layout manager configured for this container.
protected  BComponent getNextFocus(BComponent current)
          Returns the next component that should receive focus in this container given the current focus owner.
protected  BComponent getPreviousFocus(BComponent current)
          Returns the previous component that should receive focus in this container given the current focus owner.
protected  void layout()
          Instructs this component to lay itself out.
 void remove(BComponent child)
          Removes the specified child from this container.
 void remove(int index)
          Removes the child at a specific position from this container.
 void removeAll()
          Removes all children of this container.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
 boolean replace(BComponent oldc, BComponent newc)
          Replaces a given old component with a new component (if the old component exits).
 void setAlpha(float alpha)
          Sets the alpha level for this component.
 void setEnabled(boolean enabled)
          Sets this components enabled state.
 void setLayoutManager(BLayoutManager layout)
          Configures this container with an entity that will set the size and position of its children.
 void setVisible(boolean visible)
          Sets this component's visibility state.
 void validate()
          Instructs this component to lay itself out and then mark itself as valid.
protected  void wasAdded()
          This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, applyDefaultStates, boundsToString, changeCursor, configureStyle, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, stateDidChange, updateCursor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_children

protected ArrayList<BComponent> _children

_layout

protected BLayoutManager _layout
Constructor Detail

BContainer

public BContainer()
Creates a container with no layout manager. One should subsequently be set via a call to setLayoutManager(com.jmex.bui.layout.BLayoutManager).


BContainer

public BContainer(BLayoutManager layout)
Creates a container with the supplied layout manager.

Method Detail

setLayoutManager

public void setLayoutManager(BLayoutManager layout)
Configures this container with an entity that will set the size and position of its children.


getLayoutManager

public BLayoutManager getLayoutManager()
Returns the layout manager configured for this container.


add

public void add(BComponent child)
Adds a child to this container.


add

public void add(int index,
                BComponent child)
Adds a child to this container at the specified position.


add

public void add(BComponent child,
                Object constraints)
Adds a child to this container with the specified layout constraints.


add

public void add(int index,
                BComponent child,
                Object constraints)
Adds a child to this container at the specified position, with the specified layout constraints.


remove

public void remove(int index)
Removes the child at a specific position from this container.


replace

public boolean replace(BComponent oldc,
                       BComponent newc)
Replaces a given old component with a new component (if the old component exits).

Returns:
true if the old component was replaced, false otherwise.

remove

public void remove(BComponent child)
Removes the specified child from this container.


getComponentCount

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


getComponent

public BComponent getComponent(int index)
Returns the indexth component from this container.


getComponentIndex

public int getComponentIndex(BComponent component)
Returns the index of the specified component in this container or -1 if the component count not be found.


removeAll

public void removeAll()
Removes all children of this container.


setAlpha

public void setAlpha(float alpha)
Description copied from class: BComponent
Sets the alpha level for this component.

Overrides:
setAlpha in class BComponent

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: BComponent
Sets this components enabled state. A component that is not enabled should not respond to user interaction and should render itself in such a way as not to afford user interaction.

Overrides:
setEnabled in class BComponent

setVisible

public void setVisible(boolean visible)
Description copied from class: BComponent
Sets this component's visibility state. A component that is invisible is not rendered and does not contribute to the layout.

Overrides:
setVisible in class BComponent

getHitComponent

public BComponent getHitComponent(int mx,
                                  int my)
Description copied from class: BComponent
Returns the component "hit" by the specified mouse coordinates which might be this component or any of its children. This method should return null if the supplied mouse coordinates are outside the bounds of this component.

Overrides:
getHitComponent in class BComponent

validate

public void validate()
Description copied from class: BComponent
Instructs this component to lay itself out and then mark itself as valid.

Overrides:
validate in class BComponent

getDefaultStyleClass

protected String getDefaultStyleClass()
Description copied from class: BComponent
Returns the default stylesheet class to be used for all instances of this component. Derived classes will likely want to override this method and set up a default class for their type of component.

Overrides:
getDefaultStyleClass in class BComponent

layout

protected void layout()
Description copied from class: BComponent
Instructs this component to lay itself out. This is called as a result of the component changing size.

Overrides:
layout in class BComponent

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: BComponent
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class BComponent

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: BComponent
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class BComponent
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.

wasAdded

protected void wasAdded()
Description copied from class: BComponent
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).

Overrides:
wasAdded in class BComponent

wasRemoved

protected void wasRemoved()
Description copied from class: BComponent
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in BComponent.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class BComponent

getNextFocus

protected BComponent getNextFocus(BComponent current)
Returns the next component that should receive focus in this container given the current focus owner. If the supplied current focus owner is null, the container should return its first focusable component. If the container has no focusable components following the current focus, it should call BComponent.getNextFocus() to search further up the hierarchy.


getPreviousFocus

protected BComponent getPreviousFocus(BComponent current)
Returns the previous component that should receive focus in this container given the current focus owner. If the supplied current focus owner is null, the container should return its last focusable component. If the container has no focusable components before the current focus, it should call BComponent.getPreviousFocus() to search further up the hierarchy.


applyOperation

protected void applyOperation(BContainer.ChildOp op)
Applies an operation to all of our children.



Copyright © 2008 Michael Bayne. All Rights Reserved.