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

## charva.awt
Class Container

    java.lang.Object
      charva.awt.Component
          charva.awt.Container

Direct Known Subclasses:
  Box, JMenuBar, JPanel, JScrollPane, JTabbedPane, JViewport, Window

public abstract class Container
extends Component

Container is the abstract superclass of Window and Panel.

Field Summary
`protected java.util.Vector` | `_components` The list of components contained within this Container.
`protected Component` | `_currentFocus` The component (which may itself be a Container) inside this Container that currently has the input focus (or, if the input focus is currently outside this Container, the component to which focus will return if and when this Container regains focus).
`protected Insets` | `_insets` The insets define how much padding to insert inside the Container, to take into account the border frame (if any).
`protected boolean` | `_isValid` A flag that is set to true when the container is laid out, and set to false when a component is added or removed from the container (indicating that it needs to be laid out again).
`protected LayoutManager` | `_layoutMgr` The layout manager that will be used to lay out the components.
`protected Dimension` | `_minimumSize` Used for caching the minimum size of this container, so that we don't have to keep recalculating it.
`protected Dimension` | `_size` The container's size

Fields inherited from class charva.awt.Component
`_alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Constructor Summary
`Container()`

Method Summary
`Component` | `add(Component component_)` The contained component will inherit the foreground and background colors of the container if they have not been set yet.
`void` | `add(Component component_, java.lang.Object constraint_)` Adds the specified component to the end of this container.
`void` | `debug(int level_)`
`void` | `doLayout()` doLayout is intended to be used by subclasses of Container, such as Window, JPanel and JScrollPane.
`void` | `draw()` Draw all the components in this container.
`Component` | `getComponent(int n)` Returns the component at the specified index.
`Component` | `getComponentAt(int x, int y)` Returns the component that contains the specified point, or null if no component contains the point.
`Component` | `getComponentAt(Point p)` Returns the component that contains the specified point, or null if no component contains the point.
`int` | `getComponentCount()` Returns the number of components in this Container.
`Component[]` | `getComponents()` Returns an array of all the components in this container.
`Component` | `getCurrentFocus()` Return a reference to the (non-container) component inside this Container that has the keyboard input focus (or would have it, if the focus was inside this container).
`int` | `getHeight()`
`Insets` | `getInsets()`
`Dimension` | `getSize()`
`int` | `getWidth()`
`void` | `invalidate()` Marks the container and all parents above it as needing to be laid out again.
`boolean` | `isFocusTraversable()` Return true if any of the components within this Container are focus-traversable (i.e. will accept keyboard input focus when TAB or SHIFT-TAB is pressed).
`boolean` | `isValid()` Determines whether this component is valid.
`Dimension` | `minimumSize()`
`void` | `nextFocus()` Set the _currentFocus to refer to the next focus-traversable component in the list of contained components, and put FocusEvents on the queue, one for the component that is losing the focus and one for the component gaining the focus.
`void` | `previousFocus()` Set the _currentFocus to refer to the previous focus-traversable component in the list of contained components, and put FocusEvents on the queue, one for the component that is losing the focus and one for the component gaining the focus.
`void` | `processKeyEvent(KeyEvent ke_)` Invoke all the KeyListener callbacks that may have been registered for this component.
`void` | `remove(Component component_)` Removes the specified component from this container.
`void` | `requestFocus()` This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus.
`void` | `setBackground(Color color_)` Sets the background color of this container and all its contained components that do not yet have their background color set.
`void` | `setFocus(Component focus_)` Set this container's current keyboard focus.
`void` | `setForeground(Color color_)` Sets the foreground color of this container and all its contained components that do not yet have their foreground color set.
`void` | `setHeight(int height_)`
`void` | `setLayout(LayoutManager mgr_)`
`void` | `setSize(Dimension size_)`
`void` | `setSize(int width_, int height_)`
`void` | `setWidth(int width_)`
`void` | `validate()` Validates this container and all of its contained components.

Methods inherited from class charva.awt.Component
`addFocusListener, addKeyListener, contains, contains, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getLocation, getLocationOnScreen, getName, getParent, hasFocus, hide, isDisplayed, isEnabled, isTotallyObscured, isVisible, processEvent, processFocusEvent, processMouseEvent, repaint, requestSync, setBounds, setBounds, setBounds, setEnabled, setLocation, setLocation, setName, setParent, setVisible, show, validateCursesColor`

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

Field Detail

### _components

    protected java.util.Vector _components

  The list of components contained within this Container.

### _size

    protected Dimension _size

  The container's size

### _layoutMgr

    protected LayoutManager _layoutMgr

  The layout manager that will be used to lay out the components.

### _currentFocus

    protected Component _currentFocus

  The component (which may itself be a Container) inside this Container that currently has the input focus (or, if the input focus is currently outside this Container, the component to which focus will return if and when this Container regains focus).

### _insets

    protected Insets _insets

  The insets define how much padding to insert inside the Container, to take into account the border frame (if any). For a Window they will be (1,1); for a Panel, they will be (0,0).

### _isValid

    protected boolean _isValid

  A flag that is set to true when the container is laid out, and set to false when a component is added or removed from the container (indicating that it needs to be laid out again).

### _minimumSize

    protected Dimension _minimumSize

  Used for caching the minimum size of this container, so that we don't have to keep recalculating it. This dimension is valid only if _isValid is true.

Constructor Detail

### Container

    public Container()

Method Detail

### doLayout

    public void doLayout()

  doLayout is intended to be used by subclasses of Container, such as Window, JPanel and JScrollPane.

### getSize

    public Dimension getSize()

  Specified by:
    `getSize` in class `Component`

### getHeight

    public int getHeight()

  Specified by:
    `getHeight` in class `Component`

### getWidth

    public int getWidth()

  Specified by:
    `getWidth` in class `Component`

### setSize

    public void setSize(Dimension size_)

### setSize

    public void setSize(int width_,
                        int height_)

### setHeight

    public void setHeight(int height_)

### setWidth

    public void setWidth(int width_)

### minimumSize

    public Dimension minimumSize()

  Specified by:
    `minimumSize` in class `Component`

### getComponent

    public Component getComponent(int n)

  Returns the component at the specified index.

### getComponentAt

    public Component getComponentAt(Point p)

  Returns the component that contains the specified point, or null if no component contains the point. The x and y coordinates of the point are relative to the origin of this container.

### getComponentAt

    public Component getComponentAt(int x,
                                    int y)

  Returns the component that contains the specified point, or null if no component contains the point. The x and y coordinates of the point are relative to the origin of this container.

### add

    public Component add(Component component_)

  The contained component will inherit the foreground and background colors of the container if they have not been set yet.

### remove

    public void remove(Component component_)

  Removes the specified component from this container.

### add

    public void add(Component component_,
                    java.lang.Object constraint_)

  Adds the specified component to the end of this container. Also notifies the layout manager to add this component to the layout using the specified constraint. If the layout manager does not implement the LayoutManager2 interface, i.e. does not know about layout constraints, we silently ignore the constraint (maybe fix this to throw an exception?).

### setLayout

    public void setLayout(LayoutManager mgr_)

### getComponents

    public Component[] getComponents()

  Returns an array of all the components in this container.

### getComponentCount

    public int getComponentCount()

  Returns the number of components in this Container.

### draw

    public void draw()

  Draw all the components in this container.

  Specified by:
    `draw` in class `Component`

### setForeground

    public void setForeground(Color color_)

  Sets the foreground color of this container and all its contained components that do not yet have their foreground color set. Overrides the same method in the Component class.

  Overrides:
    `setForeground` in class `Component`

### setBackground

    public void setBackground(Color color_)

  Sets the background color of this container and all its contained components that do not yet have their background color set. Overrides the same method in the Component class.

  Overrides:
    `setBackground` in class `Component`

### processKeyEvent

    public void processKeyEvent(KeyEvent ke_)

  Description copied from class: `Component`
  Invoke all the KeyListener callbacks that may have been registered for this component. The KeyListener objects may modify the keycodes, and can also set the "consumed" flag.

  Overrides:
    `processKeyEvent` in class `Component`

### requestFocus

    public void requestFocus()

  Description copied from class: `Component`
  This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus.

  Overrides:
    `requestFocus` in class `Component`

### getCurrentFocus

    public Component getCurrentFocus()

  Return a reference to the (non-container) component inside this Container that has the keyboard input focus (or would have it, if the focus was inside this container). If no component inside the container has the focus, choose the first FocusTraversable component.

  Returns:
    the Component in this container that would have the focus; never null.
  Throws:
    `IllegalComponentStateException` - if there is no focus-traversable component in this container.

### nextFocus

    public void nextFocus()

  Set the _currentFocus to refer to the next focus-traversable component in the list of contained components, and put FocusEvents on the queue, one for the component that is losing the focus and one for the component gaining the focus.

### previousFocus

    public void previousFocus()

  Set the _currentFocus to refer to the previous focus-traversable component in the list of contained components, and put FocusEvents on the queue, one for the component that is losing the focus and one for the component gaining the focus.

### setFocus

    public void setFocus(Component focus_)

  Set this container's current keyboard focus. Called by the requestFocus() method of the contained component.

### isFocusTraversable

    public boolean isFocusTraversable()

  Return true if any of the components within this Container are focus-traversable (i.e. will accept keyboard input focus when TAB or SHIFT-TAB is pressed).

  Overrides:
    `isFocusTraversable` in class `Component`

### getInsets

    public Insets getInsets()

### debug

    public void debug(int level_)

  Specified by:
    `debug` in class `Component`

### validate

    public void validate()

  Validates this container and all of its contained components. The programmer must call validate() on a container to cause it to re-layout its contained components after components have been added, removed or resized.

  Overrides:
    `validate` in class `Component`

### isValid

    public boolean isValid()

  Determines whether this component is valid. A container is valid when it is correctly sized and positioned within its parent container and all its children are also valid.

  Overrides:
    `isValid` in class `Component`

### invalidate

    public void invalidate()

  Marks the container and all parents above it as needing to be laid out again.

  Overrides:
    `invalidate` in class `Component`

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