@Retention(CLASS) @Target({TYPE})
public @interface DesktopBuild
Desktop build hints, checked by the compiler.
Place this on your application’s main class – the class named by
codename1.mainName. An attribute you do not set is not written at all, so
the build server’s own default applies. The default clause below each
attribute names a constant that says nothing – see HintUnset – and this
package deliberately does not record what the server would do instead,
because that is the server’s to change.
The platform is stated once on the annotation, not on every attribute. An attribute repeats it only to disagree with it.
Which theme a desktop application gets
themeMode() is resolved against the machine the application starts on,
because one desktop binary runs on all three operating systems:
desktop.themeMode | Windows | macOS | Linux / GNOME |
|---|---|---|---|
unset, or legacy | unchanged | unchanged | unchanged |
auto, native, modern | Windows Fluent | macOS Aqua | GNOME Adwaita |
fluent | Windows Fluent | Windows Fluent | Windows Fluent |
aqua | macOS Aqua | macOS Aqua | macOS Aqua |
adwaita | GNOME Adwaita | GNOME Adwaita | GNOME Adwaita |
custom | none | none | none |
unchanged is the default and is deliberate: it is whatever the application was
built and tested against before these themes existed, because flipping it would
move every screen of every desktop application already shipped. custom differs
from it by installing no framework theme at all.
How that relates to the other theme hints
Each platform has its own hint, and each governs only its own platform:
| hint | governs | see |
|---|---|---|
desktop.themeMode | the JavaSE desktop application, on all three desktops | themeMode() |
ios.themeMode | iOS | Ios.themeMode() |
and.themeMode | Android | Android.themeMode() |
mac.themeMode | the native macOS build, a separate target from the JavaSE desktop application | Mac.themeMode() |
nativeTheme | the default for the three above, where they are unset | Build.nativeTheme() |
The one value in that last row that also reaches the desktop is
nativeTheme = ThemeMode.NATIVE, which is the single hint for “look like the
platform, everywhere”. ThemeMode.MODERN reaches iOS and Android only: it
shipped years before the desktop themes, so an application that set it for its
phone builds never asked for its desktop screens to be redrawn. themeMode here
outranks both.
Methods
public abstract Toggle adaptToRetina() default Toggle.DEFAULT | Boolean true/false defaults to true. |
public abstract Toggle fullscreen() default Toggle.DEFAULT | Starts the desktop build in full-screen mode. |
public abstract int height() default 0 | Height in pixels for the form in desktop builds, will be doubled for retina grade displays. |
public abstract Toggle interactiveScrollbars() default Toggle.DEFAULT | Enables grab-able, click-to-page desktop scrollbars. |
public abstract Toggle resizable() default Toggle.DEFAULT | Boolean true/false defaults to true. |
public abstract String themeMode() default "" | Which native theme a desktop build installs, and the one hint that decides whether a desktop application looks like the platform it’s running on. |
public abstract DesktopTitleBar titleBar() default DesktopTitleBar.DEFAULT | How the desktop window is framed: native for the OS title bar and menu bar, custom for an undecorated window with a Codename One drawn title bar, or toolbar for the legacy in-app Toolbar. |
public abstract int width() default 0 | Width in pixels for the form in desktop builds, will be doubled for retina grade displays. |
Method details
adaptToRetina
public abstract Toggle adaptToRetina() default Toggle.DEFAULTfullscreen
public abstract Toggle fullscreen() default Toggle.DEFAULTheight
public abstract int height() default 0interactiveScrollbars
public abstract Toggle interactiveScrollbars() default Toggle.DEFAULTresizable
public abstract Toggle resizable() default Toggle.DEFAULTthemeMode
public abstract String themeMode() default ""Which native theme a desktop build installs, and the one hint that decides whether a desktop application looks like the platform it’s running on.
One desktop binary runs on Windows, macOS and Linux, so the value is resolved
against the machine the application starts on rather than at build time.
auto, native and modern are one value under three spellings and select
the host’s own look: Fluent, Aqua or Adwaita. Naming a theme outright with
fluent, aqua or adwaita pins that one look on every machine instead,
which is what an application with a deliberate cross-platform identity wants.
legacy, which is also the default, keeps whatever the application was built
and tested against before these themes existed, and custom installs no
framework theme at all so the application’s own is the only one loaded.
The per-value and per-platform tables, and how this relates to the iOS,
Android, macOS and cross-platform theme hints, are on the @DesktopBuild
annotation itself.
Read by the JavaSE port at runtime rather than by a builder, so unlike most hints here it changes what the running application does rather than what’s produced for it.
titleBar
public abstract DesktopTitleBar titleBar() default DesktopTitleBar.DEFAULTwidth
public abstract int width() default 0