我使用以下代码下载和呈现网页。
public class SwingFXWe extends Application {
public final WebEngine webEngine=null;
@Override
public void start(Stage stage) {
stage.setTitle("HTML");
Scene scene = new Scene(new Group());
VBox root = new VBox();
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
String text = null;
BufferedReader reader = null;
String html="";
try {
FileInputStream fis = new FileInputStream("C:\\D.htm");
InputStreamReader isr = new InputStreamReader(fis, "windows-1251");
reader = new BufferedReader(isr);
while ((text = reader.readLine()) != null) {
html+=text+"\n";
}
}
catch (Exception e) {
// TODO: handle exception
}
webEngine.loadContent(Jsoup.parse(html).html());
root.getChildren().addAll(browser);
scene.setRoot(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
我可以从webEngine容器中获取图像和样式,以进行更改吗?