Class MegalodonteApp
java.lang.Object
megalodonte.application.MegalodonteApp
Main entry point for Megalodonte applications. Provides static factory methods
to launch a JavaFX application with the framework's bootstrap lifecycle.
Typical usage:
MegalodonteApp.appName("My App");
MegalodonteApp.run(MyHost.class, args, context -> {
context.useRouter(AppRouter.build()).start();
});
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFramework-level events dispatched to the application. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClasspath resource path (e.g.static voidSets the application display name.static String[]getArgs()Returns the command-line arguments passed to the application.static ContextReturns the application context, available afterrun(Consumer, Consumer)has been called.static voidrun(Class<? extends javafx.application.Application> appClass, String[] args, Consumer<Context> contextHandler) static voidrun(Class<? extends javafx.application.Application> appClass, String[] args, Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) Same asrun(String[], Consumer, Consumer), but launching throughappClassinstead of the shared defaultJavaFXHost.static voidstatic voidrun(Class<? extends javafx.application.Application> appClass, Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) static voidLaunches the application with command-line arguments.static voidLaunches the application with command-line arguments.static voidLaunches the application using the defaultJavaFXHostlauncher.static voidrun(Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) Launches the application using the defaultJavaFXHostlauncher.
-
Constructor Details
-
MegalodonteApp
public MegalodonteApp()
-
-
Method Details
-
getCurrentContext
Returns the application context, available afterrun(Consumer, Consumer)has been called. @return the context -
getArgs
Returns the command-line arguments passed to the application. @return the arguments array -
appName
Sets the application display name. Used byLinuxDesktopEntryfor the dev-mode.desktopfile and byBootstrapforjavafx.application.name. Must be called beforerun(Consumer, Consumer).- Parameters:
name- the application display name
-
appIcon
Classpath resource path (e.g."/assets/app_ico.png") for the app's icon. Applied to the primary stage and inherited by windows spawned through the router, unless a route declares its own icon. On Linux it is also used to seed the dev-mode.desktopentry — seeLinuxDesktopEntry. This gets the dock/taskbar icon working when running straight from a JVM (IDE,gradle run, ...) instead of an installed package. Pair with a custom launcher class (see therun(Class, ...)overloads below) to also get a WM_CLASS unique to your app.- Parameters:
classpathResourcePath- classpath resource path (e.g."/assets/app_icon.png")
-
run
Launches the application using the defaultJavaFXHostlauncher.- Parameters:
contextHandler- called once during bootstrap with the applicationContextonEvent- called for framework events (e.g.MegalodonteApp.Event.CloseRequest)
-
run
Launches the application using the defaultJavaFXHostlauncher.- Parameters:
contextHandler- called once during bootstrap with the applicationContext
-
run
public static void run(String[] args, Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) Launches the application with command-line arguments.- Parameters:
args- command-line arguments forwarded to JavaFXcontextHandler- called once during bootstrap with the applicationContextonEvent- called for framework events
-
run
-
run
public static void run(Class<? extends javafx.application.Application> appClass, String[] args, Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) Same asrun(String[], Consumer, Consumer), but launching throughappClassinstead of the shared defaultJavaFXHost.On Linux/GTK, the running window's WM_CLASS is the launched
Applicationsubclass's fully-qualified name (confirmed viaxprop WM_CLASS—appName(String)alone does not affect it). Every app defaulting toJavaFXHosttherefore reports the same WM_CLASS, and GNOME's dock/taskbar can't tell them apart (same icon, same grouping). Pass your ownMegalodonteApplicationsubclass here to get a WM_CLASS — and taskbar icon — unique to your app:public static class AppHost extends MegalodonteApplication {} static void main(String[] args) { MegalodonteApp.run(AppHost.class, args, Main::start, Main::onEvent); } -
run
-
run
public static void run(Class<? extends javafx.application.Application> appClass, Consumer<Context> contextHandler, Consumer<MegalodonteApp.Event> onEvent) -
run
-