use of com.teamdev.jxbrowser.browser.Browser in project JxBrowser-Examples by TeamDev-IP.
the class DisablePdfViewer method main.
public static void main(String[] args) {
Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
Plugins plugins = engine.plugins();
// #docfragment "disabling-pdf-viewer"
plugins.settings().disablePdfViewer();
// #enddocfragment "disabling-pdf-viewer"
Browser browser = engine.newBrowser();
invokeLater(() -> {
// Display a Swing frame with embedded BrowserView.
showGui(browser);
// Now, if you load a PDF document, it will not be displayed in the
// PDF Viewer and will be downloaded instead.
browser.navigation().loadUrl("http://www.orimi.com/pdf-test.pdf");
});
}
use of com.teamdev.jxbrowser.browser.Browser 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);
}
use of com.teamdev.jxbrowser.browser.Browser 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));
}
use of com.teamdev.jxbrowser.browser.Browser 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.browser.Browser 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/");
});
}
Aggregations