Class Component
java.lang.Object
megalodonte.base.components.Component
- All Implemented Interfaces:
ComponentInterface<Component>, megalodonte.contracts.ComponentContract<Component>
public abstract class Component
extends Object
implements ComponentInterface<Component>, megalodonte.contracts.ComponentContract<Component>
Base class for all UI components. Wraps a JavaFX
Node and provides
a React-inspired API for building component trees.
Subclasses override getJavaFxNode() to return the underlying node.
Use CreateFromJavaFxNode(Node) to wrap an existing node as a component.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for screen enter/exit transition animations. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final javafx.scene.NodeThe underlying JavaFX node.Optional properties applied to this component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComponent(javafx.scene.Node node) Creates a component wrapping the given node.protectedComponent(javafx.scene.Node node, PropsInterface props) Creates a component wrapping the given node and applies the given props. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentCreateFromJavaFxNode(javafx.scene.Node node) Factory method to create a wrapperComponentaround an existing JavaFX Node.fromJavaFxNode(javafx.scene.Node newNode) Creates a new component wrapping the given node.javafx.scene.NodeReturns the underlying JavaFX node.Binds this component to aRef, making it accessible from the parent scope.ref(megalodonte.contracts.RefContract<T> ref)
-
Field Details
-
node
protected final javafx.scene.Node nodeThe underlying JavaFX node. -
props
Optional properties applied to this component.
-
-
Constructor Details
-
Component
protected Component(javafx.scene.Node node) Creates a component wrapping the given node.- Parameters:
node- the JavaFX node to wrap
-
Component
Creates a component wrapping the given node and applies the given props.- Parameters:
node- the JavaFX node to wrapprops- the properties to apply
-
-
Method Details
-
getJavaFxNode
public javafx.scene.Node getJavaFxNode()Description copied from interface:ComponentInterfaceReturns the underlying JavaFX node. @return the JavaFX node- Specified by:
getJavaFxNodein interfaceComponentInterface<Component>
-
fromJavaFxNode
Description copied from interface:ComponentInterfaceCreates a new component wrapping the given node.- Specified by:
fromJavaFxNodein interfaceComponentInterface<Component>- Parameters:
newNode- the JavaFX node to wrap- Returns:
- a new component wrapping the node
-
CreateFromJavaFxNode
Factory method to create a wrapperComponentaround an existing JavaFX Node.- Parameters:
node- the JavaFX node to wrap (must not be null)- Returns:
- a new component wrapping the given node
- Throws:
IllegalArgumentException- if node is null
-
ref
-
ref
-