Reference
API at a glance
A quick lookup of the main Jolt types and calls for Java and for the page, with links to the page that explains each.
A quick lookup of the main types and calls, with a link to the page that explains each. Everything here is in the package io.github.b077as.jolt unless noted.
Application and options
| Call | What it does |
Application.create(AppOptions) | Builds the app on the matching backend. |
AppOptions.of(id) | App id, data folder. withDataDirectory, withQuitWhenLastWindowClosed, withQuietNativeLogs. |
app.run(onStart) / app.quit() | Run the event loop (blocks) / stop it. |
app.createWindow(WindowOptions) / app.windows() | Open a window / list open windows. |
app.dispatch, app.submit, app.isUiThread | Run on the UI thread; check the thread. |
app.openExternal(URI) | Open an http, https or mailto address in the user's program. |
app.notify(Notification) | System notification. Notifications |
app.isTraySupported(), app.createTray(icon, tooltip), app.autostart() | Tray and autostart |
SingleInstance.acquire(...) | Allow one copy per user. Tray |
WebWindow: showing a page
| Call | What it does |
loadHtml(html) | Show an HTML string. |
loadResources(AppResources, [handler], [ResourceOptions]) | Show a multi-file page; optional Java request handler. Serving files |
AppResources.classpath(base) / directory(path) | Files from the jar / from a folder. |
loadUrl(url) | Show an address (trusted origins only). |
ready() | Future that completes when the web view has started. |
WebWindow: talking to the page
| Java | Page | Notes |
window.onMessage(Consumer<String>) | jolt.postMessage(text) | Page to Java. Messaging |
window.postMessage(text) | jolt.onMessage(cb) | Java to page. |
window.eval(script) | | Run a script; JSON result as a future. |
window.addInitScript(script) | | Runs before the page's scripts. |
window.openChannel(name, [ChannelOptions]) | jolt.channel(name) | Binary pipe. Channels |
window.dialogs(), enableSaveAs() | jolt.saveAs(...) | Dialogs |
window.enableNotifications(app) | jolt.notify(...) | Notifications |
window.enableOpenWindow(app, opener) | jolt.openWindow, jolt.broadcast, jolt.onBroadcast | Pop-out windows |
| (frameless windows) | jolt.frame.minimize/toggleMaximize/close | Window look |
WebWindow: controlling the window
| Call | What it does |
setTitle, setSize, setIcon | Title, size, icon. |
setTitleBarScheme, setTitleBarColors, setBackgroundColor | Colours. |
show, hide, focus, minimize, maximize, restore, close | State changes. |
isVisible, isFocused, isMinimized, isMaximized | State queries. |
setCloseBehavior(CloseBehavior) | CLOSE (default) or HIDE. |
onClosed(Runnable) | Called when the window has closed. |
openDevTools() | Developer tools (create with withDevTools(true)). |
security(), setSecurity(...), onBlocked(...) | Security |
WindowOptions
Immutable; start from WindowOptions.defaults(). Methods: withTitle, withSize, withMinSize, withIcon, withTitleBarScheme, withBackgroundColor, withMaximized, withCentered, withVisible, withFrameless, withOwner, withDevTools, withSecurity. See Window look and placement.
Handling page requests
| Type | Main members |
RequestHandler | AppResponse handle(AppRequest); return null to let files answer. |
Router | get/post/put/patch/delete(pattern, route), group, before, onError. |
AppRequest | method, path, param, queryParams, form, formValue, bodyText, header, isHtmx, parts, part. |
AppResponse | html, text, status, redirect, withStatus, withHeader. |
ResourceOptions | withMaxRequestBytes (default 8 MB, max 1 GB), withStartPath. |
Other types
| Type | Used for |
SecurityPolicy, BlockedEvent | What pages are trusted. Security |
Dialogs, FileDialogOptions, FileFilter | Native file dialogs. Dialogs |
Notification | Toasts with click, buttons and reply. |
Tray, TrayMenu, Autostart, CloseBehavior | Tray |
BinaryChannel, ChannelOptions | Channels |
OpenWindowRequest, WindowOpener | Pop-out windows |
io.github.b077as.jolt.credentials.CredentialStore | OS keystore. Saving passwords |