|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.lwuit.Component
public class Component
Base class for all the widgets in the toolkit using the composite pattern in
a similar way to the AWT Container/Component relationship. All components are
potentially animated (need to be registered in Form
).
Form.registerAnimation(com.sun.dtv.lwuit.animations.Animation)
Field Summary | |
---|---|
static int |
BOTTOM
Box-orientation constant used to specify the bottom of a box. |
static int |
BRB_CENTER_OFFSET
Baseline resize behavior constant used to properly align components. |
static int |
BRB_CONSTANT_ASCENT
Baseline resize behavior constant used to properly align components. |
static int |
BRB_CONSTANT_DESCENT
Baseline resize behavior constant used to properly align components. |
static int |
BRB_OTHER
Baseline resize behavior constant used to properly align components. |
static int |
CENTER
Indicates a Component center alignment. |
static int |
LEFT
Box-orientation constant used to specify the left side of a box. |
static int |
RIGHT
Box-orientation constant used to specify the right side of a box. |
static int |
TOP
Box-orientation constant used to specify the top of a box. |
Fields inherited from interface com.sun.dtv.ui.Animated |
---|
ALTERNATING, LOOP, REPEATING |
Constructor Summary | |
---|---|
protected |
Component()
Creates a new instance of Component. |
Method Summary | |
---|---|
void |
addFocusListener(FocusListener l)
Registers interest in receiving callbacks for focus gained events, a focus event is invoked when the component accepts the focus. |
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false. |
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content. |
boolean |
contains(int x,
int y)
Returns true if the given absolute coordinate is contained in the Component. |
protected void |
deinitialize()
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
int |
getAbsoluteX()
Returns the absolute X location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getX(). |
int |
getAbsoluteY()
Returns the absolute Y location based on the component hierarchy, this method calculates a location on the screen for the component rather than a relative location as returned by getY(). |
int |
getAnimationMode()
Obtains the animation mode for this animation. |
int |
getBaseline(int width,
int height)
The baseline for the component text according to which it should be aligned with other components for best visual look. |
int |
getBaselineResizeBehavior()
Returns a constant indicating how the baseline varies with the size of the component. |
int |
getBottomGap()
Returns the gap to be left for the bottom scrollbar on the X axis. |
Rectangle |
getBounds()
Returns the component bounds which is sometimes more convenient than invoking getX/Y/Width/Height. |
Object |
getClientProperty(String key)
Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI's on the fly and need to track the connection between the UI and the data. |
Form |
getComponentForm()
Returns the Component Form or null if this Component is not added to a form. |
int |
getDelay()
Obtains the delay after every image for this animation when running. |
int |
getHeight()
Returns the component height. |
Component |
getNextFocusDown()
Allows us to determine which component will receive focus next when traversing with the down key. |
Component |
getNextFocusLeft()
Allows us to determine which component will receive focus next when traversing with the left key. |
Component |
getNextFocusRight()
Allows us to determine which component will receive focus next when traversing with the right key. |
Component |
getNextFocusUp()
Allows us to determine which component will receive focus next when traversing with the up key. |
Container |
getParent()
Returns the container in which this component is contained. |
int |
getPosition()
Obtains the current position the animation is at the point of time of th method call. |
Dimension |
getPreferredSize()
Returns the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. |
int |
getRepetitionMode()
Returns the repetition mode of this animation in form of a number. |
int |
getScrollAnimationSpeed()
Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode. |
int |
getScrollX()
Indicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component. |
int |
getScrollY()
Indicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component. |
int |
getSideGap()
Returns the gap to be left for the side scrollbar on the Y axis. |
Style |
getStyle()
Returns the Component Style allowing us to manipulate the look of the component. |
String |
getUIID()
Retrieves unique identifier for a component, must be overriden for a component so a style can be applied to the component |
int |
getWidth()
Returns the component width. |
int |
getX()
Returns the current component x location relatively to its parent container. |
int |
getY()
Returns the component y location relatively to its parent container. |
boolean |
handlesInput()
Prevents key events from being grabbed for focus traversal. |
boolean |
hasFocus()
Returns true if the component has focus. |
protected void |
initialize()
Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state |
boolean |
isEnabled()
Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually. |
boolean |
isFocusable()
Returns true if this component can receive focus and is enabled. |
boolean |
isFocusPainted()
Indicates whether focus should be drawn around the component or whether it will handle its own focus painting. |
protected boolean |
isInitialized()
Indicates if the component is in the initialized state, a component is initialized when its initialize method has been
invoked. |
boolean |
isRunning()
Obtains the running mode of an animation. |
boolean |
isScrollableX()
Indicates whether the component should/could scroll on the X axis. |
boolean |
isScrollableY()
Indicates whether the component should/could scroll on the Y axis. |
boolean |
isScrollVisible()
Indicate whether this component scroll is visible. |
boolean |
isSmoothScrolling()
Indicates that scrolling through the component should work as an animation. |
boolean |
isVisible()
Returns whether the component is visible or not. |
void |
jumpTo(int position)
Forces an animation to jump to the position indicated by the parameter. |
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event will call this method. |
void |
keyReleased(int keyCode)
If this Component is focused, the key released event will call this method. |
void |
keyRepeated(int keyCode)
If this Component is focused, the key repeat event will call this method. |
void |
longKeyPress(int keyCode)
If this Component is focused this method is invoked when the user presses and holds the key. |
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering. |
void |
paintBackgrounds(Graphics g)
This method paints all the parents Components Background. |
void |
paintComponent(Graphics g)
Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. |
void |
paintComponent(Graphics g,
boolean background)
Paints this component as a root by going to all the parent components and setting the absolute translation based on coordinates and scroll status. |
void |
pointerDragged(int x,
int y)
If this Component is focused, the pointer dragged event will call this method. |
void |
pointerPressed(int x,
int y)
If this Component is focused, the pointer pressed event will call this method. |
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event will call this method. |
void |
putClientProperty(String key,
Object value)
Client properties allow the association of meta-data with a component, this is useful for some applications that construct GUI's on the fly and need to track the connection between the UI and the data. |
void |
refreshTheme()
Makes sure the component is up to date with the current style object. |
void |
removeFocusListener(FocusListener l)
Deregisters interest in receiving callbacks for focus gained events. |
void |
repaint()
Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread. |
void |
repaint(int x,
int y,
int w,
int h)
Repaint the specified area of this Component. |
void |
requestFocus()
Changes the current component to the focused component, will work only for a component that belongs to a parent form. |
protected void |
scrollRectToVisible(Rectangle rect,
Component coordinateSpace)
Makes sure the component is visible in the scroll if this container is scrollable |
void |
setAnimationMode(int mode)
Sets the animation mode for this animation. |
void |
setCellRenderer(boolean cellRenderer)
Used as an optimization to mark that this component is currently being used as a cell renderer. |
void |
setDelay(int n)
Determines the delay after every image when running this animation. |
void |
setEnabled(boolean enabled)
Indicates whether component is enabled or disabled thus allowing us to prevent a component from receiving input events and indicate so visually. |
void |
setFocus(boolean focused)
This flag doesn't really give focus, its a state that determines what colors from the Style should be used when painting the component. |
void |
setFocusable(boolean focusable)
A simple setter to determine if this Component can get focused. |
void |
setFocusPainted(boolean focusPainted)
Indicates whether focus should be drawn around the component or whether it will handle its own focus painting. |
void |
setHandlesInput(boolean handlesInput)
Prevents key events from being grabbed for focus traversal. |
void |
setHeight(int height)
Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
protected void |
setInitialized(boolean initialized)
Needed to support the concept of initialization. |
void |
setIsScrollVisible(boolean isScrollVisible)
Set whether this component scroll is visible. |
void |
setNextFocusDown(Component nextFocusDown)
Allows us to determine which component will receive focus next when traversing with the down key. |
void |
setNextFocusLeft(Component nextFocusLeft)
Allows us to determine which component will receive focus next when traversing with the left key, this method doesn't affect the general focus behavior. |
void |
setNextFocusRight(Component nextFocusRight)
Allows us to determine which component will receive focus next when traversing with the right key. |
void |
setNextFocusUp(Component nextFocusUp)
Allows us to determine which component will receive focus next when traversing with the up key, this method doesn't affect the general focus behavior. |
void |
setPreferredSize(Dimension d)
Sets the Component Preferred Size, there is no guarantee the Component will be sized at its Preferred Size. |
void |
setRepetitionMode(int n)
Determines how often the animation is repeated once it has been started. |
void |
setScrollAnimationSpeed(int animationSpeed)
Scroll animation speed in milliseconds allowing a developer to slow down or accelerate the smooth animation mode. |
protected void |
setScrollX(int scrollX)
Indicates the X position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the x position of the component. |
protected void |
setScrollY(int scrollY)
Indicates the Y position of the scrolling, this number is relative to the component position and so a position of 0 would indicate the y position of the component. |
protected void |
setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
Indicates the values within the component have changed and preferred size should be recalculated |
void |
setSize(Dimension d)
Sets the Component size, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
void |
setSmoothScrolling(boolean smoothScrolling)
Indicates that scrolling through the component should work as an animation. |
void |
setStyle(Style style)
Changes the Component Style by replacing the Component Style with the given Style. |
void |
setUIID(String uiid)
Sets unique identifier for a component, as it is retrieved using getUIID . |
void |
setVisible(boolean visible)
Toggles visibility of the component. |
void |
setWidth(int width)
Sets the Component width, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
void |
setX(int x)
Sets the Component x location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
void |
setY(int y)
Sets the Component y location relative to the parent container, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
void |
start()
Starts an animation. |
void |
stop()
Stops an animation. |
void |
styleChanged(String propertyName,
Style source)
Invoked to indicate a change in a propertyName of a Style. |
String |
toString()
Overriden to return a useful value for debugging purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BRB_CONSTANT_ASCENT
getBaselineResizeBehavior()
,
Constant Field Valuespublic static final int BRB_CONSTANT_DESCENT
getBaselineResizeBehavior()
,
Constant Field Valuespublic static final int BRB_CENTER_OFFSET
getBaselineResizeBehavior()
,
Constant Field Valuespublic static final int BRB_OTHER
getBaselineResizeBehavior()
,
Constant Field Valuespublic static final int CENTER
public static final int TOP
public static final int LEFT
public static final int BOTTOM
public static final int RIGHT
Constructor Detail |
---|
protected Component()
Method Detail |
---|
public int getX()
setX(int)
public int getY()
setY(int)
public boolean isVisible()
public Object getClientProperty(String key)
key
- the key used for putClientProperty
public void putClientProperty(String key, Object value)
key
- arbitrary key for the propertyvalue
- the value assigned to the given client propertypublic void setVisible(boolean visible)
visible
- true if component is visible; otherwise falsepublic int getWidth()
setWidth(int)
public int getHeight()
setHeight(int)
public void setX(int x)
x
- the current x coordinate of the components origingetX()
public void setY(int y)
y
- the current y coordinate of the components origingetY()
public int getBaseline(int width, int height)
width
- the component widthheight
- the component height
public int getBaselineResizeBehavior()
public void setPreferredSize(Dimension d)
d
- the component dimensiongetPreferredSize()
public Dimension getPreferredSize()
setPreferredSize(com.sun.dtv.lwuit.geom.Dimension)
protected Dimension calcPreferredSize()
getPreferredSize
.
public void setWidth(int width)
width
- the width of the componentgetWidth()
,
setPreferredSize(com.sun.dtv.lwuit.geom.Dimension)
public void setHeight(int height)
height
- the height of the componentgetHeight()
,
setPreferredSize(com.sun.dtv.lwuit.geom.Dimension)
public void setSize(Dimension d)
d
- the component dimensionsetPreferredSize(com.sun.dtv.lwuit.geom.Dimension)
public Container getParent()
public void addFocusListener(FocusListener l)
l
- listener interface implementing the observable patternremoveFocusListener(com.sun.dtv.lwuit.events.FocusListener)
public void removeFocusListener(FocusListener l)
l
- listener interface implementing the observable patternaddFocusListener(com.sun.dtv.lwuit.events.FocusListener)
public void paintBackgrounds(Graphics g)
g
- the graphics objectpublic int getAbsoluteX()
getX()
public int getAbsoluteY()
getY()
public final void paintComponent(Graphics g)
g
- the graphics to paint this Component onpublic final void paintComponent(Graphics g, boolean background)
g
- the graphics to paint this Component onbackground
- if true paints all parents backgroundpublic void paint(Graphics g)
paint
in interface Animation
g
- the component graphicspublic boolean isScrollableX()
public boolean isScrollableY()
public int getScrollX()
public int getScrollY()
public int getBottomGap()
public int getSideGap()
public boolean contains(int x, int y)
x
- the given absolute x coordinatey
- the given absolute y coordinate
public Rectangle getBounds()
getX()
,
getY()
public boolean isFocusable()
public void setFocusable(boolean focusable)
focusable
- indicate whether this component can get focusedpublic boolean isFocusPainted()
public void setFocusPainted(boolean focusPainted)
focusPainted
- indicates whether focus should be drawn around the
componentpublic boolean handlesInput()
public void setHandlesInput(boolean handlesInput)
handlesInput
- indicates whether key events can be grabbed for
focus traversalpublic boolean hasFocus()
setFocus(boolean)
public void setFocus(boolean focused)
focused
- sets the state that determines what colors from the
Style should be used when painting a focused componentrequestFocus()
public Form getComponentForm()
public void repaint()
public void repaint(int x, int y, int w, int h)
x
- the x coordinate of the upper left cornery
- the y coordinate of the upper left cornerw
- the width of the areah
- the height of the areapublic void longKeyPress(int keyCode)
keyCode
- the key code value to indicate a physical key.public void keyPressed(int keyCode)
keyCode
- the key code value to indicate a physical key.public void keyReleased(int keyCode)
keyCode
- the key code value to indicate a physical key.public void keyRepeated(int keyCode)
keyCode
- the key code value to indicate a physical key.public int getScrollAnimationSpeed()
setScrollAnimationSpeed(int)
public void setScrollAnimationSpeed(int animationSpeed)
animationSpeed
- scroll animation speed in millisecondsgetScrollAnimationSpeed()
public boolean isSmoothScrolling()
public void setSmoothScrolling(boolean smoothScrolling)
smoothScrolling
- indicates if a component uses smooth scrollingpublic void pointerDragged(int x, int y)
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerPressed(int x, int y)
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
x
- the pointer x coordinatey
- the pointer y coordinatepublic Style getStyle()
setStyle(com.sun.dtv.lwuit.plaf.Style)
public void setStyle(Style style)
style
- the component Style objectgetStyle()
public void requestFocus()
public String toString()
toString
in class Object
public void refreshTheme()
public boolean animate()
Animation
animate
in interface Animation
public void setCellRenderer(boolean cellRenderer)
cellRenderer
- indicate whether this component is currently being
used as a cell rendererpublic boolean isScrollVisible()
public void setIsScrollVisible(boolean isScrollVisible)
isScrollVisible
- Indicate whether this component scroll is visiblepublic void styleChanged(String propertyName, Style source)
StyleListener
styleChanged
in interface StyleListener
propertyName
- the property name that was changedsource
- The changed Style objectpublic Component getNextFocusDown()
setNextFocusDown(com.sun.dtv.lwuit.Component)
public void setNextFocusDown(Component nextFocusDown)
nextFocusDown
- the Component which will receive focus next when traversing
with the down keygetNextFocusDown()
public Component getNextFocusUp()
setNextFocusUp(com.sun.dtv.lwuit.Component)
public void setNextFocusUp(Component nextFocusUp)
nextFocusUp
- the Component which will receive focus next when traversing
with the up keygetNextFocusUp()
public Component getNextFocusLeft()
setNextFocusLeft(com.sun.dtv.lwuit.Component)
public void setNextFocusLeft(Component nextFocusLeft)
nextFocusLeft
- the Component which will receive focus next when traversing
with the left keygetNextFocusLeft()
public Component getNextFocusRight()
setNextFocusRight(com.sun.dtv.lwuit.Component)
public void setNextFocusRight(Component nextFocusRight)
nextFocusRight
- the Component which will receive focus next when traversing
with the right keygetNextFocusRight()
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- boolean to indicated whether the component should be enables
or notpublic void start()
start()
causes a restart of the animation.
start
in interface Animated
public void stop()
stop()
has no effect.
stop
in interface Animated
public boolean isRunning()
isRunning
in interface Animated
public void jumpTo(int position)
jumpTo
in interface Animated
position
- the index in the row of images building the animation to which
the animation is forced to jumppublic int getPosition()
getPosition
in interface Animated
public void setRepetitionMode(int n)
setRepetitionMode
in interface Animated
n
- number of repetitions to be determined. This can be any number
larger than zero or LOOP
alternatively.
LOOP means that the animation runs in an endless loop until the stop()
method has been called.getRepetitionMode()
public int getRepetitionMode()
getRepetitionMode
in interface Animated
LOOP
which means the animation runs in an
endless loop until the stop()
method has
been called.setRepetitionMode(int)
public void setDelay(int n)
setDelay
in interface Animated
n
- delay in millisecondsgetDelay()
public int getDelay()
getDelay
in interface Animated
setDelay(int)
public void setAnimationMode(int mode)
setAnimationMode
in interface Animated
mode
- the animation mode. Possible values are: REPEATING
and ALTERNATING
.getAnimationMode()
public int getAnimationMode()
getAnimationMode
in interface Animated
REPEATING
and ALTERNATING
.setAnimationMode(int)
protected void initialize()
protected void deinitialize()
initialize
method.
protected void setInitialized(boolean initialized)
initialize
method
for details.
initialized
- initialization state to be setprotected boolean isInitialized()
initialize
method has been
invoked. This method has to be invoked before showing the
component to the user.
public String getUIID()
public void setUIID(String uiid)
getUIID
.
uiid
- the uiid to be setprotected void scrollRectToVisible(Rectangle rect, Component coordinateSpace)
rect
- the rectangle that need to be visiblecoordinateSpace
- the component according to whose coordinates
rect is defined. Rect's x/y are relative to that component
(they are not absolute).protected void setScrollX(int scrollX)
scrollX
- the X position of the scrollingprotected void setScrollY(int scrollY)
scrollY
- the Y position of the scrollingprotected void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)
shouldCalcPreferredSize
- indicate whether this component need to
recalculate its preferred size
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |