When rendering an inline string containing an HTML page having a 'DIV' element styled blue. A blue rectangle appears to have a padding or margin (white space) left and above the 'DIV'.
I expected the rectangle would be in the upper left (0,0) but with a white scene it seems there is some kind of inset width around the 'DIV'.
package sample;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/**
* test for border, margin or padding using WebView
*/
public class Main4 extends Application {
Scene createScene() {
final WebView webView = new WebView();
final WebEngine webEngine = webView.getEngine();
webEngine.loadContent(
"<html>\n" +
"<body>" +
"<div style='margin: 0; padding-left: 0px; width: 100; height: 100; background: blue; ' />" +
"</body>\n" +
"</html>"
);
Group grp = new Group(webView);
Scene scene = new Scene(grp, 150, 150);
scene.setFill(null);
return scene;
}
@Override public void start(Stage stage) {
stage.setScene(createScene());
stage.sizeToScene();
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
I expected the rectangle would be in the upper left (0,0) but with a white scene it seems there is some kind of inset width around the 'DIV'.
package sample;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/**
* test for border, margin or padding using WebView
*/
public class Main4 extends Application {
Scene createScene() {
final WebView webView = new WebView();
final WebEngine webEngine = webView.getEngine();
webEngine.loadContent(
"<html>\n" +
"<body>" +
"<div style='margin: 0; padding-left: 0px; width: 100; height: 100; background: blue; ' />" +
"</body>\n" +
"</html>"
);
Group grp = new Group(webView);
Scene scene = new Scene(grp, 150, 150);
scene.setFill(null);
return scene;
}
@Override public void start(Stage stage) {
stage.setScene(createScene());
stage.sizeToScene();
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}