gpt4 book ai didi

javafx - 从最小化 WebView 恢复后在 javafx 中被禁用

转载 作者:行者123 更新时间:2023-12-02 09:48:17 25 4
gpt4 key购买 nike

我的问题是当我从 Windows 任务栏恢复最小化的 javafx 应用程序时,WebView 被禁用。

调整舞台大小后,它就会启用。

Main java Code:

public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
AnchorPane root = new AnchorPane();
FXMLLoader loader = new FXMLLoader(getClass().getResource("Browser.fxml"));
root = loader.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle("Shivam Jewels ERP");
primaryStage.setMaximized(true);
primaryStage.show();
primaryStage.iconifiedProperty().addListener(new ChangeListener<Boolean>() {

@Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (t1) {
System.out.println("minimized:");
}
}
});
primaryStage.maximizedProperty().addListener(new ChangeListener<Boolean>() {

@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue) {
System.out.println("maximized:");
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
launch(args);
}
}

My JavaFX Code Is:

public class BrowserController implements Initializable {
@FXML
private WebView browser;
@FXML
private GridPane grdPn;

@Override
public void initialize(URL location, ResourceBundle resources) {
final WebEngine webEngine = browser.getEngine();
browser.getEngine().setUserStyleSheetLocation(getClass().getResource("application.css").toExternalForm());
browser.setContextMenuEnabled(false);
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
webEngine.load("http://192.168.2.6:4200");
}

}

This is my CSS Code:

 ::-webkit-scrollbar {
width: 6px;
}

::-webkit-scrollbar-track {
-webkit-border-radius: 10px;
border-radius: 10px;
}

::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(0,0,0,0.1);
}

This is my FXML Code:

 <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.web.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="382.0" prefWidth="353.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.BrowserController">
<children>
<GridPane fx:id="grdPn" layoutX="57.0" layoutY="135.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
</columnConstraints>
<rowConstraints>
<RowConstraints fillHeight="false" valignment="CENTER" vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<children>
<WebView fx:id="browser" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS" />
</children>
</GridPane>
</children>`enter code here`
</AnchorPane>

最佳答案

这实际上是多次报告的 JDK bug here , herehere 。您所描述的行为发生在 satge 最大化时。

这个 bug 计划在 JDK9 中修复,但根据 this JDK8u122 中也将得到修复:

Approved to backport to 8u-dev for 8u122.

JDK 8u122 is planned将于 2017 年 1 月发布,因此我们很快就能使用它,但现在您可以从 JDK 8u122 early access page 下载并使用早期访问版本.

我自己下载了它并测试了代码,幸运的是问题不再存在。

关于javafx - 从最小化 WebView 恢复后在 javafx 中被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41339375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com