When reducing the height of a WebView by using setMaxHeight, the parts of the WebView that should be hidden stay on screen as if the window was not updated. Execute the code below and click the "reduce" button for testing :
--- begin code
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(Main.class);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 600, 650);
VBox layout = new VBox();
root.getChildren().add(layout);
stage.setScene(scene);
stage.show();
final WebView wv = new WebView();
wv.setMaxHeight(600);
wv.getEngine().loadContent("<!DOCTYPE html><html><head><title>test</title></head><body style='background-color: blue'></body></html>");
Button reduceButton = new Button("reduce");
reduceButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
wv.setMaxHeight(100);
wv.requestFocus();
}
});
layout.getChildren().addAll(reduceButton, wv);
}
}
--- end code
--- begin code
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
Application.launch(Main.class);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 600, 650);
VBox layout = new VBox();
root.getChildren().add(layout);
stage.setScene(scene);
stage.show();
final WebView wv = new WebView();
wv.setMaxHeight(600);
wv.getEngine().loadContent("<!DOCTYPE html><html><head><title>test</title></head><body style='background-color: blue'></body></html>");
Button reduceButton = new Button("reduce");
reduceButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
wv.setMaxHeight(100);
wv.requestFocus();
}
});
layout.getChildren().addAll(reduceButton, wv);
}
}
--- end code