Search in sources :

Example 1 with EngineOptions

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

the class DomMouseEvents method main.

public static void main(String[] args) {
    EngineOptions options = EngineOptions.newBuilder(HARDWARE_ACCELERATED).build();
    Engine engine = Engine.newInstance(options);
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        JFrame frame = new JFrame("DOM Mouse Event Listener");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(800, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    loadHtmlAndWait(browser);
    findButton(browser).ifPresent(element -> {
        element.addEventListener(MOUSE_DOWN, DomMouseEvents::printEventDetails, false);
        element.addEventListener(MOUSE_UP, DomMouseEvents::printEventDetails, false);
        element.addEventListener(MOUSE_OVER, DomMouseEvents::printEventDetails, false);
    });
}
Also used : JFrame(javax.swing.JFrame) 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 2 with EngineOptions

use of com.teamdev.jxbrowser.engine.EngineOptions 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 3 with EngineOptions

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

the class DomKeyEvents method main.

public static void main(String[] args) {
    EngineOptions options = EngineOptions.newBuilder(HARDWARE_ACCELERATED).build();
    Engine engine = Engine.newInstance(options);
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        JFrame frame = new JFrame("DOM Keyboard Event Listener ");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(800, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    loadHtmlAndWait(browser);
    findInputField(browser).ifPresent(element -> {
        element.addEventListener(KEY_DOWN, DomKeyEvents::printEventDetails, false);
        element.addEventListener(KEY_PRESS, DomKeyEvents::printEventDetails, false);
        element.addEventListener(KEY_UP, DomKeyEvents::printEventDetails, false);
    });
}
Also used : JFrame(javax.swing.JFrame) 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)

Aggregations

Browser (com.teamdev.jxbrowser.browser.Browser)3 Engine (com.teamdev.jxbrowser.engine.Engine)3 EngineOptions (com.teamdev.jxbrowser.engine.EngineOptions)3 BrowserView (com.teamdev.jxbrowser.view.swing.BrowserView)3 JFrame (javax.swing.JFrame)3 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1