Component

Methods
68
Fields
5

Getting one

Box.createGlue()
Box.createHorizontalGlue()
Box.createVerticalGlue()

Methods

MethodReturnsDescription
getParent()Container?The container this component is in, or nil: the very object the plugin built, with its fields.
isValid()booleanWhether the component is laid out (validate() ran since anything changed).
invalidate()()Marks the component, and its ancestors up to the first invalid one, as needing a layout. Requests nothing.
validate()()Lays the component out now, if it is displayable: every invalid container at and under it, top down. A component that is not displayable la…
revalidate()()Invalidates the component and queues its validate root to be laid out at the next slot.
repaint()()(Component) -> (): Asks for the component to be painted again.
repaint(number, number, number, number)()
repaint(number, number, number, number, number)()
isDisplayable()booleanWhether the component's surface is attached (a registered panel, an open popup): what Swing calls having a peer.
isShowing()booleanWhether the component is on screen: displayable, and it and every ancestor visible.
addNotify()()Runs when the component becomes displayable; an override calls X.super.addNotify(self) to reach the children.
removeNotify()()Runs when the component stops being displayable; an override calls X.super.removeNotify(self) to reach the children.
isVisible()booleanWhether the component is visible (its own flag; see isShowing).
setVisible(boolean)()Shows or hides the component; a layout skips a hidden one.
isEnabled()booleanWhether the component is enabled. A disabled component still receives mouse events (its listeners run; its look ignores them) and no keys.
setEnabled(boolean)()Enables or disables the component (not its children).
getBackground()Color?The background: the component's own, else its nearest ancestor's, else nil.
setBackground(Color?)()Sets the background; nil inherits the parent's again.
getForeground()Color?The foreground: the component's own, else its nearest ancestor's, else nil.
setForeground(Color?)()Sets the foreground; nil inherits the parent's again.
getFont()Font?The font: the component's own, else its nearest ancestor's, else nil.
setFont(Font?)()Sets the font; nil inherits the parent's again.
setCursor(Cursor?)()Sets the mouse cursor shown over the component (Cursor.new(type), Cursor.getPredefinedCursor(type)); nil inherits the parent's.
getCursor()Cursor?The cursor setCursor set, or nil (inherited).
getName()string?The component's name, or nil.
setName(string?)()Names the component.
isFocusable()booleanWhether the component can take focus.
setFocusable(boolean)()Lets the component take focus, or not; a focus owner made unfocusable passes focus on.
getFocusTraversalKeysEnabled()booleanWhether Tab and Shift+Tab traverse focus from the component (else they reach its key listeners).
setFocusTraversalKeysEnabled(boolean)()Whether Tab and Shift+Tab traverse focus from the component.
requestFocusInWindow()booleanAsks for focus within the component's window; the focus events are posted. false when it cannot take focus or already has it.
requestFocus()()Asks for focus, the window's included; the focus events are posted.
hasFocus()booleanWhether the component owns focus.
isFocusOwner()booleanWhether the component owns focus (hasFocus()).
getX()numberThe x position in the parent.
getY()numberThe y position in the parent.
getWidth()numberThe width.
getHeight()numberThe height.
getBounds()RectangleThe bounds in the parent, as a new Rectangle.
setBounds(number, number, number, number)()(Component, number, number, number, number) -> (): Moves and resizes the component (a layout may change it again).
setBounds(Rectangle)()
getSize()DimensionThe size, as a new Dimension.
setSize(number, number)()(Component, number, number) -> (): Resizes the component.
setSize(Dimension)()
getLocation()PointThe position in the parent, as a new Point.
setLocation(number, number)()(Component, number, number) -> (): Moves the component.
setLocation(Point)()
getPreferredSize()DimensionThe preferred size: the size set with setPreferredSize, else the look's or the layout's, else Component's default. The native member: a…
setPreferredSize(Dimension?)()Sets the preferred size; nil computes it again. Invalidates nothing and requests nothing: a parent's cached size stays until something el…
isPreferredSizeSet()booleanWhether a preferred size was set.
getMinimumSize()DimensionThe minimum size (the native member).
setMinimumSize(Dimension?)()Sets the minimum size; nil computes it again.
getMaximumSize()DimensionThe maximum size (the native member).
setMaximumSize(Dimension?)()Sets the maximum size; nil computes it again.
addMouseListener(MouseListener)()Adds a MouseListener (a MouseAdapter subclass, or any table with the methods it needs): it runs on presses, releases, clicks, enters an…
removeMouseListener(any)()Removes a MouseListener, by identity.
getMouseListeners(){any}A copy of the MouseListeners, in registration order.
addMouseMotionListener(any)()Adds a MouseMotionListener: it runs on moves and drags.
removeMouseMotionListener(any)()Removes a MouseMotionListener, by identity.
getMouseMotionListeners(){any}A copy of the MouseMotionListeners, in registration order.
addMouseWheelListener(any)()Adds a MouseWheelListener (a table, or a function of the event).
removeMouseWheelListener(any)()Removes a MouseWheelListener, by identity.
addKeyListener(KeyListener)()Adds a KeyListener: it runs on the keys the component receives as focus owner, before the key's bindings and the editor.
removeKeyListener(any)()Removes a KeyListener, by identity.
getKeyListeners(){any}A copy of the KeyListeners, in registration order.
addFocusListener(any)()Adds a FocusListener (focusGained, focusLost).
removeFocusListener(any)()Removes a FocusListener, by identity.
getFocusListeners(){any}A copy of the FocusListeners, in registration order.
addComponentListener(any)()Adds a ComponentListener: resized, moved, shown, hidden, posted after the change.
removeComponentListener(any)()Removes a ComponentListener, by identity.
dispatchEvent(any)()Delivers an AWT mouse, key, focus or component event to this component's listeners of its kind, now, as the same object; the look's own beh…
init(Component)()The implicit no-argument constructor: the fresh state a node of this kind starts with, and nothing more. Construction runs it as every nati…
isInstance(any)booleanWhether obj is a Component object, a class(Component) subclass's included.

