HTMLEditorからWebViewをとりだす - JavaFX 2012/11/25
2012/11/25

JavaFXです。HTMLEditorからWebViewをとりだします。
そういうニーズがあるかどうか知りませんが。
 ためしたのはJava7で2.23でおこないました。

HTMLEditorにskinがあってそこにWebViewがのっかるという感じのようでした。

public static List<Node> getAllChildren(Node node) { List<Node> nodes = new ArrayList<Node>(); if(!(node instanceof Parent)){ return nodes; } for (Node child : ((Parent) node).getChildrenUnmodifiable()) { nodes.add(child); nodes.addAll(getAllChildren(child)); } return nodes; } public static WebView getWebView(HTMLEditor htmlEditor) { HTMLEditorSkin skin = (HTMLEditorSkin) htmlEditor.getSkin(); List<Node> nodes = Utils.getAllChildren(skin); for (Node node : nodes) { if (node instanceof WebView) return (WebView) node; } return null; }
もしかして一発でとれる何かあるのかしらと思いつつ。
参考にしたのは以下

: