Search in sources :

Example 41 with WebView

use of javafx.scene.web.WebView in project POL-POM-5 by PlayOnLinux.

the class StepRepresentationHtmlPresentation method drawStepContent.

@Override
protected void drawStepContent() {
    final String title = this.getParentWizardTitle();
    VBox contentPane = new VBox();
    contentPane.setId("presentationBackground");
    Label titleWidget = new Label(title + "\n\n");
    titleWidget.setId("presentationTextTitle");
    WebView webView = new WebView();
    VBox.setVgrow(webView, Priority.ALWAYS);
    webView.getEngine().loadContent(htmlToShow);
    final URL style = getClass().getResource(String.format("/org/phoenicis/javafx/themes/%s/description.css", getParent().getThemeManager().getCurrentTheme().getShortName()));
    webView.getEngine().setUserStyleSheetLocation(style.toString());
    contentPane.getChildren().addAll(webView);
    getParent().getRoot().setCenter(contentPane);
}
Also used : Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) VBox(javafx.scene.layout.VBox) URL(java.net.URL)

Example 42 with WebView

use of javafx.scene.web.WebView in project open-ecard by ecsec.

the class HTMLPanel method initFx.

/**
 * Initializes the Java FX components and fills them with content.
 *
 * @param mimeType The MimeType of the {@code content} to display.
 * @param content The content to display.
 */
private static void initFx(String mimeType, byte[] content) {
    BorderPane borderPane = new BorderPane();
    browser = new WebView();
    WebEngine engine = browser.getEngine();
    engine.loadContent(new String(content, Charset.forName("UTF-8")));
    borderPane.setCenter(browser);
    Scene scene = new Scene(borderPane, 400, 200);
    jfxPane.setScene(scene);
}
Also used : BorderPane(javafx.scene.layout.BorderPane) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine)

Example 43 with WebView

use of javafx.scene.web.WebView in project tilesfx by HanSolo.

the class MapTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    mouseHandler = event -> {
        if (event.getClickCount() == 2) {
            centerLocation();
        }
    };
    locationListener = e -> redraw();
    poiListener = c -> {
        while (c.next()) {
            if (c.wasPermutated()) {
                // Get items that have been permutated in list
                for (int i = c.getFrom(); i < c.getTo(); ++i) {
                    updatePoi(tile.getPoiList().get(i));
                }
            } else if (c.wasUpdated()) {
                // Get items that have been updated in list
                for (int i = c.getFrom(); i < c.getTo(); ++i) {
                    updatePoi(tile.getPoiList().get(i));
                }
            } else if (c.wasAdded()) {
                c.getAddedSubList().forEach(poi -> addPoi(poi));
            } else if (c.wasRemoved()) {
                c.getRemoved().forEach(poi -> removePoi(poi));
            }
        }
    };
    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    text = new Text(tile.getText());
    text.setFill(tile.getTextColor());
    Helper.enableNode(text, tile.isTextVisible());
    webView = new WebView();
    webView.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    webView.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    webView.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
    webEngine = webView.getEngine();
    webEngine.getLoadWorker().stateProperty().addListener((ov, o, n) -> {
        if (Worker.State.SUCCEEDED == n) {
            readyToGo = true;
            if (MapProvider.BW != tile.getMapProvider()) {
                changeMapProvider(tile.getMapProvider());
            }
            updateLocation();
            updateLocationColor();
            tile.getPoiList().forEach(poi -> addPoi(poi));
            addTrack(tile.getTrack());
            updateTrackColor();
        }
    });
    URL maps = Tile.class.getResource("osm.html");
    webEngine.load(maps.toExternalForm());
    getPane().getChildren().addAll(titleText, webView, text);
}
Also used : Tile(eu.hansolo.tilesfx.Tile) EventHandler(javafx.event.EventHandler) Worker(javafx.concurrent.Worker) WebView(javafx.scene.web.WebView) WebEngine(javafx.scene.web.WebEngine) Fonts(eu.hansolo.tilesfx.fonts.Fonts) Location(eu.hansolo.tilesfx.tools.Location) URL(java.net.URL) MouseEvent(javafx.scene.input.MouseEvent) Font(javafx.scene.text.Font) MapProvider(eu.hansolo.tilesfx.Tile.MapProvider) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) List(java.util.List) Helper(eu.hansolo.tilesfx.tools.Helper) ListChangeListener(javafx.collections.ListChangeListener) DateTimeFormatter(java.time.format.DateTimeFormatter) LocationEventListener(eu.hansolo.tilesfx.events.LocationEventListener) Text(javafx.scene.text.Text) WebView(javafx.scene.web.WebView) URL(java.net.URL)

