net.xoetrope.awt
Class AwtWidgetAdapter

java.lang.Object
  extended by net.xoetrope.xui.WidgetAdapter
      extended by net.xoetrope.awt.AwtWidgetAdapter

public class AwtWidgetAdapter
extends WidgetAdapter

    

Adapts the abstract component definition used by the common xui (net.xoetrope.xui) package to the concrete definition of an AWT component.

Copyright (c) Xoetrope Ltd., 1998-2005

License: see license.txt


Field Summary
 
Fields inherited from class net.xoetrope.xui.WidgetAdapter
instance
 
Method Summary
 void add(java.lang.Object container, java.lang.Object comp)
          Add a component to the container
 void add(java.lang.Object container, java.lang.Object comp, java.lang.Object constraint)
          Add a component to the container using a layout manager constraint
 void doLayout(java.lang.Object component)
          Request that the container updates its layout
 java.lang.Object getComponent(java.lang.Object container, int i)
          Get the child component at a specific index within the container.
 int getComponentCount(java.lang.Object container)
          Get the number of child components owned by this component, assuming that the component is a container.
 java.lang.Object[] getComponents(java.lang.Object container)
          Get the children.
 int getHeight(java.lang.Object component)
          Get the component height
static WidgetAdapter getInstance()
          Get an instance of this adapter.
 java.lang.Object getLayout(java.lang.Object component)
          Get the layout manager used by the container
 java.lang.Object getLocation(java.lang.Object component)
          Get the location of the component
 java.lang.String getName(java.lang.Object component)
          Get the name of the object
 java.lang.Object getParent(java.lang.Object component)
          Get the parent/owner object
 java.lang.Object getSize(java.lang.Object component)
          Get the size of the component
 int getWidth(java.lang.Object component)
          Get the component width
 int getX(java.lang.Object component)
          Get the location of the component's left (X) edge
 int getY(java.lang.Object component)
          Get the location of the component's top (Y) edge
 boolean isContainer(java.lang.Object container)
          Check if the component is a container object, that is that it is capable of containing children
 boolean isVisible(java.lang.Object component)
          Is the component visible?
 void remove(java.lang.Object component, java.lang.Object obj)
          Remove a component from the container
 void removeAll(java.lang.Object component)
          Remove all components from the container
 void repaint(java.lang.Object component)
          Request that the component repaints itself
 void setBackground(java.lang.Object component, java.lang.Object c)
          Set the background color
 void setBounds(java.lang.Object component, int x, int y, int w, int h)
          Set the current bounds for the component
 void setCursor(java.lang.Object component, java.lang.Object cursor)
          Set the current cursor for the component
 void setEnabled(java.lang.Object component, boolean b)
          Set the enabled state of the component
 void setFont(java.lang.Object component, java.lang.Object f)
          Set the font
 void setForeground(java.lang.Object component, java.lang.Object c)
          Set the foreground color
 void setLayout(java.lang.Object component, java.lang.Object lm)
          Set the layout manager for the container
 void setLocation(java.lang.Object component, int x, int y)
          Set the current location of the component
 void setName(java.lang.Object component, java.lang.String name)
          Set the name of the component
 void setSize(java.lang.Object component, int w, int h)
          Set the size of the component
 void setVisible(java.lang.Object component, boolean state)
          Set the component visiblity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static WidgetAdapter getInstance()
Get an instance of this adapter. The adapter is itself stateless so only a single instance of the class is required.

Returns:
the adapter instance

getName

public java.lang.String getName(java.lang.Object component)
Get the name of the object

Specified by:
getName in class WidgetAdapter
Parameters:
component - The component instance
Returns:
The name

getComponentCount

public int getComponentCount(java.lang.Object container)
Get the number of child components owned by this component, assuming that the component is a container.

Specified by:
getComponentCount in class WidgetAdapter
Parameters:
container - the container instance
Returns:
the number of children

getComponents

public java.lang.Object[] getComponents(java.lang.Object container)
Get the children. Assumes that the object is a container

Specified by:
getComponents in class WidgetAdapter
Parameters:
container - the container instance
Returns:
an array of the child components

getComponent

public java.lang.Object getComponent(java.lang.Object container,
                                     int i)
Get the child component at a specific index within the container. Assumes that the object is a container

Specified by:
getComponent in class WidgetAdapter
Parameters:
container - the container instance
i - the component index
Returns:
an array of the child components

isVisible

public boolean isVisible(java.lang.Object component)
Is the component visible?

Specified by:
isVisible in class WidgetAdapter
Parameters:
component - the component instance
Returns:
true if the component is visible

setVisible

public void setVisible(java.lang.Object component,
                       boolean state)
Set the component visiblity

Specified by:
setVisible in class WidgetAdapter
Parameters:
component - the component instance
state - true if the component is to be made visible

remove

