JavaFX WebView display svg file

Description

JavaFX WebView display svg file

import java.net.URL;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class Main extends Application {
   private Scene scene;

   @Override//from  ww  w  .j  a  v a  2s .c  om
   public void start(Stage stage) {
      // create the scene
      stage.setTitle("");
      final WebView browser = new WebView();
      URL url = getClass().getResource("clock3.svg");
      browser.getEngine().load(url.toExternalForm());
      scene = new Scene(browser, 320, 250, Color.rgb(0, 0, 0, .80));
      stage.setScene(scene);
      stage.show();
   }

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



PreviousNext

Related