Usage

You can use Equo Chromium in an SWT application as an SWT Control, in Swing application as Swing Component, or in a plain Java application as a Standalone browser without UI dependencies or without GUI as a Windowless browser.

SWT Toolkit

To use the Equo Chromium widget add the following Java import to your classes:

com.equo.chromium.swt.Browser
There are a few duplicated classes also (com.equo.chromium.swt.OpenWindowListener and com.equo.chromium.swt.WindowEvent) which may require changing the import or using fully qualified names if you see compile errors.

Using Equo Chromium to Create Web-based UIs

Using and integrating Equo Chromium in your Java application is as simple as adding an import sentence and instantiating the Equo Chromium browser.

First, add the following import sentence to your Java classes:

import com.equo.swt.chromium.Browser;

Then, you just need to create an instance of the Equo Chromium browser:

import com.equo.swt.chromium.Browser;
public class SinglePagePart {
    public void createBrowser(Composite parent, String url) {
        Browser browser = new Browser(parent, SWT.NONE);
        browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        browser.setUrl(url);
    }
}

Swing Toolkit

Use the Swing toolkit.

You will also need to override the default close operation so that browser processes are disposed of when you close the window [1].

import java.awt.BorderLayout;
import javax.swing.JFrame;

import com.equo.chromium.ChromiumBrowser;

public class Swing extends JFrame {

	Swing() {
		setDefaultCloseOperation(DISPOSE_ON_CLOSE); //[1]
		ChromiumBrowser browser = ChromiumBrowser.swing(getContentPane(), BorderLayout.CENTER,
				"https://docs.equo.dev/main/getting-started/introduction.html");
		setSize(800, 600);
		setVisible(true);
	}

	public static void main(String[] args) {
		new Swing();
	}
}

Standalone Toolkit

Using the Standalone toolkit you will not need to provide any graphical library since the operating system will take care of creating and managing the window for you.

import com.equo.chromium.ChromiumBrowser;

public class Standalone {
	public static void main(String[] args) {
		ChromiumBrowser browser = ChromiumBrowser
				.standalone("https://docs.equo.dev/main/getting-started/introduction.html");
		ChromiumBrowser.startBrowsers();
	}
}

Windowless Toolkit

Windowless browser toolkit.

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

import com.equo.chromium.ChromiumBrowser;

public class Windowless {
	public static void main(String[] args) throws ClassNotFoundException {
		ChromiumBrowser.earlyInit(); // (1)
		Display display = Display.getDefault();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		final ChromiumBrowser browser = ChromiumBrowser
				.windowless("https://docs.equo.dev/main/getting-started/introduction.html");
		Button button = new Button(shell, SWT.PUSH);
		button.setText("windowless");
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				browser.executeJavacript("console.log(document.body.innerHTML)");
			}
		});

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
You need use [1] and property -Dchromium.init_threads=true or use one of the methods described in Wayland Support section.

Examples

Complete Sample projects can be found here.