Class CN
- Direct Known Subclasses:
Font
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAlignment to the baseline constraintstatic final intBox-orientation constant used to specify the bottom of a box.static final intIndicates a Component center alignmentstatic final intDefines the behavior of the component placed in the center position of the layout, places the component in the center of the space available to the center component.static final intDefines the behavior of the component placed in the center position of the layout, places the component in the center of the surrounding containerstatic final intDefines the behavior of the component placed in the center position of the layout, by default it is scaled to the available spacestatic final intThe center component takes up the entire screens and the sides are automatically placed on top of it thus creating a layered effectstatic final StringThe east layout constraint (right of container).static final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intBox-orientation constant used to specify the left side of a box.static final StringConstant for the italic black native font.static final StringConstant for the italic bold native font.static final StringConstant for the italic light native font.static final StringConstant for the italic regular native font.static final StringConstant for the italic thin native font.static final StringConstant for the main black native font.static final StringConstant for the main bold native font.static final StringConstant for the main light native font.static final StringConstant for the main regular native font.static final StringConstant for the name of the main thin native font.static final StringThe north layout constraint (top of container).static final intBox-orientation constant used to specify the right side of a box.static final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final StringThe south layout constraint (bottom of container).static final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intConstant allowing us to author portable system fontsstatic final intBox-orientation constant used to specify the top of a box.static final StringThe west layout constraint (left of container).Fields inherited from class CN1Constants
DENSITY_2HD, DENSITY_4K, DENSITY_560, DENSITY_HD, DENSITY_HIGH, DENSITY_LOW, DENSITY_MEDIUM, DENSITY_VERY_HIGH, DENSITY_VERY_LOW, GALLERY_ALL, GALLERY_ALL_MULTI, GALLERY_IMAGE, GALLERY_IMAGE_MULTI, GALLERY_VIDEO, GALLERY_VIDEO_MULTI, PICKER_TYPE_CALENDAR, PICKER_TYPE_DATE, PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_DURATION, PICKER_TYPE_DURATION_HOURS, PICKER_TYPE_DURATION_MINUTES, PICKER_TYPE_STRINGS, PICKER_TYPE_TIME, SMS_BOTH, SMS_INTERACTIVE, SMS_NOT_SUPPORTED, SMS_SEAMLESS -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDefaultHeader(String key, String value) Adds a header to the global default headers, this header will be implicitly added to all requests going out from this point onwards.static voidAn error handler will receive an action event with the source exception from the EDT once an error handler is installed the default Codename One error dialog will no longer appearstatic voidAdds a listener to receive messages from the native platform.static voidAdds a generic listener to a network error that is invoked before the exception is propagated.static voidAdds a listener to be notified when progress updatesstatic voidaddToQueue(ConnectionRequest request) Adds the given network connection to the queue of executionstatic voidaddToQueueAndWait(ConnectionRequest request) Identical to add to queue but waits until the request is processed in the queue, this is useful for completely synchronous operations.static voidAdds a listener for window events such as resize or move.static voidannounceForAccessibility(Component cmp, String text) Manually announces text to native accessibility services, optionally associating the announcement with a specific component.static voidConvenience overload to announce text without specifying a component.static voidCauses the runnable to be invoked on the event dispatch thread.static voidIdentical to callSerially with the added benefit of waiting for the Runnable method to complete.static voidcallSeriallyAndWait(Runnable r, int timeout) Identical to callSerially with the added benefit of waiting for the Runnable method to complete.static voidCauses the runnable to be invoked on the event dispatch thread when the event dispatch thread is idle.static booleancanDial()Returns true if the device has dialing capabilitiesstatic BooleancanExecute(String url) Returns true if executing this URL should work, returns false if it will not and null if this is unknown.static booleanReturns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this featurestatic booleanChecks to see if you can prompt the user to install the app on their homescreen.static ImageCaptures a screenshot of the screen.static voidDeletes all the files in the application storagestatic voidStorage is cached for faster access, however this might cause a problem with refreshing objects since they are not cloned.static intconvertToPixels(float dipCount) Converts the dips count to pixels, dips are roughly 1mm in length.static intconvertToPixels(float value, byte unitType) Converts from specified unit to pixels.static intconvertToPixels(float value, byte unitType, boolean horizontal) Converts from specified unit to pixels.static intconvertToPixels(int dipCount, boolean horizontal) Converts the dips count to pixels, dips are roughly 1mm in length.static ObjectCreates a soft/weak reference to an object that allows it to be collected yet caches it.static InputStreamCreates an input stream to the given storage source filestatic OutputStreamCreates an output stream to the storage with the given namestatic ThreadcreateThread(Runnable r, String name) Start a Codename One thread that supports crash protection and similar Codename One features.static voidDeletes the specific file or empty directory.static voiddeleteStorageFile(String name) Deletes the given file name from the storagestatic voidStop receiving push notifications to this client applicationstatic voidOpens the device Dialer application with the given phone numberstatic voidExecutes the given URL on the native platformstatic booleanexistsInFileSystem(String file) Indicates whether a file existsstatic booleanexistsInStorage(String name) Returns true if the given storage file existsstatic voidExits the application...static booleanTry to exit full-screen mode if the platform supports it.static ObjectExtracts the hard reference from the soft/weak reference givenstatic voidFlush the storage cache allowing implementations that cache storage objects to storestatic StringThe application home directory is a "safe place" to store files for this application in a portable way.static StringReturns a device specific directory designed for cache style files, or null if#hasCachesDir()is falsestatic FormReturn the form currently displayed on the screen or null if no form is currently displayed.static DimensionReturns the size of the desktop hosting the application window when running on a desktop platform.static intReturns one of the density variables appropriate for this device, notice that density doesn't always correspond to resolution and an implementation might decide to change the density based on DPI constraints.static intReturn the height of the displaystatic intReturn the width of the displaystatic intThis method allows us to manipulate the drag started detection logic.static longReturns the time that the file denoted by this abstract pathname was last modified.static longgetFileLength(String file) Returns the length of the filestatic longReturns the available space in the given root directorystatic String[]Returns the filesystem roots from which the structure of the file system can be traversedstatic longReturns the size of the given root directorystatic intgetFileSystemRootType(String root) Returns the type of the root often by guessingstatic DimensionReturns the initial desktop window size hint provided by the first shown form, when available.static StringReturns a 2-3 letter code representing the platform name for the platform overridestatic PluginSupportReturns the plugin support object for the current platform.static StringgetProperty(String key, String defaultValue) Returns the property from the underlying platform deployment or the default value if no deployment values are supported.static InputStreamgetResourceAsStream(String resource) This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.static BrowserComponentGets a reference to an application-wide shared Javascript context that can be used for running Javascript commands.static intIndicates the level of SMS support in the platform as one of:#SMS_NOT_SUPPORTED(for desktop, tablet etc.),#SMS_SEAMLESS(no UI interaction),#SMS_INTERACTIVE(with compose UI),#SMS_BOTH.static RectangleReturns the number of monitors attached to the desktop environment when available.static booleanReturns true if the device has a directory dedicated for "cache" filesstatic booleanReturns true if the device has camera false otherwise.static voidInvokes runnable and blocks the current thread, if the current thread is the EDT it will still be blocked in a way that doesn't break event dispatch .static voidInvokes a Runnable with blocking disabled.static <T> TInvokes a RunnableWithResultSync with blocking disabled.static BooleanReturns true if the platform is in dark mode, null is returned for unknown statusstatic booleanReturns true if this is a desktop applicationstatic booleanisDirectory(String file) Indicates whether the given file is a directorystatic booleanisEdt()Returns true if we are currently in the event dispatch thread.static booleanChecks if async stack traces are enabled.static booleanChecks if this platform supports full-screen mode.static booleanisHiddenFile(String file) Indicates the hidden state of the filestatic booleanChecks if the app is currently running in full-screen mode.static booleanIndicates whether an application is minimizedstatic booleanisNativePickerTypeSupported(int pickerType) Indicates whether the native picker dialog is supported for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATEstatic booleanIndicates if the underlying platform supports sharing capabilitiesstatic booleanReturns true if the device is currently in portrait modestatic booleanChecks if the device supports disabling the screen display from dimming, allowing the developer to keep the screen display on.static booleanAllows detecting development mode so debugging code and special cases can be used to simplify flowstatic booleanisTablet()Indicates whether the device is a tablet, notice that this is often a guessstatic voidkillAndWait(ConnectionRequest request) Kills the given request and waits until the request is killed if it is being processed by one of the threads.static String[]Lists the files within the given directory, returns relative file names and not full file names.static String[]Lists the names of the storage filesstatic voidlockOrientation(boolean portrait) On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape modestatic voidPrints to the logstatic voidPrints to the logstatic booleanMinimizes the current application if minimization is supported by the platform (may fail).static voidCreates the given directorystatic voidA callback fired when you are allowed to prompt the user to install the app on their homescreen.static InputStreamopenFileInputStream(String file) Opens an input stream to the given filestatic OutputStreamopenFileOutputStream(String file) Opens an output stream to the given filestatic OutputStreamopenFileOutputStream(String file, int offset) Opens an output stream to the given filestatic voidopenGallery(ActionListener response, int type) Opens the device gallery to pick an image or a video.static voidpostMessage(MessageEvent message) Posts a message to the native platform.static booleanPrompts the user to install this app on their homescreen.static ObjectreadObjectFromStorage(String name) Reads the object from the storage, returns null if the object isn't therestatic voidRegister to receive push notification, invoke this method once (ever) to receive push notifications.static voidAn error handler will receive an action event with the source exception from the EDT once an error handler is installed the default Codename One error dialog will no longer appearstatic voidRemoves a listener from receiving messages from the native platform.static voidRemoves the given error listenerstatic voidAdds a listener to be notified when progress updatesstatic voidRemoves a previously registered window listener.static voidrenameFile(String file, String newName) Renames a file to the given name, expects the new name to be relative to the current directorystatic booleanTry to enter full-screen mode if the platform supports it.static voidRestore the minimized application if minimization is supported by the platformstatic voidRuns the last bookmark that was set using#setBookmark(java.lang.Runnable)static voidAllows executing a background task in a separate low priority thread.static voidsendLog()Sends the log to your email accountstatic voidsendMessage(String subject, Message msg, String... recipients) Send an email using the platform mail client.static voidSends a SMS message to the given phone numberstatic voidSends a SMS message to the given phone number, the code below demonstrates the logic of detecting platform behavior for sending SMS.static voidsetBookmark(Runnable bookmark) Sets a bookmark that can restore the app to a particular state.static voidsetDarkMode(Boolean darkMode) Override the default dark mode settingstatic voidsetDragStartPercentage(int dragStartPercentage) This method allows us to manipulate the drag started detection logic.static voidsetEnableAsyncStackTraces(boolean enable) Enables or disables async stack traces.static voidsetHiddenFile(String file, boolean h) Toggles the hidden state of the filestatic voidSets the initial desktop window size hint (percent of the desktop) that should be used when the first form is shown.static TimersetInterval(int timeout, Runnable r) Convenience method to schedule a task to run on the EDT after periodms repeating every periodms.static voidsetProperty(String key, String value) Sets a local property to the application, this method has no effect on the implementation code and only allows the user to override the logic of getProperty for internal application purposes.static voidsetScreenSaverEnabled(boolean e) If isScreenSaverDisableSupported() returns true calling this method will lock the screen display onstatic TimersetTimeout(int timeout, Runnable r) Convenience method to schedule a task to run on the EDT after timeoutms.static voidsetWindowSize(int width, int height) Requests a resize of the application window when supported by the platform.static voidShare the required information using the platform sharing services.static voidShare the required information using the platform sharing services.static ObjectshowNativePicker(int type, Component source, Object currentValue, Object data) Shows a native modal dialog allowing us to perform the picking for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATEstatic ThreadstartThread(Runnable r, String name) Start a Codename One thread that supports crash protection and similar Codename One features.static intstorageEntrySize(String name) Returns the size in bytes of the given entrystatic voidThis is the reverse method for lock orientation allowing orientation lock to be disabledstatic voidupdateNetworkThreadCount(int threadCount) Sets the number of network threads and restarts the network threadsstatic voidvibrate(int duration) Vibrates the device for the given length of time, notice that this might ignore the time value completely on some OS's where this level of control isn't supported e.g.static booleanwriteObjectToStorage(String name, Object o) Writes the given object to storage assuming it is an externalizable type or one of the supported types.
-
Field Details
-
NATIVE_MAIN_THIN
Constant for the name of the main thin native font.- See Also:
-
NATIVE_MAIN_LIGHT
-
NATIVE_MAIN_REGULAR
-
NATIVE_MAIN_BOLD
-
NATIVE_MAIN_BLACK
-
NATIVE_ITALIC_THIN
-
NATIVE_ITALIC_LIGHT
-
NATIVE_ITALIC_REGULAR
Constant for the italic regular native font.- See Also:
-
NATIVE_ITALIC_BOLD
-
NATIVE_ITALIC_BLACK
-
FACE_MONOSPACE
public static final int FACE_MONOSPACEConstant allowing us to author portable system fonts- See Also:
-
FACE_PROPORTIONAL
public static final int FACE_PROPORTIONALConstant allowing us to author portable system fonts- See Also:
-
FACE_SYSTEM
public static final int FACE_SYSTEMConstant allowing us to author portable system fonts- See Also:
-
SIZE_LARGE
public static final int SIZE_LARGEConstant allowing us to author portable system fonts- See Also:
-
SIZE_MEDIUM
public static final int SIZE_MEDIUMConstant allowing us to author portable system fonts- See Also:
-
SIZE_SMALL
public static final int SIZE_SMALLConstant allowing us to author portable system fonts- See Also:
-
STYLE_BOLD
public static final int STYLE_BOLDConstant allowing us to author portable system fonts- See Also:
-
STYLE_ITALIC
public static final int STYLE_ITALICConstant allowing us to author portable system fonts- See Also:
-
STYLE_UNDERLINED
public static final int STYLE_UNDERLINEDConstant allowing us to author portable system fonts- See Also:
-
STYLE_PLAIN
public static final int STYLE_PLAINConstant allowing us to author portable system fonts- See Also:
-
NORTH
-
SOUTH
-
WEST
-
EAST
-
CENTER
public static final int CENTERIndicates a Component center alignment- See Also:
-
TOP
public static final int TOPBox-orientation constant used to specify the top of a box.- See Also:
-
LEFT
public static final int LEFTBox-orientation constant used to specify the left side of a box.- See Also:
-
BOTTOM
public static final int BOTTOMBox-orientation constant used to specify the bottom of a box.- See Also:
-
RIGHT
public static final int RIGHTBox-orientation constant used to specify the right side of a box.- See Also:
-
BASELINE
public static final int BASELINEAlignment to the baseline constraint- See Also:
-
CENTER_BEHAVIOR_SCALE
public static final int CENTER_BEHAVIOR_SCALEDefines the behavior of the component placed in the center position of the layout, by default it is scaled to the available space- See Also:
-
CENTER_BEHAVIOR_CENTER
public static final int CENTER_BEHAVIOR_CENTERDefines the behavior of the component placed in the center position of the layout, places the component in the center of the space available to the center component.- See Also:
-
CENTER_BEHAVIOR_CENTER_ABSOLUTE
public static final int CENTER_BEHAVIOR_CENTER_ABSOLUTEDefines the behavior of the component placed in the center position of the layout, places the component in the center of the surrounding container- See Also:
-
CENTER_BEHAVIOR_TOTAL_BELOW
public static final int CENTER_BEHAVIOR_TOTAL_BELOWThe center component takes up the entire screens and the sides are automatically placed on top of it thus creating a layered effect- See Also:
-
-
Method Details
-
setBookmark
Sets a bookmark that can restore the app to a particular state. This takes a
Runnablethat will be run when#restoreToBookmark()() } is called.The primary purpose of this feature is live code refresh.
Parameters
bookmark: ARunnablethat can be run to restore the app to a particular point.
Since
8.0
-
restoreToBookmark
public static void restoreToBookmark()Runs the last bookmark that was set using
#setBookmark(java.lang.Runnable)Since
8.0
-
getDragStartPercentage
public static int getDragStartPercentage()This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.
Returns
motion percentage
-
setDragStartPercentage
public static void setDragStartPercentage(int dragStartPercentage) This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.
Parameters
dragStartPercentage: percentage of the screen required to initiate drag
-
createSoftWeakRef
Creates a soft/weak reference to an object that allows it to be collected yet caches it. This method is in the porting layer since CLDC only includes weak references while some platforms include nothing at all and some include the superior soft references.
Parameters
o: object to cache
Returns
a caching object or null if caching isn't supported
-
extractHardRef
-
isEnableAsyncStackTraces
public static boolean isEnableAsyncStackTraces()Checks if async stack traces are enabled. If enabled, the stack trace at the point of
#callSerially(java.lang.Runnable)calls will be recorded, and logged in the case that there is an uncaught exception.Currently this is only supported in the JavaSE/Simulator port.
Returns
Whether async stack traces are enabled.
Since
7.0
See also
- #setEnableAsyncStackTraces(boolean)
-
setEnableAsyncStackTraces
public static void setEnableAsyncStackTraces(boolean enable) Enables or disables async stack traces. If enabled, the stack trace at the point of
#callSerially(java.lang.Runnable)calls will be recorded, and logged in the case that there is an uncaught exception.Currently this is only supported in the JavaSE/Simulator port.
Parameters
enable: True to enable async stack traces.
Since
7.0
See also
- #isEnableAsyncStackTraces()
-
vibrate
public static void vibrate(int duration) Vibrates the device for the given length of time, notice that this might ignore the time value completely on some OS's where this level of control isn't supported e.g. iOS see: https://github.com/codenameone/CodenameOne/issues/1904
Parameters
duration: length of time to vibrate (might be ignored)
-
announceForAccessibility
Manually announces text to native accessibility services, optionally associating the announcement with a specific component. Normally, components are announced automatically when they receive focus; this method is for cases where an announcement is needed outside the normal focus lifecycle.
Parameters
-
cmp: the component related to this announcement ornullfor the root view -
text: the message to announce
-
-
announceForAccessibility
Convenience overload to announce text without specifying a component.
Parameters
text: the message to announce
-
isEdt
public static boolean isEdt()Returns true if we are currently in the event dispatch thread. This is useful for generic code that can be used both with the EDT and outside of it.
Returns
- Returns:
- true if we are currently in the event dispatch thread; otherwise false
-
callSerially
Causes the runnable to be invoked on the event dispatch thread. This method returns immediately and will not wait for the serial call to occur
Parameters
r: @param r runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events
-
callSeriallyOnIdle
Causes the runnable to be invoked on the event dispatch thread when the event dispatch thread is idle. This method returns immediately and will not wait for the serial call to occur. Notice this method is identical to call serially but will perform the runnable only when the EDT is idle
Parameters
r: @param r runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events
-
scheduleBackgroundTask
Allows executing a background task in a separate low priority thread. Tasks are serialized so they don't overload the CPU.
Parameters
r: the task to perform in the background
-
callSeriallyAndWait
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
Parameters
r: @param r runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events
Throws
IllegalStateException: @throws IllegalStateException if this method is invoked on the event dispatch thread (e.g. during paint or event handling).
-
callSeriallyAndWait
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
Parameters
-
r: @param r runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events -
timeout: timeout duration, on timeout the method just returns
Throws
IllegalStateException: @throws IllegalStateException if this method is invoked on the event dispatch thread (e.g. during paint or event handling).
-
-
invokeAndBlock
Invokes runnable and blocks the current thread, if the current thread is the EDT it will still be blocked in a way that doesn't break event dispatch . Important: calling this method spawns a new thread that shouldn't access the UI!
See this section in the developer guide for further information.
Parameters
r: runnable (NOT A THREAD!) that will be invoked synchroniously by this method
-
invokeWithoutBlocking
Invokes a Runnable with blocking disabled. If any attempt is made to block (i.e. call
#invokeAndBlock(java.lang.Runnable)from inside this Runnable, it will result in aBlockingDisallowedExceptionbeing thrown.Parameters
r: Runnable to be run immediately.
Throws
BlockingDisallowedException: @throws BlockingDisallowedException If#invokeAndBlock(java.lang.Runnable)is attempted anywhere in the Runnable.
Since
7.0
-
invokeWithoutBlockingWithResultSync
Invokes a RunnableWithResultSync with blocking disabled. If any attempt is made to block (i.e. call
#invokeAndBlock(java.lang.Runnable)from inside this Runnable, it will result in aBlockingDisallowedExceptionbeing thrown.Parameters
r: Runnable to be run immediately.
Throws
BlockingDisallowedException: @throws BlockingDisallowedException If#invokeAndBlock(java.lang.Runnable)is attempted anywhere in the Runnable.
Since
7.0
-
minimizeApplication
public static boolean minimizeApplication()Minimizes the current application if minimization is supported by the platform (may fail). Returns false if minimization failed.
Returns
false if minimization failed true if it succeeded or seems to be successful
-
isMinimized
public static boolean isMinimized()Indicates whether an application is minimized
Returns
true if the application is minimized
-
restoreMinimizedApplication
public static void restoreMinimizedApplication()Restore the minimized application if minimization is supported by the platform -
getCurrentForm
Return the form currently displayed on the screen or null if no form is currently displayed.
Returns
- Returns:
- the form currently displayed on the screen or null if no form is currently displayed
-
getDisplayWidth
public static int getDisplayWidth()Return the width of the display
Returns
the width of the display
-
getDisplayHeight
public static int getDisplayHeight()Return the height of the display
Returns
the height of the display
-
convertToPixels
public static int convertToPixels(int dipCount, boolean horizontal) Converts the dips count to pixels, dips are roughly 1mm in length. This is a very rough estimate and not to be relied upon
Parameters
-
dipCount: the dips that we will convert to pixels -
horizontal: indicates pixels in the horizontal plane
Returns
value in pixels
-
-
convertToPixels
public static int convertToPixels(float value, byte unitType, boolean horizontal) Converts from specified unit to pixels.
Parameters
-
value: The value to convert, expressed in unitType. -
unitType: @param unitType The unit type. One ofStyle#UNIT_TYPE_DIPS,Style#UNIT_TYPE_PIXELS,Style#UNIT_TYPE_REM,Style#UNIT_TYPE_SCREEN_PERCENTAGE,Style#UNIT_TYPE_VH,Style#UNIT_TYPE_VW,Style#UNIT_TYPE_VMIN,Style#UNIT_TYPE_VMAX -
horizontal: Whether screen percentage units should be based on horitonzal or vertical percentage.
Returns
The value converted to pixels.
Since
8.0
-
-
convertToPixels
public static int convertToPixels(float value, byte unitType) Converts from specified unit to pixels.
Parameters
-
value: The value to convert, expressed in unitType. -
unitType: @param unitType The unit type. One ofStyle#UNIT_TYPE_DIPS,Style#UNIT_TYPE_PIXELS,Style#UNIT_TYPE_REM,Style#UNIT_TYPE_SCREEN_PERCENTAGE,Style#UNIT_TYPE_VH,Style#UNIT_TYPE_VW,Style#UNIT_TYPE_VMIN,Style#UNIT_TYPE_VMAX
Returns
The value converted to pixels.
Since
8.0
-
-
convertToPixels
public static int convertToPixels(float dipCount) Converts the dips count to pixels, dips are roughly 1mm in length. This is a very rough estimate and not to be relied upon. This version of the method assumes square pixels which is pretty much the norm.
Parameters
dipCount: the dips that we will convert to pixels
Returns
value in pixels
-
getResourceAsStream
This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.
Parameters
resource: relative/absolute URL based on the Java convention
Returns
input stream for the resource or null if not found
-
addEdtErrorHandler
An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default Codename One error dialog will no longer appear
Parameters
e: listener receiving the errors
-
removeEdtErrorHandler
An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default Codename One error dialog will no longer appear
Parameters
e: listener receiving the errors
-
exitApplication
public static void exitApplication()Exits the application... -
getProperty
Returns the property from the underlying platform deployment or the default value if no deployment values are supported. This is equivalent to the getAppProperty from the jad file.
The implementation should be responsible for the following keys to return reasonable valid values for the application:
-
AppName
-
User-Agent
-
AppVersion
-
Platform - Similar to microedition.platform
-
OS - returns what is the underlying platform e.g. - iOS, Android, RIM, SE...
-
OSVer - OS version when available as a user readable string (not necessarily a number e.g: 3.2.1).
Parameters
-
key: the key of the property -
defaultValue: a default return value
Returns
the value of the property
-
-
setProperty
Sets a local property to the application, this method has no effect on the implementation code and only allows the user to override the logic of getProperty for internal application purposes.
Parameters
-
key: key the key of the property -
value: the value of the property
-
-
canExecute
Returns true if executing this URL should work, returns false if it will not and null if this is unknown.
Boolean can = Display.getInstance().canExecute("imdb:///find?q=godfather"); if(can != null && can) { Display.getInstance().execute("imdb:///find?q=godfather"); } else { Display.getInstance().execute("http://www.imdb.com"); }Parameters
url: the url that would be executed
Returns
- Returns:
- true if executing this URL should work, returns false if it will not and null if this is unknown
-
execute
Executes the given URL on the native platform
Boolean can = Display.getInstance().canExecute("imdb:///find?q=godfather"); if(can != null && can) { Display.getInstance().execute("imdb:///find?q=godfather"); } else { Display.getInstance().execute("http://www.imdb.com"); }Parameters
url: the url to execute
-
getDeviceDensity
public static int getDeviceDensity()Returns one of the density variables appropriate for this device, notice that density doesn't always correspond to resolution and an implementation might decide to change the density based on DPI constraints.
Returns
one of the DENSITY constants of Display
-
isPortrait
public static boolean isPortrait()Returns true if the device is currently in portrait mode
Returns
true if the device is in portrait mode
-
requestFullScreen
public static boolean requestFullScreen()Try to enter full-screen mode if the platform supports it.
Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
Returns
- Returns:
true on success. This will also return true if the app is already running in full-screen mode. It will return false if the app fails to enter full-screen mode.
Since
6.0
See also
-
#exitFullScreen()
-
#isInFullScreenMode()
-
#isFullScreenSupported()
-
-
exitFullScreen
public static boolean exitFullScreen()Try to exit full-screen mode if the platform supports it.
Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
Returns
- Returns:
true on success. This will also return true if the app is already NOT in full-screen mode. It will return false if the app fails to exit full-screen mode.
Since
6.0
See also
-
#requestFullScreen()
-
#isInFullScreenMode()
-
#isFullScreenSupported()
-
-
isInFullScreenMode
public static boolean isInFullScreenMode()Checks if the app is currently running in full-screen mode.
Returns
true if the app is currently in full-screen mode.
Since
6.0
See also
-
#requestFullScreen()
-
#exitFullScreen()
-
#isFullScreenSupported()
-
-
isFullScreenSupported
public static boolean isFullScreenSupported()Checks if this platform supports full-screen mode. If full-screen mode is supported, you can use the
#requestFullScreen(),#exitFullScreen(), and#isInFullScreenMode()methods to enter and exit full-screen - and query the current state.Currently only desktop and Javascript builds support full-screen mode; And Javascript only supports this on certain browsers. See the MDN Fullscreen API docs for a list of browsers that support full-screen.
When running in the simulator, full-screen is only supported for the desktop skin.
Returns
true if Full-screen mode is supported on this platform.
Since
6.0
See also
-
#requestFullScreen()
-
#exitFullScreen()
-
#isInFullScreenMode()
-
-
canForceOrientation
public static boolean canForceOrientation()Returns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this feature
Returns
true if lockOrientation would work
-
lockOrientation
public static void lockOrientation(boolean portrait) On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape mode
Parameters
portrait: true to lock to portrait mode, false to lock to landscape mode
-
unlockOrientation
public static void unlockOrientation()This is the reverse method for lock orientation allowing orientation lock to be disabled -
isTablet
public static boolean isTablet()Indicates whether the device is a tablet, notice that this is often a guess
Returns
true if the device is assumed to be a tablet
-
isDesktop
public static boolean isDesktop()Returns true if this is a desktop application
Returns
true if this is a desktop application
-
getDesktopSize
Returns the size of the desktop hosting the application window when running on a desktop platform.
Returns
the desktop size
-
getWindowBounds
Returns the number of monitors attached to the desktop environment when available.
Returns
the number of monitors Returns the current bounds of the application window when supported by the platform.
Returns
the window bounds
-
setWindowSize
public static void setWindowSize(int width, int height) Requests a resize of the application window when supported by the platform.
Parameters
-
width: the desired window width -
height: the desired window height
-
-
getInitialWindowSizeHintPercent
Returns the initial desktop window size hint provided by the first shown form, when available.
Returns
the stored hint or
null -
setInitialWindowSizeHintPercent
Sets the initial desktop window size hint (percent of the desktop) that should be used when the first form is shown. This is primarily useful for desktop environments where the Codename One application is hosted in a window rather than full-screen.
Parameters
hint: @param hint aDimensionwhose width/height represent percentages of the desktop to use for the initial window size, ornullto clear a previously stored hint
-
addWindowListener
Adds a listener for window events such as resize or move.
Parameters
l: the listener to add
-
removeWindowListener
Removes a previously registered window listener.
Parameters
l: the listener to remove
-
canDial
public static boolean canDial()Returns true if the device has dialing capabilities
Returns
false if it cannot dial
-
isDarkMode
Returns true if the platform is in dark mode, null is returned for unknown status
Returns
true in case of dark mode
-
setDarkMode
Override the default dark mode setting
Parameters
darkMode: can be set to null to reset to platform default
-
openGallery
Opens the device gallery to pick an image or a video.
The method returns immediately and the response is sent asynchronously to the given ActionListener Object as the source value of the event (as a String)
E.g. within the callback action performed call you can use this code:
String path = (String) evt.getSource();.A more detailed sample of picking a video file can be seen here:
final Form hi = new Form("MediaPlayer", new BorderLayout()); hi.setToolbar(new Toolbar()); Style s = UIManager.getInstance().getComponentStyle("Title"); FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_VIDEO_LIBRARY, s); hi.getToolbar().addCommandToRightBar(new Command("", icon) { @Override public void actionPerformed(ActionEvent evt) { Display.getInstance().openGallery((e) -> { if(e != null && e.getSource() != null) { String file = (String)e.getSource(); try { Media video = MediaManager.createMedia(file, true); hi.removeAll(); hi.add(BorderLayout.CENTER, new MediaPlayer(video)); hi.revalidate(); } catch(IOException err) { Log.e(err); } } }, Display.GALLERY_VIDEO); } }); hi.show();Parameters
-
response: a callback Object to retrieve the file path -
type: one of the following#GALLERY_IMAGE,#GALLERY_VIDEO,#GALLERY_ALL
Throws
RuntimeException: if this feature failed or unsupported on the platform
-
-
getPlatformName
Returns a 2-3 letter code representing the platform name for the platform override
Returns
the name of the platform e.g. ios, rim, win, and, me, HTML5
-
dial
Opens the device Dialer application with the given phone number
Parameters
phoneNumber
-
getSMSSupport
public static int getSMSSupport()Indicates the level of SMS support in the platform as one of:
#SMS_NOT_SUPPORTED(for desktop, tablet etc.),#SMS_SEAMLESS(no UI interaction),#SMS_INTERACTIVE(with compose UI),#SMS_BOTH.The sample below demonstrates the use case for this property:
switch(Display.getInstance().getSMSSupport()) { case Display.SMS_NOT_SUPPORTED: return; case Display.SMS_SEAMLESS: showUIDialogToEditMessageData(); Display.getInstance().sendSMS(phone, data); return; default: Display.getInstance().sendSMS(phone, data); return; }Returns
one of the SMS_* values
-
sendSMS
Sends a SMS message to the given phone number
Parameters
-
phoneNumber: to send the sms -
message: the content of the sms
- Throws:
IOException
-
-
sendSMS
public static void sendSMS(String phoneNumber, String message, boolean interactive) throws IOException Sends a SMS message to the given phone number, the code below demonstrates the logic of detecting platform behavior for sending SMS.
switch(Display.getInstance().getSMSSupport()) { case Display.SMS_NOT_SUPPORTED: return; case Display.SMS_SEAMLESS: showUIDialogToEditMessageData(); Display.getInstance().sendSMS(phone, data); return; default: Display.getInstance().sendSMS(phone, data); return; }Parameters
-
phoneNumber: to send the sms -
message: the content of the sms -
interactive: indicates the SMS should show a UI or should not show a UI if applicable see getSMSSupport
See also
- #getSMSSupport()
- Throws:
IOException
-
-
registerPush
public static void registerPush()Register to receive push notification, invoke this method once (ever) to receive push notifications. -
deregisterPush
public static void deregisterPush()Stop receiving push notifications to this client application -
createThread
Start a Codename One thread that supports crash protection and similar Codename One features.
Parameters
-
r: runnable to run, NOTICE the thread MUST be explicitly started! -
name: the name for the thread
Returns
a thread instance which must be explicitly started!
-
-
startThread
Start a Codename One thread that supports crash protection and similar Codename One features.
Parameters
-
r: runnable to run, NOTICE the thread MUST be explicitly started! -
name: the name for the thread
Returns
a thread instance which must be explicitly started!
Deprecated
confusing name, use
java.lang.String)instead -
-
isScreenSaverDisableSupported
public static boolean isScreenSaverDisableSupported()Checks if the device supports disabling the screen display from dimming, allowing the developer to keep the screen display on. -
setScreenSaverEnabled
public static void setScreenSaverEnabled(boolean e) If isScreenSaverDisableSupported() returns true calling this method will lock the screen display on
Parameters
e: @param e when set to true the screen saver will work as usual and when set to false the screen will not turn off automatically
-
hasCamera
public static boolean hasCamera()Returns true if the device has camera false otherwise. -
isNativePickerTypeSupported
public static boolean isNativePickerTypeSupported(int pickerType) Indicates whether the native picker dialog is supported for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE
Parameters
pickerType: the picker type constant
Returns
true if the native platform supports this picker type
-
showNativePicker
Shows a native modal dialog allowing us to perform the picking for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE
Parameters
-
type: the picker type constant -
source: @param source the source component (optional) the native dialog will be placed in relation to this component if applicable -
currentValue: the currently selected value -
data: additional meta data specific to the picker type when applicable
Returns
the value from the picker or null if the operation was canceled.
-
-
log
Prints to the log
Parameters
s: the string
-
log
Prints to the log
Parameters
s: the exception
-
sendLog
public static void sendLog()Sends the log to your email account -
sendMessage
Send an email using the platform mail client.
The code below demonstrates sending a simple message with attachments using the devices native email client:
Message m = new Message("Body of message"); m.getAttachments().put(textAttachmentUri, "text/plain"); m.getAttachments().put(imageAttachmentUri, "image/png"); Display.getInstance().sendMessage(new String[] {"[email protected]"}, "Subject of message", m);Parameters
-
subject: e-mail subject -
msg: the Message to send -
recipients: array of e-mail addresses
-
-
isSimulator
public static boolean isSimulator()Allows detecting development mode so debugging code and special cases can be used to simplify flow
Returns
true if we are running in the simulator, false otherwise
-
addDefaultHeader
Adds a header to the global default headers, this header will be implicitly added to all requests going out from this point onwards. The main use case for this is for authentication information communication via the header.
Parameters
-
key: the key of the header -
value: the value of the header
-
-
addToQueueAndWait
Identical to add to queue but waits until the request is processed in the queue, this is useful for completely synchronous operations.
Parameters
request: the request object to add
-
addToQueue
Adds the given network connection to the queue of execution
Parameters
request: network request for execution
-
killAndWait
Kills the given request and waits until the request is killed if it is being processed by one of the threads. This method must not be invoked from a network thread!
Parameters
request
-
addNetworkErrorListener
Adds a generic listener to a network error that is invoked before the exception is propagated. Note that this handles also server error codes by default! You can change this default behavior setting to false ConnectionRequest.setHandleErrorCodesInGlobalErrorHandler(boolean). Consume the event in order to prevent it from propagating further.
Parameters
e: callback will be invoked with the Exception as the source object
-
removeNetworkErrorListener
Removes the given error listener
Parameters
e: callback to remove
-
addNetworkProgressListener
Adds a listener to be notified when progress updates
Parameters
al: action listener
-
removeNetworkProgressListener
Adds a listener to be notified when progress updates
Parameters
al: action listener
-
updateNetworkThreadCount
public static void updateNetworkThreadCount(int threadCount) Sets the number of network threads and restarts the network threads
Parameters
threadCount: the new number of threads
-
clearStorageCache
public static void clearStorageCache()Storage is cached for faster access, however this might cause a problem with refreshing objects since they are not cloned. Clearing the cache allows to actually reload from the storage file. -
flushStorageCache
public static void flushStorageCache()Flush the storage cache allowing implementations that cache storage objects to store -
deleteStorageFile
Deletes the given file name from the storage
Parameters
name: the name of the storage file
-
clearStorage
public static void clearStorage()Deletes all the files in the application storage -
createStorageOutputStream
Creates an output stream to the storage with the given name
Parameters
name: the storage file name
Returns
an output stream of limited capacity
- Throws:
IOException
-
createStorageInputStream
Creates an input stream to the given storage source file
Parameters
name: the name of the source file
Returns
the input stream
- Throws:
IOException
-
existsInStorage
Returns true if the given storage file exists
Parameters
name: the storage file name
Returns
true if it exists
-
listStorageEntries
Lists the names of the storage files
Returns
the names of all the storage files
-
storageEntrySize
Returns the size in bytes of the given entry
Parameters
name: the name of the entry
Returns
the size in bytes
-
writeObjectToStorage
Writes the given object to storage assuming it is an externalizable type or one of the supported types.
The sample below demonstrates the usage and registration of the
com.codename1.io.Externalizableinterface:// File: Main.java public Main { public void init(Object o) { theme = UIManager.initFirstTheme("/theme"); // IMPORTANT: Notice we don't use MyClass.class.getName()! This won't work due to obfuscation! Util.register("MyClass", MyClass.class); } public void start() { //... } public void stop() { //... } public void destroy() { //... } }// File: MyClass.java public MyClass implements Externalizable { // allows us to manipulate the version, in this case we are demonstrating a data change between the initial release // and the current state of object data private static final int VERSION = 2; private String name; private Map data; // this field was added after version 1 private Date startedAt; public int getVersion() { return VERSION; } public void externalize(DataOutputStream out) throws IOException { Util.writeUTF(name, out); Util.writeObject(data, out); if(startedAt != null) { out.writeBoolean(true); out.writeLong(startedAt.getTime()); } else { out.writeBoolean(false); } } public void internalize(int version, DataInputStream in) throws IOException { name = Util.readUTF(in); data = (Map)Util.readObject(in); if(version > 1) { boolean hasDate = in.readBoolean(); if(hasDate) { startedAt = new Date(in.readLong()); } } } public String getObjectId() { // IMPORTANT: Notice we don't use getClass().getName()! This won't work due to obfuscation! return "MyClass"; } }// File: ReadAndWrite.java // will read the file or return null if failed MyClass object = (MyClass)Storage.getInstance().readObject("NameOfFile"); // write the object back to storage Storage.getInstance().writeObject("NameOfFile", object);Parameters
-
name: store name -
o: object to store
Returns
true for success, false for failure
-
-
readObjectFromStorage
Reads the object from the storage, returns null if the object isn't there
The sample below demonstrates the usage and registration of the
com.codename1.io.Externalizableinterface:// File: Main.java public Main { public void init(Object o) { theme = UIManager.initFirstTheme("/theme"); // IMPORTANT: Notice we don't use MyClass.class.getName()! This won't work due to obfuscation! Util.register("MyClass", MyClass.class); } public void start() { //... } public void stop() { //... } public void destroy() { //... } }// File: MyClass.java public MyClass implements Externalizable { // allows us to manipulate the version, in this case we are demonstrating a data change between the initial release // and the current state of object data private static final int VERSION = 2; private String name; private Map data; // this field was added after version 1 private Date startedAt; public int getVersion() { return VERSION; } public void externalize(DataOutputStream out) throws IOException { Util.writeUTF(name, out); Util.writeObject(data, out); if(startedAt != null) { out.writeBoolean(true); out.writeLong(startedAt.getTime()); } else { out.writeBoolean(false); } } public void internalize(int version, DataInputStream in) throws IOException { name = Util.readUTF(in); data = (Map)Util.readObject(in); if(version > 1) { boolean hasDate = in.readBoolean(); if(hasDate) { startedAt = new Date(in.readLong()); } } } public String getObjectId() { // IMPORTANT: Notice we don't use getClass().getName()! This won't work due to obfuscation! return "MyClass"; } }// File: ReadAndWrite.java // will read the file or return null if failed MyClass object = (MyClass)Storage.getInstance().readObject("NameOfFile"); // write the object back to storage Storage.getInstance().writeObject("NameOfFile", object);Parameters
name: name of the store
Returns
object stored under that name
-
getFileSystemRoots
Returns the filesystem roots from which the structure of the file system can be traversed
Returns
the roots of the filesystem
-
getFileSystemRootType
Returns the type of the root often by guessing
Parameters
root: the root whose type we are checking
Returns
one of the type constants above
-
listFiles
Lists the files within the given directory, returns relative file names and not full file names.
Parameters
directory: the directory in which files should be listed
Returns
array of file names
- Throws:
IOException
-
getFileSystemRootSizeBytes
Returns the size of the given root directory
Parameters
root: the root directory in the filesystem
Returns
the byte size of the directory
-
getFileSystemRootAvailableSpace
Returns the available space in the given root directory
Parameters
root: the root directory in the filesystem
Returns
the bytes available in the directory
-
mkdir
Creates the given directory
Parameters
directory: the directory name to create
-
delete
Deletes the specific file or empty directory.
Parameters
file: file or empty directory to delete
-
existsInFileSystem
Indicates whether a file exists
Parameters
file: the file to check
Returns
true if the file exists and false otherwise
-
isHiddenFile
Indicates the hidden state of the file
Parameters
file: file
Returns
true for a hidden file
-
setHiddenFile
Toggles the hidden state of the file
Parameters
-
file: file -
h: hidden state
-
-
renameFile
-
getFileLength
Returns the length of the file
Parameters
file: file
Returns
length of said file
-
getFileLastModifiedFile
Returns the time that the file denoted by this abstract pathname was last modified.
Returns
- Returns:
A long value representing the time the file was last modified, measured in milliseconds
Deprecated
-
isDirectory
Indicates whether the given file is a directory
Parameters
file: file
Returns
true if its a directory
-
openFileOutputStream
Opens an output stream to the given file
Parameters
file: the file
Returns
the output stream
- Throws:
IOException
-
openFileInputStream
Opens an input stream to the given file
Parameters
file: the file
Returns
the input stream
- Throws:
IOException
-
openFileOutputStream
Opens an output stream to the given file
Parameters
-
file: the file -
offset: position in the file
Returns
the output stream
- Throws:
IOException
-
-
getAppHomePath
The application home directory is a "safe place" to store files for this application in a portable way. On some platforms such as Android & iOS this path may be visible only to the application itself, other apps won't have permission to access this path.
The sample below uses the app home directory to save a file so we can share it using the
com.codename1.components.ShareButton:Form hi = new Form("ShareButton"); ShareButton sb = new ShareButton(); sb.setText("Share Screenshot"); hi.add(sb); Image screenshot = Image.createImage(hi.getWidth(), hi.getHeight()); hi.revalidate(); hi.setVisible(true); hi.paintComponent(screenshot.getGraphics(), true); String imageFile = FileSystemStorage.getInstance().getAppHomePath() + "screenshot.png"; try(OutputStream os = FileSystemStorage.getInstance().openOutputStream(imageFile)) { ImageIO.getImageIO().save(screenshot, os, ImageIO.FORMAT_PNG, 1); } catch(IOException err) { Log.e(err); } sb.setImageToShare(imageFile, "image/png");Returns
a writable directory that represent the application home directory
-
hasCachesDir
public static boolean hasCachesDir()Returns true if the device has a directory dedicated for "cache" files
Returns
true if a caches style directory exists in this device type
-
getCachesDir
Returns a device specific directory designed for cache style files, or null if
#hasCachesDir()is falseReturns
file URL or null
-
canInstallOnHomescreen
public static boolean canInstallOnHomescreen()Checks to see if you can prompt the user to install the app on their homescreen. This is only relevant for the Javascript port with PWAs. This is not a "static" property, as it only returns true if the app is in a state that allows you to prompt the user. E.g. if you have previously prompted the user and they have declined, then this will return false.
Best practice is to use
#onCanInstallOnHomescreen(java.lang.Runnable)to be notified when you are allowed to prompt the user for installation. Then call#promptInstallOnHomescreen()inside that method - or sometime after.Example
`onCanInstallOnHomescreen(()->{ if (canInstallOnHomescreen()) { if (promptInstallOnHomescreen()) { // User accepted installation` else { // user rejected installation } } }); }https://developers.google.com/web/fundamentals/app-install-banners/
Returns
True if you are able to prompt the user to install the app on their homescreen.
Since
6.0
See also
-
#promptInstallOnHomescreen()
-
#onCanInstallOnHomescreen(java.lang.Runnable)
-
-
promptInstallOnHomescreen
public static boolean promptInstallOnHomescreen()Prompts the user to install this app on their homescreen. This is only relevant in the javascript port.
Returns
- Returns:
The result of the user prompt. true if the user accepts the installation, false if they reject it.
Since
6.0
See also
-
#canInstallOnHomescreen()
-
#onCanInstallOnHomescreen(java.lang.Runnable)
-
-
onCanInstallOnHomescreen
A callback fired when you are allowed to prompt the user to install the app on their homescreen. Only relevant in the javascript port.
Parameters
r: @param r Runnable that will be run when/if you are permitted to prompt the user to install the app on their homescreen.
Since
6.0
-
captureScreen
Captures a screenshot of the screen.
Returns
An image of the screen, or null if it fails.
Since
7.0
-
addMessageListener
Adds a listener to receive messages from the native platform. This is a mechanism to communicate between the app and the native platform. Currently the Javascript port is the only port to use this mechanism.
In the Javascript port, javascript can send messages to the CN1 app by calling
window.dispatchEvent(new CustomEvent('cn1inbox', {detail:'The message', code: SOMEINTEGER)); }Parameters
l: The listener.
Since
7.0
-
removeMessageListener
Removes a listener from receiving messages from the native platform. This is a mechanism to communicate between the app and the native platform. Currently the Javascript port is the only port to use this mechanism.
Parameters
l: The listener.
Since
7.0
-
postMessage
Posts a message to the native platform. This is a mechanism to communicate between the app and the native platform. Currently the Javascript port is the only port to use this mechanism.
In the Javascript port these messages can be received in Javascript by adding an event listener for 'cn1outbox' events to the 'window' object. The message is contained in the event data "detail" key. And the code in the 'code' key.
Parameters
message: The message to send to the native platform.
Since
7.0
-
setTimeout
Convenience method to schedule a task to run on the EDT after timeoutms.
Parameters
-
timeout: The timeout in milliseconds. -
r: The task to run.
Returns
The Timer object that can be used to cancel the task.
Since
7.0
See also
- #setInterval(int, java.lang.Runnable)
-
-
setInterval
Convenience method to schedule a task to run on the EDT after periodms repeating every periodms.
Parameters
-
timeout: The delay and repeat in milliseconds. -
r: The runnable to run on the EDT.
Returns
The timer object which can be used to cancel the task.
Since
7.0
See also
- #setTimeout(int, java.lang.Runnable)
-
-
getPluginSupport
Returns the plugin support object for the current platform. Use this object for registering plugins.
Returns
The plugin support object.
Since
8.0
-