BOTTOM_ALIGNMENT
public static final float BOTTOM_ALIGNMENT
CENTER_ALIGNMENT
public static final float CENTER_ALIGNMENT
LEFT_ALIGNMENT
public static final float LEFT_ALIGNMENT
RIGHT_ALIGNMENT
public static final float RIGHT_ALIGNMENT
TOP_ALIGNMENT
public static final float TOP_ALIGNMENT
_alignmentX
protected float _alignmentX
the X-alignment of this component
_alignmentY
protected float _alignmentY
the Y-alignment of this component
_background
protected Color _background
If the background color is null, this component inherits the
background color of its parent Container.
_cursesColor
protected int _cursesColor
The number of this component's color-pair, as computed by the
ncurses COLOR_PAIR macro. This is set when the component
is added to a container and whenever the colors are changed after
that, so we don't have to re-determine it every time we draw the
component.
A value of -1 indicates that the color-pair number needs to be
recomputed.
_enabled
protected boolean _enabled
This flag is true if this component can react to user input.
_focusListeners
protected Vector _focusListeners
A list of FocusListeners registered for this component.
_foreground
protected Color _foreground
If the foreground color is null, this component inherits the
foreground color of its parent Container.
_keyListeners
protected Vector _keyListeners
A list of KeyListeners registered for this component.
_origin
protected Point _origin
The coordinates of the top-left corner of the component, relative to
its parent container.
_parent
protected WeakReference _parent
A WeakReference to the Container (e.g Window, Panel or Dialog)
that contains us. The reason that we use a WeakReference is to
allow the parent to be garbage-collected when there are no more
strong references to it.
_visible
protected boolean _visible
A flag that determines whether this component should be displayed
(if its parent is displayed).
This flag is set to true by default, except for Window which is
initially invisible.
addFocusListener
public void addFocusListener(FocusListener fl_)
Register a FocusListener object for this component.
addKeyListener
public void addKeyListener(KeyListener kl_)
Register a KeyListener object for this component.
contains
public boolean contains(Point p)
Checks whether this component "contains" the specified point,
where the point's x and y coordinates are defined to be relative
to the top left corner of the parent Container.
contains
public boolean contains(int x,
int y)
debug
public abstract void debug(int level_)
draw
public abstract void draw()
To be implemented by concrete subclasses.
getAlignmentX
public float getAlignmentX()
Returns the alignment along the X axis. This indicates how the
component would like to be aligned relative to ther components.
0 indicates left-aligned, 0.5 indicates centered and 1 indicates
right-aligned.
getAlignmentY
public float getAlignmentY()
Returns the alignment along the Y axis. This indicates how the
component would like to be aligned relative to ther components.
0 indicates top-aligned, 0.5 indicates centered and 1 indicates
bottom-aligned.
getAncestorWindow
public Window getAncestorWindow()
Get the Window that contains this component.
getBackground
public Color getBackground()
Get the background color of this component. If it is null,
the component will inherit the background color of its
parent container.
getBounds
public Rectangle getBounds()
Get the bounding rectangle of this component, relative to
the origin of its parent Container.
getCursesColor
public int getCursesColor()
getForeground
public Color getForeground()
Get the foreground color of this component. If it is null,
the component will inherit the foreground color of its
parent container.
getHeight
public abstract int getHeight()
getLocation
public Point getLocation()
getLocationOnScreen
public Point getLocationOnScreen()
Return the absolute coordinates of this component's origin.
Note that Window (which is a subclass of Container)
has a _parent value of null, but it overrides this method.
getName
public String getName()
Returns the name of the component.
getParent
public Container getParent()
Get the parent container of this component. Can return null if the
component has no parent.
getWidth
public abstract int getWidth()
hasFocus
public boolean hasFocus()
Returns true if this Component has the keyboard input focus.
hide
public void hide()
This method has been replaced by
setVisible(boolean)
.
invalidate
public void invalidate()
Marks the component and all parents above it as needing to be laid out
again. This method is overridden by Container.
isDisplayed
public boolean isDisplayed()
A component is "displayed" if it is contained within a displayed Window.
Even though it may be "displayed", it may be obscured by other
Windows that are on top of it; and it may not be visible to the user
because the _visible
flag may be false.
isEnabled
public boolean isEnabled()
Determine whether this component can react to user input.
isFocusTraversable
public boolean isFocusTraversable()
Indicates whether this component can be traversed using Tab or
Shift-Tab keyboard focus traversal. If this
method returns "false" it can still request focus using requestFocus(),
but it will not automatically be assigned focus during keyboard focus
traversal.
isTotallyObscured
public boolean isTotallyObscured()
Return true if this component is totally obscured by one or more
windows that are stacked above it.
isValid
public boolean isValid()
Determines whether this component has a valid layout. A component
is valid when it is correctly sized and positioned within its
parent container and all its children (in the case of a Container)
are also valid. The default implementation returns true; this method
is overridden by Container.
isVisible
public boolean isVisible()
Returns true if this component is displayed when its parent
container is displayed.
minimumSize
public abstract Dimension minimumSize()
processEvent
protected void processEvent(AWTEvent evt_)
Process events that are implemented by all components.
This can be overridden by subclasses, to handle custom events.
processFocusEvent
public void processFocusEvent(FocusEvent fe_)
Invoke all the FocusListener callbacks that may have been registered
for this component.
processKeyEvent
public void processKeyEvent(KeyEvent ke_)
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.
processMouseEvent
public void processMouseEvent(MouseEvent e)
Process a MouseEvent that was generated by clicking the mouse
somewhere inside this component.
repaint
public void repaint()
Causes this component to be repainted as soon as possible
(this is done by posting a RepaintEvent onto the system queue).
requestFocus
public 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.
requestSync
public void requestSync()
Causes a SyncEvent to be posted onto the AWT queue, thus requesting
a refresh of the physical screen.
setBackground
public void setBackground(Color color_)
Set the background color of this component.
setBounds
public void setBounds(Rectangle bounds)
setBounds
public void setBounds(int top_,
int left_,
int bottom_,
int right_)
setEnabled
public void setEnabled(boolean flag_)
Enable this component to react to user input. Components
are enabled by default.
setForeground
public void setForeground(Color color_)
Set the foreground color of this component.
setLocation
public void setLocation(Point origin_)
setLocation
public void setLocation(int x_,
int y_)
setName
public void setName(String name_)
Sets the name of the component.
setParent
public void setParent(Container container_)
Set the parent container of this component. This is intended to
be called by Container objects only.
Note that we use a WeakReference so that the parent can be garbage-
collected when there are no more strong references to it.
setVisible
public void setVisible(boolean visible_)
Shows or hides this component depending on the value of the
parameter visible_
show
public void show()
This method has been replaced by
setVisible(boolean)
.
validate
public void validate()
Ensures that this component is laid out correctly.
This method is primarily intended to be used on instances of
Container. The default implementation does nothing; it is
overridden by Container.
validateCursesColor
public void validateCursesColor()
Compute the component's ncurses color-pair from its foreground
and background colors. If either color is null, it means that the
component has not been added to a container yet, so don't do
anything (the colors will be validated when the component is added
to the container).