次のようなコードがあります。
public void handle(MouseEvent event) {
//if (event.getEventType() == MouseEvent.MOUSE_CLICKED) {
if ( ( event.getEventType() == MouseEvent.MOUSE_PRESSED )&&
(event.isPrimaryButtonDown()) ) {
x1 = x2 = event.getX();
y1 = y2 = event.getY();
line = new BoundLine(pane, event, x1, y1, x2, y2);
pane.getChildren().add(line);
//line.getEventDispatcher().dispatchEvent(event, null);
}
}
「MouseEvent イベント」をすぐにjavafx.scene.shape.Line
(コードの行) オブジェクトに伝播することは可能ですか? 試してみline.getEventDispatcher().dispatchEvent(event, null);
ましたが、次のメッセージ エラーが表示されます。
スレッド "JavaFX アプリケーション スレッド" で例外が発生しました。 LinesEditCtx02$MouseHandler.handle(LinesEditCtx02.java:105) com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69) com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217) com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170) com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38) com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37) com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35) com.sun .javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92) com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53) com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java) :33) javafx.event.Event.fireEvent(Event.java:171) で javafx.scene.Scene$MouseHandler.process(Scene.java:3324) で javafx.scene.Scene$MouseHandler.process(Scene.java: 3164) で javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3119) で javafx.scene.Scene.impl_processMouseEvent(Scene.java:1559) で javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2261) com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:228) com.sun.glass.ui.View.handleMouseEvent(View.java:528) com.sun.glass.ui .View.notifyMouse(View.java:922) at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java: 82) java.lang.Thread.run(Thread.java:722) で