Search in sources :

Example 31 with Engine

use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.

the class DisableZoom method main.

public static void main(String[] args) {
    Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        JFrame frame = new JFrame("Disable Zoom");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    browser.navigation().loadUrlAndWait("https://www.google.com");
    // Disabling zoom.
    browser.zoom().disable();
    // Setting zoom to 300% that will not be applied.
    browser.zoom().level(ZoomLevel.P_300);
}
Also used : JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 32 with Engine

use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.

the class SamplePart method createComposite.

@PostConstruct
public void createComposite(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).licenseKey("your_license_key").build());
    Browser browser = engine.newBrowser();
    Text addressBar = new Text(parent, SWT.SINGLE);
    addressBar.setText("https://google.com");
    addressBar.addListener(SWT.Traverse, event -> {
        if (event.detail == SWT.TRAVERSE_RETURN) {
            browser.navigation().loadUrl(addressBar.getText());
        }
    });
    browser.navigation().loadUrl(addressBar.getText());
    GridData textGrid = new GridData();
    textGrid.horizontalAlignment = GridData.FILL;
    addressBar.setLayoutData(textGrid);
    BrowserView view = BrowserView.newInstance(parent, browser);
    view.setLayoutData(new GridData(FILL, FILL, true, true));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) BrowserView(com.teamdev.jxbrowser.view.swt.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser) PostConstruct(javax.annotation.PostConstruct)

Example 33 with Engine

use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.

the class TargetApp method main.

public static void main(String[] args) {
    // Set your JxBrowser license key.
    System.setProperty("jxbrowser.license.key", "your_license_key");
    // #docfragment "forward-remote-debugging-port"
    // Create a builder for EngineOptions.
    EngineOptions.Builder builder = EngineOptions.newBuilder(HARDWARE_ACCELERATED);
    // Configure Engine with the remote debugging port obtained from the command line args.
    remoteDebuggingPortFromCommandLine(args).ifPresent(builder::remoteDebuggingPort);
    // #enddocfragment "forward-remote-debugging-port"
    // Creating Chromium engine.
    Engine engine = Engine.newInstance(builder.build());
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        // Creating Swing component for rendering web content
        // loaded in the given Browser instance.
        BrowserView view = BrowserView.newInstance(browser);
        // Creating and displaying Swing app frame.
        JFrame frame = new JFrame();
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                engine.close();
            }
        });
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(800, 700);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        browser.navigation().loadUrl("https://google.com");
    });
}
Also used : JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) EngineOptions(com.teamdev.jxbrowser.engine.EngineOptions) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 34 with Engine

use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-QuickStart by TeamDev-IP.

the class HelloWorld method main.

public static void main(String[] args) {
    // Initialize Chromium.
    Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
    // Create a Browser instance.
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        JFrame frame = new JFrame("JxBrowser AWT/Swing");
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Shutdown Chromium and release allocated resources.
                engine.close();
            }
        });
        // Create and embed Swing BrowserView component to display web content.
        frame.add(BrowserView.newInstance(browser));
        frame.setSize(1280, 800);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        // Load the required web page.
        browser.navigation().loadUrl("https://html5test.com/");
    });
}
Also used : JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 35 with Engine

use of com.teamdev.jxbrowser.engine.Engine 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)

Aggregations

Browser (com.teamdev.jxbrowser.browser.Browser)70 Engine (com.teamdev.jxbrowser.engine.Engine)70 JFrame (javax.swing.JFrame)50 BrowserView (com.teamdev.jxbrowser.view.swing.BrowserView)46 BorderLayout (java.awt.BorderLayout)8 HARDWARE_ACCELERATED (com.teamdev.jxbrowser.engine.RenderingMode.HARDWARE_ACCELERATED)7 SwingUtilities (javax.swing.SwingUtilities)7 WindowConstants (javax.swing.WindowConstants)7 EngineOptions (com.teamdev.jxbrowser.engine.EngineOptions)6 Document (com.teamdev.jxbrowser.dom.Document)5 Frame (com.teamdev.jxbrowser.frame.Frame)5 JsObject (com.teamdev.jxbrowser.js.JsObject)5 FrameLoadFinished (com.teamdev.jxbrowser.navigation.event.FrameLoadFinished)5 WindowAdapter (java.awt.event.WindowAdapter)4 WindowEvent (java.awt.event.WindowEvent)4 OFF_SCREEN (com.teamdev.jxbrowser.engine.RenderingMode.OFF_SCREEN)3 Navigation (com.teamdev.jxbrowser.navigation.Navigation)3 Bitmap (com.teamdev.jxbrowser.ui.Bitmap)3 BrowserView (com.teamdev.jxbrowser.view.javafx.BrowserView)3 BrowserView (com.teamdev.jxbrowser.view.swt.BrowserView)3