JFXPanel with WebView in JDK8
Lidierth Malcolm
malcolm.lidierth at kcl.ac.uk
Tue Nov 5 11:37:19 PST 2013
NOTE: THIS EXCEPTION OCCURS WITH JDK8, BUT NOT WITH JDK7
public class NewFXMain1 {
public static void main(String[] args) throws InterruptedException,
InvocationTargetException {
EventQueue.invokeAndWait(new Runnable() {
// Create the Swing components on the EDT
@Override
public void run() {
JFrame f = new JFrame();
f.getContentPane().setPreferredSize(new Dimension(500,
500));
f.pack();
f.setVisible(true);
final JFXPanel jfx = new JFXPanel();
f.getContentPane().add(jfx);
// FX Thread
Platform.runLater(new Runnable() {
@Override
public void run() {
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
// This is a reference to a web page on the
Waterloo web site
webEngine.load("http://waterloo.sourceforge.net/devwebpage/MathJax/mathjax.html");
Scene s = new Scene(browser);
jfx.setScene(s);
}
});
}
});
}
}
This gives (Note: using JDK8 and Running from NetBeans 7.4):
Executing
C:\Users\malcolm\Documents\waterloo\Sources\Java\kcl-waterloo-jfx\dist\run1852659813\kcl-waterloo-jfx.jar
using platform C:\Program Files\Java\jdk1.8.0/bin/java
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
javafx.embed.swing.JFXPanel.getInputMethodRequests(JFXPanel.java:744)
at
sun.awt.im.InputMethodAdapter.haveActiveClient(InputMethodAdapter.java:61)
at sun.awt.windows.WInputMethod.activate(WInputMethod.java:285)
at sun.awt.im.InputContext.activateInputMethod(InputContext.java:396)
at sun.awt.im.InputContext.focusGained(InputContext.java:338)
at sun.awt.im.InputContext.dispatchEvent(InputContext.java:245)
at
sun.awt.im.InputMethodContext.dispatchEvent(InputMethodContext.java:196)
at java.awt.Component.dispatchEventImpl(Component.java:4817)
at java.awt.Container.dispatchEventImpl(Container.java:2293)
at java.awt.Component.dispatchEvent(Component.java:4707)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:986)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:610)
at java.awt.Component.dispatchEventImpl(Component.java:4756)
at java.awt.Container.dispatchEventImpl(Container.java:2293)
at java.awt.Component.dispatchEvent(Component.java:4707)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
More information about the openjfx-dev
mailing list