publicabstractclassApplicationextendsObjectApplicationclassfromwhichJavaFXapplicationsextend.Life-cycleTheentrypointforJavaFXapplicationsistheApplicationclass.TheJavaFXruntimedoesthefollowing,inorder,wheneveranapplicationislaunched:ConstructsaninstanceofthespecifiedApplicationclassCallstheinit()methodCallsthestart(javafx.stage.Stage)methodWaitsfortheapplicationtofinish,whichhappenswheneitherofthefollowingoccur:theapplicationcallsPlatform.exit()thelastwindowhasbeenclosedandtheimplicitExitattributeonPlatformistrueCallsthestop()methodNotethatthestartmethodisabstractandmustbeoverridden.Theinitandstopmethodshaveconcreteimplementationsthatdonothing.CallingPlatform.exit()isthepreferredwaytoexplicitlyterminateaJavaFXApplication.DirectlycallingSystem.exit(int)isanacceptablealternative,butdoesn'tallowtheApplicationstop()methodtorun.AJavaFXApplicationshouldnotattempttouseJavaFXaftertheFXtoolkithasterminatedorfromaShutdownHook,thatis,afterthestop()methodreturnsorSystem.exit(int)iscalled.
2023/3/9 22:14:18
10.11MB
api
1