public class SimpleEventHandlerProperty extends SimpleObjectProperty<EventHandler<? super ActionDataEvent>> implements EventHandlerProperty
action
in the
FXBeanInfo
.
It is usually easier to use
FXBeanInfo.Builder.action(java.lang.String, java.lang.Runnable)
or
FXBeanInfo.Builder.action(java.lang.String, javafx.event.EventHandler)
,
but should properties be the preferred way to represent actions,
here is how to use them:
class CountingBean implementsFXBeanInfo
.Provider { private int count; finalEventHandlerProperty
incrementAction = newSimpleEventHandlerProperty
(this, "actionWithoutParameters", (ev) -> { count++; }); finalEventHandlerProperty
addAction = newSimpleEventHandlerProperty
(this, "actionWithEvent", (ev) -> { count += ((Number
) ev.getSource()).intValue(); }); finalEventHandlerProperty
addTwiceAction = newSimpleEventHandlerProperty
(this, "actionWithData", (ev) -> { count += ev.getSource(Number
.class).intValue(); count += ev.getProperty(Number
.class, "any").intValue(); }); private finalFXBeanInfo
info =FXBeanInfo
.newBuilder(this) .action(this.incrementAction) .action(this.addAction) .action(this.addTwiceAction) .build(); @Override
publicFXBeanInfo
getFXBeanInfo() { return info; } }
Constructor and Description |
---|
SimpleEventHandlerProperty()
Default constructor.
|
SimpleEventHandlerProperty(EventHandler<? super ActionDataEvent> handler)
Constructor with handler.
|
SimpleEventHandlerProperty(Object bean,
String name)
Constructor with bean and name.
|
SimpleEventHandlerProperty(Object bean,
String name,
EventHandler<? super ActionDataEvent> handler)
Constructor with all attributes.
|
getBean, getName
addListener, addListener, bind, fireValueChangedEvent, get, invalidated, isBound, removeListener, removeListener, set, toString, unbind
bindBidirectional, setValue, unbindBidirectional
asString, asString, asString, getValue, isEqualTo, isEqualTo, isNotEqualTo, isNotEqualTo, isNotNull, isNull, objectExpression
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBean, getName
addListener, getValue, removeListener
addListener, removeListener
getValue
public SimpleEventHandlerProperty()
public SimpleEventHandlerProperty(EventHandler<? super ActionDataEvent> handler)
handler
- provide the handlerpublic SimpleEventHandlerProperty(Object bean, String name)
bean
- the beanname
- the name of the propertypublic SimpleEventHandlerProperty(Object bean, String name, EventHandler<? super ActionDataEvent> handler)
bean
- the beanname
- name of the propertyhandler
- handlerCopyright © 2020. All rights reserved.