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

Display WebVIew SVG

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7u6, 7u15
    • javafx
    • None
    • Linux, Windows 7

    • web

      I have a problem with a webView component.
      In fact, I load with an iframe an url which contains SVG ( I can't modify the generated html).
      All works but this code is not displayed :
      package javafxapplication3;

      import java.io.IOException;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javafx.application.Application;
      import static javafx.application.Application.launch;
      import javafx.geometry.HPos;
      import javafx.geometry.VPos;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.Region;
      import javafx.scene.paint.Color;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;
      import javax.script.ScriptException;
      import org.apache.axis.AxisFault.*;

      public class JavaFXApplication3 extends Application {

          private Scene scene;

          @Override
          public void start(Stage stage) {
              // create the scene
              stage.setTitle("Web View");
              try {
                  scene = new Scene(new Browser(), 750, 500, Color.web("#666970"));
              } catch (IOException ex) {
                  Logger.getLogger(JavaFXApplication3.class.getName()).log(Level.SEVERE, null, ex);
              } catch (ScriptException ex) {
                  Logger.getLogger(JavaFXApplication3.class.getName()).log(Level.SEVERE, null, ex);
              }
              stage.setScene(scene);
              //scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
              stage.show();
          }

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

      class Browser extends Region {

          final WebView browser = new WebView();
          final WebEngine webEngine = browser.getEngine();

          public Browser() throws IOException, ScriptException {
              //apply the styles
              getStyleClass().add("browser");
              // load the web page
              webEngine.load("http://spagobi.eng.it/SpagoBI//servlet/AdapterHTTP?NEW_SESSION=true&ACTION_NAME=EXECUTE_DOCUMENT_ACTION&user_id=bi30&OBJECT_LABEL=Historical_Sales&ROLE=%2Fspagobi%2Fadmin&TOOLBAR_VISIBLE=true&SLIDERS_VISIBLE=TRUE");
              //webEngine.loadContent(null);
              //webEngine.load(ur);
              //add the web view to the scene
              getChildren().add(browser);

          }

          private Node createSpacer() {
              Region spacer = new Region();
              HBox.setHgrow(spacer, Priority.ALWAYS);
              return spacer;
          }

          @Override
          protected void layoutChildren() {
              double w = getWidth();
              double h = getHeight();
              layoutInArea(browser, 0, 0, w, h, 0, HPos.CENTER, VPos.CENTER);
          }

          @Override
          protected double computePrefWidth(double height) {
              return 750;
          }

          @Override
          protected double computePrefHeight(double width) {
              return 500;
          }
      }


      you can choose whatever you want in the select list and click on the gear ton run the document and see the chart.

      Thanks in advance !

            peterz Peter Zhelezniakov
            oflorianjfx Oliver Florian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: