use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.
the class FindText 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);
JTextField searchField = new JTextField("Text to find");
searchField.addActionListener(e -> browser.textFinder().find(searchField.getText(), findResult -> System.out.println("Matches found: " + findResult.numberOfMatches())));
JFrame frame = new JFrame("Find Text");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(searchField, BorderLayout.NORTH);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
browser.navigation().loadUrl("https://www.google.com");
}
use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.
the class GetHtml 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("Get HTML");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
});
Navigation navigation = browser.navigation();
// Add the callback for waiting till the page is loaded.
navigation.on(FrameLoadFinished.class, event -> {
if (event.frame().isMain()) {
browser.mainFrame().ifPresent(frame -> System.out.println("HTML = " + frame.html()));
}
});
navigation.loadUrl("https://www.teamdev.com/jxbrowser#features");
}
use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.
the class Html5Video 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("HTML5 Video");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
browser.navigation().loadUrl("http://www.quirksmode.org/html5/tests/video.html");
}
use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.
the class LocalWebStorage method main.
public static void main(String[] args) {
Engine engine = Engine.newInstance(OFF_SCREEN);
Browser browser = engine.newBrowser();
browser.navigation().loadUrlAndWait("https://www.google.com");
browser.mainFrame().ifPresent(frame -> {
frame.localStorage().putItem(KEY, "Tom");
System.out.println((String) frame.executeJavaScript(format("window.localStorage.getItem(\"%s\")", KEY)));
});
}
use of com.teamdev.jxbrowser.engine.Engine in project JxBrowser-Examples by TeamDev-IP.
the class MuteAudio 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);
JButton muteAudioButton = new JButton("Mute Audio");
muteAudioButton.addActionListener(e -> {
Audio audio = browser.audio();
if (audio.isMuted()) {
audio.unmute();
} else {
audio.mute();
}
updateButtonText(muteAudioButton, browser);
});
JFrame frame = new JFrame("Mute Audio");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(muteAudioButton, BorderLayout.NORTH);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
browser.navigation().loadUrl("https://www.youtube.com/");
}
Aggregations