Class org.aswing.Component

Description

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.

See Also

Field Index

creater, MAX_CLICK_INTERVAL, ON_CLICKED, ON_CREATED, ON_DESTROY, ON_HIDDEN, ON_KILLFOCUS, ON_MOVED, ON_PAINT, ON_PRESS, ON_RELEASE, ON_RELEASEOUTSIDE, ON_RESIZED, ON_ROLLOUT, ON_ROLLOVER, ON_SETFOCUS, ON_SHOWN, ON_STATE_CHANGED

Inherited from EventDispatcher

Method Index

addTo(), attachMovieClip(), bringToBottomDepth(), bringToTopDepth(), componentToGlobal(), createMovieClip(), createTextField(), destroy(), doLayout(), getAlignmentX(), getAlignmentY(), getBackground(), getBorder(), getBounds(), getDepth(), getFont(), getForeground(), getGlobalLocation(), getGraphics(), getHeight(), getID(), getInsets(), getLocation(), getMaximumSize(), getMinimumSize(), getMousePosition(), getName(), getPaintBounds(), getParent(), getPreferredSize(), getSize(), getToolTipText(), getUIClassID(), getUIProperty(), getWidth(), getX(), getY(), globalToComponent(), hitTest(), invalidate(), isClipMasked(), isDisplayable(), isEnabled(), isFocusable(), isFocused(), isOpaque(), isTriggerEnabled(), isUseHandCursor(), isValid(), isValidateRoot(), isVisible(), paintImmediately(), removeFromContainer(), repaint(), revalidate(), revalidateIfNecessary(), setAlignmentX(), setAlignmentY(), setBackground(), setBorder(), setBounds(), setClipMasked(), setEnabled(), setFocus(), setFocusable(), setFont(), setForeground(), setGlobalLocation(), setLocation(), setMaximumSize(), setMinimumSize(), setName(), setOpaque(), setPreferredSize(), setSize(), setToolTipText(), setTriggerEnabled(), setUIProperty(), setUseHandCursor(), setVisible(), swapDepths(), toString(), updateUI(), validate()

Inherited from EventDispatcher

Field Detail

ON_CREATED

static public ON_CREATED:String
When the component was created due to displayable
onCreated Event{source:Component}

ON_DESTROY

static public ON_DESTROY:String
When the component was removed due to undisplayable
onDestroy Event{source:Component}

ON_PAINT

static public ON_PAINT:String
When the component painting. onPaint Event{source:Component}

ON_SHOWN

static public ON_SHOWN:String
onShown Event{source:Component}

ON_HIDDEN

static public ON_HIDDEN:String
onHidden Event{source:Component}

ON_MOVED

static public ON_MOVED:String
onMoved Event{source:Component, oldPos:Point, newPos:Point}

ON_RESIZED

static public ON_RESIZED:String
onResized Event{source:Component, oldSize:Dimension, newSize:Dimension}

ON_STATE_CHANGED

static public ON_STATE_CHANGED:String
When the component's state changed. This is not implemented by every components. If a component implemented to fire this event, it should declare this property again.
onStateChanged Event{source:Component}

See Also

ON_PRESS

static public ON_PRESS:String
just actived component has this event. onPress Event{source:Component}

ON_RELEASE

static public ON_RELEASE:String
just actived component has this event. onRelease Event{source:Component}

ON_RELEASEOUTSIDE

static public ON_RELEASEOUTSIDE:String
just actived component has this event. onReleaseOutSide Event{source:Component}

ON_ROLLOVER

static public ON_ROLLOVER:String
just actived component has this event. onRollOver Event{source:Component}

ON_ROLLOUT

static public ON_ROLLOUT:String
just actived component has this event. onRollOut Event{source:Component}

ON_CLICKED

static public ON_CLICKED:String
just actived component has this event. onClicked Event{source:Component, clickCount:Number}

ON_SETFOCUS

static public ON_SETFOCUS:String

ON_KILLFOCUS

static public ON_KILLFOCUS:String

MAX_CLICK_INTERVAL

static public MAX_CLICK_INTERVAL:Number

creater

static public creater:ElementCreater [Read Only]

Method Detail

getID

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.

getUIClassID

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.

Return

the UIDefaults key for a ComponentUI subclass

See Also

setName

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.

See Also

getName

public function getName():String

See Also

updateUI

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);
   }
  

See Also

setUIProperty

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.

Parameters

namethe property name
valuethe value

getUIProperty

public function getUIProperty(name:String)

Returns the UI delegated property value.

Parameters

namethe property name

Return

the value

addTo

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.

See Also

removeFromContainer

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.

See Also

destroy

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.

See Also

getParent

public function getParent():Container

setBorder

public function setBorder(b:Border):Void

getBorder

public function getBorder():Border

getInsets

public function getInsets():Insets

getGraphics

public function getGraphics():Graphics

Returns a graphics of the Component.

repaint

public function repaint():Void

Redraws the component face next frame.This method can be called often, so it needs to execute quickly.

See Also

getPaintBounds

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

return the rectangle that component should paint in.

See Also

paintImmediately

public function paintImmediately():Void

Redraw the component face immediately.

See Also

revalidate

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.

See Also

revalidateIfNecessary

public function revalidateIfNecessary():Void

invalidate

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.

See Also

