Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## waba.ui
Class Container

    java.lang.Object
      |
      +--waba.ui.Control
            |
            +--waba.ui.Container

Direct Known Subclasses:
  ComboBox, Grid, GridContainer, JustifiedContainer, ListBox, MultiEdit, ScrollBar, TabPanel, Window

public class Container
extends Control

Container is a control that contains child controls.

Field Summary
`static byte` | `BORDER_LOWERED` used in the setBorderStyle method
`static byte` | `BORDER_NONE` used in the setBorderStyle method
`static byte` | `BORDER_RAISED` used in the setBorderStyle method
`static byte` | `BORDER_SIMPLE` used in the setBorderStyle method
`protected Control` | `children` The children of the container.
`protected int` | `lastH`
`protected int` | `lastW`
`protected int` | `lastX`
`protected int` | `lastY`
`protected Window` | `parentWindow`
`protected Control` | `tail` The tail of the children list.

Fields inherited from class waba.ui.Control
`AFTER, appId, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, enabled, FILL, FIT, fm, fmH, focusLess, font, foreColor, foreDis, height, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, visible, width, x, x2, y, y2`

Constructor Summary
`Container()` Creates a container with the default colors.

Method Summary
`void` | `add(Control control)` Adds a child control to this container.
`void` | `add(Control control, int x, int y)` Add the control to this container and set its rect to be the given x,y and PREFERRED as width/height relative to the last control added
`void` | `add(Control control, int x, int y, Control relative)` Add the control to this container and set its rect to be the given x,y and PREFERRED as width/height relative to the given control
`void` | `broadcastEvent(Event e)` posts a event to the children of this container and to all containers inside this containers; recursively.
`Control` | `findChild(int x, int y)` Returns the child located at the given x and y coordinates.
`Control[]` | `getChildren()` return an array of Controls that are added to this Container. if theres no Controls, returns null.
`Rect` | `getClientRect()` returns the client rect for this Container, in relative coords
`protected void` | `onColorsChanged(boolean colorsChanged)` Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.
`void` | `onPaint(Graphics g)` Draws the border (if any).
`protected void` | `onStart()` Called when this container can be initialized
`void` | `paintChildren(Graphics g, int x, int y, int width, int height)` Called by the system to draw the children of the container.
`void` | `remove(Control control)` Removes a child control from the container.
`void` | `setBorderStyle(byte border)` Sets the border for this container.
`void` | `setEnabled(boolean enabled)` sets if this container and all childrens can or not accept events

Methods inherited from class waba.ui.Control
`addTimer, contains, createGraphics, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getPreferredHeight, getPreferredWidth, getRect, getSize, isDisplayed, isEnabled, isVisible, onBoundsChanged, onEvent, onFontChanged, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### children

    protected Control children

  The children of the container.

### tail

    protected Control tail

  The tail of the children list.

### BORDER_NONE

    public static final byte BORDER_NONE

  used in the setBorderStyle method

### BORDER_LOWERED

    public static final byte BORDER_LOWERED

  used in the setBorderStyle method

### BORDER_RAISED

    public static final byte BORDER_RAISED

  used in the setBorderStyle method

### BORDER_SIMPLE

    public static final byte BORDER_SIMPLE

  used in the setBorderStyle method

### parentWindow

    protected Window parentWindow

### lastX

    protected int lastX

### lastY

    protected int lastY

### lastW

    protected int lastW

### lastH

    protected int lastH

Constructor Detail

### Container

    public Container()

  Creates a container with the default colors. Important note: this container has no default size. If adding to the MainWindow as another container, you may set its size as `MainWindow.getMainWindow().getClientRect()`.

  If you're extending the Container class and adding controls in its constructor, you may come into problems if you don't set the bounds as the first thing. This is easy if you're just adding the controls to a MainWindow. But if you're adding to a TabPanel, for example, there is no way to know the TabPanel's size. The solution for this problem is to pass in the constructor of your Container class the Rect with the desired bounds, as demonstrated in the examples/ui/ContainerSwitch

Method Detail

### add

    public void add(Control control,
                    int x,
                    int y)

  Add the control to this container and set its rect to be the given x,y and PREFERRED as width/height relative to the last control added

### add

    public void add(Control control,
                    int x,
                    int y,
                    Control relative)

  Add the control to this container and set its rect to be the given x,y and PREFERRED as width/height relative to the given control

### add

    public void add(Control control)

  Adds a child control to this container. Important: If you're swapping containers from the MainWindow, be sure that you set the focus on the new container after calling this add method. Otherwise, a MenuBar will not work. Or, use the handy method Window.swap

### remove

    public void remove(Control control)

  Removes a child control from the container.

### findChild

    public Control findChild(int x,
                             int y)

  Returns the child located at the given x and y coordinates.

### getChildren

    public Control[] getChildren()

  return an array of Controls that are added to this Container. if theres no Controls, returns null.

### setEnabled

    public void setEnabled(boolean enabled)

  sets if this container and all childrens can or not accept events
  Overrides:
    setEnabled in class Control

### broadcastEvent

    public void broadcastEvent(Event e)

  posts a event to the children of this container and to all containers inside this containers; recursively.
  Since:
    SuperWaba2.0beta4

### paintChildren

    public void paintChildren(Graphics g,
                              int x,
                              int y,
                              int width,
                              int height)

  Called by the system to draw the children of the container.

### setBorderStyle

    public void setBorderStyle(byte border)

  Sets the border for this container. Use BORDER_NONE,BORDER_LOWERED,BORDER_RAISED,BORDER_SIMPLE.

### getClientRect

    public Rect getClientRect()

  returns the client rect for this Container, in relative coords

### onColorsChanged

    protected void onColorsChanged(boolean colorsChanged)

  Description copied from class: Control
  Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled
  Overrides:
    onColorsChanged in class Control

### onPaint

    public void onPaint(Graphics g)

  Draws the border (if any). If you override this method, be sure to call `super.onPaint(g);`, or the border will not be drawn.
  Overrides:
    onPaint in class Control
  Tags copied from class: Control
  Parameters:
    `g` - the graphics object for drawing
  See Also:
    `Graphics`

### onStart

    protected void onStart()

  Called when this container can be initialized
  Since:
    SuperWaba 3.4

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD