The super class for all UIs.
The maximumSize and minimumSize are the component's represent max or min size.
You can set a Component's size max than its maximumSize, but when it was drawed,
it will not max than its maximumSize.Just as its maximumSize and posited itself
in that size dimension you just setted. The position is relative to getAlignmentX
and getAlignmentY
.
static public ON_CREATED:String
static public ON_DESTROY:String
static public ON_PAINT:String
static public ON_SHOWN:String
static public ON_HIDDEN:String
static public ON_MOVED:String
static public ON_RESIZED:String
static public ON_STATE_CHANGED:String
static public ON_PRESS:String
static public ON_RELEASE:String
static public ON_RELEASEOUTSIDE:String
static public ON_ROLLOVER:String
static public ON_ROLLOUT:String
static public ON_CLICKED:String
static public ON_SETFOCUS:String
static public ON_KILLFOCUS:String
static public MAX_CLICK_INTERVAL:Number
static public creater:ElementCreater [Read Only]
public function getID():Object
Returns the component's id.(Type Object(usually a string)) Each component have their owner different id. This id is generated by Component constructor, you should not to modify its value.
public function getUIClassID():String
Returns the UIDefaults
key used to
look up the name of the org.aswing.plaf.ComponentUI
class that defines the look and feel
for this component. Most applications will never need to
call this method. Subclasses of Component
that support
pluggable look and feel should override this method to
return a UIDefaults
key that maps to the
ComponentUI
subclass that defines their look and feel.
the UIDefaults
key for a
ComponentUI
subclass
public function setName(name:String):Void
This just for test, every component's root_mc name start with the name set here. Different Component can have same name, suggest every type of component have a name same to his class name, or you want to test, you can set any name to any component, but besure that you'd better set the same before it added to a container.
public function updateUI():Void
Resets the UI property to a value from the current look and feel.
Component
subclasses must override this method
like this:
public void updateUI() { setUI((SliderUI)UIManager.getUI(this); }
public function setUIProperty(name:String, value):Void
Sets the UI delegated property value.
If the property value in component is undefined, then the delegated value
will be used.
name | the property name |
value | the value |
public function getUIProperty(name:String)
Returns the UI delegated property value.
name | the property name |
the value
public function addTo(parent:Container):Void
Create and add this component to a Container. the method must only can call in a Container's method, else the Container's layout maybe wrong and Container event will not be called If component was added to a displayable container it could be diplayable. else it could be not diplayable.
public function removeFromContainer():Void
Destroy and remove this component from its parent(Container). If it has not parent, call the destroy method to remove it.
public function destroy():Void
Destroy(Remove) the component's source movie clips.
After this, this component was undisplayable, has no parent, has no child...
When a displayable component be destroied, the event onDestroy will be generated.
Note:You'd better not call this method directly, if you want to remove a compoent, call
its method removeFromContainer, it will notify its parent to remove and then destroy it.
public function repaint():Void
Redraws the component face next frame.This method can be called often, so it needs to execute quickly.
public function getPaintBounds():Rectangle
Returns the bounds that component should paint in.
This is same to some paint method param b:Rectangle.
So if you want to paint outside those method, you can get the
rectangle from here.
If this component has a little maximum size, and then current
size is larger, the bounds return from this method will be related
to getAlignmentX
,
getAlignmentY
and
getMaximumSize
.
return the rectangle that component should paint in.
public function revalidate():Void
Supports deferred automatic layout.
Calls invalidate
and then adds this component's
validateRoot
to a list of components that need to be
validated. Validation will occur after all currently pending
events have been dispatched. In other words after this method
is called, the first validateRoot (if any) found when walking
up the containment hierarchy of this component will be validated.
By default, JWindow
, JScrollPane
,
and JTextField
return true
from isValidateRoot
.
This method will or will not automatically be called on this component when a property value changes such that size, location, or internal layout of this component has been affected.But invalidate will do called after thats method, so you want to get the contents of the GUI to update you should call this method.
public function invalidate():Void
Invalidates this component. This component and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.
public function validate():Void
Ensures that this component has a valid layout. This method is
primarily intended to operate on instances of Container
.
public function isValidateRoot():Boolean
If this method returns true, revalidate calls by descendants of this component will cause the entire tree beginning with this root to be validated. Returns false by default. JScrollPane overrides this method and returns true.
always returns false
public function isValid():Boolean
Determines whether this component is valid. A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid. In order to account for peers' size requirements, components are invalidated before they are first shown on the screen. By the time the parent container is fully realized, all its components will be valid.
true
if the component is valid, false
otherwise
public function doLayout():Void
layout this component. Locate this component to its location and visible its visible.
public function setClipMasked(m:Boolean):Void
Sets whether the component clip should be masked by its bounds. By default it is true.
m | whether the component clip should be masked. |
public function isClipMasked():Boolean
Returns whether the component clip should be masked by its bounds. By default it is true.
whether the component clip should be masked.
public function setVisible(v:Boolean):Void
Set a component to be hide or shown. If a component was hide, some laterly operation may not be done, they will be done when next shown, ex: repaint, doLayout .... So suggest you dont changed a component's visible frequently.
public function isDisplayable():Boolean
Determines whether this component is displayable.
A component is displayable when it is connected to a native screen resource.
A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable.
A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable.
public function setFont(newFont:ASFont):Void
set the text format for this component.
this method will cause a repaint method call.
If you change to a larger or smaller size format, you may need to call
this component's parent to doLayout to make this layout well.
public function setOpaque(b:Boolean):Void
If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through.
The default value of this property is false for JComponent
.
However, the default value for this property on most standard
Component
subclasses (such as JButton
and
JTree
) is look-and-feel dependent.
b | true if this component should be opaque |
public function isOpaque():Boolean
Returns true if this component is completely opaque.
An opaque component paints every pixel within its rectangular bounds. A non-opaque component paints only a subset of its pixels or none at all, allowing the pixels underneath it to "show through". Therefore, a component that does not fully paint its pixels provides a degree of transparency.
Subclasses that guarantee to always completely paint their contents should override this method and return true.
true if this component is completely opaque
public function setBounds():Void
setBounds(bounds:Rectangle)
setBounds(x:Number, y:Number, width:Number, height:Number)
public function getBounds(b:Rectangle):Rectangle
Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.
Stores the bounds value of this component into "return value" b and returns b. If b is null or undefined a new Rectangle object is allocated.
b | the return value, modified to the component's bounds. |
public function setLocation():Void
setLocation(x:Number, y:Number)
setLocation(p:Point)
Set the component's location, if it is diffs from old location, invalidate it to wait validate. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent.
public function setGlobalLocation():Void
setGlobalLocation(x:Number, y:Number)
setGlobalLocation(p:Point)
Set the component's location in global coordinate.
public function getLocation(p:Point):Point
getLocation(p:Point)
getLocation()
Stores the location value of this component into "return value" p and returns p. If p is null or undefined a new Point object is allocated.
p | the return value, modified to the component's location. |
public function getGlobalLocation(p:Point):Point
getGlobalLocation(p:Point)
getGlobalLocation()
Stores the global location value of this component into "return value" p and returns p. If p is null or undefined a new Point object is allocated.
p | the return value, modified to the component's global location. |
public function setSize():Void
setSize(width:Number, height:Number)
setSize(dim:Dimension)
Set the component's size, the width and height all will be setted to not less than zero,
then set the size.
You can set a Component's size max than its maximumSize, but when it was drawed,
it will not max than its maximumSize.Just as its maximumSize and posited itself
in that size dimension you just setted. The position is relative to getAlignmentX
public function getSize(s:Dimension):Dimension
getSize(s:Dimension)
getSize()
Stores the size value of this component into "return value" s and returns s. If s is null or undefined a new Dimension object is allocated.
public function setToolTipText(t:String):Void
Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.
t | the string to display; if the text is null, the tool tip is turned off for this component |
public function getToolTipText():String
Returns the tooltip string that has been set with setToolTipText.
the text of the tool tip
public function getAlignmentX():Number
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to its size when its size is maxer than its maximumSize. The value should be a number between 0 and 1 where 0 represents alignment start from left, 1 is aligned the furthest away from the left, 0.5 is centered, etc.
the alignment along the x axis, 0 by default
public function getAlignmentY():Number
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to its size when its size is maxer than its maximumSize. The value should be a number between 0 and 1 where 0 represents alignment start from top, 1 is aligned the furthest away from the top, 0.5 is centered, etc.
the alignment along the y axis, 0 by default
public function setMinimumSize():Void
setMinimumSize(d:Dimension)
setMinimumSize(width:Number, height:Number)
Set the minimumSize, then the component's minimumSize is specified. otherwish getMinimumSize will can the count method.
public function setMaximumSize():Void
setMaximumSize(d:Dimension)
setMaximumSize(width:Number, height:Number)
Set the maximumSize, then the component's maximumSize is specified. otherwish getMaximumSize will can count method.
public function setPreferredSize():Void
setPreferredSize(d:Dimension)
setPreferredSize(width:Number, height:Number)
Set the preferredSize, then the component's preferredSize is specified. otherwish getPreferredSize will count method.
public function setEnabled(b:Boolean):Void
Enable or disable the component.
If a component is disabled, it will not fire mouse events. And some component will has different interface when enabled or disabled. But it will also eat mouse clicks when disable even it will not fire mouse events.
b | true to enable the component, false to disable it. |
public function setTriggerEnabled(b:Boolean):Void
Sets whether the component trigger be enabled.
If it is enabled, it will fire events when mouse roll, press on the component, of course it eats the mouse clicks so its container may not got clicks. If it is disabled, it will not fire events when mouse roll press on, And the importance is that it will not eat the mouse clicks.
Default value is true.
b | true to enable trigger, false to disable it. |
public function setUseHandCursor(b:Boolean):Void
Sets whether use hand cursor when mouse move on this component. Default is false.
b | true to use hand cursor when mouse move on this component, false not. |
public function createMovieClip(nameStart:String, depth:Number):MovieClip
Creates and returns an empty MovieClip from the Component's target MovieClip.
Note that if you create an new MC for a border or icon you should remove them in your uninstallXXx method of them.
nameStart | the prefix of the created MovieClip's name. |
depth | the depth of the created MovieClip. |
public function attachMovieClip(linkage:String, nameStart:String, depth:Number):MovieClip
Attaches and returns a MovieClip from the Component's target MovieClip.
Note that if you attach an new MC for a border or icon you should remove them in your uninstallXXx method of them.
linkage | the linkage id of the MovieClip in your Symbol Library. |
nameStart | the prefix of the attached MovieClip's name. |
depth | the depth of the attached MovieClip. |
public function createTextField(nameStart:String, depth:Number):TextField
Creates and returns an textfiled from the Component's target MovieClip.
Note that if you create an new textfiled for a border or icon you should remove them in your uninstallXXx method of them.
nameStart | the prefix of the created textfiled's name. |
depth | the depth of the created textfiled. |
public function getDepth():Number
Returns the component's mc's depth. It will return undefined when this component is displayable.
public function swapDepths(target):Void
Swap the component's mc's depth. This is only effective when this component is displayable.
public function bringToTopDepth():Void
Brings this component at top depth of all brothers. This is only effective when this component is displayable.
public function bringToBottomDepth():Void
Brings this component at bottom depth of all brothers. This is only effective when this component is displayable.
public function getMousePosition():Point
Returns the position of the mouse in the Component area. (0, 0) is the top left of the component bounds.
the position of the mouse in the Component area.