My problem is when I am restoring minimized javafx application from windows taskbar WebView become disabled.
After resize stage it becomes enabled.
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>