Package org.apache.pivot.wtk
Class DesktopApplicationContext
- java.lang.Object
-
- org.apache.pivot.wtk.ApplicationContext
-
- org.apache.pivot.wtk.DesktopApplicationContext
-
- All Implemented Interfaces:
java.lang.Thread.UncaughtExceptionHandler,Application.UncaughtExceptionHandler
public final class DesktopApplicationContext extends ApplicationContext
Application context used to execute applications in a native frame window.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDesktopApplicationContext.DisplayListenerDisplay listener interface.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.ApplicationContext
ApplicationContext.DisplayHost, ApplicationContext.QueuedCallback, ApplicationContext.ResourceCacheDictionary, ApplicationContext.ScheduledCallback
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCENTER_ARGUMENTstatic java.lang.StringDEFAULT_HOST_WINDOW_TITLEstatic java.lang.StringFULL_SCREEN_ARGUMENTstatic java.lang.StringHEIGHT_ARGUMENTstatic java.lang.StringMAXIMIZED_ARGUMENTstatic java.lang.StringORIGIN_ARGUMENTstatic java.lang.StringPRESERVE_SPLASH_SCREEN_ARGUMENTstatic java.lang.StringRESIZABLE_ARGUMENTstatic java.lang.StringUNDECORATED_ARGUMENTstatic java.lang.StringUSE_APPLICATION_INSTANCE_ARGUMENTstatic java.lang.StringWIDTH_ARGUMENTstatic java.lang.StringX_ARGUMENTstatic java.lang.StringY_ARGUMENT-
Fields inherited from class org.apache.pivot.wtk.ApplicationContext
applications, displays, origin
-
-
Constructor Summary
Constructors Constructor Description DesktopApplicationContext()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DisplaycreateDisplay(int width, int height, int x, int y, boolean modal, boolean resizable, boolean undecorated, java.awt.Window owner, DesktopApplicationContext.DisplayListener displayCloseListener)Creates a new secondary display.static voidexit()Terminates the application context.static booleanexit(boolean optional)Terminates the application context.static booleanisActive()static booleanisFullScreen()Returns the full-screen mode flag.static voidmain(java.lang.Class<? extends Application> applicationClass)Utility method to make it easier to definemain()entry-points into applications.static voidmain(java.lang.Class<? extends Application> applicationClass, java.lang.String[] applicationArgs)/** Utility method to make it easier to definemain()entry-points into applications.static voidmain(java.lang.String[] args)Primary application entry point.static voidmain(Application applicationInstance)Utility method to make it easier to definemain()entry-points into applications.
This is useful if application instance has already been created, for example from a scripting environment and I set some external properties in the application for later reuse, so I must use that instance.
But it's important to NOT call usual methods of application lifecycle before passing it here, to avoid side effects.static voidmain(Application applicationInstance, java.lang.String[] applicationArgs)Utility method to make it easier to definemain()entry-points into applications.
This is useful if application instance has already been created, for example from a scripting environment and I set some external properties in the application for later reuse, so I must use that instance.
But it's important to NOT call usual methods of application lifecycle before passing it here, to avoid side effects.static voidreplaceSplashScreen(Display display)Gets the window hosting the specified Display and makes it visible.
This will cause a visibleSplashScreento be closed.
It is intended to be called one time when the Pivot application has initialized its UI and the SplashScreen is ready to be dismissed, but can be safely called regardless of whether there is now, or used to be, a visible SplashScreen.static voidsetFullScreen(boolean fullScreen)Sets the full-screen mode flag.static voidsizeHostToFit(Window window)Sizes the window's native host frame to match its preferred size.-
Methods inherited from class org.apache.pivot.wtk.ApplicationContext
applyStylesheet, applyStylesheet, createTimer, defaultUncaughtExceptionHandler, destroyTimer, getDisplays, getJavaVersion, getJVMVersion, getOrigin, getPivotVersion, getResourceCache, handleUncaughtException, handleUncaughtException, invalidateDisplays, queueCallback, queueCallback, runAndScheduleRecurringCallback, runAndScheduleRecurringCallback, scheduleCallback, scheduleRecurringCallback, scheduleRecurringCallback, uncaughtException
-
-
-
-
Field Detail
-
DEFAULT_HOST_WINDOW_TITLE
public static final java.lang.String DEFAULT_HOST_WINDOW_TITLE
- See Also:
- Constant Field Values
-
X_ARGUMENT
public static final java.lang.String X_ARGUMENT
- See Also:
- Constant Field Values
-
Y_ARGUMENT
public static final java.lang.String Y_ARGUMENT
- See Also:
- Constant Field Values
-
WIDTH_ARGUMENT
public static final java.lang.String WIDTH_ARGUMENT
- See Also:
- Constant Field Values
-
HEIGHT_ARGUMENT
public static final java.lang.String HEIGHT_ARGUMENT
- See Also:
- Constant Field Values
-
CENTER_ARGUMENT
public static final java.lang.String CENTER_ARGUMENT
- See Also:
- Constant Field Values
-
RESIZABLE_ARGUMENT
public static final java.lang.String RESIZABLE_ARGUMENT
- See Also:
- Constant Field Values
-
MAXIMIZED_ARGUMENT
public static final java.lang.String MAXIMIZED_ARGUMENT
- See Also:
- Constant Field Values
-
UNDECORATED_ARGUMENT
public static final java.lang.String UNDECORATED_ARGUMENT
- See Also:
- Constant Field Values
-
FULL_SCREEN_ARGUMENT
public static final java.lang.String FULL_SCREEN_ARGUMENT
- See Also:
- Constant Field Values
-
PRESERVE_SPLASH_SCREEN_ARGUMENT
public static final java.lang.String PRESERVE_SPLASH_SCREEN_ARGUMENT
- See Also:
- Constant Field Values
-
ORIGIN_ARGUMENT
public static final java.lang.String ORIGIN_ARGUMENT
- See Also:
- Constant Field Values
-
USE_APPLICATION_INSTANCE_ARGUMENT
public static final java.lang.String USE_APPLICATION_INSTANCE_ARGUMENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isActive
public static boolean isActive()
-
exit
public static void exit()
Terminates the application context. this call is the same as exit(true)
-
exit
public static boolean exit(boolean optional)
Terminates the application context.- Parameters:
optional- Iftrue, shutdown is optional and may be cancelled. Iffalse, shutdown cannot be cancelled.- Returns:
- Whether shutdown was canceled by the application.
-
main
public static void main(java.lang.String[] args)
Primary application entry point.- Parameters:
args- application arguments
-
isFullScreen
public static boolean isFullScreen()
Returns the full-screen mode flag.- Returns:
- Whether or not the application is/should be displayed full screen.
-
setFullScreen
public static void setFullScreen(boolean fullScreen)
Sets the full-screen mode flag.- Parameters:
fullScreen- Whether to display the application full screen.
-
replaceSplashScreen
public static void replaceSplashScreen(Display display)
Gets the window hosting the specified Display and makes it visible.
This will cause a visibleSplashScreento be closed.
It is intended to be called one time when the Pivot application has initialized its UI and the SplashScreen is ready to be dismissed, but can be safely called regardless of whether there is now, or used to be, a visible SplashScreen.- Parameters:
display- Display to make visible- See Also:
SplashScreen
-
sizeHostToFit
public static void sizeHostToFit(Window window)
Sizes the window's native host frame to match its preferred size.- Parameters:
window- The window to size.- Throws:
java.lang.IllegalArgumentException- if the window parameter isnull.java.lang.IllegalStateException- if the application is being displayed full screen.
-
createDisplay
public static Display createDisplay(int width, int height, int x, int y, boolean modal, boolean resizable, boolean undecorated, java.awt.Window owner, DesktopApplicationContext.DisplayListener displayCloseListener)
Creates a new secondary display.- Parameters:
width- The new width for the secondary display.height- The height for the secondary display.x- The new X-position for the display.y- The new Y-position for the display.modal- Whether or not the new display is to be modal.resizable- Whether or not to make the new display resizable by the user.undecorated- Whether the new display should be undecorated (that is just a bare window) or normal.owner- The owner for the new display.displayCloseListener- The listener for the dialog being closed.- Returns:
- The newly created display.
- Throws:
java.lang.IllegalStateException- if the full screen flag is set.
-
main
public static final void main(java.lang.Class<? extends Application> applicationClass)
Utility method to make it easier to definemain()entry-points into applications. For example:public class MyApp implements Application { public static void main(String[] args) throws Exception { DesktopApplicationContext.main(MyApp.class); } }- Parameters:
applicationClass- the class of Application entry point
-
main
public static final void main(java.lang.Class<? extends Application> applicationClass, java.lang.String[] applicationArgs)
/** Utility method to make it easier to definemain()entry-points into applications. For example:public class MyApp implements Application { public static void main(String[] args) throws Exception { DesktopApplicationContext.main(MyApp.class, args); } }- Parameters:
applicationClass- the class of Application entry pointapplicationArgs- application arguments
-
main
public static final void main(Application applicationInstance)
Utility method to make it easier to definemain()entry-points into applications.
This is useful if application instance has already been created, for example from a scripting environment and I set some external properties in the application for later reuse, so I must use that instance.
But it's important to NOT call usual methods of application lifecycle before passing it here, to avoid side effects.- Parameters:
applicationInstance- an instance of Application entry point
-
main
public static final void main(Application applicationInstance, java.lang.String[] applicationArgs)
Utility method to make it easier to definemain()entry-points into applications.
This is useful if application instance has already been created, for example from a scripting environment and I set some external properties in the application for later reuse, so I must use that instance.
But it's important to NOT call usual methods of application lifecycle before passing it here, to avoid side effects.- Parameters:
applicationInstance- an instance of Application entry pointapplicationArgs- application arguments
-
-