Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8120652

WebView adds padding (or margin) when rendered on the Scene.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7u60
    • javafx
    • Windows 7 JDK 8 b106 32 bit

    • web

      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);
          }
      }

            peterz Peter Zhelezniakov
            cdea Carl Dea
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: