JWebView by levlabs · In Development
API style and naming
The planned JWebView Java API can be written in two spellings. Both examples below show the same steps with the same values. All names are provisional.
Status: draft
Nothing described here is available yet. The Snake Case spelling follows the current written API draft. The Idiomatic Java spelling is a proposal. One stable Java spelling will be chosen; both variants shown here serve the evaluation. We make no statement about aliases or compatibility between them.
The same example in both spellings
Idiomatic Java (draft spelling)
Follows common Java conventions: PascalCase types such as WebViewConfiguration, camelCase methods such as hardwareAccelerated() and loadUrl(). It would read like the JDK and Swing code around it.
WebViewConfiguration configuration =
WebViewConfiguration.hardwareAccelerated()
.licenseKey(System.getenv("JWEBVIEW_LICENSE"));
JWebView page = new JWebView(configuration);
page.navigation().loadUrl("https://example.com");
JFrame frame = new JFrame("My application");
frame.add(page);
frame.setSize(1100, 720);
frame.setVisible(true);
Snake Case (current API draft)
Types are written Pascal_case, for example WebView_configuration. Methods and fields are snake_case, for example hardware_accelerated() and load_url(). Constants are ALL_CAPS. Overrides of Swing and JDK methods, such as setSize, keep their own camelCase.
WebView_configuration configuration =
WebView_configuration.hardware_accelerated()
.license_key(System.getenv("JWEBVIEW_LICENSE"));
JWebView page = new JWebView(configuration);
page.navigation().load_url("https://example.com");
JFrame frame = new JFrame("My application");
frame.add(page);
frame.setSize(1100, 720);
frame.setVisible(true);
What differs
| Element | Idiomatic Java (draft) | Snake Case |
|---|---|---|
| Types | WebViewConfiguration | WebView_configuration |
| Methods | hardwareAccelerated(), loadUrl() | hardware_accelerated(), load_url() |
| Annotation | @JsAccessible | @Js_accessible |
| Constants | MINIMAL_UI | MINIMAL_UI |
| Swing and JDK names | setSize, getenv | setSize, getenv |
What does not differ: the order of the calls, the arguments, the values, and what each name stands for.
Which spelling would you prefer? Tell us in a Product Preview conversation.