包SwingUtilities
具有很好的功能convertMouseEvent
,用于将组件上的鼠标事件转换为另一组件上的鼠标事件:
MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(originalComponent, event, otherComponent);
同时,JavaFX中的MouseEvent
具有方法copyFor
为另一个组件创建MouseEvent
的副本:
MouseEvent convertedEvent = e.copyFor(e.getSource(), otherComponent);
我想做类似的事情将JavaFx MouseEvent e
转换为Swing鼠标事件。
我找不到内置函数,因此我尝试编写自己的函数。我无法轻易转换两个字段:
e.getEventType().getEventType().getName()
是否有办法从e
的属性中获取修饰符?
软件包SwingUtilities具有很好的功能convertMouseEvent,可以将组件上的鼠标事件转换为另一个组件上的鼠标事件:MouseEvent convertEvent = SwingUtilities ....
SwingEvents
中的功能可能有用。