public final class FxUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> void |
bind(javafx.collections.ObservableList<? super T> list,
javafx.beans.value.ObservableValue<? extends java.util.List<? extends T>> observable)
Binds an observable list to a list property.
|
static <T> void |
bind(javafx.beans.property.Property<T> property,
DataSource<T> dataSource)
Binds a property to the data of a data source.
|
static <K,V,T> void |
bind(javafx.beans.property.Property<T> property,
javafx.collections.ObservableMap<K,V> map,
K key,
java.util.function.Function<V,T> converter)
Binds a property to the value of an entry in a map.
|
static <T> void |
bindBidirectional(javafx.beans.property.Property<T> property,
DataSource<T> dataSource)
Bidirectionally binds a property and a data source.
|
static java.util.Optional<javafx.scene.control.Label> |
getLabel(javafx.scene.Node node)
Gets the label associated with a node.
|
static javafx.scene.control.MenuItem |
menuItem(java.lang.String text,
javafx.event.EventHandler<javafx.event.ActionEvent> eventHandler)
Creates a menu item with the given text and event handler.
|
static javafx.scene.control.MenuItem |
menuLabel(java.lang.String text)
Creates a disabled menu item for use as a label.
|
static java.util.concurrent.CompletableFuture<java.lang.Boolean> |
runOnFxThread(java.lang.Runnable task)
Runs a task on the JavaFX application thread as soon as possible.
|
static java.lang.String |
toHexString(javafx.scene.paint.Color color)
Converts a JavaFX color to a hex web string in the format
#RRGGBBAA . |
static javafx.beans.binding.When |
when(javafx.beans.property.Property<java.lang.Boolean> condition)
A more general version of
Bindings.when(ObservableBooleanValue)
that can accept general boolean properties as conditions. |
public static java.util.concurrent.CompletableFuture<java.lang.Boolean> runOnFxThread(java.lang.Runnable task)
task
- the task to run. If null, the method will return immediately and no action
will be taken.true
once the task has runpublic static <K,V,T> void bind(javafx.beans.property.Property<T> property, javafx.collections.ObservableMap<K,V> map, K key, java.util.function.Function<V,T> converter)
K
- the type of keys in the mapV
- the type of values in the mapT
- the type of data in the propertyproperty
- the property to bindmap
- the map to bind tokey
- the key of the entry to bind toconverter
- a function for converting map values to a type the property can acceptpublic static <T> void bind(javafx.beans.property.Property<T> property, DataSource<T> dataSource)
T
- the type of data of the sourceproperty
- the property to binddataSource
- the data source to bind topublic static <T> void bind(javafx.collections.ObservableList<? super T> list, javafx.beans.value.ObservableValue<? extends java.util.List<? extends T>> observable)
T
- the type of elements in the listlist
- the observable list to bindobservable
- the property to bind topublic static <T> void bindBidirectional(javafx.beans.property.Property<T> property, DataSource<T> dataSource)
T
- the type of dataproperty
- the property to binddataSource
- the data source to bindpublic static javafx.beans.binding.When when(javafx.beans.property.Property<java.lang.Boolean> condition)
Bindings.when(ObservableBooleanValue)
that can accept general boolean properties as conditions.condition
- the condition to bind toBindings.when(ObservableBooleanValue)
public static java.lang.String toHexString(javafx.scene.paint.Color color)
#RRGGBBAA
. The string can be read with
Color.web
to create a Color
object that the string represents.color
- the color to convert to a hex string.public static javafx.scene.control.MenuItem menuItem(java.lang.String text, javafx.event.EventHandler<javafx.event.ActionEvent> eventHandler)
text
- the text of the menu itemeventHandler
- the handler to call when the menu item is acted uponpublic static javafx.scene.control.MenuItem menuLabel(java.lang.String text)
text
- the text of the labelpublic static java.util.Optional<javafx.scene.control.Label> getLabel(javafx.scene.Node node)
node
- the node to get the label for