PreviewEnvironment
interface PreviewEnvironment
Prepares the JVM that renders this classpath's Previews, so every one of them is rendered the way the application would render it.
A preview process starts as a bare JVM: no look and feel installed, the default scaling, and the default locale. This is where those are settled, and it settles which look and feel every Preview on the classpath renders under by default.
An implementation is found through java.util.ServiceLoader, so it needs a constructor that takes no arguments and a META-INF/services/org.jetbrains.compose.swing.tooling.PreviewEnvironment entry naming it. At most one may be on a preview's classpath; a second is an error rather than a winner.
class ApplicationPreviews : PreviewEnvironment {
override fun prepare() {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
}
}Content copied to clipboard