use of com.teamdev.jxbrowser.zoom.ZoomLevels in project JxBrowser-Examples by TeamDev-IP.
the class ZoomLevel 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("Change Zoom Level");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
// Listen to the zoom changed events.
ZoomLevels levels = engine.zoomLevels();
levels.on(ZoomLevelChanged.class, event -> System.out.println("Url: " + event.host() + "\n" + "Zoom level: " + event.level()));
Navigation navigation = browser.navigation();
navigation.on(FrameLoadFinished.class, event -> {
if (event.frame().isMain()) {
browser.zoom().level(com.teamdev.jxbrowser.zoom.ZoomLevel.P_200);
}
});
navigation.loadUrl("https://www.google.com");
}
Aggregations