I created a small demo that embeds WebView into a SWT window. Dragging something from another application into WebView causes a NullPointerException. To reproduce it select some text in Firefox or Chrome browser and then drag it into the WebView. Exception stacktrace looks like the one in RT-24664.
JavaFX Application Thread uncaught: java.lang.RuntimeException
java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.javafx.tk.quantum.FxEventLoop$Impl.send(FxEventLoop.java:35)
at com.sun.javafx.tk.quantum.FxEventLoop.sendEvent(FxEventLoop.java:108)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget.handleDragEnter(EmbeddedSceneDropTarget.java:55)
at javafx.embed.swt.FXCanvas$HostContainer$2.dragOver(FXCanvas.java:748)
at javafx.embed.swt.FXCanvas$HostContainer$2.dragEnter(FXCanvas.java:718)
at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:60)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.dnd.DropTarget.DragEnter(DropTarget.java:297)
at org.eclipse.swt.dnd.DropTarget$3.method3(DropTarget.java:243)
at org.eclipse.swt.internal.ole.win32.COMObject.callback3(COMObject.java:92)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
at webviewbrowser.WebViewBrowserSWT.main(WebViewBrowserSWT.java:115)
Caused by: java.lang.NullPointerException
at javafx.scene.web.WebView$18.handle(WebView.java:1173)
at javafx.scene.web.WebView$18.handle(WebView.java:1165)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$DnDGesture.handleExitEnter(Scene.java:2878)
at javafx.scene.Scene$DnDGesture.processTargetEnterOver(Scene.java:2775)
at javafx.scene.Scene$DnDGesture.access$6100(Scene.java:2607)
at javafx.scene.Scene$DropTargetListener.dragEnter(Scene.java:2523)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler$1.run(GlassSceneDnDEventHandler.java:63)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler$1.run(GlassSceneDnDEventHandler.java:54)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragEnter(GlassSceneDnDEventHandler.java:54)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragEnter(GlassSceneDnDEventHandler.java:176)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget$1.call(EmbeddedSceneDropTarget.java:66)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget$1.call(EmbeddedSceneDropTarget.java:55)
at com.sun.javafx.tk.quantum.FxEventLoop$Impl.send(FxEventLoop.java:33)
... 17 more
It looks like I cannot attach files so here's the Java code:
package webviewbrowser;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.scene.web.WebViewBuilder;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class WebViewBrowserSWT
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
Group group = new Group();
final Scene scene = new Scene(group);
final WebView webView = WebViewBuilder.create().build();
group.getChildren().add(webView);
canvas.setScene(scene);
shell.setText("WebView");
scene.widthProperty().addListener(new ChangeListener<Object>()
{
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue)
{
Double width = (Double) newValue;
webView.setPrefWidth(width.doubleValue());
}
});
scene.heightProperty().addListener(new ChangeListener<Object>()
{
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue)
{
Double width = (Double) newValue;
webView.setPrefHeight(width.doubleValue());
}
});
webView.getEngine().load("http://html5demos.com/drag#");
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
JavaFX Application Thread uncaught: java.lang.RuntimeException
java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.javafx.tk.quantum.FxEventLoop$Impl.send(FxEventLoop.java:35)
at com.sun.javafx.tk.quantum.FxEventLoop.sendEvent(FxEventLoop.java:108)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget.handleDragEnter(EmbeddedSceneDropTarget.java:55)
at javafx.embed.swt.FXCanvas$HostContainer$2.dragOver(FXCanvas.java:748)
at javafx.embed.swt.FXCanvas$HostContainer$2.dragEnter(FXCanvas.java:718)
at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:60)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.dnd.DropTarget.DragEnter(DropTarget.java:297)
at org.eclipse.swt.dnd.DropTarget$3.method3(DropTarget.java:243)
at org.eclipse.swt.internal.ole.win32.COMObject.callback3(COMObject.java:92)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
at webviewbrowser.WebViewBrowserSWT.main(WebViewBrowserSWT.java:115)
Caused by: java.lang.NullPointerException
at javafx.scene.web.WebView$18.handle(WebView.java:1173)
at javafx.scene.web.WebView$18.handle(WebView.java:1165)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$DnDGesture.handleExitEnter(Scene.java:2878)
at javafx.scene.Scene$DnDGesture.processTargetEnterOver(Scene.java:2775)
at javafx.scene.Scene$DnDGesture.access$6100(Scene.java:2607)
at javafx.scene.Scene$DropTargetListener.dragEnter(Scene.java:2523)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler$1.run(GlassSceneDnDEventHandler.java:63)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler$1.run(GlassSceneDnDEventHandler.java:54)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragEnter(GlassSceneDnDEventHandler.java:54)
at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragEnter(GlassSceneDnDEventHandler.java:176)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget$1.call(EmbeddedSceneDropTarget.java:66)
at com.sun.javafx.tk.quantum.EmbeddedSceneDropTarget$1.call(EmbeddedSceneDropTarget.java:55)
at com.sun.javafx.tk.quantum.FxEventLoop$Impl.send(FxEventLoop.java:33)
... 17 more
It looks like I cannot attach files so here's the Java code:
package webviewbrowser;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.scene.web.WebViewBuilder;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class WebViewBrowserSWT
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
Group group = new Group();
final Scene scene = new Scene(group);
final WebView webView = WebViewBuilder.create().build();
group.getChildren().add(webView);
canvas.setScene(scene);
shell.setText("WebView");
scene.widthProperty().addListener(new ChangeListener<Object>()
{
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue)
{
Double width = (Double) newValue;
webView.setPrefWidth(width.doubleValue());
}
});
scene.heightProperty().addListener(new ChangeListener<Object>()
{
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue)
{
Double width = (Double) newValue;
webView.setPrefHeight(width.doubleValue());
}
});
webView.getEngine().load("http://html5demos.com/drag#");
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}