ConstrainedPanel

A Swing component that measures and places Foundation content by a MeasurePolicy: the component Layout, Row, Column and Box each build, and the way to host Foundation content in a Swing tree you build yourself. Give it content with setContent.

Under a Foundation parent it is measured with the constraints that parent offers.

It installs no UI delegate. It is transparent by default and paints its background itself when opaque. When it holds one Scrollable child and is the view of a JScrollPane, it scrolls by that child's rows or lines.

Its policy reads are tracked only while a node of a Compose composition holds it: Layout, org.jetbrains.compose.swing.node.SwingNode or setContent declares it. Reads for children added with add are not tracked.

A stock parent reads a preferred or minimum size without offering constraints. The preferred size comes from MeasurePolicy.preferredSize and the minimum size from the policy's intrinsic functions. A preferred or minimum size set on the panel replaces the policy's result for that read.

A layer a policy places a child with takes effect on a panel no node holds, which then revalidates nothing.

Constructors

Link copied to clipboard
constructor(measurePolicy: MeasurePolicy = maybeCachedBoxMeasurePolicy(Alignment.TopStart, propagateMinConstraints = true), parentDataProtocol: LayoutParentDataProtocol? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The lines the last measure provided; none where a set preferred size supplied it.

Link copied to clipboard
@set:BeanProperty(description = "The preferred horizontal alignment of the component.")
open var alignmentX: Float
Link copied to clipboard
@set:BeanProperty(description = "The preferred vertical alignment of the component.")
open var alignmentY: Float
Link copied to clipboard
@get:BeanProperty(bound = false)
open val ancestorListeners: Array<out AncestorListener?>?
Link copied to clipboard
@set:BeanProperty(bound = false, expert = true, description = "Determines if this component automatically scrolls its contents when dragged.")
open var autoscrolls: Boolean
Link copied to clipboard
@set:BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
open var background: Color?
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
open var border: Border?
Link copied to clipboard
open var bounds: Rectangle?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(preferred = true, description = "Popup to show")
open var componentPopupMenu: JPopupMenu?
Link copied to clipboard
open val components: Array<out Component?>?
Link copied to clipboard
override val constrainedHeight: Int

The height the last measure settled on.

Link copied to clipboard
override val constrainedWidth: Int

The width the last measure settled on.

Link copied to clipboard
Link copied to clipboard
open var cursor: Cursor?
Link copied to clipboard
@set:BeanProperty(bound = false, preferred = true, enumerationValues = ["DebugGraphics.NONE_OPTION", "DebugGraphics.LOG_OPTION", "DebugGraphics.FLASH_OPTION", "DebugGraphics.BUFFERED_OPTION"], description = "Diagnostic options for graphics operations.")
open var debugGraphicsOptions: Int
Link copied to clipboard
open override var decoration: Decoration

The decoration this component paints through; Decoration.None until the library writes one.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
open var font: Font?
Link copied to clipboard
@set:BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
open var foreground: Color?
Link copied to clipboard
open override val graphics: Graphics?
Link copied to clipboard
@get:BeanProperty(bound = false)
open val height: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(description = "Whether or not the JPopupMenu is inherited")
open var inheritsPopupMenu: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(description = "The component's input verifier.")
open var inputVerifier: InputVerifier?
Link copied to clipboard
open override val insets: Insets
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
open var isEnabled: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val isFontSet: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@get:BeanProperty(bound = false)
open val isManagingFocus: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(expert = true, description = "The component's opacity")
open override var isOpaque: Boolean
Link copied to clipboard
Link copied to clipboard
@get:BeanProperty(bound = false)
val isPaintingForPrint: Boolean
Link copied to clipboard
@get:BeanProperty(bound = false)
open val isPaintingTile: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val isShowing: Boolean
Link copied to clipboard
open val isValid: Boolean
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(hidden = true, visualUpdate = true)
open var isVisible: Boolean
Link copied to clipboard
open val keyListeners: Array<out KeyListener?>?
Link copied to clipboard
Link copied to clipboard
open var locale: Locale?
Link copied to clipboard
open var location: Point?
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(description = "The maximum size of the component.")
open var maximumSize: Dimension?
Link copied to clipboard
@set:BeanProperty(description = "The minimum size of the component.")
open var minimumSize: Dimension?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val mousePosition: Point?
Link copied to clipboard
Link copied to clipboard
open var name: String?
Link copied to clipboard
Link copied to clipboard
open val parent: Container?
Link copied to clipboard
Link copied to clipboard
@set:BeanProperty(preferred = true, description = "The preferred size of the component.")
open var preferredSize: Dimension?
Link copied to clipboard
@get:BeanProperty(bound = false)
open val registeredKeyStrokes: Array<out KeyStroke?>?
Link copied to clipboard
@get:BeanProperty(bound = false)
open val rootPane: JRootPane?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var size: Dimension?
Link copied to clipboard
open val toolkit: Toolkit?
Link copied to clipboard
@set:BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
open var toolTipText: String?
Link copied to clipboard
@get:BeanProperty(bound = false)
open val topLevelAncestor: Container?
Link copied to clipboard
@set:BeanProperty(hidden = true, description = "Mechanism for transfer of data to and from the component")
open var transferHandler: TransferHandler?
Link copied to clipboard
Link copied to clipboard
open var ui: ComponentUI?
Link copied to clipboard
@get:BeanProperty(bound = false, expert = true, description = "UIClassID")
open val uiClassID: String?
Link copied to clipboard
@set:BeanProperty(description = "Whether the Component verifies input before accepting focus.")
open var verifyInputWhenFocusTarget: Boolean
Link copied to clipboard
Link copied to clipboard
@get:BeanProperty(bound = false)
open val visibleRect: Rectangle?
Link copied to clipboard
@get:BeanProperty(bound = false)
open val width: Int
Link copied to clipboard
@get:BeanProperty(bound = false)
open val x: Int
Link copied to clipboard
@get:BeanProperty(bound = false)
open val y: Int

Functions

Link copied to clipboard
open fun action(evt: Event?, what: Any?): Boolean
Link copied to clipboard
open fun add(popup: PopupMenu?)
open fun add(comp: Component?): Component?
open fun add(comp: Component?, constraints: Any?)
open fun add(comp: Component?, index: Int): Component?
open fun add(name: String?, comp: Component?): Component?
open fun add(comp: Component?, constraints: Any?, index: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun addNotify()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun bounds(): Rectangle?
Link copied to clipboard
open fun checkImage(image: Image?, observer: ImageObserver?): Int
open fun checkImage(image: Image?, width: Int, height: Int, observer: ImageObserver?): Int
Link copied to clipboard
open fun computeVisibleRect(visibleRect: Rectangle?)
Link copied to clipboard
open operator fun contains(p: Point?): Boolean
open override fun contains(x: Int, y: Int): Boolean
Link copied to clipboard
open fun countComponents(): Int
Link copied to clipboard
open fun createImage(producer: ImageProducer?): Image?
open fun createImage(width: Int, height: Int): Image?
Link copied to clipboard
open fun createToolTip(): JToolTip?
Link copied to clipboard
open fun createVolatileImage(width: Int, height: Int): VolatileImage?
open fun createVolatileImage(width: Int, height: Int, caps: ImageCapabilities?): VolatileImage?
Link copied to clipboard
open fun deliverEvent(e: Event?)
Link copied to clipboard
open fun disable()
Link copied to clipboard
Link copied to clipboard
open fun doLayout()
Link copied to clipboard
open fun enable()
open fun enable(b: Boolean)
Link copied to clipboard
open fun enableInputMethods(enable: Boolean)
Link copied to clipboard
open fun findComponentAt(x: Int, y: Int): Component?
Link copied to clipboard
open fun firePropertyChange(propertyName: String?, oldValue: Boolean, newValue: Boolean)
open fun firePropertyChange(propertyName: String?, oldValue: Byte, newValue: Byte)
open fun firePropertyChange(propertyName: String?, oldValue: Char, newValue: Char)
open fun firePropertyChange(propertyName: String?, oldValue: Double, newValue: Double)
open fun firePropertyChange(propertyName: String?, oldValue: Float, newValue: Float)
open fun firePropertyChange(propertyName: String?, oldValue: Int, newValue: Int)
open fun firePropertyChange(propertyName: String?, oldValue: Long, newValue: Long)
open fun firePropertyChange(propertyName: String?, oldValue: Short, newValue: Short)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getBaseline(width: Int, height: Int): Int
Link copied to clipboard
open fun getBounds(rv: Rectangle?): Rectangle?
Link copied to clipboard
Link copied to clipboard
open fun getComponent(n: Int): Component?
Link copied to clipboard
open fun getComponentAt(x: Int, y: Int): Component?
Link copied to clipboard
open fun getComponentZOrder(comp: Component?): Int
Link copied to clipboard
open fun getConditionForKeyStroke(aKeyStroke: KeyStroke?): Int
Link copied to clipboard
Link copied to clipboard
open fun getFontMetrics(font: Font?): FontMetrics?
Link copied to clipboard
open override fun getGraphics(): Graphics?
Link copied to clipboard
open override fun getInsets(): Insets
open override fun getInsets(insets: Insets?): Insets
Link copied to clipboard
open fun <T : EventListener?> getListeners(listenerType: Class<T?>?): Array<out T?>?
Link copied to clipboard
open fun getLocation(rv: Point?): Point?
Link copied to clipboard
open fun getMousePosition(allowChildren: Boolean): Point?
Link copied to clipboard
open fun getPopupLocation(event: MouseEvent?): Point?
Link copied to clipboard

The one scrollable child's answer plus this panel's insets, so a border or a shadow around it is not clipped.

Link copied to clipboard
open override fun getScrollableBlockIncrement(visibleRect: Rectangle, orientation: Int, direction: Int): Int
Link copied to clipboard

Whether the panel is laid out at the viewport's height; see getScrollableTracksViewportWidth.

Link copied to clipboard

Whether the panel is laid out at the viewport's width: where its content asks for that, and where the viewport is wider than the panel asks to be, which is the stretch a pane gives a view that is no Scrollable.

Link copied to clipboard
open override fun getScrollableUnitIncrement(visibleRect: Rectangle, orientation: Int, direction: Int): Int
Link copied to clipboard
open fun getSize(rv: Dimension?): Dimension?
Link copied to clipboard
open fun getToolTipLocation(event: MouseEvent?): Point?
Link copied to clipboard
open fun gotFocus(evt: Event?, what: Any?): Boolean
Link copied to clipboard
open fun grabFocus()
Link copied to clipboard
open fun handleEvent(evt: Event?): Boolean
Link copied to clipboard
open fun hasFocus(): Boolean
Link copied to clipboard
open fun hide()
Link copied to clipboard
open fun imageUpdate(img: Image?, infoflags: Int, x: Int, y: Int, w: Int, h: Int): Boolean
Link copied to clipboard
open fun insets(): Insets?
Link copied to clipboard
open fun inside(x: Int, y: Int): Boolean
Link copied to clipboard
open override fun invalidate()
Link copied to clipboard
Link copied to clipboard
open override fun isOpaque(): Boolean
Link copied to clipboard
open override fun isOptimizedDrawingEnabled(): Boolean
Link copied to clipboard
open fun keyDown(evt: Event?, key: Int): Boolean
Link copied to clipboard
open fun keyUp(evt: Event?, key: Int): Boolean
Link copied to clipboard
open fun layout()
Link copied to clipboard
open fun list()
open fun list(out: PrintStream?)
open fun list(out: PrintWriter?)
open fun list(out: PrintStream?, indent: Int)
open fun list(out: PrintWriter?, indent: Int)
Link copied to clipboard
open fun locate(x: Int, y: Int): Component?
Link copied to clipboard
open fun location(): Point?
Link copied to clipboard
open fun lostFocus(evt: Event?, what: Any?): Boolean
Link copied to clipboard
override fun maxIntrinsicHeight(width: Int): Int

The smallest height beyond which a taller height never makes the width smaller, at width, or at an unbounded width where it is Constraints.Infinity.

Link copied to clipboard
override fun maxIntrinsicWidth(height: Int): Int

The smallest width beyond which a wider width never makes the height smaller, at height, or at an unbounded height where it is Constraints.Infinity.

Link copied to clipboard
override fun measure(constraints: Constraints)

Measures this panel under constraints. A preferred size set on the panel is the result, as it is for getPreferredSize(); the policy measures only where none is set.

Link copied to clipboard
open fun minimumSize(): Dimension?
Link copied to clipboard
override fun minIntrinsicHeight(width: Int): Int

The smallest height at which the content paints correctly at width, or at an unbounded width where it is Constraints.Infinity.

Link copied to clipboard
override fun minIntrinsicWidth(height: Int): Int

A minimum size set on the panel is the min intrinsic width, and a preferred size set is the max intrinsic width, as they are for getMinimumSize() and getPreferredSize(). Otherwise the policy's intrinsic functions return the result, inside the border insets.

Link copied to clipboard
open fun mouseDown(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun mouseDrag(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun mouseEnter(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun mouseExit(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun mouseMove(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun mouseUp(evt: Event?, x: Int, y: Int): Boolean
Link copied to clipboard
open fun move(x: Int, y: Int)
Link copied to clipboard
open fun nextFocus()
Link copied to clipboard
open override fun onAttached(node: SwingComponentNode<*>)
Link copied to clipboard
open override fun onDeclaredNodesChanged(componentNode: SwingComponentNode<*>, nodes: List<SwingModifier.Node>)

Gathers the decoration the nodes declare and writes it to decoration. Not to be overridden.

Link copied to clipboard
open override fun onDetached(node: SwingComponentNode<*>)
Link copied to clipboard
open override fun paint(g: Graphics)
Link copied to clipboard
open fun paintAll(g: Graphics?)
Link copied to clipboard
Link copied to clipboard
open override fun paintImmediately(x: Int, y: Int, w: Int, h: Int)
Link copied to clipboard
open fun postEvent(e: Event?): Boolean
Link copied to clipboard
Link copied to clipboard
open fun prepareImage(image: Image?, observer: ImageObserver?): Boolean
open fun prepareImage(image: Image?, width: Int, height: Int, observer: ImageObserver?): Boolean
Link copied to clipboard
open fun print(g: Graphics?)
Link copied to clipboard
open fun printAll(g: Graphics?)
Link copied to clipboard
Link copied to clipboard
fun putClientProperty(key: Any?, value: Any?)
Link copied to clipboard
open fun registerKeyboardAction(anAction: ActionListener?, aKeyStroke: KeyStroke?, aCondition: Int)
open fun registerKeyboardAction(anAction: ActionListener?, aCommand: String?, aKeyStroke: KeyStroke?, aCondition: Int)
Link copied to clipboard
open fun remove(comp: Component?)
open fun remove(popup: MenuComponent?)
open override fun remove(index: Int)
Link copied to clipboard
open override fun removeAll()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun removeNotify()
Link copied to clipboard
open fun repaint()
open fun repaint(tm: Long)
open fun repaint(x: Int, y: Int, width: Int, height: Int)
open fun repaint(r: Rectangle?)
open override fun repaint(tm: Long, x: Int, y: Int, width: Int, height: Int)
Link copied to clipboard
Link copied to clipboard
open fun requestFocus()
open fun requestFocus(cause: FocusEvent.Cause?)
open fun requestFocus(temporary: Boolean): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun reshape(x: Int, y: Int, w: Int, h: Int)
Link copied to clipboard
open fun resize(d: Dimension?)
open fun resize(width: Int, height: Int)
Link copied to clipboard
open fun revalidate()
Link copied to clipboard
open fun scrollRectToVisible(aRect: Rectangle?)
Link copied to clipboard
override fun setBounds(x: Int, y: Int, width: Int, height: Int)
Link copied to clipboard
open fun setComponentZOrder(comp: Component?, index: Int)
Link copied to clipboard
fun ConstrainedPanel.setContent(parent: CompositionContext? = null, content: @Composable ConstrainedScope.() -> Unit): DisposableHandle

Sets the composable content of this panel as JComponent.setContent does. The content is laid out by the panel's MeasurePolicy and reads ConstrainedScope, so layout modifiers declared at its top level, such as fillMaxWidth, padding or aspectRatio, apply against the panel as they do inside a Layout.

Link copied to clipboard
open fun setFocusTraversalKeys(id: Int, keystrokes: Set<out AWTKeyStroke?>?)
Link copied to clipboard
fun setInputMap(condition: Int, map: InputMap?)
Link copied to clipboard
override fun setLayout(mgr: LayoutManager?)

Accepts only the layout manager the panel builds from its MeasurePolicy.

Link copied to clipboard
open fun setMixingCutoutShape(shape: Shape?)
Link copied to clipboard
open fun show()
open fun show(b: Boolean)
Link copied to clipboard
open fun size(): Dimension?
Link copied to clipboard
open fun transferFocus()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun unregisterKeyboardAction(aKeyStroke: KeyStroke?)
Link copied to clipboard
open fun update(g: Graphics?)
Link copied to clipboard
open fun updateUI()
Link copied to clipboard
open fun validate()