Search in sources :

Example 1 with BrowserView

use of com.teamdev.jxbrowser.view.javafx.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class DefaultOpenPopupCallback method on.

@Override
public Response on(Params params) {
    Browser browser = params.popupBrowser();
    Platform.runLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        Stage stage = new Stage();
        StackPane root = new StackPane();
        Scene scene = new Scene(root);
        root.getChildren().add(view);
        stage.setScene(scene);
        updateBounds(stage, params.initialBounds());
        stage.setOnCloseRequest(event -> browser.close());
        browser.on(TitleChanged.class, event -> Platform.runLater(() -> stage.setTitle(event.title())));
        browser.on(BrowserClosed.class, event -> Platform.runLater(stage::close));
        browser.on(UpdateBoundsRequested.class, event -> Platform.runLater(() -> updateBounds(stage, event.bounds())));
        stage.show();
    });
    return Response.proceed();
}
Also used : Stage(javafx.stage.Stage) BrowserView(com.teamdev.jxbrowser.view.javafx.BrowserView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 2 with BrowserView

use of com.teamdev.jxbrowser.view.javafx.BrowserView in project JxBrowser-QuickStart by TeamDev-IP.

the class HelloWorld method start.

@Override
public void start(Stage primaryStage) {
    // Initialize Chromium.
    Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
    Browser browser = engine.newBrowser();
    // Load the required web page.
    browser.navigation().loadUrl("https://html5test.com");
    // Create and embed JavaFX BrowserView component to display web content.
    BrowserView view = BrowserView.newInstance(browser);
    Scene scene = new Scene(new BorderPane(view), 1280, 800);
    primaryStage.setTitle("JxBrowser JavaFX");
    primaryStage.setScene(scene);
    primaryStage.show();
    // Shutdown Chromium and release allocated resources.
    primaryStage.setOnCloseRequest(event -> engine.close());
}
Also used : BorderPane(javafx.scene.layout.BorderPane) BrowserView(com.teamdev.jxbrowser.view.javafx.BrowserView) Scene(javafx.scene.Scene) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 3 with BrowserView

use of com.teamdev.jxbrowser.view.javafx.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class BrowserViewInJFxPanel method main.

public static void main(String[] args) {
    Engine engine = Engine.newInstance(OFF_SCREEN);
    Browser browser = engine.newBrowser();
    JFXPanel panel = new JFXPanel();
    Platform.runLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        panel.setScene(new Scene(view));
    });
    SwingUtilities.invokeLater(() -> {
        JFrame frame = new JFrame("JavaFX BrowserView in Swing app");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(panel, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    });
    browser.navigation().loadUrl("https://www.google.com");
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.javafx.BrowserView) Scene(javafx.scene.Scene) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 4 with BrowserView

use of com.teamdev.jxbrowser.view.javafx.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class BrowserViewInTabPane method start.

@Override
public void start(Stage primaryStage) {
    Engine engine = Engine.newInstance(OFF_SCREEN);
    Browser browserOne = engine.newBrowser();
    browserOne.navigation().loadUrl("https://www.google.com");
    BrowserView viewOne = BrowserView.newInstance(browserOne);
    Tab tabOne = new Tab("Browser One");
    tabOne.setContent(viewOne);
    Browser browserTwo = engine.newBrowser();
    browserTwo.navigation().loadUrl("https://www.teamdev.com");
    BrowserView viewTwo = BrowserView.newInstance(browserTwo);
    Tab tabTwo = new Tab("Browser Two");
    tabTwo.setContent(viewTwo);
    TabPane tabPane = new TabPane();
    tabPane.getTabs().add(tabOne);
    tabPane.getTabs().add(tabTwo);
    Group root = new Group();
    Scene scene = new Scene(root, 700, 500);
    BorderPane pane = new BorderPane();
    pane.prefHeightProperty().bind(scene.heightProperty());
    pane.prefWidthProperty().bind(scene.widthProperty());
    pane.setCenter(tabPane);
    root.getChildren().add(pane);
    primaryStage.setTitle("Browser View In Tab Pane");
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : TabPane(javafx.scene.control.TabPane) Group(javafx.scene.Group) BorderPane(javafx.scene.layout.BorderPane) Tab(javafx.scene.control.Tab) BrowserView(com.teamdev.jxbrowser.view.javafx.BrowserView) Scene(javafx.scene.Scene) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 5 with BrowserView

use of com.teamdev.jxbrowser.view.javafx.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class JavaFxBrowserView method start.

@Override
public void start(final Stage primaryStage) {
    Engine engine = Engine.newInstance(OFF_SCREEN);
    Browser browser = engine.newBrowser();
    BrowserView view = BrowserView.newInstance(browser);
    Scene scene = new Scene(new BorderPane(view), 700, 500);
    primaryStage.setTitle("JavaFx BrowserView");
    primaryStage.setScene(scene);
    primaryStage.show();
    browser.navigation().loadUrl("https://www.google.com");
}
Also used : BorderPane(javafx.scene.layout.BorderPane) BrowserView(com.teamdev.jxbrowser.view.javafx.BrowserView) Scene(javafx.scene.Scene) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Aggregations

Browser (com.teamdev.jxbrowser.browser.Browser)5 BrowserView (com.teamdev.jxbrowser.view.javafx.BrowserView)5 Scene (javafx.scene.Scene)5 Engine (com.teamdev.jxbrowser.engine.Engine)4 BorderPane (javafx.scene.layout.BorderPane)3 JFXPanel (javafx.embed.swing.JFXPanel)1 Group (javafx.scene.Group)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 StackPane (javafx.scene.layout.StackPane)1 Stage (javafx.stage.Stage)1 JFrame (javax.swing.JFrame)1