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);
});
}
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");
});
}
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);
});
}
Aggregations