Search in sources :

Example 36 with BrowserView

use of com.teamdev.jxbrowser.view.swing.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class FileUpload 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("File Upload");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    browser.set(OpenFileCallback.class, (params, tell) -> tell.open(Paths.get("file.txt")));
    browser.mainFrame().ifPresent(mainFrame -> {
        mainFrame.loadHtml("Please specify a file, or a set of files:<br>\n" + "<input type='file' name='datafile' size='40'>");
    });
}
Also used : JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 37 with BrowserView

use of com.teamdev.jxbrowser.view.swing.BrowserView in project JxBrowser-Examples by TeamDev-IP.

the class FilterImages 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("Filter Images");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    engine.network().set(BeforeUrlRequestCallback.class, params -> {
        if (params.urlRequest().resourceType() == IMAGE) {
            return BeforeUrlRequestCallback.Response.cancel();
        }
        return BeforeUrlRequestCallback.Response.proceed();
    });
    browser.navigation().loadUrl("https://www.google.com");
}
Also used : JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 38 with BrowserView

use of com.teamdev.jxbrowser.view.swing.BrowserView 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");
}
Also used : SwingUtilities(javax.swing.SwingUtilities) JTextField(javax.swing.JTextField) Browser(com.teamdev.jxbrowser.browser.Browser) HARDWARE_ACCELERATED(com.teamdev.jxbrowser.engine.RenderingMode.HARDWARE_ACCELERATED) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) WindowConstants(javax.swing.WindowConstants) JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) JTextField(javax.swing.JTextField) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 39 with BrowserView

use of com.teamdev.jxbrowser.view.swing.BrowserView 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");
}
Also used : Navigation(com.teamdev.jxbrowser.navigation.Navigation) JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Example 40 with BrowserView

use of com.teamdev.jxbrowser.view.swing.BrowserView 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");
}
Also used : JFrame(javax.swing.JFrame) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Aggregations

BrowserView (com.teamdev.jxbrowser.view.swing.BrowserView)49 Browser (com.teamdev.jxbrowser.browser.Browser)47 JFrame (javax.swing.JFrame)47 Engine (com.teamdev.jxbrowser.engine.Engine)46 BorderLayout (java.awt.BorderLayout)8 HARDWARE_ACCELERATED (com.teamdev.jxbrowser.engine.RenderingMode.HARDWARE_ACCELERATED)7 SwingUtilities (javax.swing.SwingUtilities)7 WindowConstants (javax.swing.WindowConstants)7 EngineOptions (com.teamdev.jxbrowser.engine.EngineOptions)5 Document (com.teamdev.jxbrowser.dom.Document)4 FrameLoadFinished (com.teamdev.jxbrowser.navigation.event.FrameLoadFinished)4 WindowAdapter (java.awt.event.WindowAdapter)4 WindowEvent (java.awt.event.WindowEvent)4 Navigation (com.teamdev.jxbrowser.navigation.Navigation)3 JButton (javax.swing.JButton)3 Frame (com.teamdev.jxbrowser.frame.Frame)2 Path (java.nio.file.Path)2 Content (com.intellij.ui.content.Content)1 UnsupportedRenderingModeException (com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException)1 SpellCheckCompleted (com.teamdev.jxbrowser.browser.event.SpellCheckCompleted)1