JComponent

Extends
Container
Methods
24
Fields
4

Getting one

JComponent.new()

Methods

MethodReturnsDescription
paintComponent(Graphics2D)()The native paintComponent(g): the look's paint of the component (its background when opaque, then the kind's content; a bare JComponent…
setBorder(Border?)()Sets the border: one of the prelude's (EmptyBorder.new(...), BorderFactory.createMatteBorder(...), ...), a Luau Border (any table wit…
getBorder()Border?The border setBorder was given (the very table), or nil.
isOpaque()booleanWhether the component paints every pixel of its bounds (its background first).
setOpaque(boolean)()Makes the component paint its background, or not.
setToolTipText(string?)()Sets the tooltip text (plain or <html>); a component with one takes the mouse from its parent's listeners. nil removes it.
getToolTipText()string?The tooltip text setToolTipText set, or nil.
putClientProperty(any, any)()Stores a client property (any key but nil); "html.disable", "FlatLaf.style", "FlatLaf.styleClass" and "JButton.buttonType" also c…
getClientProperty(any)anyThe client property under key, the very value stored, or nil.
setAlignmentX(number)()Sets the horizontal alignment a BoxLayout reads, clamped to 0..1.
setAlignmentY(number)()Sets the vertical alignment a BoxLayout reads, clamped to 0..1.
isRequestFocusEnabled()booleanWhether a press may give the component focus.
setRequestFocusEnabled(boolean)()Whether a press may give the component focus.
getInheritsPopupMenu()booleanWhether a child with no popup menu of its own shows this one.
setInheritsPopupMenu(boolean)()Whether the component shows its parent's popup menu when it has none.
getFontMetrics(Font)FontMetricsThe metrics font measures with in a component: the look's text rendering (the fonts antialiased as their gasp table says), so a width c…
getComponentPopupMenu()Component?The popup menu shown on a popup trigger (a right click) over it: its own, or with setInheritsPopupMenu(true) its parent's.
setComponentPopupMenu(JPopupMenu?)()Shows popup on a popup trigger (a right click) over it, at the pointer; nil removes it. The component keeps the menu alive.
updateUI()()Re-installs the look's defaults the plugin has not set, then lays out and repaints as the kind's look does.
getInputMap(condition: number?)InputMapThe component's InputMap for WHEN_FOCUSED (or the condition given), the same one each call.
getActionMap()ActionMapThe component's ActionMap, the same one each call.
new()JComponentA new lightweight component.
init(JComponent)()A new lightweight component.
isInstance(any)booleanWhether obj is a JComponent object, a class(JComponent) subclass's included.

Fields

FieldTypeDescription
WHEN_FOCUSEDnumberJComponent.WHEN_FOCUSED: 0.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENTnumberJComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT: 1.
WHEN_IN_FOCUSED_WINDOWnumberJComponent.WHEN_IN_FOCUSED_WINDOW: 2.
superContainerClassContainer's class table: the base class.

Returned by

MethodReturnsDescription
JComponentClass.newJComponentA new lightweight component.

Method details

paintComponent

paintComponent: (JComponent, Graphics2D) -> ()

The native paintComponent(g): the look's paint of the component (its background when opaque, then the kind's content; a bare JComponent paints nothing), with no override consulted. A plugin class's own paintComponent(g) is what Rust calls when the component is painted (on a repaint, never per frame), with a Graphics2D translated to the component, clipped to it, its colour and font the component's, valid only during the call; it reaches this through X.super.paintComponent(self, g). An error in an override ends that repaint where it happened, and is logged.

setBorder

setBorder: (JComponent, Border?) -> ()

Sets the border: one of the prelude's (EmptyBorder.new(...), BorderFactory.createMatteBorder(...), ...), a Luau Border (any table with paintBorder and getBorderInsets), or nil, which removes even the look's border. The insets become the border's.

isOpaque

isOpaque: (JComponent) -> boolean

Whether the component paints every pixel of its bounds (its background first).

setOpaque

setOpaque: (JComponent, boolean) -> ()

Makes the component paint its background, or not.

setToolTipText

setToolTipText: (JComponent, string?) -> ()

Sets the tooltip text (plain or <html>); a component with one takes the mouse from its parent's listeners. nil removes it.

putClientProperty

putClientProperty: (JComponent, any, any) -> ()

Stores a client property (any key but nil); "html.disable", "FlatLaf.style", "FlatLaf.styleClass" and "JButton.buttonType" also change the look.

setAlignmentX

setAlignmentX: (JComponent, number) -> ()

Sets the horizontal alignment a BoxLayout reads, clamped to 0..1.

setAlignmentY

setAlignmentY: (JComponent, number) -> ()

Sets the vertical alignment a BoxLayout reads, clamped to 0..1.

getFontMetrics

getFontMetrics: (JComponent, Font) -> FontMetrics

The metrics font measures with in a component: the look's text rendering (the fonts antialiased as their gasp table says), so a width computed here is the one the label lays out with.

updateUI

updateUI: (JComponent) -> ()

Re-installs the look's defaults the plugin has not set, then lays out and repaints as the kind's look does.

getInputMap

getInputMap: (JComponent, condition: number?) -> InputMap

The component's InputMap for WHEN_FOCUSED (or the condition given), the same one each call.

isInstance

isInstance: (any) -> boolean

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