validate

public function validate():Void

Ensures that this component has a valid layout. This method is primarily intended to operate on instances of Container.

See Also

isValidateRoot

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.

Return

always returns false

isValid

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.

Return

true if the component is valid, false otherwise

See Also

doLayout

public function doLayout():Void

layout this component. Locate this component to its location and visible its visible.

setClipMasked

public function setClipMasked(m:Boolean):Void

Sets whether the component clip should be masked by its bounds. By default it is true.

Parameters

mwhether the component clip should be masked.

See Also

isClipMasked

public function isClipMasked():Boolean

Returns whether the component clip should be masked by its bounds. By default it is true.

Return

whether the component clip should be masked.

See Also

setVisible

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.

isVisible

public function isVisible():Boolean

isDisplayable

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.

setFont

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.

getFont

public function getFont():ASFont

setBackground

public function setBackground(c:ASColor):Void

getBackground

public function getBackground():ASColor

setForeground

public function setForeground(c:ASColor):Void

getForeground

public function getForeground():ASColor

setOpaque

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.

Parameters

btrue if this component should be opaque

See Also

isOpaque

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.

Return

true if this component is completely opaque

See Also

setBounds

public function setBounds():Void

setBounds(bounds:Rectangle)
setBounds(x:Number, y:Number, width:Number, height:Number)

getBounds

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.

Parameters

bthe return value, modified to the component's bounds.

See Also

setLocation

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.

setGlobalLocation

public function setGlobalLocation():Void

setGlobalLocation(x:Number, y:Number)
setGlobalLocation(p:Point)

Set the component's location in global coordinate.

See Also

  • setLocation()
  • MovieClip.localToGlobal()
  • MovieClip.globalToLocal()

getLocation

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.

Parameters

pthe return value, modified to the component's location.

getGlobalLocation

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.

Parameters

pthe return value, modified to the component's global location.

See Also

setSize

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

See Also

getSize

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.

Parameters

setToolTipText

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.

Parameters

tthe string to display; if the text is null, the tool tip is turned off for this component

getToolTipText

public function getToolTipText():String

Returns the tooltip string that has been set with setToolTipText.

Return

the text of the tool tip

See Also

setAlignmentX

public function setAlignmentX(ax:Number):Void

Parameters

ax

See Also

setAlignmentY

public function setAlignmentY(ay:Number):Void

Parameters

ay

See Also

getAlignmentX

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.

Return

the alignment along the x axis, 0 by default

getAlignmentY

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.

Return

the alignment along the y axis, 0 by default

getMinimumSize

public function getMinimumSize():Dimension

getMaximumSize

public function getMaximumSize():Dimension

getPreferredSize

public function getPreferredSize():Dimension

setMinimumSize

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.

Parameters

See Also

setMaximumSize

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.

Parameters

See Also

setPreferredSize

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.

Parameters

See Also

getWidth

public function getWidth():Number

getHeight

public function getHeight():Number

getX

public function getX():Number

getY

public function getY():Number

setEnabled

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.

Parameters

btrue to enable the component, false to disable it.

See Also

isEnabled

public function isEnabled():Boolean

Returns whether the component is enabled.

See Also

setTriggerEnabled

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.

Parameters

btrue to enable trigger, false to disable it.

See Also

isTriggerEnabled

public function isTriggerEnabled():Boolean

Returns is trigger enabled.

See Also

setUseHandCursor

public function setUseHandCursor(b:Boolean):Void

Sets whether use hand cursor when mouse move on this component. Default is false.

Parameters

btrue to use hand cursor when mouse move on this component, false not.

isUseHandCursor

public function isUseHandCursor():Boolean

Return

whether use hand cursor when mouse move on this component.

See Also

createMovieClip

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.

Parameters

nameStartthe prefix of the created MovieClip's name.
depththe depth of the created MovieClip.

attachMovieClip

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.

Parameters

linkagethe linkage id of the MovieClip in your Symbol Library.
nameStartthe prefix of the attached MovieClip's name.
depththe depth of the attached MovieClip.

createTextField

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.

Parameters

nameStartthe prefix of the created textfiled's name.
depththe depth of the created textfiled.

getDepth

public function getDepth():Number

Returns the component's mc's depth. It will return undefined when this component is displayable.

swapDepths

public function swapDepths(target):Void

Swap the component's mc's depth. This is only effective when this component is displayable.

bringToTopDepth

public function bringToTopDepth():Void

Brings this component at top depth of all brothers. This is only effective when this component is displayable.

bringToBottomDepth

public function bringToBottomDepth():Void

Brings this component at bottom depth of all brothers. This is only effective when this component is displayable.

hitTest

public function hitTest(x, y, shapeFlag):Boolean

Returns the component's clip mc hitTest()

getMousePosition

public function getMousePosition():Point

Returns the position of the mouse in the Component area. (0, 0) is the top left of the component bounds.

Return

the position of the mouse in the Component area.

globalToComponent

public function globalToComponent(p:Point):Point

componentToGlobal

public function componentToGlobal(p:Point):Point

toString

public function toString():String

isFocusable

public function isFocusable(Void):Boolean

setFocusable

public function setFocusable(val:Boolean):Void

isFocused

public function isFocused(Void):Boolean

setFocus

public function setFocus(val:Boolean):Void