public abstract class Application
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Application.EventHandler |
Modifier and Type | Field and Description |
---|---|
private static Application |
application |
private static java.lang.String |
DEFAULT_NAME |
private static java.util.Map |
deviceDetails |
private static boolean |
disableThreadChecks |
private Application.EventHandler |
eventHandler |
private static java.lang.Thread |
eventThread |
private boolean |
initialActiveEventReceived |
private java.lang.String[] |
initialOpenedFiles |
private static boolean |
loaded |
protected java.lang.String |
name |
private static int |
nestedEventLoopCounter |
private boolean |
terminateWhenLastWindowClosed |
Modifier | Constructor and Description |
---|---|
protected |
Application() |
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.Object |
_enterNestedEventLoop() |
protected abstract int |
_getKeyCodeForChar(char c) |
protected abstract void |
_invokeAndWait(java.lang.Runnable runnable) |
protected abstract void |
_invokeLater(java.lang.Runnable runnable) |
protected abstract void |
_leaveNestedEventLoop(java.lang.Object retValue) |
protected boolean |
_supportsInputMethods() |
protected boolean |
_supportsSystemMenu() |
protected abstract boolean |
_supportsTransparentWindows() |
protected abstract boolean |
_supportsUnifiedWindows() |
static void |
checkEventThread()
Verifies that the current thread is the event thread, and throws
an exception if this is not so.
|
Accessible |
createAccessible() |
abstract Cursor |
createCursor(int type) |
abstract Cursor |
createCursor(int x,
int y,
Pixels pixels) |
EventLoop |
createEventLoop() |
Menu |
createMenu(java.lang.String title) |
Menu |
createMenu(java.lang.String title,
boolean enabled) |
MenuBar |
createMenuBar() |
MenuItem |
createMenuItem(java.lang.String title) |
MenuItem |
createMenuItem(java.lang.String title,
MenuItem.Callback callback) |
MenuItem |
createMenuItem(java.lang.String title,
MenuItem.Callback callback,
int shortcutKey,
int shortcutModifiers) |
MenuItem |
createMenuItem(java.lang.String title,
MenuItem.Callback callback,
int shortcutKey,
int shortcutModifiers,
Pixels pixels) |
abstract Pixels |
createPixels(int width,
int height,
java.nio.ByteBuffer data) |
(package private) static Pixels |
createPixels(int width,
int height,
int[] data,
float scale) |
abstract Pixels |
createPixels(int width,
int height,
java.nio.IntBuffer data) |
abstract Pixels |
createPixels(int width,
int height,
java.nio.IntBuffer data,
float scale) |
abstract Robot |
createRobot() |
abstract Timer |
createTimer(java.lang.Runnable runnable) |
abstract View |
createView() |
abstract Window |
createWindow(long parent) |
Window |
createWindow(Screen screen,
int styleMask)
Create a window.
|
abstract Window |
createWindow(Window owner,
Screen screen,
int styleMask)
Create a window.
|
(package private) static java.lang.Object |
enterNestedEventLoop()
Starts a nested event loop.
|
protected void |
finishTerminating() |
static Application |
GetApplication() |
java.lang.String |
getDataDirectory()
Gets a platform specific path that can be used to store
application data.
|
static java.util.Map |
getDeviceDetails() |
Application.EventHandler |
getEventHandler() |
protected static java.lang.Thread |
getEventThread() |
java.lang.String |
getHighContrastTheme()
Gets the Name of the currently active high contrast theme.
|
static int |
getKeyCodeForChar(char c)
Returns a VK_ code of a key capable of producing the given unicode
character with respect to the currently active keyboard layout or
VK_UNDEFINED if the character isn't present in the current layout.
|
java.lang.String |
getName()
Gets the name for the application.
|
(package private) static float |
getScaleFactor(int x,
int y,
int w,
int h) |
boolean |
hasMultiTouch() |
boolean |
hasPointer() |
boolean |
hasTouch() |
boolean |
hasTwoLevelFocus() |
boolean |
hasVirtualKeyboard() |
boolean |
hasWindowManager() |
void |
installDefaultMenus(MenuBar menubar)
Install app's default native menus:
on Mac OS X - Apple menu (showing the app name) with a single Quit menu item
on Windows - NOP
on Linux - NOP
|
static void |
invokeAndWait(java.lang.Runnable runnable)
Block the current thread and wait until the given runnable finishes
running on the native event loop thread.
|
static void |
invokeLater(java.lang.Runnable runnable)
Schedule the given runnable to run on the native event loop thread
some time in the future, and return immediately.
|
static boolean |
isEventThread()
Returns
true if the current thread is the event thread. |
static boolean |
isNestedLoopRunning() |
(package private) static void |
leaveNestedEventLoop(java.lang.Object retValue)
Terminates the current nested event loop.
|
protected static void |
loadNativeLibrary() |
protected static void |
loadNativeLibrary(java.lang.String libname) |
void |
menuAboutAction() |
private void |
notifyDidBecomeActive() |
private void |
notifyDidFinishLaunching() |
private void |
notifyDidHide() |
private void |
notifyDidReceiveMemoryWarning() |
private void |
notifyDidResignActive() |
private void |
notifyDidUnhide() |
private void |
notifyOpenFiles(java.lang.String[] files) |
void |
notifyRenderingFinished()
Notifies the Application that rendering has completed for current pulse.
|
private boolean |
notifyThemeChanged(java.lang.String themeName) |
private void |
notifyWillBecomeActive() |
private void |
notifyWillFinishLaunching() |
private void |
notifyWillHide() |
private void |
notifyWillQuit() |
private void |
notifyWillResignActive() |
private void |
notifyWillUnhide() |
static void |
reportException(java.lang.Throwable t) |
static void |
run(java.lang.Runnable launchable) |
protected abstract void |
runLoop(java.lang.Runnable launchable) |
static void |
setDeviceDetails(java.util.Map details) |
void |
setEventHandler(Application.EventHandler eventHandler) |
protected static void |
setEventThread(java.lang.Thread thread) |
void |
setName(java.lang.String name)
Sets the name for the application.
|
void |
setTerminateWhenLastWindowClosed(boolean b) |
boolean |
shouldTerminateWhenLastWindowClosed() |
boolean |
shouldUpdateWindow() |
protected abstract CommonDialogs.FileChooserResult |
staticCommonDialogs_showFileChooser(Window owner,
java.lang.String folder,
java.lang.String filename,
java.lang.String title,
int type,
boolean multipleMode,
CommonDialogs.ExtensionFilter[] extensionFilters,
int defaultFilterIndex) |
protected abstract java.io.File |
staticCommonDialogs_showFolderChooser(Window owner,
java.lang.String folder,
java.lang.String title) |
protected abstract Size |
staticCursor_getBestSize(int width,
int height) |
protected abstract void |
staticCursor_setVisible(boolean visible) |
protected abstract int |
staticPixels_getNativeFormat() |
protected abstract Screen[] |
staticScreen_getScreens() |
protected abstract double |
staticScreen_getVideoRefreshPeriod() |
protected abstract int |
staticTimer_getMaxPeriod() |
protected abstract int |
staticTimer_getMinPeriod() |
protected abstract int |
staticView_getMultiClickMaxX() |
protected abstract int |
staticView_getMultiClickMaxY() |
protected abstract long |
staticView_getMultiClickTime() |
boolean |
supportsInputMethods() |
boolean |
supportsSystemMenu() |
boolean |
supportsTransparentWindows() |
boolean |
supportsUnifiedWindows() |
void |
terminate() |
private static final java.lang.String DEFAULT_NAME
protected java.lang.String name
private Application.EventHandler eventHandler
private boolean initialActiveEventReceived
private java.lang.String[] initialOpenedFiles
private static boolean loaded
private static Application application
private static java.lang.Thread eventThread
private static final boolean disableThreadChecks
private static volatile java.util.Map deviceDetails
private boolean terminateWhenLastWindowClosed
private static int nestedEventLoopCounter
protected static void loadNativeLibrary(java.lang.String libname)
protected static void loadNativeLibrary()
public static void setDeviceDetails(java.util.Map details)
public static java.util.Map getDeviceDetails()
public static void run(java.lang.Runnable launchable)
protected abstract void runLoop(java.lang.Runnable launchable)
protected void finishTerminating()
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the new application namepublic java.lang.String getDataDirectory()
private void notifyWillFinishLaunching()
private void notifyDidFinishLaunching()
private void notifyWillBecomeActive()
private void notifyDidBecomeActive()
private void notifyWillResignActive()
private boolean notifyThemeChanged(java.lang.String themeName)
private void notifyDidResignActive()
private void notifyDidReceiveMemoryWarning()
private void notifyWillHide()
private void notifyDidHide()
private void notifyWillUnhide()
private void notifyDidUnhide()
private void notifyOpenFiles(java.lang.String[] files)
private void notifyWillQuit()
public void installDefaultMenus(MenuBar menubar)
public Application.EventHandler getEventHandler()
public void setEventHandler(Application.EventHandler eventHandler)
public final boolean shouldTerminateWhenLastWindowClosed()
public final void setTerminateWhenLastWindowClosed(boolean b)
public boolean shouldUpdateWindow()
public boolean hasWindowManager()
public void notifyRenderingFinished()
public void terminate()
public static Application GetApplication()
protected static void setEventThread(java.lang.Thread thread)
protected static java.lang.Thread getEventThread()
public static boolean isEventThread()
true
if the current thread is the event thread.public static void checkEventThread()
java.lang.IllegalStateException
- if the current thread is not the event threadpublic static void reportException(java.lang.Throwable t)
protected abstract void _invokeAndWait(java.lang.Runnable runnable)
public static void invokeAndWait(java.lang.Runnable runnable)
protected abstract void _invokeLater(java.lang.Runnable runnable)
public static void invokeLater(java.lang.Runnable runnable)
protected abstract java.lang.Object _enterNestedEventLoop()
protected abstract void _leaveNestedEventLoop(java.lang.Object retValue)
static java.lang.Object enterNestedEventLoop()
leaveNestedEventLoop(Object)
method.
Note that this method may only be invoked on the main (event handling)
thread.
An application may enter several nested loops recursively. There's no
limit of recursion other than that imposed by the native stack size.java.lang.RuntimeException
- if the current thread is not the main threadstatic void leaveNestedEventLoop(java.lang.Object retValue)
enterNestedEventLoop()
was called previously. You may specify a return value for the
enterNestedEventLoop() method by passing the argument retValue
to
the leaveNestedEventLoop().
Note that this method may only be invoked on the main (event handling)
thread.java.lang.RuntimeException
- if the current thread is not the main threadjava.lang.IllegalStateException
- if the application hasn't started a nested
event looppublic static boolean isNestedLoopRunning()
public void menuAboutAction()
public abstract Window createWindow(Window owner, Screen screen, int styleMask)
public final Window createWindow(Screen screen, int styleMask)
public abstract Window createWindow(long parent)
public abstract View createView()
public abstract Cursor createCursor(int type)
protected abstract void staticCursor_setVisible(boolean visible)
protected abstract Size staticCursor_getBestSize(int width, int height)
public final Menu createMenu(java.lang.String title)
public final Menu createMenu(java.lang.String title, boolean enabled)
public final MenuBar createMenuBar()
public final MenuItem createMenuItem(java.lang.String title)
public final MenuItem createMenuItem(java.lang.String title, MenuItem.Callback callback)
public final MenuItem createMenuItem(java.lang.String title, MenuItem.Callback callback, int shortcutKey, int shortcutModifiers)
public final MenuItem createMenuItem(java.lang.String title, MenuItem.Callback callback, int shortcutKey, int shortcutModifiers, Pixels pixels)
public abstract Pixels createPixels(int width, int height, java.nio.ByteBuffer data)
public abstract Pixels createPixels(int width, int height, java.nio.IntBuffer data)
public abstract Pixels createPixels(int width, int height, java.nio.IntBuffer data, float scale)
protected abstract int staticPixels_getNativeFormat()
static Pixels createPixels(int width, int height, int[] data, float scale)
static float getScaleFactor(int x, int y, int w, int h)
public abstract Robot createRobot()
protected abstract double staticScreen_getVideoRefreshPeriod()
protected abstract Screen[] staticScreen_getScreens()
public abstract Timer createTimer(java.lang.Runnable runnable)
protected abstract int staticTimer_getMinPeriod()
protected abstract int staticTimer_getMaxPeriod()
public final EventLoop createEventLoop()
public Accessible createAccessible()
protected abstract CommonDialogs.FileChooserResult staticCommonDialogs_showFileChooser(Window owner, java.lang.String folder, java.lang.String filename, java.lang.String title, int type, boolean multipleMode, CommonDialogs.ExtensionFilter[] extensionFilters, int defaultFilterIndex)
protected abstract java.io.File staticCommonDialogs_showFolderChooser(Window owner, java.lang.String folder, java.lang.String title)
protected abstract long staticView_getMultiClickTime()
protected abstract int staticView_getMultiClickMaxX()
protected abstract int staticView_getMultiClickMaxY()
public java.lang.String getHighContrastTheme()
protected boolean _supportsInputMethods()
public final boolean supportsInputMethods()
protected abstract boolean _supportsTransparentWindows()
public final boolean supportsTransparentWindows()
public boolean hasTwoLevelFocus()
public boolean hasVirtualKeyboard()
public boolean hasTouch()
public boolean hasMultiTouch()
public boolean hasPointer()
protected abstract boolean _supportsUnifiedWindows()
public final boolean supportsUnifiedWindows()
protected boolean _supportsSystemMenu()
public final boolean supportsSystemMenu()
protected abstract int _getKeyCodeForChar(char c)
public static int getKeyCodeForChar(char c)
c
- the character