Example 44 with WebView

use of javafx.scene.web.WebView in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method initComponents.

private void initComponents() {
    Platform.runLater(() -> {
        pane = new StackPane();
        webComponent = new WebView();
        engine = webComponent.getEngine();
        pane.getChildren().add(webComponent);
        initHyperlinkListener();
        initConsoleListener();
        Scene scene = new Scene(pane);
        panel.setScene(scene);
        panel.setVisible(true);
        updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
    });
    add(panel, BorderLayout.CENTER);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
Also used : DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 45 with WebView

use of javafx.scene.web.WebView in project PokeGOAPI-Java by Grover-c13.

the class SolveCaptchaExample method completeCaptcha.

private static void completeCaptcha(final PokemonGo api, final String challengeURL) {
    // Run this on the swing thread
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            // Run on JFX Thread
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    JFXPanel panel = new JFXPanel();
                    // Create a WebView and WebEngine to display the captcha from challengeURL.
                    WebView view = new WebView();
                    WebEngine engine = view.getEngine();
                    // Set UserAgent so the captcha shows correctly in the WebView.
                    engine.setUserAgent(CaptchaSolveHelper.USER_AGENT);
                    engine.load(challengeURL);
                    final JFrame frame = new JFrame("Solve Captcha");
                    // Register listener to receive the token when the captcha has been solved from inside the WebView.
                    CaptchaSolveHelper.Listener listener = new CaptchaSolveHelper.Listener() {

                        @Override
                        public void onTokenReceived(String token) {
                            System.out.println("Token received: " + token + "!");
                            // Remove this listener as we no longer need to listen for tokens, the captcha has been solved.
                            CaptchaSolveHelper.removeListener(this);
                            try {
                                // Close this window, it not valid anymore.
                                frame.setVisible(false);
                                frame.dispose();
                                if (api.verifyChallenge(token)) {
                                    System.out.println("Captcha was correctly solved!");
                                } else {
                                    // verifyChallenge will receive a new captcha url if this one is invalid
                                    System.out.println("Captcha was incorrectly solved! Please try again.");
                                }
                            } catch (Exception e) {
                                Log.e("Main", "Error while solving captcha!", e);
                            }
                        }
                    };
                    CaptchaSolveHelper.registerListener(listener);
                    // Applies the WebView to this panel
                    panel.setScene(new Scene(view));
                    frame.getContentPane().add(panel);
                    frame.setSize(500, 500);
                    frame.setVisible(true);
                    // Don't allow this window to be closed
                    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
                    frame.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            System.out.println("Please solve the captcha before closing the window!");
                        }
                    });
                }
            });
        }
    });
}
Also used : CaptchaSolveHelper(com.pokegoapi.util.CaptchaSolveHelper) JFXPanel(javafx.embed.swing.JFXPanel) LoginListener(com.pokegoapi.api.listener.LoginListener) WindowAdapter(java.awt.event.WindowAdapter) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WebView(javafx.scene.web.WebView)

Aggregations

WebView (javafx.scene.web.WebView)50 Scene (javafx.scene.Scene)31 WebEngine (javafx.scene.web.WebEngine)15 BorderPane (javafx.scene.layout.BorderPane)10 Button (javafx.scene.control.Button)9 URL (java.net.URL)8 ObservableValue (javafx.beans.value.ObservableValue)7 Label (javafx.scene.control.Label)7 Tooltip (javafx.scene.control.Tooltip)7 StackPane (javafx.scene.layout.StackPane)6 VBox (javafx.scene.layout.VBox)6 Stage (javafx.stage.Stage)6 State (javafx.concurrent.Worker.State)5 JFXPanel (javafx.embed.swing.JFXPanel)5 ScrollPane (javafx.scene.control.ScrollPane)5 JFrame (javax.swing.JFrame)5 URI (java.net.URI)4 InvalidationListener (javafx.beans.InvalidationListener)4 FXCollections (javafx.collections.FXCollections)4 javafx.scene.layout (javafx.scene.layout)4