本文整理了Java中javafx.scene.control.MenuItem.addEventHandler()
方法的一些代码示例,展示了MenuItem.addEventHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.addEventHandler()
方法的具体详情如下:
包路径:javafx.scene.control.MenuItem
类名称:MenuItem
方法名:addEventHandler
暂无
代码示例来源:origin: io.reactivex/rxjavafx
public static Observable<ActionEvent> fromActionEvents(final MenuItem source) {
return Observable.create((ObservableEmitter<ActionEvent> subscriber) -> {
final EventHandler<ActionEvent> handler = subscriber::onNext;
source.addEventHandler(ActionEvent.ANY, handler);
subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeEventHandler(ActionEvent.ANY, handler)));
}).subscribeOn(JavaFxScheduler.platform());
}
代码示例来源:origin: io.reactivex.rxjava2/rxjavafx
public static Observable<ActionEvent> fromActionEvents(final MenuItem source) {
return Observable.create((ObservableEmitter<ActionEvent> subscriber) -> {
final EventHandler<ActionEvent> handler = subscriber::onNext;
source.addEventHandler(ActionEvent.ANY, handler);
subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeEventHandler(ActionEvent.ANY, handler)));
}).subscribeOn(JavaFxScheduler.platform());
}
代码示例来源:origin: org.jrebirth.af/core
/**
* Add an event handler on the given node according to annotation OnXxxxx.
*
* @param target the graphical node, must be not null (is a subtype of EventTarget)
* @param annotation the OnXxxx annotation
*
* @throws CoreException if an error occurred while linking the event handler
*/
private void addHandler(final EventTarget target, final Annotation annotation) throws CoreException {
// Build the auto event handler for this annotation
final AnnotationEventHandler<Event> aeh = new AnnotationEventHandler<>(this.callbackObject, annotation);
for (final EnumEventType eet : (EnumEventType[]) ClassUtility.getAnnotationAttribute(annotation, "value")) {
if (target instanceof Node) {
((Node) target).addEventHandler(eet.eventType(), aeh);
} else if (target instanceof MenuItem) {
if (eet.eventType() == ActionEvent.ACTION) {
((MenuItem) target).addEventHandler(ActionEvent.ACTION, new AnnotationEventHandler<>(this.callbackObject, annotation));
} else {
((MenuItem) target).setOnMenuValidation(aeh);
}
} else if (target instanceof Window) {
((Window) target).addEventHandler(eet.eventType(), aeh);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!