在插入imageview之前,webview完美无缺!但插入imageview后,webview显示但不能滚动!
有人提到,imageview仅适用于第一个首页。我的意思是当Button点击时,图像将消失。我通过这种方式在buttonhandle中处理这段代码 -
img.setImage(null);
System.gc();
我的fxml文件 -
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.web.WebView?>
<AnchorPane id="AnchorPane" fx:id="anc" prefHeight="560.0" prefWidth="784.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.WebController">
<children>
<TextField fx:id="txt" layoutX="14.0" layoutY="33.0" onAction="#txtHandle" prefHeight="25.0" prefWidth="625.0" AnchorPane.leftAnchor="3.0" AnchorPane.rightAnchor="145.0" />
<Button fx:id="bt" layoutX="702.0" layoutY="33.0" mnemonicParsing="false" onAction="#handle" prefHeight="25.0" prefWidth="68.0" text="Go" AnchorPane.rightAnchor="14.0" />
<MenuBar fx:id="menubar" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefWidth="784.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="14.0">
<menus>
<Menu mnemonicParsing="false" text="Menu">
<items>
<MenuItem mnemonicParsing="false" text="History" />
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Option">
<items>
<MenuItem mnemonicParsing="false" onAction="#blockHandle" text="Block Site" />
<MenuItem fx:id="viewBlock" mnemonicParsing="false" onAction="#viewBlockHandle" text="View Blocked Websites" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" onAction="#aboutHandle" text="About Us" />
</items>
</Menu>
</menus>
</MenuBar>
<WebView fx:id="webView" prefHeight="495.0" prefWidth="784.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="65.0" />
<VBox alignment="CENTER" layoutX="244.0" layoutY="168.0" prefHeight="344.0" prefWidth="458.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="65.0">
<children>
<ImageView fx:id="img" fitHeight="288.0" fitWidth="394.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../Image/logo.png" />
</image>
</ImageView>
</children>
</VBox>
</children>
</AnchorPane>