Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFXWebView导入节点_Java_Svg_Javafx - Fatal编程技术网

JavaFXWebView导入节点

JavaFXWebView导入节点,java,svg,javafx,Java,Svg,Javafx,我使用WebView显示一个SVG图像,我想添加另一个SVG图像作为原始SVG的一个节点的子节点,类似于这里使用batik所描述的内容:。然后我得到一个ClassCastException。 这里是我使用基本SVG图像的地方: final String svg = "background.svg"; final uri = Paths.get(svg).toAbsolutePath().toUri(); WebView root = new WebView(); root.getEngine()

我使用WebView显示一个SVG图像,我想添加另一个SVG图像作为原始SVG的一个节点的子节点,类似于这里使用batik所描述的内容:。然后我得到一个ClassCastException。 这里是我使用基本SVG图像的地方:

final String svg = "background.svg";
final uri = Paths.get(svg).toAbsolutePath().toUri();
WebView root = new WebView();
root.getEngine().load(uri.toString());
SVG正确显示。 然后我有一段代码,当用户按下按钮时执行,它试图将另一个图像添加到父SVG:

File anotherFile = new File("over.svg");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(anotherFile);

Node e = root.getEngine().getDocument().importNode(doc.getDocumentElement(), true);
root.getEngine().getDocument().appendChild(e);
尝试使用importNode时发生以下异常:

java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.dom.DeferredElementImpl cannot be cast to
com.sun.webkit.dom.NodeImpl