public void remove(java.lang.Object component,
                   java.lang.Object obj)
Remove a component from the container

Specified by:
remove in class WidgetAdapter
Parameters:
component - the container instance
obj - the component to remove

removeAll

public void removeAll(java.lang.Object component)
Remove all components from the container

Specified by:
removeAll in class WidgetAdapter
Parameters:
component - the container instance

add

public void add(java.lang.Object container,
                java.lang.Object comp)
Add a component to the container

Specified by:
add in class WidgetAdapter
Parameters:
container - the container instance
comp - the component instance

add

public void add(java.lang.Object container,
                java.lang.Object comp,
                java.lang.Object constraint)
Add a component to the container using a layout manager constraint

Specified by:
add in class WidgetAdapter
Parameters:
container - the container instance
comp - the component instance
constraint - the layout constraint

setLayout

public void setLayout(java.lang.Object component,
                      java.lang.Object lm)
Set the layout manager for the container

Specified by:
setLayout in class WidgetAdapter
Parameters:
component - the container instance
lm - the LayoutManager instance

getLayout

public java.lang.Object getLayout(java.lang.Object component)
Get the layout manager used by the container

Specified by:
getLayout in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the LayoutManager instance

doLayout

public void doLayout(java.lang.Object component)
Request that the container updates its layout

Specified by:
doLayout in class WidgetAdapter
Parameters:
component - the container instance

setForeground

public void setForeground(java.lang.Object component,
                          java.lang.Object c)
Set the foreground color

Specified by:
setForeground in class WidgetAdapter
Parameters:
component - the container instance
c - the color

setBackground

public void setBackground(java.lang.Object component,
                          java.lang.Object c)
Set the background color

Specified by:
setBackground in class WidgetAdapter
Parameters:
component - the container instance
c - the color

setFont

public void setFont(java.lang.Object component,
                    java.lang.Object f)
Set the font

Specified by:
setFont in class WidgetAdapter
Parameters:
component - the container instance
f - the font

getSize

public java.lang.Object getSize(java.lang.Object component)
Get the size of the component

Specified by:
getSize in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the size (an instance of java.awt.Dimension) of the object

getParent

public java.lang.Object getParent(java.lang.Object component)
Get the parent/owner object

Specified by:
getParent in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the parent Component

setEnabled

public void setEnabled(java.lang.Object component,
                       boolean b)
Set the enabled state of the component

Specified by:
setEnabled in class WidgetAdapter
Parameters:
component - the container instance
b - true to enable

setCursor

public void setCursor(java.lang.Object component,
                      java.lang.Object cursor)
Set the current cursor for the component

Specified by:
setCursor in class WidgetAdapter
Parameters:
component - the container instance
cursor - the cursor object

setBounds

public void setBounds(java.lang.Object component,
                      int x,
                      int y,
                      int w,
                      int h)
Set the current bounds for the component

Specified by:
setBounds in class WidgetAdapter
Parameters:
component - the container instance
x - the left/x edge coordinates
y - the top/y edge coordinates
w - the width dimension
h - the height dimension

setSize

public void setSize(java.lang.Object component,
                    int w,
                    int h)
Set the size of the component

Specified by:
setSize in class WidgetAdapter
Parameters:
component - the container instance
w - the width dimension
h - the height dimension

setLocation

public void setLocation(java.lang.Object component,
                        int x,
                        int y)
Set the current location of the component

Specified by:
setLocation in class WidgetAdapter
Parameters:
component - the container instance
x - the left/x edge coordinates
y - the top/y edge coordinates

getLocation

public java.lang.Object getLocation(java.lang.Object component)
Get the location of the component

Specified by:
getLocation in class WidgetAdapter
Parameters:
component - the component instance
Returns:
the AWT Point object indicating the location

getX

public int getX(java.lang.Object component)
Get the location of the component's left (X) edge

Specified by:
getX in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the x coordinate

getY

public int getY(java.lang.Object component)
Get the location of the component's top (Y) edge

Specified by:
getY in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the y coordinate

getWidth

public int getWidth(java.lang.Object component)
Get the component width

Specified by:
getWidth in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the width

getHeight

public int getHeight(java.lang.Object component)
Get the component height

Specified by:
getHeight in class WidgetAdapter
Parameters:
component - the container instance
Returns:
the height

setName

public void setName(java.lang.Object component,
                    java.lang.String name)
Set the name of the component

Specified by:
setName in class WidgetAdapter
Parameters:
component - the container instance
name - the new component name

repaint

public void repaint(java.lang.Object component)
Request that the component repaints itself

Specified by:
repaint in class WidgetAdapter
Parameters:
component - the container instance

isContainer

public boolean isContainer(java.lang.Object container)
Check if the component is a container object, that is that it is capable of containing children

Specified by:
isContainer in class WidgetAdapter
Parameters:
container - the container instance
Returns:
true if the object is a container