fork download
  1. import javafx.application.Application;
  2. import javafx.geometry.HPos;
  3. import javafx.geometry.VPos;
  4. import javafx.scene.Node;
  5. import javafx.scene.Scene;
  6. import javafx.scene.layout.HBox;
  7. import javafx.scene.layout.Priority;
  8. import javafx.scene.layout.Region;
  9. import javafx.scene.paint.Color;
  10. import javafx.scene.web.WebEngine;
  11. import javafx.scene.web.WebView;
  12. import javafx.stage.Stage;
  13.  
  14.  
  15. public class WebViewSample extends Application {
  16. private Scene scene;
  17. @Override public void start(Stage stage) {
  18. // create the scene
  19. stage.setTitle("Web View");
  20. scene = new Scene(new Browser(),750,500, Color.web("#666970"));
  21. stage.setScene(scene);
  22. scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
  23. stage.show();
  24. }
  25.  
  26. public static void main(String[] args){
  27. launch(args);
  28. }
  29. }
  30. class Browser extends Region {
  31.  
  32. final WebView browser = new WebView();
  33. final WebEngine webEngine = browser.getEngine();
  34.  
  35. public Browser() {
  36. //apply the styles
  37. getStyleClass().add("browser");
  38. // load the web page
  39. webEngine.load("http://w...content-available-to-author-only...e.com/products/index.html");
  40. //add the web view to the scene
  41. getChildren().add(browser);
  42.  
  43. }
  44. private Node createSpacer() {
  45. Region spacer = new Region();
  46. HBox.setHgrow(spacer, Priority.ALWAYS);
  47. return spacer;
  48. }
  49.  
  50. @Override protected void layoutChildren() {
  51. double w = getWidth();
  52. double h = getHeight();
  53. layoutInArea(browser,0,0,w,h,0, HPos.CENTER, VPos.CENTER);
  54. }
  55.  
  56. @Override protected double computePrefWidth(double height) {
  57. return 750;
  58. }
  59.  
  60. @Override protected double computePrefHeight(double width) {
  61. return 500;
  62. }
  63. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: class WebViewSample is public, should be declared in a file named WebViewSample.java
public class WebViewSample extends Application {
       ^
Main.java:1: error: package javafx.application does not exist
import javafx.application.Application;
                         ^
Main.java:2: error: package javafx.geometry does not exist
import javafx.geometry.HPos;
                      ^
Main.java:3: error: package javafx.geometry does not exist
import javafx.geometry.VPos;
                      ^
Main.java:4: error: package javafx.scene does not exist
import javafx.scene.Node;
                   ^
Main.java:5: error: package javafx.scene does not exist
import javafx.scene.Scene;
                   ^
Main.java:6: error: package javafx.scene.layout does not exist
import javafx.scene.layout.HBox;
                          ^
Main.java:7: error: package javafx.scene.layout does not exist
import javafx.scene.layout.Priority;
                          ^
Main.java:8: error: package javafx.scene.layout does not exist
import javafx.scene.layout.Region;
                          ^
Main.java:9: error: package javafx.scene.paint does not exist
import javafx.scene.paint.Color;
                         ^
Main.java:10: error: package javafx.scene.web does not exist
import javafx.scene.web.WebEngine;
                       ^
Main.java:11: error: package javafx.scene.web does not exist
import javafx.scene.web.WebView;
                       ^
Main.java:12: error: package javafx.stage does not exist
import javafx.stage.Stage;
                   ^
Main.java:15: error: cannot find symbol
public class WebViewSample extends Application {
                                   ^
  symbol: class Application
Main.java:16: error: cannot find symbol
    private Scene scene;
            ^
  symbol:   class Scene
  location: class WebViewSample
Main.java:17: error: cannot find symbol
    @Override public void start(Stage stage) {
                                ^
  symbol:   class Stage
  location: class WebViewSample
Main.java:30: error: cannot find symbol
class Browser extends Region {
                      ^
  symbol: class Region
Main.java:32: error: cannot find symbol
    final WebView browser = new WebView();
          ^
  symbol:   class WebView
  location: class Browser
Main.java:33: error: cannot find symbol
    final WebEngine webEngine = browser.getEngine();
          ^
  symbol:   class WebEngine
  location: class Browser
Main.java:44: error: cannot find symbol
    private Node createSpacer() {
            ^
  symbol:   class Node
  location: class Browser
Main.java:17: error: method does not override or implement a method from a supertype
    @Override public void start(Stage stage) {
    ^
Main.java:20: error: cannot find symbol
        scene = new Scene(new Browser(),750,500, Color.web("#666970"));
                    ^
  symbol:   class Scene
  location: class WebViewSample
Main.java:20: error: cannot find symbol
        scene = new Scene(new Browser(),750,500, Color.web("#666970"));
                                                 ^
  symbol:   variable Color
  location: class WebViewSample
Main.java:27: error: cannot find symbol
        launch(args);
        ^
  symbol:   method launch(String[])
  location: class WebViewSample
Main.java:32: error: cannot find symbol
    final WebView browser = new WebView();
                                ^
  symbol:   class WebView
  location: class Browser
Main.java:37: error: cannot find symbol
        getStyleClass().add("browser");
        ^
  symbol:   method getStyleClass()
  location: class Browser
Main.java:41: error: cannot find symbol
        getChildren().add(browser);
        ^
  symbol:   method getChildren()
  location: class Browser
Main.java:45: error: cannot find symbol
        Region spacer = new Region();
        ^
  symbol:   class Region
  location: class Browser
Main.java:45: error: cannot find symbol
        Region spacer = new Region();
                            ^
  symbol:   class Region
  location: class Browser
Main.java:46: error: cannot find symbol
        HBox.setHgrow(spacer, Priority.ALWAYS);
                              ^
  symbol:   variable Priority
  location: class Browser
Main.java:46: error: cannot find symbol
        HBox.setHgrow(spacer, Priority.ALWAYS);
        ^
  symbol:   variable HBox
  location: class Browser
Main.java:50: error: method does not override or implement a method from a supertype
    @Override protected void layoutChildren() {
    ^
Main.java:51: error: cannot find symbol
        double w = getWidth();
                   ^
  symbol:   method getWidth()
  location: class Browser
Main.java:52: error: cannot find symbol
        double h = getHeight();
                   ^
  symbol:   method getHeight()
  location: class Browser
Main.java:53: error: cannot find symbol
        layoutInArea(browser,0,0,w,h,0, HPos.CENTER, VPos.CENTER);
                                        ^
  symbol:   variable HPos
  location: class Browser
Main.java:53: error: cannot find symbol
        layoutInArea(browser,0,0,w,h,0, HPos.CENTER, VPos.CENTER);
                                                     ^
  symbol:   variable VPos
  location: class Browser
Main.java:56: error: method does not override or implement a method from a supertype
    @Override protected double computePrefWidth(double height) {
    ^
Main.java:60: error: method does not override or implement a method from a supertype
    @Override protected double computePrefHeight(double width) {
    ^
38 errors
stdout
Standard output is empty