Fields

FieldTypeDescription
TOP_ALIGNMENTnumberComponent.TOP_ALIGNMENT: 0.
CENTER_ALIGNMENTnumberComponent.CENTER_ALIGNMENT: 0.5.
BOTTOM_ALIGNMENTnumberComponent.BOTTOM_ALIGNMENT: 1.
LEFT_ALIGNMENTnumberComponent.LEFT_ALIGNMENT: 0.
RIGHT_ALIGNMENTnumberComponent.RIGHT_ALIGNMENT: 1.

Returned by

MethodReturnsDescription
AwtInputEvent.getComponentComponent?The component, as getSource().
AwtInputEvent.getSourceComponent?The component the event is about, for an event a Swing listener is handed (a panel's mouse, wheel or key listener): the component the liste…
AwtWindow.getFocusOwnerComponent?The component that has focus in the window while it is focused, else nil.
AwtWindow.getMostRecentFocusOwnerComponent?The component that gets focus when the window is focused again: the focus owner, or the last one.
BoxClass.createGlueComponentA filler that grows both ways.
BoxClass.createHorizontalGlueComponentA filler that grows horizontally.
BoxClass.createHorizontalStrutComponentA fixed-width filler.
BoxClass.createRigidAreaComponentA fixed-size filler.
BoxClass.createVerticalGlueComponentA filler that grows vertically.
BoxClass.createVerticalStrutComponentA fixed-height filler.
ComponentEvent.getComponentComponent?The component, as getSource().
Container.addComponent(Container, Component) -> Component: Adds comp last (taking it from any container it was in), and answers it. Invalidates this containe…
Container.getComponentComponentThe child at index n (from 0).
Container.getComponents{Component}The children, in index order (array index 1 is child index 0: the top-most).
FocusEvent.getOppositeComponentComponent?The other component in the change, or nil (another window, the game).
JComponent.getComponentPopupMenuComponent?The popup menu shown on a popup trigger (a right click) over it: its own, or with setInheritsPopupMenu(true) its parent's.
JLabel.getLabelForComponent?The component this label labels, or nil.
JSpinner.getEditorComponent?The editor: a JSpinner.DefaultEditor holding the formatted field (getEditor():getTextField()).
JSpinnerDefaultEditor.getSpinnerComponent?The spinner it edits, or nil.
JSpinnerDefaultEditor.getTextFieldComponent?The formatted field it shows the value in.
JViewport.getViewComponent?The view, or nil.
SwingEvent.getSourceComponent?The component the event is about, or nil when its source is not a component (a model) or was collected since.

Method details

getParent

getParent: (Component) -> Container?

The container this component is in, or nil: the very object the plugin built, with its fields.

isValid

isValid: (Component) -> boolean

Whether the component is laid out (validate() ran since anything changed).

invalidate

invalidate: (Component) -> ()

Marks the component, and its ancestors up to the first invalid one, as needing a layout. Requests nothing.

validate

validate: (Component) -> ()

Lays the component out now, if it is displayable: every invalid container at and under it, top down. A component that is not displayable lays out nothing.

revalidate

revalidate: (Component) -> ()

Invalidates the component and queues its validate root to be laid out at the next slot.

repaint

repaint: ((Component) -> ()) & ((Component, number, number, number, number) -> ()) & ((Component, number, number, number, number, number) -> ())

(Component) -> (): Asks for the component to be painted again.

(Component, number, number, number, number) -> (): Asks for a rectangle of the component, in its own coordinates, to be painted again.

(Component, number, number, number, number, number) -> (): Asks for a rectangle to be painted again within tm milliseconds (it is now).

isDisplayable

isDisplayable: (Component) -> boolean

Whether the component's surface is attached (a registered panel, an open popup): what Swing calls having a peer.

isShowing

isShowing: (Component) -> boolean

Whether the component is on screen: displayable, and it and every ancestor visible.

addNotify

addNotify: (Component) -> ()

Runs when the component becomes displayable; an override calls X.super.addNotify(self) to reach the children.

removeNotify

removeNotify: (Component) -> ()

Runs when the component stops being displayable; an override calls X.super.removeNotify(self) to reach the children.

isVisible

isVisible: (Component) -> boolean

Whether the component is visible (its own flag; see isShowing).

setVisible

setVisible: (Component, boolean) -> ()

Shows or hides the component; a layout skips a hidden one.

isEnabled

isEnabled: (Component) -> boolean

Whether the component is enabled. A disabled component still receives mouse events (its listeners run; its look ignores them) and no keys.

setEnabled

setEnabled: (Component, boolean) -> ()

Enables or disables the component (not its children).

getFont

getFont: (Component) -> Font?

The font: the component's own, else its nearest ancestor's, else nil.

setCursor

setCursor: (Component, Cursor?) -> ()

Sets the mouse cursor shown over the component (Cursor.new(type), Cursor.getPredefinedCursor(type)); nil inherits the parent's.

setFocusable

setFocusable: (Component, boolean) -> ()

Lets the component take focus, or not; a focus owner made unfocusable passes focus on.

requestFocusInWindow

requestFocusInWindow: (Component) -> boolean

Asks for focus within the component's window; the focus events are posted. false when it cannot take focus or already has it.

requestFocus

requestFocus: (Component) -> ()

Asks for focus, the window's included; the focus events are posted.

setBounds

setBounds: ((Component, number, number, number, number) -> ()) & ((Component, Rectangle) -> ())

(Component, number, number, number, number) -> (): Moves and resizes the component (a layout may change it again).

(Component, Rectangle) -> (): Moves and resizes the component to r.

setSize

setSize: ((Component, number, number) -> ()) & ((Component, Dimension) -> ())

(Component, number, number) -> (): Resizes the component.

(Component, Dimension) -> (): Resizes the component to d.

setLocation

setLocation: ((Component, number, number) -> ()) & ((Component, Point) -> ())

(Component, number, number) -> (): Moves the component.

(Component, Point) -> (): Moves the component to p.

getPreferredSize

getPreferredSize: (Component) -> Dimension

The preferred size: the size set with setPreferredSize, else the look's or the layout's, else Component's default. The native member: an override's X.super.getPreferredSize(self) reaches it.

setPreferredSize

setPreferredSize: (Component, Dimension?) -> ()

Sets the preferred size; nil computes it again. Invalidates nothing and requests nothing: a parent's cached size stays until something else invalidates it.

addMouseListener

addMouseListener: (Component, MouseListener) -> ()

Adds a MouseListener (a MouseAdapter subclass, or any table with the methods it needs): it runs on presses, releases, clicks, enters and exits, in registration order, and makes the component take the mouse from its parent.

addKeyListener

addKeyListener: (Component, KeyListener) -> ()

Adds a KeyListener: it runs on the keys the component receives as focus owner, before the key's bindings and the editor.

addComponentListener

addComponentListener: (Component, any) -> ()

Adds a ComponentListener: resized, moved, shown, hidden, posted after the change.

dispatchEvent

dispatchEvent: (Component, any) -> ()

Delivers an AWT mouse, key, focus or component event to this component's listeners of its kind, now, as the same object; the look's own behaviour (a button's press, say) is not run.

init

init: (Component) -> ()

The implicit no-argument constructor: the fresh state a node of this kind starts with, and nothing more. Construction runs it as every native base's super(); new does not take it.

isInstance

isInstance: (any) -> boolean

Whether obj is a Component object, a class(Component) subclass's included.