org.zaval.lw
Class LwList

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.LwList
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwComponent, LwComposite, LwContainer, LwFocusListener, LwKeyListener, LwMouseListener, PosListener, ScrollObj, Validationable
Direct Known Subclasses:
LwComboList

public class LwList
extends LwPanel
implements LwKeyListener, LwMouseListener, LwFocusListener, LwComposite, PosListener, ScrollObj

This is list component. The main features of the component are shown in the list below:


Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwList()
          Constructs a list component with no items.
 
Method Summary
 void add(java.lang.String s)
          Adds an item to the list.
 void addSelectionListener(LwActionListener l)
          Adds the specified selection listener to receive selection events from this list component.
 boolean canHaveFocus()
          Specifies if the component can have focus.
 boolean catchInput(LwComponent child)
          Checks if input events for the specified child component should be caught.
protected  void drawPosMarker(java.awt.Graphics g)
          Invoked to paint position marker.
protected  void drawSelMarker(java.awt.Graphics g)
          Invoked to paint selection marker.
 void focusGained(LwFocusEvent e)
          Invoked when the light weight component gained focus.
 void focusLost(LwFocusEvent e)
          Invoked when the light weight component lost focus.
protected  LwLayout getDefaultLayout()
          Gets the default layout manager that is set with the container during initialization.
 java.awt.Point getLayoutOffset()
          Returns the offset.
 PosController getPosController()
          Gets the position controller.
 java.awt.Color getPosRectColor()
          Gets the position rectangle color.
 java.awt.Color getSelectColor()
          Gets the selection marker color.
 LwComponent getSelected()
          Gets the selected item component.
 int getSelectedIndex()
          Gets the selected item index.
 java.awt.Point getSOLocation()
          Gets the scroll object location.
 java.awt.Dimension getSOSize()
          Gets the scroll object size.
 void insert(int i, java.lang.Object s, LwComponent d)
          Inserts the specified lightweight component with the specified constraints as a child of this container at the specified position in the container list.
 boolean isSelected(int i)
          Tests if the item with the specified index is selected or not.
 void keyPressed(LwKeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(LwKeyEvent e)
          Invoked when a key has been released.
 void keyTyped(LwKeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(LwMouseEvent e)
          Invoked when the mouse button has been clicked on a light weight component.
 void mouseEntered(LwMouseEvent e)
          Invoked when the mouse enters a light weight component.
 void mouseExited(LwMouseEvent e)
          Invoked when the mouse exits a light weight component.
 void mousePressed(LwMouseEvent e)
          Invoked when the mouse button has been pressed on a light weight component.
 void mouseReleased(LwMouseEvent e)
          Invoked when the mouse button has been released on a light weight component.
 boolean moveContent()
          Tests if the scroll component performs scrolling by changing its location or moving view.
protected  boolean notifyScrollMan(int index)
          Notifies the scroll manager that an item component at the specified index should be fully visible.
protected  int pageSize(int d)
          Returns the page size for the specified direction.
 void paintOnTop(java.awt.Graphics g)
          Paints this component.
protected  void perform(int from)
          Creates and fires appropriate selection event for list of selection listeners.
 void posChanged(PosEvent e)
          Invoked when a virtual position has been changed.
 void remove(int i)
          Removes the component, specified by the index, from this container.
 void removeAll()
          Removes all child components from this container.
 void removeSelectionListener(LwActionListener l)
          Removes the specified selection listener so it no longer receives selection events from this list component.
 void select(int index)
          Selects the item by the specified index.
 void setLwLayout(LwLayout l)
          Sets the layout manager for this container.
 void setPosController(PosController c)
          Sets the specified position controller.
 void setPosRectColor(java.awt.Color c)
          Sets the color for a position rectangle.
 void setScrollMan(ScrollMan m)
          Sets the specified scroll manager for the scroll object.
 void setSelectColor(java.awt.Color c)
          Sets the selection marker color.
 void setSOLocation(int x, int y)
          Sets the specified scroll object location.
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLwComponentAt, getLwLayout, indexOf, insert, invalidate, recalc, remove, setBackground, setOpaque, toFront, updateCashedPs
 
Methods inherited from class org.zaval.lw.LwCanvas
getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, paint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwContainer
add, add, getLwLayout, indexOf
 
Methods inherited from interface org.zaval.lw.LwComponent
getLwComponentAt, getLwParent, getViewMan, getVisiblePart, setBackground, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, paint, repaint, repaint, setOpaque, update
 
Methods inherited from interface org.zaval.util.Validationable
invalidate, isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 
Methods inherited from interface org.zaval.lw.LayoutContainer
count, get
 

Constructor Detail

LwList

public LwList()
Constructs a list component with no items.
Method Detail

canHaveFocus

public boolean canHaveFocus()
Description copied from interface: LwComponent
Specifies if the component can have focus.
Specified by:
canHaveFocus in interface LwComponent
Overrides:
canHaveFocus in class LwCanvas
Following copied from interface: org.zaval.lw.LwComponent
Returns:
true if the component can have the focus.

setPosController

public void setPosController(PosController c)
Sets the specified position controller. The controller manages the virtual cursor location.
Parameters:
c - the specified position controller.

setLwLayout

public void setLwLayout(LwLayout l)
Sets the layout manager for this container. The layout manager has to implement org.zaval.misc.PosInfo interface, the interface allows to control virtual position of the list component with the position controller of the component.
Specified by:
setLwLayout in interface LwContainer
Overrides:
setLwLayout in class LwPanel
Parameters:
l - the specified layout manager.

getPosController

public PosController getPosController()
Gets the position controller.
Returns:
a position controller.

getSelectColor

public java.awt.Color getSelectColor()
Gets the selection marker color.
Returns:
a selection marker color.

setSelectColor

public void setSelectColor(java.awt.Color c)
Sets the selection marker color.
Parameters:
c - the selection marker color.

getPosRectColor

public java.awt.Color getPosRectColor()
Gets the position rectangle color.
Returns:
a position rectangle color.

setPosRectColor

public void setPosRectColor(java.awt.Color c)
Sets the color for a position rectangle. The position rectangle is rendered around a list item where the current position is.
Parameters:
c - the color.

add

public void add(java.lang.String s)
Adds an item to the list. The method creates LwLabel component with the specified label and adds it to the list.
Parameters:
s - the specified label.

select

public void select(int index)
Selects the item by the specified index.
Parameters:
index - the specified item index.

getSelectedIndex

public int getSelectedIndex()
Gets the selected item index.
Returns:
a selected item index.

isSelected

public boolean isSelected(int i)
Tests if the item with the specified index is selected or not.
Returns:
true if the item with the specified index is selected; otherwise false.

addSelectionListener

public void addSelectionListener(LwActionListener l)
Adds the specified selection listener to receive selection events from this list component. The event is represented by LwActionEvent where getData method returns Integer object that is selection index.
Parameters:
l - the specified listener.

removeSelectionListener

public void removeSelectionListener(LwActionListener l)
Removes the specified selection listener so it no longer receives selection events from this list component.
Parameters:
l - the specified listener.

paintOnTop

public void paintOnTop(java.awt.Graphics g)
Paints this component. The method is overrided to paint the list item selection rectangle.
Specified by:
paintOnTop in interface LwContainer
Overrides:
paintOnTop in class LwPanel
Parameters:
g - the graphics context to be used for painting.

drawSelMarker

protected void drawSelMarker(java.awt.Graphics g)
Invoked to paint selection marker.
Parameters:
g - the graphics context to be used for painting.

drawPosMarker

protected void drawPosMarker(java.awt.Graphics g)
Invoked to paint position marker.
Parameters:
g - the graphics context to be used for painting.

mouseClicked

public void mouseClicked(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been clicked on a light weight component.
Specified by:
mouseClicked in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseEntered

public void mouseEntered(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse enters a light weight component.
Specified by:
mouseEntered in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseExited

public void mouseExited(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse exits a light weight component.
Specified by:
mouseExited in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mousePressed

public void mousePressed(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been pressed on a light weight component.
Specified by:
mousePressed in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseReleased

public void mouseReleased(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been released on a light weight component.
Specified by:
mouseReleased in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

keyPressed

public void keyPressed(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been pressed.
Specified by:
keyPressed in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyReleased

public void keyReleased(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been released.
Specified by:
keyReleased in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

keyTyped

public void keyTyped(LwKeyEvent e)
Description copied from interface: LwKeyListener
Invoked when a key has been typed.
Specified by:
keyTyped in interface LwKeyListener
Following copied from interface: org.zaval.lw.event.LwKeyListener
Parameters:
e - the specified key event.

focusGained

public void focusGained(LwFocusEvent e)
Description copied from interface: LwFocusListener
Invoked when the light weight component gained focus.
Specified by:
focusGained in interface LwFocusListener
Following copied from interface: org.zaval.lw.event.LwFocusListener
Parameters:
e - the specified focus event.

focusLost

public void focusLost(LwFocusEvent e)
Description copied from interface: LwFocusListener
Invoked when the light weight component lost focus.
Specified by:
focusLost in interface LwFocusListener
Following copied from interface: org.zaval.lw.event.LwFocusListener
Parameters:
e - the specified focus event.

catchInput

public boolean catchInput(LwComponent child)
Description copied from interface: LwComposite
Checks if input events for the specified child component should be caught.
Specified by:
catchInput in interface LwComposite
Following copied from interface: org.zaval.lw.LwComposite
Parameters:
child - the specified child component.
Returns:
true if input events for the child component should be caught by this component; false otherwise.

posChanged

public void posChanged(PosEvent e)
Description copied from interface: PosListener
Invoked when a virtual position has been changed.
Specified by:
posChanged in interface PosListener
Following copied from interface: org.zaval.misc.event.PosListener
Parameters:
e - the specified pos event.

insert

public void insert(int i,
                   java.lang.Object s,
                   LwComponent d)
Description copied from interface: LwContainer
Inserts the specified lightweight component with the specified constraints as a child of this container at the specified position in the container list. The method should call componentAdded method its layout manager to inform the layout manager that the new child has been added with the given constraints.
Specified by:
insert in interface LwContainer
Overrides:
insert in class LwPanel
Following copied from interface: org.zaval.lw.LwContainer
Parameters:
i - the position in the container list at which to insert the component.
s - the object expressing layout contraints for this.
c - the lightweight component to be added.

remove

public void remove(int i)
Description copied from interface: LwContainer
Removes the component, specified by the index, from this container. The layout manager of this container should be informed by calling componentRemoved method of the manager.
Specified by:
remove in interface LwContainer
Overrides:
remove in class LwPanel
Following copied from interface: org.zaval.lw.LwContainer
Parameters:
index - the index of the component to be removed.

removeAll

public void removeAll()
Description copied from interface: LwContainer
Removes all child components from this container. The layout manager of this container should be informed by calling componentRemoved method of the manager for every child component that has been removed.
Specified by:
removeAll in interface LwContainer
Overrides:
removeAll in class LwPanel

getSOLocation

public java.awt.Point getSOLocation()
Description copied from interface: ScrollObj
Gets the scroll object location.
Specified by:
getSOLocation in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Returns:
a scroll object location.

setSOLocation

public void setSOLocation(int x,
                          int y)
Description copied from interface: ScrollObj
Sets the specified scroll object location. The method defines a mechanism that will be used to scrool the object.
Specified by:
setSOLocation in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Parameters:
x - the specified x coordinate.
y - the specified y coordinate.

getSOSize

public java.awt.Dimension getSOSize()
Description copied from interface: ScrollObj
Gets the scroll object size. The size is a size that the scroll object wants to have.
Specified by:
getSOSize in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Returns:
a scroll object size.

setScrollMan

public void setScrollMan(ScrollMan m)
Description copied from interface: ScrollObj
Sets the specified scroll manager for the scroll object. The manager reference should be used with the scroll object to notify when the scroll object has been moved or resized.
Specified by:
setScrollMan in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Parameters:
m - the specified scroll manager.

moveContent

public boolean moveContent()
Description copied from interface: ScrollObj
Tests if the scroll component performs scrolling by changing its location or moving view.
Specified by:
moveContent in interface ScrollObj
Following copied from interface: org.zaval.misc.ScrollObj
Returns:
true if the scroll component organizes scrolling by moving its view; otherwise false.

getLayoutOffset

public java.awt.Point getLayoutOffset()
Description copied from interface: LayoutContainer
Returns the offset. The offset can be used with a layout manager to offset child components locations of the container according to the offset values. The offset is represented with java.awt.Point class, the x is offset for x-coordinates and y is offset for y-coordinates. The ability to offset child components with a layout manager is used with the library to organize scrolling.
Specified by:
getLayoutOffset in interface LayoutContainer
Overrides:
getLayoutOffset in class LwPanel
Following copied from interface: org.zaval.lw.LayoutContainer
Returns:
an offset to move children.

getSelected

public LwComponent getSelected()
Gets the selected item component.
Returns:
a selected item component.

perform

protected void perform(int from)
Creates and fires appropriate selection event for list of selection listeners.
Parameters:
from - the selected item index.

notifyScrollMan

protected boolean notifyScrollMan(int index)
Notifies the scroll manager that an item component at the specified index should be fully visible. The scroll manager should scrolls the list view to make the component fully visible if it is necessary.
Parameters:
index - the specified index.
Returns:
true if the item component has not been fully visible; false otherwise.

pageSize

protected int pageSize(int d)
Returns the page size for the specified direction.
Parameters:
d - the specified direction. Use -1 value to specify bottom-up direction and 1 value to specify up-bottom direction.
Returns:
a page size.

getDefaultLayout

protected LwLayout getDefaultLayout()
Description copied from class: LwPanel
Gets the default layout manager that is set with the container during initialization. This implementation of the method returns LwRastLayout as the default layout manager, the layout manager is got as a static object by "layout.raster" key.
Overrides:
getDefaultLayout in class LwPanel
Following copied from class: org.zaval.lw.LwPanel
Returns:
a layout manager.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org