Vous êtes sur la page 1sur 2967

Overview (Codename One API)

Overview (Codename One API)


Codename One - Write Once Run Anywhere Native Mobile Apps Using Java
See: Description

Package

Description

com.codename1.ads

A legacy banner Ads API.

com.codename1.analytics

The analytics API allows tracking your mobile application usage in the
field to give you real-time data on how your application is used.

com.codename1.capture

Package for capturing photos, audio or video from the


camera/microphone.

com.codename1.charts

The main ChartComponent Package

com.codename1.charts.models

Provides the classes that handle the data values (data model) to be used
by displaying the charts.

com.codename1.charts.renderers Provides renderer classes that keep the chart rendering / drawing styles.
com.codename1.charts.transitions
com.codename1.charts.util

Utility classes that provide helper methods used by most of the other
packages.

com.codename1.charts.views

Provides the classes that handle the actual rendering / drawing of the
charts, based on the provided model and renderer.

com.codename1.cloud

Provides cloud related services such as storage, binding widgets to the


cloud seamlessly so they can be persisted easily.

com.codename1.codescan

Deprecated!!: Please use the cn1-codescan library instead.

com.codename1.components

Generic elaborate components that make use of both UI elements and


storage.

com.codename1.contacts

Provides access to the contacts list from the device

com.codename1.db

SQLite support.

com.codename1.facebook

Legacy generic implementation of the Facebook API with simplified


OAuth integration to allow social sharing.

com.codename1.facebook.ui

User interface for integrating with basic Facebook features currently


mostly the Like button

com.codename1.io

Codename One IO is intended as a componentized solution for IO


operations that allows us to centralize IO logic while maintaining a more
portable approach for threads.

com.codename1.io.gzip

gzip support based on https://github.com/ymnk/jzlib

com.codename1.io.services

Default WebService implementations

com.codename1.io.tar

Tar support allowing us to package multiple separate files into a single


package which is useful in supporting hierarchies in a portable way.

com.codename1.javascript

The Codename One JS Bridge package includes classes that facilitate


the interaction between Java and Javascript in a Codename One
application.

com.codename1.l10n

The Localization API allows developers to adapt their applications to


different geographic locales and conventions.

com.codename1.location

Simple abstraction of location services (GPS/Triangulation) providing


user global positioning and monitoring over such changes.

com.codename1.maps

The mapping API allows developers to use maps in their applications,


add layers on top of the map and to enhance the API with additional
Layers, Providers and functionality.

com.codename1.maps.layers

The Layers are elements that are displayed on the map.

com.codename1.maps.providers

These are the map providers, currently http://www.openstreetmap.org/ is


supported.

com.codename1.media

Video and audio playback support are handled within this package using
the Media/Media manager APIs.

com.codename1.messaging

Overview (Codename One API)


This API allows to send e-mail messages through underlying platforms
e-mail clients.
com.codename1.notifications
com.codename1.payment

In-App Billing/Purchase API's are abstracted by this package.

com.codename1.processing

IO Related tools and utilities, e.g.

com.codename1.push

Push notification support using either device specific protocols when


available

com.codename1.share

Sharing services, that can be registered on the ShareButton

com.codename1.social

Connectors for native social network SDK's

com.codename1.system

Low level calls into the Codename One system, including support for
making platform native API calls.

com.codename1.testing

This package contains everything necessary for unit tests, automation of


tests and everything in between.

com.codename1.ui
com.codename1.ui.animations

All components are animatable by potential and additional animations


(unrelated to a specific component) can be installed on the fly, transitions
between forms are also handled as part of this package.

com.codename1.ui.events

Observable pattern event listeners in the spirit of AWT 1.1's event


dispatching architecture, all events are dispatched on the EDT (Event
Dispatch Thread).

com.codename1.ui.geom

Contains classes related to geometry locations and calculations such as


rectangle and size

com.codename1.ui.html

This package is deprecated and used only for legacy support, use the
WebBrowser component from the components package.

com.codename1.ui.layouts

Layout managers allow a Container to arrange its components by a set


of rules that adapt to specific densities (ppi - pixels per inch).

com.codename1.ui.layouts.mig
com.codename1.ui.list

Lists are highly customizable and serve as the basis for ComboBox and
other components (such as carousels etc) they employ a similar MVC
approach to Swing including the renderer pattern.

com.codename1.ui.painter

allows us to draw arbitrary elements of graphics from


plain/scaled/tiled images to gradients and pretty much any form of
graphic drawing we can imagine.

com.codename1.ui.plaf

Look of the application can be fully customized via this package, it


represents a rendering layer that can be plugged in separately in runtime
and themed to provide any custom look.

com.codename1.ui.spinner

Spinners allows picking of simple sequential values similarly to combo


boxes but of a much wider value set.

com.codename1.ui.table

Table component for editing and viewing tabular data and arranging
Codename One components in a tabular form

com.codename1.ui.tree

Tree component for displaying hierarchy based information and its


related classes

com.codename1.ui.util

Utility features that are either too domain specific or don't "fit" into any
other packages including the Resource file format loading API.

com.codename1.ui.validation

The validation framework allows us to mark invalid input in text


components and disable components in the case of invalid input

com.codename1.util

General utilities classes

com.codename1.util.regex

A simple regular expression API that is portable across all platforms

com.codename1.xml

The XML package allows parsing XML documents into DOM objects.

Painter

java.io
java.lang
java.lang.annotation

Overview (Codename One API)


java.lang.invoke
java.lang.ref
java.net
java.text
java.util

Codename One - Write Once Run Anywhere Native Mobile Apps Using
Java
Codename One allows Java developers to write their app once and have it work on all mobile devices (iOS,
Android etc.). It features a simulator, designer (visual theme/builder) and ports to multiple OS's.
Codename One is a mature open source project and its roots go back to Sun Microsystems (2006) where one
of its core underlying components was developed and open sourced.
Codename One is open source. This includes the libraries, native OS ports, resource editor & native VM
code. It also includes themes and separate related projects containing demos, skins etc.
You can understand more about how Codename One works and how the API fits into everything in this
stackoverflow answer.
Other Resources
Developer Guide
How Do I? - Get quick video answers and short tutorials for common questions
The Codename One Blog
cn1libs are extensions to Codename One that allow using device native functionality
Stack Overflow's Codename One Tag
Community Discussion Forum
The Open Source project on github
Build Codename One from source code

Codename One - Write Once Run Anywhere Native Mobile Apps Using Java

Overview (Codename One API)

Package java.util

Interface

Description

Collection<E>

Collection

is the root of the collection hierarchy.

Comparator<T>

A Comparator is used to compare two objects to determine their ordering with


respect to each other.

Deque<E>

A kind of collection that can insert or remove element at both ends("double


ended queue").

Enumeration<T>

An object that implements the Enumeration interface generates a series of


elements, one at a time.

EventListener

EventListener is the superclass of all event listener interfaces.

Iterator<E>

An Iterator is used to sequence over a collection of objects.

List<E>

A List is a collection which maintains an ordering for its elements.

ListIterator<E>

An ListIterator is used to sequence over a List of objects.

Map<K,V>

A Map is a data structure consisting of a set of keys and values in which each
key is mapped to a single value.

Map.Entry<K,V>

Map.Entry

NavigableMap<K,V>

NavigableMap is a SortedMap with navigation methods answering the closest


matches for specified item.

NavigableSet<E>

NavigableSet is a SortedSet with navigation methods answering the closest


matches for specified item.

is a key/value mapping contained in a Map.

is the interface to be implemented by objects that receive notification


of updates on an Observable object.
Observer

Observer
Queue<E>

This kind of collection provides advanced operations compared to basic


collections, such as insertion, extraction, and inspection.

RandomAccess

RandomAccess is implemented by List implementations that support fast


(usually constant time) random access.

Set<E>

A Set is a data structure which does not allow duplicate elements.

SortedMap<K,V>

A map that has its keys ordered.

SortedSet<E>

SortedSet is a Set which iterates over its elements in a sorted order.

Class
AbstractCollection<E>

Description
Class AbstractCollection is an abstract implementation
of the Collection interface.

AbstractList<E>

is an abstract implementation of the List


interface, optimized for a backing store which supports
random access.

AbstractMap<K,V>

This class is an abstract implementation of the Map


interface.

AbstractMap.SimpleEntry<K,V>

A key-value mapping.

AbstractList

AbstractMap.SimpleImmutableEntry<K,V> An immutable key-value mapping.


AbstractQueue<E>

AbstractQueue is an abstract class which implements


some of the methods in Queue.

AbstractSequentialList<E>

AbstractSequentialList is an abstract implementation of


the List interface.

AbstractSet<E>

An AbstractSet is an abstract implementation of the Set


interface.

ArrayDeque<E>

An implementation of Deque, backed by an array.

ArrayList<E>

ArrayList is an implementation of List, backed by an


array.

Package java.util

Overview (Codename One API)


Arrays

Arrays

contains static methods which operate on arrays.

BitSet

The BitSet class implements a bit field.

Calendar

Calendar is an abstract base class for converting


between a Date object and a set of integer fields such as
YEAR, MONTH, DAY, HOUR, and so on.

Collections

Collections contains
Collection classes.

Date

The class Date represents a specific instant in time, with


millisecond precision.

Dictionary<K,V>

Note: Do not use this class since it is obsolete.

EventListenerProxy

This abstract class provides a simple wrapper for objects


of type EventListener.

HashMap<K,V>

HashMap is an implementation of Map.

HashSet<E>

HashSet is an implementation of a Set.

Hashtable<K,V>

Hashtable associates keys with values.

IdentityHashMap<K,V>

IdentityHashMap is a variant on HashMap which tests


equality by reference instead of equality by value.

LinkedHashMap<K,V>

LinkedHashMap is a variant of HashMap.

LinkedHashSet<E>

LinkedHashSet is a variant of HashSet.

LinkedList<E>

LinkedList is an implementation of List, backed by a


linked list.

Observable

Observable is used to notify a group of Observer objects


when a change occurs.

PriorityQueue<E>

A PriorityQueue holds elements on a priority heap, which


orders the elements according to their natural order or
according to the comparator specified at construction
time.

Random

An instance of this class is used to generate a stream of


pseudorandom numbers.

static methods which operate on

is a Last-In/First-Out(LIFO) data structure which


represents a stack of objects.
Stack

Stack<E>
StringTokenizer

The StringTokenizer class allows an application to


break a string into tokens by performing code point
comparison.

Timer
TimerTask
TimeZone

TimeZone represents a time zone offset, and also


figures out daylight savings.

TreeMap<K,V>

TreeMap is an implementation of SortedMap.

TreeSet<E>

TreeSet is an implementation of SortedSet.

Vector<E>

Vector is a variable size contiguous indexable array of


objects.

Exception

Description

An ConcurrentModificationException is thrown when a


ConcurrentModificationException Collection is modified and an existing iterator on the Collection is
used to modify the Collection as well.
EmptyStackException

Thrown by methods in the Stack class to indicate that the stack is


empty.

NoSuchElementException

Thrown by the nextElement method of an Enumeration to indicate


that there are no more elements in the enumeration.

Package java.util

Overview (Codename One API)

Package java.text

Class
DateFormat

Description
Deprecated
this class has many issues in iOS and other platforms, please use the
L10NManager

DateFormatPatterns Common patterns for dates, times, and timestamps.


DateFormatSymbols
Format

An abstract class for parsing and formatting localisation sensitive information,


compatible with JDK 6.

SimpleDateFormat

Deprecated
this class has many issues in iOS and other platforms, please use the
L10NManager

Exception

Description

ParseException An error occurred during parsing.

Package java.text

Overview (Codename One API)

Package java.net

Class
URI

Description
An implementation of a Univeral Resource Identifier (URI).

Exception

Description

URISyntaxException

Package java.net

Overview (Codename One API)

Package java.lang.ref

Class
Reference

Description
Abstract base class for reference objects.

WeakReference This class provides support for weak references.

Package java.lang.ref

Overview (Codename One API)

Package java.lang

Interface
Appendable

Description
Declares methods to append characters or character sequences.

AutoCloseable
CharSequence

This interface represents an ordered set of characters and defines the methods to
probe them.

Cloneable

This (empty) interface must be implemented by all classes that wish to support
cloning.

Comparable<T>

This interface should be implemented by all classes that wish to define a natural
order of their instances.

Iterable<T>

Objects of classes that implement this interface can be used within a foreach
statement.

Runnable

The Runnable interface should be implemented by any class whose instances are
intended to be executed by a thread.

Class

Description

Boolean

The Boolean class wraps a value of the primitive type boolean in an object.

Byte

The Byte class is the standard wrapper for byte values.

Character

The Character class wraps a value of the primitive type char in an object.

Class<T>

Instances of the class Class represent classes and interfaces in a running Java
application.

Double

The Double class wraps a value of the primitive type double in an object.

Enum<E extends
Enum<E>>

Implementation class required to compile enums

Float

The Float class wraps a value of primitive type float in an object.

Integer

The Integer class wraps a value of the primitive type int in an object.

Long

The Long class wraps a value of the primitive type long in an object.

Math

The class Math contains methods for performing basic numeric operations.

Object

Class Object is the root of the class hierarchy.

Runtime

Every Java application has a single instance of class Runtime that allows the
application to interface with the environment in which the application is
running.

Short

The Short class is the standard wrapper for short values.

String

The String class represents character strings.

StringBuffer

A string buffer implements a mutable sequence of characters.

StringBuilder

A string buffer implements a mutable sequence of characters.

System

The System class contains several useful class fields and methods.

Thread

A thread is a thread of execution in a program.

Throwable

The Throwable class is the superclass of all errors and exceptions in the Java
language.

Void

Exception

Description

ArithmeticException

Thrown when an exceptional arithmetic condition has occurred.

ArrayIndexOutOfBoundsException

Thrown to indicate that an array has been accessed with an


illegal index.

ArrayStoreException

Thrown to indicate that an attempt has been made to store the


wrong type of object into an array of objects.

Package java.lang

10

Overview (Codename One API)


ClassCastException

Thrown to indicate that the code has attempted to cast an object


to a subclass of which it is not an instance.

ClassNotFoundException

Thrown when an application tries to load in a class through its


string name using the forName method in class Class but no
definition for the class with the specified name could be found.

CloneNotSupportedException

Thrown when a program attempts to clone an object which does


not support the Cloneable interface.

Exception

The class Exception and its subclasses are a form of Throwable


that indicates conditions that a reasonable application might
want to catch.

IllegalAccessException

Thrown when an application tries to load in a class, but the


currently executing method does not have access to the
definition of the specified class, because the class is not public
and in another package.

IllegalArgumentException

Thrown to indicate that a method has been passed an illegal or


inappropriate argument.

IllegalMonitorStateException

Thrown to indicate that a thread has attempted to wait on an


object's monitor or to notify other threads waiting on an object's
monitor without owning the specified monitor.

IllegalStateException
IllegalThreadStateException

Thrown to indicate that a thread is not in an appropriate state for


the requested operation.

IndexOutOfBoundsException

Thrown to indicate that an index of some sort (such as to an


array, to a string, or to a vector) is out of range.

InstantiationException

Thrown when an application tries to create an instance of a


class using the newInstance method in class Class, but the
specified class object cannot be instantiated because it is an
interface or is an abstract class.

InterruptedException

Thrown when a thread is waiting, sleeping, or otherwise paused


for a long time and another thread interrupts it.

NegativeArraySizeException

Thrown if an application tries to create an array with negative


size.

NullPointerException

Thrown when an application attempts to use null in a case


where an object is required.

NumberFormatException

Thrown to indicate that the application has attempted to convert


a string to one of the numeric types, but that the string does not
have the appropriate format.

RuntimeException

RuntimeException is the superclass of those exceptions that


can be thrown during the normal operation of the Java Virtual
Machine.

SecurityException

Thrown by the system to indicate a security violation.

Thrown by the charAt method in class String and by other String


StringIndexOutOfBoundsException methods to indicate that an index is either negative or greater
than or equal to the size of the string.

Error

Description

AssertionError
Error

An Error is a subclass of Throwable that indicates serious problems


that a reasonable application should not try to catch.

IncompatibleClassChangeError is the superclass of all classes


IncompatibleClassChangeError which represent errors that occur when inconsistent class files are
loaded into the same running image.

LinkageError

is the superclass of all error classes that occur when


loading and linking class files.
LinkageError

NoClassDefFoundError

Package java.lang

11

Overview (Codename One API)


Thrown if the Java Virtual Machine tries to load in the definition of a
class (as part of a normal method call or as part of creating a new
instance using the new expression) and no definition of the class
could be found.
NoSuchFieldError

Thrown when the virtual machine notices that a program tries to


reference, on a class or object, a field that does not exist.

OutOfMemoryError

Thrown when the Java Virtual Machine cannot allocate an object


because it is out of memory, and no more memory could be made
available by the garbage collector.

VirtualMachineError

Thrown to indicate that the Java Virtual Machine is broken or has


run out of resources necessary for it to continue operating.

Annotation Type

Description

Deprecated

An annotation for marking an element as deprecated.

Override

An annotation to indicate that a method is intended to override a superclass


method.

SuppressWarnings

An annotation that indicates a compiler should suppress any warnings of the


type specified in the SuppressWarnings.value().

Package java.lang

12

Overview (Codename One API)

Package java.lang.invoke

Class

Description

CallSite

Deprecated
these classes are used internally for Lambda compatibility

LambdaMetafactory

Deprecated
these classes are used internally for Lambda compatibility

MethodHandle

Deprecated
these classes are used internally for Lambda compatibility

MethodHandles

Deprecated
these classes are used internally for Lambda compatibility

MethodHandles.Lookup
MethodType

Package java.lang.invoke

Deprecated
these classes are used internally for Lambda compatibility

13

Overview (Codename One API)

Package java.lang.annotation

Interface

Description

Annotation A mirror of java.lang.Annotation.

Enum
ElementType

Description
A mirror of java.lang.annotation.ElementType.

RetentionPolicy A mirror of java.lang.annotation.RetentionPolicy.

Exception

Description

IncompleteAnnotationException A mirror of java.lang.annotation.IncompleteAnnotationException.

Error

Description

AnnotationFormatError A mirror of java.lang.annotation.AnnotationFormatError.

Annotation Type Description


Documented
Inherited
Retention
Target

Package java.lang.annotation

14

Overview (Codename One API)

Package java.io

Interface

Description

DataInput

The DataInput interface provides for reading bytes from a binary stream and
reconstructing from them data in any of the Java primitive types.

DataOutput

The DataOutput interface provides for converting data from any of the Java primitive
types to a series of bytes and writing these bytes to a binary stream.

Flushable

Indicates that an output object can be flushed.

Serializable Here to simplify porting, won't actually work...

Class

Description

ByteArrayInputStream

A ByteArrayInputStream contains an internal buffer that contains bytes that


may be read from the stream.

ByteArrayOutputStream

This class implements an output stream in which the data is written into a
byte array.

DataInputStream

A data input stream lets an application read primitive Java data types from
an underlying input stream in a machine-independent way.

DataOutputStream

A data output stream lets an application write primitive Java data types to
an output stream in a portable way.

InputStream

This abstract class is the superclass of all classes representing an input


stream of bytes.

InputStreamReader

An InputStreamReader is a bridge from byte streams to character streams:


It reads bytes and translates them into characters.

OutputStream

This abstract class is the superclass of all classes representing an output


stream of bytes.

OutputStreamWriter

An OutputStreamWriter is a bridge from character streams to byte streams:


Characters written to it are translated into bytes.

PrintStream

A PrintStream adds functionality to another output stream, namely the


ability to print representations of various data values conveniently.

Reader

Abstract class for reading character streams.

Writer

Abstract class for writing to character streams.

Exception

Description

EOFException

Signals that an end of file or end of stream has been reached


unexpectedly during input.

InterruptedIOException

Signals that an I/O operation has been interrupted.

IOException

Signals that an I/O exception of some sort has occurred.

UnsupportedEncodingException The Character Encoding is not supported.


UTFDataFormatException

Package java.io

Signals that a malformed UTF-8 string has been read in a data


input stream or by any class that implements the data input
interface.

15

Overview (Codename One API)

Package com.codename1.xml
The XML package allows parsing XML documents into DOM objects.
See: Description

Interface
ParserCallback

Description
A callback used to dispatch errors encountered while parsing XML
resources

Class
Element

Description
The Element class defines a single XML element with its attributes and children.

XMLParser Parser class used to parse an XML document into a DOM object (Element).
XMLWriter

Package com.codename1.xml Description


The XML package allows parsing XML documents into DOM objects.

Package com.codename1.xml

16

Overview (Codename One API)

Package com.codename1.util.regex
A simple regular expression API that is portable across all platforms
See: Description

Interface

Description

CharacterIterator Encapsulates different types of character sources - String, InputStream, ...

Class

Description

CharacterArrayCharacterIterator Encapsulates char[] as CharacterIterator


RE

RE is an efficient, lightweight regular expression evaluator/matcher


class.

ReaderCharacterIterator

Encapsulates java.io.Reader as CharacterIterator

RECharacter
RECompiler

A regular expression compiler class.

REDebugCompiler

A subclass of RECompiler which can dump a regular expression


program for debugging purposes.

REProgram

A class that holds compiled regular expressions.

REUtil

This is a class that contains utility helper methods for this package.

StreamCharacterIterator

Encapsulates java.io.InputStream as CharacterIterator.

StringCharacterIterator

Encapsulates String as CharacterIterator.

StringReader

Exception

Description

RESyntaxException Exception thrown to indicate a syntax error in a regular expression.

Package com.codename1.util.regex Description


A simple regular expression API that is portable across all platforms

Package com.codename1.util.regex

17

Overview (Codename One API)

Package com.codename1.util
General utilities classes
See: Description

Interface
Callback<T>

Description
Simple interface that allows asynchronous code to perform a parameterized callback
or failure in a similar way to GWT's callback interface

LazyValue<T> Useful when passing a value that might not exist to a function, e.g.

Class

Description

Base64

This class implements Base64 encoding/decoding functionality as specified in


RFC 2045 (http://www.ietf.org/rfc/rfc2045.txt).

BigDecimal

Class representing a simple version of a big decimal.

BigInteger

A simplified version of big integer from the bouncy castle implementation

CaseInsensitiveOrder

A string comparator equivalent to String.CASE_INSENSITIVE_ORDER which


isn't available in Codename One

CStringBuilder

Deprecated
we will be moving to the proper string builder very soon

MathUtil

MathUtil for Java ME.

StringUtil

Various utility methods for manipulating strings

Package com.codename1.util Description


General utilities classes

Package com.codename1.util

18

Overview (Codename One API)

Package com.codename1.ui.validation
The validation framework allows us to mark invalid input in text components and disable components in the
case of invalid input
See: Description

Interface
Constraint

Description
To perform validation we add a constraint to a validator, a constraint defines whether a
value if valid for a given object

Class

Description

GroupConstraint Groups several constraints as if they are one constraint


LengthConstraint Creates a validation constraint based on minimum input length
RegexConstraint Creates a validation constraint based on a regular expression
Binds validation constraints to form elements, when validation fails it can be
highlighted directly on the component via an emblem or change of the UIID (to
original UIID name + "Invalid" e.g.

Validator

Enum

Description

Validator.HighlightMode Indicates the validation failure modes

Package com.codename1.ui.validation Description


The validation framework allows us to mark invalid input in text components and disable components in the
case of invalid input

Package com.codename1.ui.validation

19

Overview (Codename One API)

Package com.codename1.ui.util
Utility features that are either too domain specific or don't "fit" into any other packages including the Resource
file format loading API.
See: Description

Class

Description

Effects

Static utility class useful for simple visual effects that don't quite fit anywhere
else in the core API.

EmbeddedContainer

This class is mostly used internally by the GUI builder and isn't very useful for
general purpose.

EventDispatcher

Handles event dispatching while guaranteeing that all events would be fired
properly on the EDT regardless of their source.

GlassTutorial

A Glass Tutorial appears on top of the UI especially on a touch device but


could be on any device and points to/circles components within the UI
coupled with explanation of what they do and a tint of the screen.

ImageIO

Enable simple operations on image file & image objects such as dynamic
scaling and storage to binary formats such as JPEG.

Resources

Loads resources from the binary resource file generated by the Codename
One Designer.

SwipeBackSupport

Allows binding a swipe listener to the form that enables the user to swipe
back to the previous form.

UIBuilder

The UI builder can create a user interface based on the UI designed in the
resource editor and allows us to bind to said UI.

UITimer

Simple timer callback that is invoked on the CodenameOne EDT thread


rather than on a separate thread.

WeakHashMap<K,V> Helper weak hash map substitute

Package com.codename1.ui.util Description


Utility features that are either too domain specific or don't "fit" into any other packages including the Resource
file format loading API.

Package com.codename1.ui.util

20

Overview (Codename One API)

Package com.codename1.ui.tree
Tree component for displaying hierarchy based information and its related classes
See: Description

Interface

Description

TreeModel

Arranges tree node objects, a node can essentially be anything and it will be displayed in
a hierarchy using the Tree

Class
Tree

Description
The Tree component allows constructing simple tree component hierarchies that can be
expanded seamlessly with no limit.

Package com.codename1.ui.tree Description


Tree component for displaying hierarchy based information and its related classes

Package com.codename1.ui.tree

21

Overview (Codename One API)

Package com.codename1.ui.table
Table component for editing and viewing tabular data and arranging Codename One components in a tabular
form
See: Description

Interface
TableModel

Description
The table and table model class are complimentry classes allowing the quick
construction of tabular data controls.

Class

Description

DefaultTableModel

A default implementation of the table model based on a two dimensional


array.

Table

The Table class represents a grid of data that can be used for rendering a
grid of components/labels.

TableLayout

TableLayout is a very elaborate constraint based layout manager that can


arrange elements in rows/columns while defining constraints to control
complex behavior such as spanning, alignment/weight etc.
Notice that the table layout is in the com.codename1.ui.table package and
not in the layouts package.

TableLayout.Constraint

Represents the layout constraint for an entry within the table indicating the
desired position/behavior of the component.

Package com.codename1.ui.table Description


Table component for editing and viewing tabular data and arranging Codename One components in a tabular
form

Package com.codename1.ui.table

22

Overview (Codename One API)

Package com.codename1.ui.spinner
Spinners allows picking of simple sequential values similarly to combo boxes but of a much wider value set.
See: Description

Class

Description

BaseSpinner

Base class for spinners

DateSpinner

A date spinner allows selecting a date value within the given date range

DateTimeSpinner

The date and time spinner extends the time spinner by allowing to pick a specific
day as well

GenericSpinner

A spinner class that allows arbitrary values, this is effectively a combo box
replacement for platforms where a combo box is not available

NumericSpinner

A spinner class that allows picking a number

Picker

Picker

TimeSpinner

Allows selecting a time of day either in 24 hour batches or AM/PM format

is a component and API that allows either popping up a spinner or using


the native picker API when applicable.

Package com.codename1.ui.spinner Description


Spinners allows picking of simple sequential values similarly to combo boxes but of a much wider value set.
They are mostly designed for picking dates, numbers or hours of the day.

Package com.codename1.ui.spinner

23

Overview (Codename One API)

Package com.codename1.ui.plaf
Look of the application can be fully customized via this package, it represents a rendering layer that can be
plugged in separately in runtime and themed to provide any custom look.
See: Description

Class

Description

Border

Base class that allows us to render a border for a component, a border is


drawn before the component and is drawn within the padding region of the
component.

DefaultLookAndFeel

Deprecated
this class is still crucial for some features in Codename One.

LookAndFeel

Deprecated
this class is still crucial for some features in Codename One.

Style

Represents the look of a given component: colors, fonts, transparency, margin


and padding & images.

UIManager

Central point singleton managing the look of the application, this class allows
us to customize the styles (themes) as well as the look instance.

Package com.codename1.ui.plaf Description


Look of the application can be fully customized via this package, it represents a rendering layer that can be
plugged in separately in runtime and themed to provide any custom look. Unlike the Swing PLAF this layer
does not support any aspect of "feel" as in event handling etc. since these aspects would require a much
bigger and more elaborate layer unfit for small device OTA delivery.
Sizes of components are also calculated by the LookAndFeel since the size is very much affected by the look
of the application e.g. the thickness of the border and the font sizes.

Package com.codename1.ui.plaf

24

Overview (Codename One API)

Package com.codename1.ui.painter
allows us to draw arbitrary elements of graphics from plain/scaled/tiled images to gradients and pretty
much any form of graphic drawing we can imagine.
See: Description
Painter

Class

Description

BackgroundPainter A painter that draws the background of a component based on its style
PainterChain

A painter chain allows us to chain together several painters to provide a "layer"


effect where each painter only draws one element.

Package com.codename1.ui.painter Description


allows us to draw arbitrary elements of graphics from plain/scaled/tiled images to gradients and pretty
much any form of graphic drawing we can imagine. Painters are "hooked" into the core of the API thus
allowing us to customize every aspect of it. See Component and Form.
Painter

Package com.codename1.ui.painter

25

Overview (Codename One API)

Package com.codename1.ui
See: Description

Interface

Description

Painter

Painter can be used to draw on components backgrounds.

URLImage.ImageAdapter

Allows applying resize logic to downloaded images you can use constant
resize behaviors defined in this class.

Class

Description

AnimationManager

Animation manager concentrates all of the animations for a given form into
a single place that allows us to manage all mutations to a Form in a way the
prevents collisions between mutations.

AutoCompleteTextField

An editable TextField with completion suggestions that show up in a drop


down menu while the user types in text.

BrowserComponent

The browser component is an interface to an embeddable native platform


browser on platforms that support embedding the native browser in place, if
you need wide compatibility and flexibility you should check out the
HTMLComponent which provides a lightweight 100% cross platform web
component.
This component will only work on platforms that support embedding a
native browser which exclude earlier versions of Blackberry devices and
J2ME devices.
Its recommended that you place this component in a fixed position (none
scrollable) on the screen without other focusable components to prevent
confusion between focus authority and allow the component to scroll itself
rather than CodenameOne making that decision for it.

Button

Button is the base class for several UI widgets allowing clickability.

ButtonGroup

This class is used to create a multiple-exclusion scope for RadioButton.

Calendar

Date widget for selecting a date/time value.


To localize strings for month names use the values "Calendar.Month" using
the 3 first characters of the month name in the resource localization e.g.

CheckBox

CheckBox is a button that can be selected or deselected and displays its


state to the user.

ComboBox<T>

A ComboBox is a list that allows only one selection at a time, when a user
clicks the ComboBox a popup button with the full list of elements allows the
selection of a single element.

Command

The Command class provides a useful extension to the ActionListener


interface in cases where the same functionality may be accessed by
several controls.

Component

The component class is the basis of all UI widgets in Codename One, to


arrange multiple components together we use the Container class which
itself "IS A" Component subclass.

ComponentGroup

A component group is a container that applies the given UIID to a set of


components within it and gives the same UIID with "First"/"Last" prepended
to the first and last components.

Container

A composite pattern with Component, allows nesting and arranging multiple


components using a pluggable layout manager architecture.

Dialog

A dialog is a form that occupies a part of the screen and appears as a


modal entity to the developer.

Display

Central class for the API that manages rendering/events and is used to
place top level components (Form) on the "display".

EncodedImage

An image that only keeps the binary data of the source file used to load it in
permanent memory.

Font

Codename One currently supports 3 font types:

Package com.codename1.ui

26

Overview (Codename One API)


FontImage

An image based on icon fonts that adapts its environment

Form

Top level component that serves as the root for the UI, this Container
handles the menus and title while placing content between them.

Graphics

Abstracts the underlying platform graphics context thus allowing us to


achieve portability between MIDP devices and CDC devices.

Image

Abstracts the underlying platform images allowing us to treat them as a


uniform object.

InfiniteContainer

This abstract Container can scroll indefinitely (or at least until we run out of
data).

Label

Allows displaying a single line of text and icon (both optional) with different
alignment options.

List<T>

A set of elements that is rendered using a ListCellRenderer and are


extracted via the ListModel.
A list can represent many UI concepts ranging from a carousel to a "todo"
checklist, this is made possible thanks to extensive use of Swing's style of
MVC.

MenuBar

This class represents the Form MenuBar.

NavigationCommand

The NavigationCommand is a Command that navigates to a given Form.

PeerComponent

A peer component is essentially a "dummy" Codename One component


used to calculate the position of the actual native platform specific
component.

RadioButton

RadioButton is a Button that maintains a selection state exclusively within a


specific ButtonGroup.

RGBImage

An image that stores its data as an integer RGB array internally, this image
cannot be manipulated via Graphics primitives however its array is
accessible and modifiable programmatically.

SideMenuBar

This is Menu Bar that displays it's commands on a side bar navigation
similar to Google+/Facbook apps navigation

Slider

The slider component serves both as a slider widget to allow users to select
a value on a scale via touch/arrows and also to indicate progress.

Stroke

Encapsulates the stroke used for drawing paths.

SwipeableContainer

SwipeableContainer

allows us to side swipe a component and expose


underlying configuration within it.

Tabs

A component that lets the user switch between a group of components by


clicking on a tab with a given title and/or icon.

TextArea

An optionally multi-line editable region that can display text and allow a user
to edit it.

TextField

A specialized version of TextArea with some minor deviations from the


original specifically:

Toolbar

Toolbar replaces the default title area with a powerful abstraction that
allows functionality ranging from side menus (hamburger) to title animations
and any arbitrary component type.

Transform

Encapsulates a 3D transform that can be used in Graphics contexts or with


Shapes to transform in various ways.

URLImage

URLImage

VirtualKeyboard

This class represent the Codename One Light Weight Virtual Keyboard

allows us to create an image from a URL.

Package com.codename1.ui Description


Main widget package containing the component/container "composite" similar both in terminology and design
to Swing/AWT.

Package com.codename1.ui Description

27

Overview (Codename One API)

Component/Container Relationship
Containers can be nested one within the other to form elaborate UI's. Containers use
com.codename1.ui.layouts to arrange the components within. This is important as it allows a container can
adapt to changing resolution, DPI, orientation, font size etc.

A container doesn't implicitly reflow its elements and in that regard follows the direction of AWT/Swing. As a
result the layout can be animated to create a flowing effect for UI changes. This also provides improved
performance as a bonus. See this sample of Container animation:
You can learn more about layout managers here and about event handling here.

Component Gallery
The component gallery below isn't complete or exhaustive but it should give you a sense of the types of
widgets available within Codename One in a glance.

AutoCompleteTextField

AutoCompleteTextField

provides suggestions as you type into the text field

BrowserComponent

Component/Container Relationship

28

Overview (Codename One API)


BrowserComponent

allows us to embed an OS native browser into the app and connect to its JavaScript

runtime!

Button

Button

allows us to bind events to a click

Link Button

Button

can also be used as a hyperlink

Calendar

presents a visual date picker. Notice that we recommend using the Picker class which is superior
when running on the device for most use cases.
Calendar

CheckBox

provides a check flag to tick on/off. RadioButton provides an exclusive check marking that only
applies to one radio within the group. Both can also appear as toggle buttons
CheckBox

BrowserComponent

29

Overview (Codename One API)

ComboBox

ComboBox is a list with


Picker class which is

a single visible entry that can popup the full list. Notice that we recommend using the
superior when running on the device for most use cases

Command

& Toolbar provide deep customization of the title area and allow us to place elements in the side
menu (hamburger), overflow menu etc.
Command

ComponentGroup

ComponentGroup

allows us to group components together in a a group and manipulate their UIID's.

Dialog

Dialog

allows us to notify/ask the user in a modal/modless way.

ComboBox

30

Overview (Codename One API)

InfiniteContainer

InfiniteContainer

& InfiniteScrollAdapter implement a Container that can dynamically fetch more data

Label

Label

displays text and/or icons to the user

List

List a list of items, this is a rather elaborate component to


Container, InfiniteContainer or InfiniteScrollAdapter

work with! We often recommend just using

MultiList

a list that is a bit simpler to work with than List List although our recommendation to use
something else still applies
MultiList

InfiniteContainer

31

Overview (Codename One API)

Slider

Slider

allows us to indicate progress or allows the user to drag a bar to indicate volume (as in quantity)

SwipeableContainer

SwipeableContainer

enables side swipe gesture to expose additional functionality

Tabs

Tabs

places components/containers into tabbable entries, allows swiping between choices thru touch

Carousel

Tabs

can also be used as a swipe carousel

TextArea/Field

Slider

32

Overview (Codename One API)

TextArea

& TextField allow for user input via the keyboard (virtual or otherwise)

Table

Table

displays optionally editable tabular data to the user

Tree

Tree

displays data in a tree like hierarchy

ChartComponent

ChartComponent

can embed a wide range of visualization aids and animations into your app

ImageViewer

TextArea/Field

33

Overview (Codename One API)

ImageViewer

swipe, pinch to zoom and pan images

InfiniteProgress

InfiniteProgress

provides a constantly spinning component

InteractionDialog

InteractionDialog

an "always on top" Dialog

MediaPlayer

MediaPlayer

allows playing media including video coupled with the MediaManager

MultiButton

ImageViewer

34

Overview (Codename One API)

MultiButton

is much more than a button

OnOffSwitch

OnOffSwitch

allows us to toggle a state similar to the CheckBox but with a more modern look

ShareButton

ShareButton

provides native "social share" functionality

ShareButton

when running on the device (Android)

SpanLabel

MultiButton

35

Overview (Codename One API)

SpanLabel

a text label that "seamlessly" breaks lines

SpanButton

SpanButton

a button that "seamlessly" breaks lines

Picker (Date)

Picker

allows us to show an OS native picker UI (Date Picker)

Picker (Time)

Picker

allows us to show an OS native picker UI (Time Picker)

ToastBar

SpanLabel

36

Overview (Codename One API)

ToastBar

shows a non-obtrusive notice on the bottom of the Form

ToastBar

37

Overview (Codename One API)

Package com.codename1.ui.list
Lists are highly customizable and serve as the basis for ComboBox and other components (such as carousels
etc) they employ a similar MVC approach to Swing including the renderer pattern.
See: Description

Interface
CellRenderer<T>

Description
Deprecated
this interface was added for ContainerList which is now deprecated.

A "rubber stamp" tool that allows us to extract a component (often the same
component instance for all invocations) that is initialized to the value of the
ListCellRenderer<T>
current item extracted from the model, this component is drawn on the list and
discarded.
ListModel<T>

Represents the data structure of the list, thus allowing a list to represent any
potential data source by referencing different implementations of this interface.

Class

Description

ContainerList

Deprecated
the performance of ContainerList is worse than the performance of
List or Container.

DefaultListCellRenderer<T>

Default implementation of the renderer based on a label see the


ListCellRenderer for more information about the use and purpose of
this class

DefaultListModel<T>

Default implementation of the list model based on a List of elements.

FilterProxyListModel<T>

This class allows filtering/sorting a list model dynamically using a text


field

GenericListCellRenderer<T>

The generic list cell renderer can display containers or arbitrary


Codename One components as items in a list.

MultiList

A list with a MultiButton renderer.

Package com.codename1.ui.list Description


Lists are highly customizable and serve as the basis for ComboBox and other components (such as carousels
etc) they employ a similar MVC approach to Swing including the renderer pattern. ListCellRenderer allows us
to customize the appearance of a list entry, it works as a "rubber stamp" by drawing the rendered component
and discarding its state thus allowing very large lists with very little component state overhead.
allows us to represent the underlying data structure for the List/ComboBox without requiring all the
data to reside in memory or in a specific structure. This allows a model to represent a data source of any type,
coupled with the renderer the data source can be returned in an internal representation state and still be
rendered properly to the screen.
ListModel

Package com.codename1.ui.list

38

Overview (Codename One API)

Package com.codename1.ui.layouts
Layout managers allow a Container to arrange its components by a set of rules that adapt to specific
densities (ppi - pixels per inch).
See: Description

Class

Description

BorderLayout

A border layout lays out a container, arranging and resizing its components to
fit in five regions: north, south, east, west, and center.

BoxLayout

Layout manager that places elements in a row (X_AXIS) or column (Y_AXIS)


according to box orientation.

CoordinateLayout

Deprecated
the usage of this layout is strongly discouraged as elements will not adapt to
the right position/size

FlowLayout

FlowLayout is the default layout manager for Codename One Containers and
Forms.

GridBagConstraints Port of the GridBag code from Apache's Harmony


GridBagLayout

Codename One port of the infamous GridBagLayout based on the Apache


Harmony code.

GridLayout

The components are arranged in a grid based on available space, all cells in
the grid are given exactly the same size which matches the largest preferred
size or available space.

GroupLayout

GroupLayout is a LayoutManager that hierarchically groups components to


achieve common, and not so common, layouts.

Insets

Port of Insets from Harmony for the use of the GridBag code

LayeredLayout

The LayeredLayout places the components in order one on top of the other and
sizes them all to the size of the largest component.

Layout

Abstract class that can be used to arrange components in a container using a


predefined algorithm.

LayoutStyle

LayoutStyle is used to determine how much space to place between


components during layout.

Package com.codename1.ui.layouts Description


Layout managers allow a Container to arrange its components by a set of rules that adapt to specific
densities (ppi - pixels per inch). A layout manager is an arranging algorithm encapsulated by an abstract class
implementation that places components absolutely based on the "hints" received.

Layout Managers that ship with Codename One


FlowLayout

is default layout manager, simple, flexible and with a few caveats.

Package com.codename1.ui.layouts

39

Overview (Codename One API)

BorderLayout

is ubiquitous thru Codename One code.

BorderLayout

can also behave differently based on the center behavior flag

Layout Managers that ship with Codename One

40

Overview (Codename One API)

BoxLayout

Y axis is a the work-horse of component lists

BoxLayout

X axis is a simpler replacement to flow layout and has grow/no grow variants.

Layout Managers that ship with Codename One

41

Overview (Codename One API)

GridLayout

arranges elements in a grid where all elements have an equal size. It can auto adapt the column

count.

Layout Managers that ship with Codename One

42

Overview (Codename One API)

is similar in many regards to HTML tables. Notice that its in the com.codename1.ui.table
package and not in this package.
TableLayout

Layout Managers that ship with Codename One

43

Overview (Codename One API)


is unique in the sense that it is meant to costruct layers and not the UI positions. It only lays
out on the Z axis.
LayeredLayout

GridBagLayout

MigLayout

was added to Codename One to ease the porting of Swing/AWT applications.

is a popular 3rd party layout manager its Codename One port is experimental.

Layout Managers that ship with Codename One

44

Overview (Codename One API)

Layout Managers that ship with Codename One

45

Overview (Codename One API)

Package com.codename1.ui.layouts.mig

Interface

Description

ComponentWrapper A class that wraps the important parts of a Component.


ContainerWrapper

A class that wraps a container that contains components.

InCellGapProvider

An interface to implement if you want to decide the gaps between two types of
components within the same cell.

Class

Description

AC

A constraint that holds the column or row constraints for the grid.

BoundSize

A size that contains minimum, preferred and maximum size of type UnitValue.

CC

A simple value holder for one component's constraint.

ConstraintParser Parses string constraints.


DimConstraint

A simple value holder for a constraint for one dimension.

Grid

Holds components in a grid.

LayoutCallback

A class to extend if you want to provide more control over where a component is
placed or the size of it.

LayoutUtil

A utility class that has only static helper methods.

LC

Contains the constraints for an instance of the LC layout manager.

LinkHandler
MigLayout

Deprecated
this is currently an experimental integration and has known bugs do not rely on
this layout for production

PlatformDefaults Currently handles Windows, Mac OS X, and GNOME spacing.


UnitConverter
UnitValue

Package com.codename1.ui.layouts.mig

46

Overview (Codename One API)

Package com.codename1.ui.html
This package is deprecated and used only for legacy support, use the WebBrowser component from the
components package.
See: Description

Interface

Description

AsyncDocumentRequestHandler Provides an interface for Asynchronous request handling.

DocumentRequestHandler

The DocumentRequestHandler interface should be implemented


so it returns documents in requested URLs.
Concrete classes should handle in its single method all necessary
networking and IO issues.
Implementations of this interface are used by HTMLComponent to
obtain links and form results

HTMLCallback

HTMLCallback is used to dispatch document lifecycle events.

IOCallback

This interface is implemented by HTMLComponent and


ResourceThread (The two classes using the
AsyncDocumentRequestHandler)

Class

Description

AsyncDocumentRequestHandlerImpl

Implementation of the HTML components document request


handler to allow simple HTML support in CodenameOne.

DefaultDocumentRequestHandler

Default implementation of the HTML components document


request handler to allow simple HTML support in Codename
One.

DefaultHTMLCallback

This is a default implementation of HTMLCallback that


basically doesn't do much but does keep the
HTMLComponent work intact.

DocumentInfo

DocumentInfo holds important information about a document


that is loading.

HTMLComponent

Deprecated
this component includes some customizability advantages but
its probably better for 99% of the use cases to use the
WebBrowser Component from the Components package.

HTMLElement

The HTMLElement class defines a single HTML element with


its attributes and children.

HTMLParser

The HTMLParser class is used to parse an XHTML-MP 1.0


document into a DOM object (Element).

HTMLUtils

This class contains several useful static methods for HTML

Package com.codename1.ui.html Description


This package is deprecated and used only for legacy support, use the WebBrowser component from the
components package. The HTML package allows rendering XHTML-MP 1.0 documents including WCSS
support.

Package com.codename1.ui.html

47

Overview (Codename One API)

Package com.codename1.ui.geom
Contains classes related to geometry locations and calculations such as rectangle and size
See: Description

Interface

Description

PathIterator This interface provides a directed path over the boundary of a shape.
Shape

An interface that can be implemented by any class that wants to be drawable as a


shape.

Class

Description

Dimension

Utility class that holds a width and height that represents a dimension of a component
or element

Dimension2D

Utility class that holds a width and height that represents a dimension of a component
or element

GeneralPath

A general geometric path, consisting of any number of subpaths constructed out of


straight lines and cubic or quadratic Bezier curves.

Point

Utility class that holds x,y

Point2D

Utility class that holds x,y

Rectangle

Represents a Rectangle position (x, y) and Dimension (width, height), this is useful for
measuring coordinates within the application.

Rectangle2D

Represents a Rectangle position (x, y) and Dimension (width, height), this is useful for
measuring coordinates within the application.

Package com.codename1.ui.geom Description


Contains classes related to geometry locations and calculations such as rectangle and size

Package com.codename1.ui.geom

48

Overview (Codename One API)

Package com.codename1.ui.events
Observable pattern event listeners in the spirit of AWT 1.1's event dispatching architecture, all events are
dispatched on the EDT (Event Dispatch Thread).
See: Description

Interface
ActionListener

Description
Event callback interface invoked when a component action occurs

Important: Calls to this interface are always performed on a


separate thread from the EDT! They are performed on the native
BrowserNavigationCallback webkit rendering thread or native event dispatch thread, this
interface MUST NEVER block or synchronize against the EDT
which WILL lead to deadlocks.
DataChangedListener

Event callback interface invoked when a ListModel changes its state


thus indicating to the view that it should refresh.

FocusListener

Observes focus change events for a given form and invokes the
callbacks to enable us to assign functionality based on current focused
component.

ScrollListener

Invoked to indicate a scroll change events

SelectionListener

Invoked to indicate a selection change in the list model

StyleListener

Invoked to indicate a change in a Style property

Class

Description

ActionEvent Event object delivered when an ActionListener callback is invoked

Enum

Description

ActionEvent.Type The event type, as declared when the event is created.

Package com.codename1.ui.events Description


Observable pattern event listeners in the spirit of AWT 1.1's event dispatching architecture, all events are
dispatched on the EDT (Event Dispatch Thread). See the overview documentation for further information and
Display.

Package com.codename1.ui.events

49

Overview (Codename One API)

Package com.codename1.ui.animations
All components are animatable by potential and additional animations (unrelated to a specific component) can
be installed on the fly, transitions between forms are also handled as part of this package.
See: Description

Interface

Description

Animation Allows any object to react to events and draw an animation at a fixed interval.

Class

Description

AnimationObject

An animation object is an element within the timeline that has a visibility state
for rendering at a given point in time.

CommonTransitions

Contains common transition animations including the following: Slide - the


exiting form slides out of the screen while the new form slides in.

ComponentAnimation

Parent class representing an animation object within the AnimationManager


queue.

FlipTransition

A Transitions that flips between 2 views

MorphTransition

A transition inspired by the Android L release morph activity effect allowing a


set of components in one form/container to morph into another in a different
container/form.

Motion

Abstracts the notion of physical motion over time from a numeric location to
another.

Timeline

A timeline represents the motions of animation objects

Transition

Represents a transition animation between two forms this class is used


internally by Display to play an animation when moving from one form to the
next.

Package com.codename1.ui.animations Description


All components are animatable by potential and additional animations (unrelated to a specific component) can
be installed on the fly, transitions between forms are also handled as part of this package. Animation thread
handling and painting is handled uniformly to avoid the complexity of threading and its potential performance
penalty on small devices.

Package com.codename1.ui.animations

50

Overview (Codename One API)

Package com.codename1.testing
This package contains everything necessary for unit tests, automation of tests and everything in between.
See: Description

Interface
UnitTest

Description
A Codename One unit test interface, you would normally like to derive from AbstractTest
which is less verbose and contains many helper methods.

Class

Description

AbstractTest

A unit test class that simplifies the process of writing test cases for Codename
One.

DeviceRunner

Runs the test cases from the test build of the app, notice that this class is
abstract since device/app specific code can exist in the implementation

Produces test reporting in the format of JUnit XML for compatibility with tools
JUnitXMLReporting that consume JUnit test case results see
http://code.google.com/p/codenameone/issues/detail?id=446 for more details.
TestReporting

Test reports can be overriden to provide custom test reporting options you can
replace the test reporter on the device by sending the build argument
build.testReporter='com.x.MyTestReporterClass'.

TestUtils

Various utility classes to automate UI testing

Package com.codename1.testing Description


This package contains everything necessary for unit tests, automation of tests and everything in between.

Package com.codename1.testing

51

Overview (Codename One API)

Package com.codename1.system
Low level calls into the Codename One system, including support for making platform native API calls.
See: Description

Interface

Description

CrashReport

Invoked to indicate that an exception occurred, it is up to the developer to decide


whether to send the device log to the server by invoking Log.sendLog().

NativeInterface

This is a marker interface that should be extended by a user interface in order to


indicate that said interface is implemented in native code.

URLCallback

In platforms that support opening an application via URL this interface can be
implemented by the main class to support such functionality.

Class

Description

DefaultCrashReporter

A default implementation of the crash reporter that instantly sends the crash
data to the server.

NativeLookup

Creates an instance of the native interface which will call the underlying
platform using the convention documented in the package docs.

Package com.codename1.system Description


Low level calls into the Codename One system, including support for making platform native API calls. Notice
that when we say "native" we do not mean C/C++ always but rather the platforms "native" environment. So in
the case of Android the Java code will be invoked with full access to the Android API's, in case of iOS an
Objective-C message would be sent and so forth.
Native interfaces are designed to only allow primitive types, Strings, arrays (single dimension only!) of
primitives and PeerComponent values. Any other type of parameter/return type is prohibited. However, once
in the native layer the native code can act freely and query the Java layer for additional information.
Furthermore, native methods should avoid features such as overloading, varargs (or any Java 5+ feature for
that matter) to allow portability for languages that do not support such features (e.g. C).
Important! Do not rely on pass by reference/value behavior since they vary between platforms.
Implementing a native layer effectively means:
1. Creating an interface that extends NativeInterface and only defines methods with the
arguments/return values declared in the previous paragraph.
2. Creating the proper native implementation hierarchy based on the call conventions for every platform
within the native directory
E.g. to create a simple hello world interface do something like:
package com.my.code;
public interface MyNative extends NativeInteface {
String helloWorld(String hi);
}

Then to use that interface use MyNative my = (MyNative)NativeLookup.create(MyNative.class);


Notice that for this to work you must implement the native code on all supported platforms!
To implement the native code use the following convention. For Java based platforms (Android, RIM, J2ME):
Just create a Java class that resides in the same package as the NativeInterface you created and bares the
same name with Impl appended e.g.: MyNativeImpl. So for these platforms the code would look something
like this:
package com.my.code;
public class MyNativeImpl implements MyNative {
public String helloWorld(String hi) {
// code that can invoke Android/RIM/J2ME respectively

Package com.codename1.system

52

Overview (Codename One API)


}
}

Notice that this code will only be compiled on the server build and is not compiled on the client. These sources
should be placed under the appropriate folder in the native directory and are sent to the server for compilation.
For Objective-C, one would need to define a class matching the name of the package and the class name
combined where the "." elements are replaced by underscores. One would need to provide both a header and
an "m" file following this convention e.g.:

Package com.codename1.system Description

53

Overview (Codename One API)

Package com.codename1.social
Connectors for native social network SDK's
See: Description

Class

Description

Invokes the native bundled facebook SDK to login/logout of facebook, notice that
in order for this to work server build arguments must indicate that you are using
FacebookConnect
the facebook sdk! To accomplish this just define: facebook.appId=YourAppId in
your build arguments.
GoogleConnect

The GoogleConnect Login class allows the sign in with google functionality.

Login

The Login abstract base class is used to simplify Oauth2 authentications


services.

LoginCallback

This class is used to indicate whether login was successful or not, it is an


abstract class rather than an interface in order to allow additional features in the
future.

Package com.codename1.social Description


Connectors for native social network SDK's

Package com.codename1.social

54

Overview (Codename One API)

Package com.codename1.share
Sharing services, that can be registered on the ShareButton
See: Description

Class
EmailShare

Description
Email sharing service.

FacebookShare Facebook sharing service


ShareService

This is an abstract sharing service.

SMSShare

SMS Sharing service

Package com.codename1.share Description


Sharing services, that can be registered on the ShareButton

Package com.codename1.share

55

Overview (Codename One API)

Package com.codename1.push
Push notification support using either device specific protocols when available
See: Description

Interface
PushCallback

Description
This callback interface is invoked when a push notification is received by the
application.

Class
Push

Description
Utility class for sending a push message to a different device through the Codename One
push servers.

Package com.codename1.push Description


Push notification support using either device specific protocols when available

Package com.codename1.push

56

Overview (Codename One API)

Package com.codename1.processing
IO Related tools and utilities, e.g.
See: Description

Class
Result

Description
An evaluator for a very small expression language to extract primitive types from structured
information.

Package com.codename1.processing Description


IO Related tools and utilities, e.g. expression language to assist in JSON parsing

Package com.codename1.processing

57

Overview (Codename One API)

Package com.codename1.payment
In-App Billing/Purchase API's are abstracted by this package.
See: Description

Interface

Description

PurchaseCallback

Callback interface that the main class must implement in order for
in-app-purchasing to work.

RestoreCallback

Callback interface that the main class must implement in order for the restore
option of in-app-purchasing to work.

Class

Description

Product

Represents a product within the system

Purchase

Represents the status of in-app-purchase goods, this class provides information about
products purchased by a user as well as the ability to purchase additional products.

Package com.codename1.payment Description


In-App Billing/Purchase API's are abstracted by this package. It encapsulates the different types of vendor
stores and payment API's available on the market.

Package com.codename1.payment

58

Overview (Codename One API)

Package com.codename1.notifications

Interface

Description

LocalNotificationCallback An interface that can be implemented by the application's main class (i.e.

Class

Description

LocalNotification Local notifications are user notifications that are scheduled by the app itself.

Package com.codename1.notifications

59

Overview (Codename One API)

Package com.codename1.messaging
This API allows to send e-mail messages through underlying platforms e-mail clients.
See: Description

Class

Description

Message Represents a message to be sent using underlying platform e-mail client.

Package com.codename1.messaging Description


This API allows to send e-mail messages through underlying platforms e-mail clients.

Package com.codename1.messaging

60

Overview (Codename One API)

Package com.codename1.media
Video and audio playback support are handled within this package using the Media/Media manager APIs.
See: Description

Interface
Media

Description
Media control interface allows for media playback, recording.

Class

Description

Allow us to create objects using String URI's or with a stream to the media data.
Notice that the underlying platforms contains the actual codecs, therefore you need
MediaManager
to play common media file types such as mp3, mp4 to successfully play them across
devices on all target platforms.

Package com.codename1.media Description


Video and audio playback support are handled within this package using the Media/Media manager APIs.
Said API's allow for video playback both within a native full screen player and embedded within an application
screen.

Package com.codename1.media

61

Overview (Codename One API)

Package com.codename1.maps.providers
These are the map providers, currently http://www.openstreetmap.org/ is supported.
See: Description

Class

Description

GoogleMapsProvider

This is a GoogleMaps Provider


https://developers.google.com/maps/documentation/staticmaps/

MapProvider

This is a generic map provider.

OpenStreetMapProvider This is an OpenStreetMap Provider http://www.openstreetmap.org/


TiledProvider

This is a tiled map provider

Package com.codename1.maps.providers Description


These are the map providers, currently http://www.openstreetmap.org/ is supported.

Package com.codename1.maps.providers

62

Overview (Codename One API)

Package com.codename1.maps
The mapping API allows developers to use maps in their applications, add layers on top of the map and to
enhance the API with additional Layers, Providers and functionality.
See: Description

Interface

Description

MapListener Invoked when the map is panned or zoomed

Class

Description

BoundingBox

This class declares a bounding box of coordinates on the map.

Coord

This class declares a coordinate point on a map.

MapComponent

All communication with the map and layers should be done in WGS84, it takes care
of coordinates transformation.

Mercator

Represents a Mercator projection http://en.wikipedia.org/wiki/Mercator_projection

Projection

This class represents a projection type.

ProxyHttpTile

This Tile brings the tile image from a given http url.

Tile

This class represents a single tile on a map.

Package com.codename1.maps Description


The mapping API allows developers to use maps in their applications, add layers on top of the map and to
enhance the API with additional Layers, Providers and functionality. The mapping was contributed by Roman
Kamyk

Package com.codename1.maps

63

Overview (Codename One API)

Package com.codename1.maps.layers
The Layers are elements that are displayed on the map.
See: Description

Interface
Layer

Description
a Layer interface.

Class

Description

AbstractLayer

This class represents an abstract layer on the map.

ArrowLinesLayer

This class is responsible for painting arrows that indicates direction of walk on
map.

LinesLayer

This is a Lines Layer

PointLayer

Do not use this layer directly, you need to add this layer into a PointsLayer class
instance in order for it to work as expected!

PointsLayer

This is a Points Layer

Package com.codename1.maps.layers Description


The Layers are elements that are displayed on the map.

Package com.codename1.maps.layers

64

Overview (Codename One API)

Package com.codename1.maker
This package is deprecated and will be removed in a coming revision
See: Description

Class
MakerPlugin

Description
Deprecated
this class is no longer supported and will be removed in an upcoming revision

Package com.codename1.maker Description


This package is deprecated and will be removed in a coming revision

Package com.codename1.maker

65

Overview (Codename One API)

Package com.codename1.location
Simple abstraction of location services (GPS/Triangulation) providing user global positioning and monitoring
over such changes.
See: Description

Interface

Description

GeofenceListener Listener interface for the Geofence background tracking functionality.


LocationListener

This is a Listener to the Locations events see


LocationManager.setLocationListener

Class

Description

Geofence

Metadata for geofencing support that allows tracking user location in the
background while the app is inactive.

Location

This class represents a Location Object

The LocationManager is the main entry to retrieveLocation or to bind a


LocationManager LocationListener, important: in order to use location on iOS you will need to define
the build argument ios.locationUsageDescription.
LocationRequest This class is used when requesting to listen to location update.

Package com.codename1.location Description


Simple abstraction of location services (GPS/Triangulation) providing user global positioning and monitoring
over such changes.

Package com.codename1.location

66

Overview (Codename One API)

Package com.codename1.l10n
The Localization API allows developers to adapt their applications to different geographic locales and
conventions.
See: Description

Class
DateFormat

Description
A class for parsing and formatting localisation sensitive dates, compatible with
Jave 6 SDK.

DateFormatPatterns Common patterns for dates, times, and timestamps.


DateFormatSymbols
Format

An abstract class for parsing and formatting localisation sensitive information,


compatible with JDK 6.

L10NManager

The localization manager allows adapting values for display in different locales

SimpleDateFormat

A class for parsing and formatting dates with a given pattern, compatible with
the Java 6 API.

Exception

Description

ParseException An error occurred during parsing.

Package com.codename1.l10n Description


The Localization API allows developers to adapt their applications to different geographic locales and
conventions.

Package com.codename1.l10n

67

Overview (Codename One API)

Package com.codename1.javascript
The Codename One JS Bridge package includes classes that facilitate the interaction between Java and
Javascript in a Codename One application.
See: Description

Interface
JSFunction

Description
The JSFunction interface allows you to implement functions in Java that can be called
from Javascript.

Class

Description

JavascriptContext Represents a Javascript context of a single BrowserComponent.


JSObject

A Java Wrapper around a Javascript object.

Package com.codename1.javascript Description


The Codename One JS Bridge package includes classes that facilitate the interaction between Java and
Javascript in a Codename One application. It allows both Java to Javascript communication and the reverse
via a mechanism similar to the one employed by Phone Gap/Apache Cordova.

Requirements
The bridge will only run on platforms that include a native browser component. This includes iOS, Android,
Windows, Desktop & JavaScript at this time.

Usage
The JavascriptContext class lays the foundation by enabling you to call Javascript code directly from Java. It
provides automatic type conversion between Java and Javascript types as follows:

Java to Javascript
Java Type

Javascript Type
String
String
Double/Integer/Float/Long Number
Boolean
Boolean
JSObject
Object
null
null
Other
Not Allowed

Javascript to Java
Javascript Type Java Type
Number
Double
String
String
Boolean
Boolean
Object
JSObject
Function
JSObject
Array
JSObject
null
null
undefined
null
Note that this conversion table is more verbose than necessary, since Javascript functions and arrays are, in
fact Objects themselves, so those rows are redundant. All Javascript objects are converted to JSObjects.

Package com.codename1.javascript

68

Overview (Codename One API)

Getting Started
In order to start interacting with a Javascript environment, you need to create a WebBrowser and load a page.
Then inside the WebBrowser's onLoad() handler, you can create a JavascriptContext on the internal
BrowserComponent object:

Getting Values
The JavascriptContext.get(String) method is used to get values from Javascript. It takes an arbitrary
Javascript expression, executes it, and returns the result, after converting it to the corresponding Java type.
E.g. if the result is a String, it will return a String and if it is a Number it will return a java Double object. If the
result is an Object, it will return a JSObject.
The following is a simple example that retrieves the document content, which is a string:
If you run this example in the simulator, you'll see something like the following:

Note: You don't see the WebBrowser in the background here due to a bug in the simulator. If you run this
example on a device, you will see the WebBrowser component in the background.
Returning Numeric Values
As mentioned in the conversion table above, numeric values are automatically converted to java.lang.Double
objects. The following example, returns the width and height properties of the window for use in Java.

Getting Started

69

Overview (Codename One API)


The result, when run in the simulator would be something like:

Returning Objects
The previous examples involved only primitive return values. The JavascriptContext abstraction, in these
cases, doesn't offer a whole lot of added-value over just using the
BrowserComponent.executeJavascriptAndReturnString() method. The real value is when we are dealing with
objects.
The following example obtains a reference to the window object and wraps it in a proxy JSObject class so that
we can work directly with the window object:
This code produces the exact same result as the previous example. The difference is the intermediary step of
wrapping the window object in a JSObject, and obtaining the outerHeight and outerWidth properties directly
via that proxy object.
You can obtain a JSObject proxy for any Javascript object, even ones that you create on the fly. The following
example creates an anonymous object with some keys and values and uses a JSObject proxy to interact with
this object from Java.
The result is as follows:

Getting Values

70

Overview (Codename One API)

See Working With Objects for more information about working with the JSObject class.
Returning Functions and Arrays
In Javascript, functions and arrays are just objects, so these are also encapsulated as JSObject proxies. See
Working with Arrays and Workin with Functions for more details on how to work with these values via the
JSObject interface.

Setting Values
Just as you can get values from Javascript using JavascriptContext's get() method, you can also set values
via JavascriptContext.set(String,Object).
The following is a simple example that sets the location, and causes it to redirect to a different page:
If you run this example, you should see your browser display the Codename One website after a redirect.

Getting Values

71

Overview (Codename One API)

Setting Object Values


The previous example showed us setting a primitive String value. You can do the same with other primitives
like numbers and booleans, but you can also set Object values using the set() method.
The following example creates an anonymous Javascript object, wraps it in a JSObject proxy, sets some
values on it, then sets the object as a property of the top-level window object.
As a result, you should see the following content set as the body of the HTML page in the WebBrowser. Note
that we can refer to the "steve" object that we just set directly/globally because the "window" object's
properties are always available directly through the global namespace in Javascript.

Setting Values

72

Overview (Codename One API)

Working with Objects


Previously examples showed how to obtain a JSObject proxy to a Javascript object. There are 4 ways to get a
JSObject:
1. Create an anonymous object:
JSObject obj = (JSObject)ctx.get("{}");

2. Reference an existing object directly:


JSObject obj = (JSObject)ctx.get("window.location");

3. As the result of a Javascript expression or function call:


JSObject obj = (JSObject)ctx.get("document.getElementById('mydiv')")

4. Retrieve an Object member variable from another JSObject:


JSObject obj = (JSObject)otherObj.get("aPropertyThatIsAnObject")
JSObjects are essentially just proxies around a
JSObject are just sent directly to the Javascript

Javascript object. Any calls to retrieve properties from a


context, and the result returned. The JSObject object doesn't
store copies the javascript object's properties. It just retrieves them as they are required via the
JSObject.get(String) method.

Getting Simple Values


You can always retrieve the properties of an object using the JSObject.get(String) method. It takes the
name of the property as a parameter, and returns its value, converted to the appropriate Java type. (e.g. if it is
a String, it returns a String, if it is a number it returns a Double, and if it is an Object, it returns an object.
E.g.
String name = (String)obj.get("name");
Double age = (Double)obj.get("age");

Is equivalent to the following javascript:


var name = obj.name; var age = obj.age;

Assuming that the obj variable in Java is a proxy for the same obj variable in the javascript example.

Getting Nested Object Values


Often, in Javascript, an object contains a heirarchy of nested child objects. E.g.
var obj = {
name : 'Steve',
position : {
x : 100,
y : 105,
z : -25
}
}

In this case you may want to obtain the x coordinate of the nested position object. JSObject allows you to use
the dot '.' notation for referencing sub-properties like this. E.g.
Double x = (Double)obj.get("position.x")

This feature raises the issue of how, then, to access properties that contain a '.' in its name. E.g.
var obj = {
name : 'Steve',
position : {
x : 100,
y : 105,
z : -25
},
'position.x' : 200
}

In this example there is a top-level property named 'position.x' as well as a property at the component address
position.x. This is a contrived example that is meant to be somewhat confusing in order to demonstrate how to

Working with Objects

73

Overview (Codename One API)


differentiate between requests for properties in the child object heirarchy and top-level properties that happen
to include a '.' in the property name.
We can force the retrieval of a top-level property by wrapping the key in single quotes:
Double x1 = (Double)obj.get("'position.x'")

This would return 200 for the above example, whereas:


Double x2 = (Double)obj.get("position.x")

Would return 100


.

Setting Object Values


The JSObject.set(String,Object) method works the same as the JavascriptContext.set(String,Object)
method except that it treats the local object as the root node. It allows you to easily set properties on the
object. Values set here should be provided using Java values as they will automatically be converted to the
appropriate associated Javascript type. If you are setting an Object as a value, then you'll need to set it as a
JSObject and not a string representation of the object. This is because Strings will just be converted to
Javascript strings.
Properties set via the JSObject.set(String,Object) method modify the underlying Javascript object directly
so that the change is immediately effective inside the javascript environment.
Just as with the JSObject.get(String) method, you can set the values of direct properties or nested
properties using the dot '.' notation. And just like JSObject.get(String), you can force setting a direct
property in cases where the property name includes a '.', by wrapping the key inside single quotes.
E.g.:
// Create a team object , and leave city null for now.
JSObject blueJays = (JSObject)ctx.get("{name : 'Blue Jays', city : null}");
// Create a city object and leave country null for now.
JSObject toronto = (JSObject)ctx.get("{name : 'Toronto', country : null}");
// Create a country object
JSObject canada = (JSObject)ctx.get("{name : 'Canada'}");
// Set the team's city to toronto
blueJays.set("city", toronto);
// Set toronto's country to canada
toronto.set("country", canada);
// Retrieve the name of the country where the blue jays play
String countryName = (String)blueJays.get("city.country.name");
// Should contain "Canada"
// Change the name of Canada to "Canuck land" using nested
// dot notation on the blueJays object.
blueJays.set("city.country.name", "Canuck land");
String blueJaysCountry = (String)blueJays.get("city.country.name");
String torontoCountry = (String)tornoto.get("country.name");
String canadaName = (String)canada.get("name");
//Note that all of these should be equal and contain "Canuck land"

Calling Object Methods


The com.codename1.javascript.JSObject#call(String,Object) method allows you to call javascript methods
that are members of the underlying object. It arguments are passed as an Object[] array. These will be
automatically converted from the Java type to the corresponding Javascript type. Java type conversion are the
same as using the JavascriptContext.set(String,Object) method.

Getting Nested Object Values

74

Overview (Codename One API)


The following example shows an object with a simple add() method that just adds two numbers together:
JSObject obj = (JSObject)ctx.get("{ add : function(a,b){ return a+b;}}");
Double result = (Double)obj.call("add",
new Object[]{new Integer(1), new Integer(3)}
);
// Result should be 4.0

Working with Arrays


In javascript, arrays are just objects that include a special ability to be iterated. You can use the alternate
version of JSObject.get(int) which takes an int as a parameter to retrieve the elements of an array.
For example, consider the following javascript object:
var obj = {
name : 'Blue
players : [
{ name :
{ name :
{ name :
]
}

Jays',
'George Bell', age : 31},
'Tony Fernandez', age : 34},
'Lloyd Moseby', age : 29}

Then assuming we have a JSObject proxy for this object, we could loop through the players array and output
the name and age of each player as follows:
JObject players = (JObject)obj.get("players");
int len = ((Double)players.get("length")).intValue();
for ( int i=0; i<len; i++){
JSObject player = (JSObject)players.get(i);
Log.p("Name : "+player.get("name")+" age : "+player.get("age"));
}

Calling Java Methods from Javascript


So far, our examples have been limited to Java calling into Javascript. However, it may be useful to be able to
also go the other way: call java methods from Javascript. Some applications of this might include:
Capturing video, or using the camera on the phone
Getting the phone location
Accessing the file system or storage API
The Codename One JS bridge supports javascript to java method calling by way of the JSFunction interface
and the JSObject.set(String,Object) methods on the JSObject class. You can implement a JSFunction
object and register it as a callback with a JSObject, then you will be able to execute this object's apply method
via a Javascript proxy.
As an example, let's implement a simple logging function:
JSObject logger = (JSObject)ctx.get("{}");
logger.set("log", new JSFunction(){
public void apply(JSObject self, Object[] args) {
String msg = (String)args[0];
Log.p("[Javascript Logger] "+msg);
}
});
ctx.set("window.logger", logger);

c.executeAndReturnString("logger.log('This is a test message');");

If you execute this code in the simulator, you'll see the following output in the console:

Calling Object Methods

75

Overview (Codename One API)


[EDT] 0:0:0,0 - [Javascript Logger] This is a test message

Running it on a device will yield similar output in the device log file.
Let's step through this code to see what is happening. First we create a new, empty javascript object and
wrap it in a JSObject proxy. Then we use the JSObject's JSObject.set(String,Object) method to add an
anonymous JSFunction object to it with the propery of "log". This step registers a method proxy on the
Javascript side that acts just like a normal javascript method, but which actually triggers the JSFunction's
JSFunction.apply(JSObject,Object[]) method.
We then set this logger object to the global javascript scope by making it a direct child of the window object.
Finally we issue a Javascript method call to logger.log(). This is what effectively calls the apply() method on
our JSFunction object.

Caveats
JSFunction callbacks are executed asynchronously so as to prevent deadlocks. This means that you
cannot return a value from this method using a return statement (hence the reason why the interface definition
for JSFunction.apply(JSObject,Object[]) is void.
If you want to return a value back to Javascript, then you'll need to do it by providing a callback
function as one of the parameters, and call this callback method from inside the
JSFunction.apply(JSObject,Object[]) method upon completion.

Example: Passing a Javascript Callback to Your Callback


Since JSFunction callbacks are executed asynchronously, if you want to be able to return a result back to
Javascript, you will need to do this via a Javascript callback. This is quite a common pattern in Javascript
since it is single threaded and relies upon non-blocking patterns.
As an example, let's create a JSFunction callback that adds two numbers together and returns the result to
Javascript via a callback:
First we will create the JSFunction object to perform the addition, as follows:
WebBrowser b = new WebBrowser(){
protected void onLoad(String url){
JSObject window = (JSObject)ctx.get("window");
window.set("addAsync", new JSFunction(){
public void apply(JSObject self, final Object[] args) {
Double a = (Double)args[0];
Double b = (Double)args[1];
JSObject callback = (JSObject)args[2];
double result = a.doubleValue() + b.doubleValue();
callback.call(new Object[]{new Double(result)});
}
});
}
};
b.setURL("jar:///ca/weblite/codename1/tests/AddAsync.html");

In this snippet, we start by obtaining a reference to the "window" object. We then add a method to this object
named "addAsync". This method is a JSFunction object that we implement inline. The apply() method of the
JSFunction object is the Java method that will be executed when the addAsync method is called from
Javascript. In this case the addAsync method expects three parameters:
1. The two numbers that are being added together.
2. A Javascript callback method that will be executed when completed and passed the result of the
addition as a parameter.
Notice that all numerical arguments are converted to Java Double objects, and the callback function is
converted to a JSObject object. Also notice the use of callback.call(), which just calls the callback as a
function itself. With this variant of the call() method, the window object is used as this. Notice also that we

Calling Java Methods from Javascript

76

Overview (Codename One API)


pass the result inside an Object[] array. This array will be expanded to the direct javascript function
parameters. (i.e. it will not pass an array as the parameter to the javascript method, the array elements are
extracted and passed individually.
Now, let's look at the HTML page contents for our example:
<!DOCTYPE html>
<html>
<head>
<title>Addition Example</title>
</head>
<body>
<div>Addition Example</div>
<p><input type="text" size="4" id="input1"/> +
<input type="text" size="4" id="input2"/> =
<span id="result"></span>
</p>
<p><button id="calculate">Calculate</button></p>
<script src="AddAsync.js"></script>
</body>
</html>

Our HTML simply includes two text fields (to input the values to be added together), a button to initiate the
calculation, and a <span> tag where the result will be placed when the calculation is complete.
Finally it includes the AddAsync.js Javascript file (which is placed in the same directory as the AddAsync.html
file. Its contents are as follows:
document
.getElementById('calculate')
.addEventListener('click', function(){
var aField = document.getElementById('input1');
var bField = document.getElementById('input2');
var a = parseFloat(aField.value);
var b = parseFloat(bField.value);
window.addAsync(a, b, function(result){
document.getElementById('result').innerHTML = result;
});
}, true);

This script attaches an event handler to the calculate button that gets the values from the two input fields and
passes it to the window.addAsync() method for calculation. The addAsync() method is actually our java
JSFunction that we implemented earlier.
One small word about the placement of these files: This example is taken from a class
ca.weblite.codename1.tests.CodenameOneTests. The AddAsync.html and AddAsync.js files are included in
the same directory as the CodenameOneTests.java file ( i.e. /ca/weblite/codename1/tests). We used the
WebBrowser's setURL() method to load the AddAsync.html file from an absolute path using jar: protocol.
Currently this is the best way of loading local HTML files into a WebBrowser object (i.e. use the jar: protocol
and provide an absolute path).
The result of running this app is as follows:

Example: Passing a Javascript Callback to Your Callback

77

Overview (Codename One API)

Example: Exposing the Camera to Javascript


The following creates a Javascript function for taking photos on a mobile device. It involves a simple webpage
with a "Capture" button. When the user clicks this button, it will dispatch a function call to CodenameOne to
access the device's camera. After the user takes a picture, CodenameOne will execute a Javascript callback
to add the picture to the webpage.
The HTML page source is as follows:
This loads the CameraExample.js script:
document.getElementById('capture')
.addEventListener('click', function(){
camera.capture(function(url){
if ( url == null ){
// No image was provided
return;
}
var results = document.getElementById('results');
results.appendChild(document.createTextNode("testing"));
var img = document.createElement('img');
img.setAttribute('src',url);
img.setAttribute('width', '100');
img.setAttribute('height', '100');
results.appendChild(img);
})
}, true);

Example: Exposing the Camera to Javascript

78

Overview (Codename One API)


The CameraExample.js script attaches a listener to the 'click' event of the "Capture" button which simply calls
the camera.capture() method, which is actually a JSFunction that has been registered with the Javascript
runtime. This actually calls into Java.
We pass a callback function into camera.capture() which will be executed upon successfully completion of
the camera. This is a common programming pattern in Javascript. If a non-null URL is passed to this callback
function, it is expected to be the URL of the image (it will be a local file URL.
The Java code that powers this example is as follows:
This example puts together most of the features of the CodenameOne-JS library.
1. It creates a new JSObject from within Java code to serve as the camera object.
2. It registers a JSFunction callback as a Javascript function which is added as a method to the camera
object.
3. It shows the use of the call() method of JSObject to call the callback function that was provided by
Javascript from inside the JSFunction's apply() method.

Example: Exposing the Camera to Javascript

79

Overview (Codename One API)

Package com.codename1.io.tar
Tar support allowing us to package multiple separate files into a single package which is useful in supporting
hierarchies in a portable way.
See: Description

Class

Description

Octal
TarConstants
TarEntry
TarHeader

Header

TarInputStream
TarOutputStream
TarUtils

Package com.codename1.io.tar Description


Tar support allowing us to package multiple separate files into a single package which is useful in supporting
hierarchies in a portable way. This is based on the work contributed in Issue 754.

Package com.codename1.io.tar

80

Overview (Codename One API)

Package com.codename1.io.services
Default WebService implementations
See: Description

Class

Description

CachedData

Cached data class for use with the cached data service

CachedDataService

Simple service that allows downloading and caching data locally.

Deprecated
this class uses an unconventional storage mechanism and has many
ImageDownloadService
issues, we recommend replacing it with the simpler and more powerful
URLImage or Util.dowloadFileTo* calls.
RSSService

Simple RSS read and parse request, to handle errors just subclass this and
override parsingError.

TwitterRESTService

Calls to the Twitter REST API can be performed via this class although
currently support for authentication isn't implemented due to the transition
to oAuth instead of basic authentication.

Package com.codename1.io.services Description


Default WebService implementations

Package com.codename1.io.services

81

Overview (Codename One API)

Package com.codename1.io
Codename One IO is intended as a componentized solution for IO operations that allows us to centralize IO
logic while maintaining a more portable approach for threads.
See: Description

Interface

Description

Externalizable

Similar to the Java SE externalizable interface this interface allows an object


to declare itself as externalizable for serialization.

IOProgressListener

Callback for IO updates from a buffered input/output stream

JSONParseCallback

The event based parser allows parsing without creating an object tree by
receiving callbacks to this class.

Socket.StopListening This interface can be invoked to stop listening on a server socket

Class

Description

AccessToken

This class represent an access token.

BufferedInputStream

Based on the buffered input stream from the JDK with some
minor tweaks to allow external classes to monitor stream status
and progress.

BufferedOutputStream

Based on the buffered output stream from the JDK with some
minor tweaks to allow external classes to monitor stream status
and progress.

CacheMap

A cache map is essentially a hashtable that indexes entries


based on age and is limited to a fixed size.

CharArrayReader

A specialized Reader for reading the contents of a char array.

ConnectionRequest

This class represents a connection object in the form of a


request response typically common for HTTP/HTTPS
connections.

Cookie

A cookie for an HTTP request

CSVParser

Simple CSV parser very useful for importing data into


applications quickly from a CSV source

FileSystemStorage

Unlike networking, the file system storage mostly tries to


emulate java.io.File with some simplifications for mobile
devices.
A lot of API's rely on FileSystemStorage as its the API native
code usually uses consistently.

JSONParser

Fast and dirty parser for JSON content on the web, it essentially
returns a Map object containing the object fields mapped to their
values.

Log

Pluggable logging framework that allows a developer to log into


storage using the file connector API.

MultipartRequest

A multipart post request allows a developer to submit large


binary data files to the server in a multipart mime post request.

NetworkEvent

Event containing more meta data for network events which may
be error events or an update for progress indication code.

NetworkManager

Main entry point for managing the connection requests, this is


essentially a threaded queue that makes sure to route all
connections via the network thread while sending the callbacks
through the Codename One EDT.

Oauth2

This is a utility class that allows Oauth2 authentication This


utility uses the Codename One XHTML Component to display
the authentication pages.

Preferences

Simple map like class to store application and Codename One


preference settings.

Package com.codename1.io

82

Overview (Codename One API)


Properties

A Properties object is a Hashtable where the keys and values


must be Strings.

Socket

Class implementing the socket API

SocketConnection

Callback for establishment of a socket connection.

Storage

Abstracts the underlying application specific storage system


such as RMS

Util

Various utility methods used for HTTP/IO operations

WebServiceProxyCall

Utility class used by the webservice proxy code to invoke server


code

WebServiceProxyCall.WSDefinition

Webservice definition type, allows defining the argument values


for a specific WS call

Package com.codename1.io Description


Codename One IO is intended as a componentized solution for IO operations that allows us to centralize IO
logic while maintaining a more portable approach for threads. It also exposes several device specific
behaviors such as APN selection, network type selection in a more seamless way.
Codename One's standard UI is used mostly for the EDT and event convention although the package
displays error messages using Codename One dialogs and provides several IO related widgets to ease
working with the platform.

Package com.codename1.io Description

83

Overview (Codename One API)

Package com.codename1.io.gzip
gzip support based on https://github.com/ymnk/jzlib
See: Description

Class

Description

Adler32
CRC32
Deflate
Deflater
DeflaterOutputStream
FilterInputStream

Simple version of filter input stream

FilterOutputStream

Dummy implementation of filter output stream

GZConnectionRequest A connection request that can detect a GZipped response and parse it
GZIPHeader
GZIPInputStream
GZIPOutputStream
Inflater
InflaterInputStream
JZlib
ZStream

Deprecated
Not for public use in the future.

Exception

Description

GZIPException

Package com.codename1.io.gzip Description


gzip support based on https://github.com/ymnk/jzlib

Package com.codename1.io.gzip

84

Overview (Codename One API)

Package com.codename1.facebook.ui
User interface for integrating with basic Facebook features currently mostly the Like button
See: Description

Class

Description

Generic "Like" button that enables us to submit a like to facebook, to get the post id
required for the like functionality you will need to use a tool such as:
LikeButton
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fposts You
can ask it to list your posts and then seek the correct id within the returned JSON

Package com.codename1.facebook.ui Description


User interface for integrating with basic Facebook features currently mostly the Like button

Package com.codename1.facebook.ui

85

Overview (Codename One API)

Package com.codename1.facebook
Legacy generic implementation of the Facebook API with simplified OAuth integration to allow social sharing.
See: Description

Class
Album

Description
This class represents a Facebook Photo Object
http://developers.facebook.com/docs/reference/api/album

This is the main access API to the facebook graph API


FaceBookAccess http://developers.facebook.com/docs/reference/api/ This class encapsulates the
Network access and provide simple methods to acess the Facebook servers.
FBObject

This is a base class for all FaceBook Objects

Page

This class represents a Facebook Page object


https://developers.facebook.com/docs/reference/api/page/

Photo

This class represents a Facebook Photo Object


http://developers.facebook.com/docs/reference/api/photo/

Post

This class represents a Facebook Post Object


http://developers.facebook.com/docs/reference/api/post/

User

This class represents a Facebook User objject


http://developers.facebook.com/docs/reference/api/user/

Package com.codename1.facebook Description


Legacy generic implementation of the Facebook API with simplified OAuth integration to allow social sharing.
It is recommended to migrate to the new social package services

Package com.codename1.facebook

86

Overview (Codename One API)

Package com.codename1.db
SQLite support.
See: Description

Interface

Description

Cursor

The Cursor Object is used to iterate over the results

Row

This Class represents a database row.

Class
Database

Description
This is a Database SQLite class, this class allows developers to connect to a database
and preform sql queries on the data.

Package com.codename1.db Description


SQLite support.

Package com.codename1.db

87

Overview (Codename One API)

Package com.codename1.contacts
Provides access to the contacts list from the device
See: Description

Class

Description

Address

This class represents a Contact Address

Contact

This class represents a Contact information from the device Address Book

ContactsManager

This class uses as the Contacts manager of the device, it enables the possibility
To get the Contacts that are available on the device.

ContactsModel

This Contacts model is responsible for querying Contacts from the device and to
cache the data for faster usage

Package com.codename1.contacts Description


Provides access to the contacts list from the device

Package com.codename1.contacts

88

Overview (Codename One API)

Package com.codename1.components
Generic elaborate components that make use of both UI elements and storage.
See: Description

Class

Description

Ads

This is an Ads Component, this Component can displays banner/text ads


on a Form.

FileEncodedImage

An encoded image that stores the actual data of the encoded image in a
disk file or resource and loads it only when necessary.

This class is identical to FileEncodedImage with the difference of using


FileEncodedImageAsync asynchronous loading for files (and the animation framework) which will
not work for all cases (e.g.
FileTree

Simple class showing off the filesystem as a tree component

FileTreeModel

A tree model representing the file system as a whole, notice that this class
returns absolute file names which would result in an unreadable tree.

FloatingHint

A floating hint is similar to a text field with a hint.

ImageViewer

ImageViewer allows zooming/panning an image and potentially flicking


between multiple images within a list of images.

InfiniteProgress

Shows a "Washing Machine" infinite progress indication animation, to


customize the image you can either use the infiniteImage theme constant
or the setAnimation method.

InfiniteScrollAdapter

Allows adapting a scroll container to scroll indefinitely (or at least until


running out of data), this effectively works by showing an infinite progress
indicator when reaching scroll end then allowing code to fetch additional
components.

InteractionDialog

Unlike a regular dialog the interaction dialog only looks like a dialog, it
resides in the layered pane and can be used to implement features where
interaction with the background form is still required.
Since this code is designed for interaction all "dialogs" created thru here
are modless and never block.

MasterDetail

Master-detail utility class simplifying the process of defining a


master/detail

MediaPlayer

Video playback component with control buttons for back, play/pause and
forward buttons.

MultiButton

A powerful button like component that allows multiple rows/and an icon to


be added every row/icon can have its own UIID.

OnOffSwitch

The on/off switch is a checkbox of sort (although it derives container) that


represents its state as a switch each of which has a short label associated
with it.

Progress

Displays a progress dialog with the ability to cancel an ongoing operation

ReplaceableImage

Allows the image data to be replaced at runtime when a different image is


available.

RSSReader

A List implementing an RSS reader that automatically populates itself with


content from the RSS chanel.

ScaleImageButton

Button that simplifies the usage of scale to fill/fit.

ScaleImageLabel

Label that simplifies the usage of scale to fill/fit.

ShareButton

The share button allows sharing a String or an image either thru the
defined sharing services or thru the native OS sharing support.

SliderBridge

Binds a slider to network progress events so it shows the pro

SpanButton

A complex button similar to MultiButton that breaks lines automatically and


looks like a regular button (more or less).

SpanLabel

Package com.codename1.components

89

Overview (Codename One API)


A multi line label component that can be easily localized, this is simply
based on a text area combined with a label.
StorageImage

An encoded image that stores the actual data of the encoded image in
storage.

StorageImageAsync

Asynchronous storage image that loads in the background and not during
the paint cycle effectively not blocking the EDT drawing speed.

ToastBar

An API to present status messages to the user in an unobtrusive manner.

WebBrowser

A simple browser view that encapsulates a usable version of


HTMLComponent or BrowserComponent and automatically picks the right
component for the platform preferring BrowserComponent whenever it is
supported.

Package com.codename1.components Description


Generic elaborate components that make use of both UI elements and storage. These are relatively high level
components such as RSS reader, IO progress indication etc.

Package com.codename1.components Description

90

Overview (Codename One API)

Package com.codename1.codescan
Deprecated!!: Please use the cn1-codescan library instead.
See: Description

Interface

Description

ScanResult

Deprecated
Use the cn1-codescanner cn1lib.

Class

Description

CodeScanner

Deprecated
Use the cn1-codescanner cn1lib.

Package com.codename1.codescan Description


Deprecated!!: Please use the cn1-codescan library instead.
Bar/QR code scanning API, currently based on the zxing implementation

Package com.codename1.codescan

91

Overview (Codename One API)

Package com.codename1.cloud
Provides cloud related services such as storage, binding widgets to the cloud seamlessly so they can be
persisted easily.
See: Description

Interface
BindTarget

Description
Allows binding arbitrary components to data storage

Deprecated
CloudResponse<T> the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1
CustomProperty

Deprecated
the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1

Class

Description

Deprecated
CloudImageProperty the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1
CloudListModel

Deprecated
the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1

CloudObject

Deprecated
the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1

CloudPersona

Deprecated
the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1

CloudStorage

Deprecated
this API is targeted for removal due to changes in Google App Engine API
support

Exception

Description

Deprecated
CloudException the cloud storage API is no longer supported, we recommend switching to a
solution such as parse4cn1

Package com.codename1.cloud Description


Provides cloud related services such as storage, binding widgets to the cloud seamlessly so they can be
persisted easily. This package makes use of features available for pro accounts.

Package com.codename1.cloud

92

Overview (Codename One API)

Package com.codename1.charts.views
Provides the classes that handle the actual rendering / drawing of the charts, based on the provided model
and renderer.
See: Description

Class

Description

AbstractChart

An abstract class to be implemented by the chart


rendering classes.

BarChart

The bar chart rendering class.

BubbleChart

The bubble chart rendering class.

ClickableArea
CombinedXYChart

The combined XY chart rendering class.

CombinedXYChart.XYCombinedChartDef Definition of a chart inside a combined XY chart.


CubicLineChart

The interpolated (cubic) line chart rendering class.

DialChart

The dial chart rendering class.

DoughnutChart

The doughnut chart rendering class.

LineChart

The line chart rendering class.

PieChart

The pie chart rendering class.

PieMapper

PieChart Segment Selection Management.

PieSegment

Holds An PieChart Segment

RangeBarChart

The range bar chart rendering class.

RangeStackedBarChart
RoundChart

An abstract class to be extended by round like chart


rendering classes.

ScatterChart

The scatter chart rendering class.

TimeChart

The time chart rendering class.

XYChart

The XY chart rendering class.

Enum

Description

BarChart.Type The bar chart type enum.


PointStyle

The chart point style enumerator.

Package com.codename1.charts.views Description


Provides the classes that handle the actual rendering / drawing of the charts, based on the provided model
and renderer.

Package com.codename1.charts.views

93

Overview (Codename One API)

Package com.codename1.charts.util
Utility classes that provide helper methods used by most of the other packages.
See: Description

Class

Description

ColorUtil
MathHelper

Utility class for math operations.

NumberFormat

Package com.codename1.charts.util Description


Utility classes that provide helper methods used by most of the other packages.

Package com.codename1.charts.util

94

Overview (Codename One API)

Package com.codename1.charts.transitions

Class

Description

SeriesTransition

A base class for series transitions of ChartComponent.

XYMultiSeriesTransition

A transition to animate the values of a MultipleSeriesDataset (used by


BarChart).

XYSeriesTransition

A transition for enabling animations between different values in an


XYSeries.

XYValueSeriesTransition

A transition for enabling animations between different values in an


XYSeries.

Package com.codename1.charts.transitions

95

Overview (Codename One API)

Package com.codename1.charts.renderers
Provides renderer classes that keep the chart rendering / drawing styles.
See: Description

Class

Description

BasicStroke

A descriptor for the stroke style.

DefaultRenderer

An abstract renderer to be extended by the multiple series


classes.

DialRenderer

Dial chart renderer.

SimpleSeriesRenderer

A simple series renderer.

XYMultipleSeriesRenderer

Multiple XY series renderer.

XYSeriesRenderer

A renderer for the XY type series.

XYSeriesRenderer.FillOutsideLine A descriptor for the line fill behavior.

Enum

Description

DialRenderer.Type
XYMultipleSeriesRenderer.Orientation

An enum for the XY chart orientation of the X axis.

XYSeriesRenderer.FillOutsideLine.Type

Package com.codename1.charts.renderers Description


Provides renderer classes that keep the chart rendering / drawing styles.

Package com.codename1.charts.renderers

96

Overview (Codename One API)

Package com.codename1.charts
The main ChartComponent Package
See: Description

Class

Description

ChartComponent The top level component for displaying charts


ChartUtil

A utility class for painting a chart onto a Graphics context.

Package com.codename1.charts Description

The main ChartComponent Package


The charts package enables Codename One developers to add charts and visualizations to their apps
without having to include external libraries or embedding web views. We also wanted to harness the new
features in the graphics pipeline to maximize performance.
Device Support
Since the charts package makes use of 2D transformations and shapes, it requires some of the graphics
features that are not yet available on all platforms. Currently the following platforms are supported:
1. Simulator
2. Android
3. iOS
Features
1. Built-in support for many common types of charts including bar charts, line charts, stacked
charts, scatter charts, pie charts and more.
2. Pinch Zoom - The com.codename1.charts,ChartComponent class includes optional pinch zoom
support.
3. Panning Support - The com.codename1.charts,ChartComponent class includes optional support for
panning.
Chart Types
The com.codename1.charts package includes models and renderers for many different types of charts. It is
also extensible so that you can add your own chart types if required. The following screen shots demonstrate
a small sampling of the types of charts that can be created.

The main ChartComponent Package

97

Overview (Codename One API)

The above screenshots were taken from the ChartsDemo app. Y ou can start playing with this app by
checking it out from our git repository.
How to Create A Chart
Adding a chart to your app involves four steps:
1. Build the model. You can construct a model (aka data set) for the chart using one of the existing
model classes in the com.codename1.charts.models package. Essentially, this is just where you add
the data that you want to display.
2. Set up a renderer. You can create a renderer for your chart using one of the existing renderer
classes in the com.codename1.charts.renderers package. The renderer allows you to specify how the
chart should look. E.g. the colors, fonts, styles, to use.
3. Create the Chart View. Use one of the existing view classes in the com.codename1.charts.views
package.
4. Create a com.codename1.charts,ChartComponent . In order to add your chart to the UI, you need to
wrap it in a com.codename1.charts,ChartComponent object.
You can check out the ChartsDemo app for specific examples, but here is a high level view of some code that
creates a Pie Chart.
The charts package is derived work from the excellent open source aChartEngine API.

The main ChartComponent Package

98

Overview (Codename One API)

Package com.codename1.charts.models
Provides the classes that handle the data values (data model) to be used by displaying the charts.
See: Description

Class

Description

CategorySeries

A series for the category charts like the pie ones.

MultipleCategorySeries

A series for the multiple category charts like the doughnut.

Point

A class to encapsulate the definition of a point.

RangeCategorySeries

A series for the range category charts like the range bar.

SeriesSelection
TimeSeries

A series for the date / time charts.

XYMultipleSeriesDataset A series that includes 0 to many XYSeries.


XYSeries

An XY series encapsulates values for XY charts like line, time, area,


scatter...

XYValueSeries

An extension of the XY series which adds a third dimension.

Package com.codename1.charts.models Description


Provides the classes that handle the data values (data model) to be used by displaying the charts.

Package com.codename1.charts.models

99

Overview (Codename One API)

Package com.codename1.charts.compat

Class
Canvas

Description
Deprecated

GradientDrawable
Paint

Deprecated

Paint.Align
Paint.Cap
Paint.Join
PathMeasure

Deprecated

Enum

Description

GradientDrawable.Orientation
Paint.Style

Package com.codename1.charts.compat

100

Overview (Codename One API)

Package com.codename1.capture
Package for capturing photos, audio or video from the camera/microphone.
See: Description

Class

Description

Capture This is the main class for capturing media files from the device.

Package com.codename1.capture Description


Package for capturing photos, audio or video from the camera/microphone.

Package com.codename1.capture

101

Overview (Codename One API)

Package com.codename1.analytics
The analytics API allows tracking your mobile application usage in the field to give you real-time data on how
your application is used.
See: Description

Class

Description

The analytics service allows an application to report its usage, it is seamlessly


AnalyticsService invoked by GUI builder applications if analytics is enabled for your application! To
enable analytics just use the init() method of the analytics service.

Package com.codename1.analytics Description


The analytics API allows tracking your mobile application usage in the field to give you real-time data on how
your application is used. This API currently delegates to the Google analytics service through the Codename
One cloud.
Notice that analytics is automatically added GUI applications created by the GUI builder, you only need to
enable Analytics specifically by invoking the init method and the pages will be logged automatically.

Package com.codename1.analytics

102

Overview (Codename One API)

Package com.codename1.ads
A legacy banner Ads API.
See: Description

Class

Description

AdsService This is an abstract Ads Service.


InnerActive

This is an Ad service implementation by InnerActive see:


http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne

Package com.codename1.ads Description


A legacy banner Ads API. This has been replaced by more modern approaches mainly thru cn1libs.
Currently inner-active ads Network is supported please refer to inner-active for more information

Package com.codename1.ads

103

Overview (Codename One API)


Codename One - Write Once Run Anywhere Native Mobile Apps Using Java
See: Description

Package

Description

com.codename1.ads

A legacy banner Ads API.

com.codename1.analytics

The analytics API allows tracking your mobile application usage in the
field to give you real-time data on how your application is used.

com.codename1.capture

Package for capturing photos, audio or video from the


camera/microphone.

com.codename1.charts

The main ChartComponent Package

com.codename1.charts.models

Provides the classes that handle the data values (data model) to be used
by displaying the charts.

com.codename1.charts.renderers Provides renderer classes that keep the chart rendering / drawing styles.
com.codename1.charts.transitions
com.codename1.charts.util

Utility classes that provide helper methods used by most of the other
packages.

com.codename1.charts.views

Provides the classes that handle the actual rendering / drawing of the
charts, based on the provided model and renderer.

com.codename1.cloud

Provides cloud related services such as storage, binding widgets to the


cloud seamlessly so they can be persisted easily.

com.codename1.codescan

Deprecated!!: Please use the cn1-codescan library instead.

com.codename1.components

Generic elaborate components that make use of both UI elements and


storage.

com.codename1.contacts

Provides access to the contacts list from the device

com.codename1.db

SQLite support.

com.codename1.facebook

Legacy generic implementation of the Facebook API with simplified


OAuth integration to allow social sharing.

com.codename1.facebook.ui

User interface for integrating with basic Facebook features currently


mostly the Like button

com.codename1.io

Codename One IO is intended as a componentized solution for IO


operations that allows us to centralize IO logic while maintaining a more
portable approach for threads.

com.codename1.io.gzip

gzip support based on https://github.com/ymnk/jzlib

com.codename1.io.services

Default WebService implementations

com.codename1.io.tar

Tar support allowing us to package multiple separate files into a single


package which is useful in supporting hierarchies in a portable way.

com.codename1.javascript

The Codename One JS Bridge package includes classes that facilitate


the interaction between Java and Javascript in a Codename One
application.

com.codename1.l10n

The Localization API allows developers to adapt their applications to


different geographic locales and conventions.

com.codename1.location

Simple abstraction of location services (GPS/Triangulation) providing


user global positioning and monitoring over such changes.

com.codename1.maps

The mapping API allows developers to use maps in their applications,


add layers on top of the map and to enhance the API with additional
Layers, Providers and functionality.

com.codename1.maps.layers

The Layers are elements that are displayed on the map.

com.codename1.maps.providers

These are the map providers, currently http://www.openstreetmap.org/ is


supported.

com.codename1.media

Video and audio playback support are handled within this package using
the Media/Media manager APIs.

com.codename1.messaging

Package com.codename1.ads Description

104

Overview (Codename One API)


This API allows to send e-mail messages through underlying platforms
e-mail clients.
com.codename1.notifications
com.codename1.payment

In-App Billing/Purchase API's are abstracted by this package.

com.codename1.processing

IO Related tools and utilities, e.g.

com.codename1.push

Push notification support using either device specific protocols when


available

com.codename1.share

Sharing services, that can be registered on the ShareButton

com.codename1.social

Connectors for native social network SDK's

com.codename1.system

Low level calls into the Codename One system, including support for
making platform native API calls.

com.codename1.testing

This package contains everything necessary for unit tests, automation of


tests and everything in between.

com.codename1.ui
com.codename1.ui.animations

All components are animatable by potential and additional animations


(unrelated to a specific component) can be installed on the fly, transitions
between forms are also handled as part of this package.

com.codename1.ui.events

Observable pattern event listeners in the spirit of AWT 1.1's event


dispatching architecture, all events are dispatched on the EDT (Event
Dispatch Thread).

com.codename1.ui.geom

Contains classes related to geometry locations and calculations such as


rectangle and size

com.codename1.ui.html

This package is deprecated and used only for legacy support, use the
WebBrowser component from the components package.

com.codename1.ui.layouts

Layout managers allow a Container to arrange its components by a set


of rules that adapt to specific densities (ppi - pixels per inch).

com.codename1.ui.layouts.mig
com.codename1.ui.list

Lists are highly customizable and serve as the basis for ComboBox and
other components (such as carousels etc) they employ a similar MVC
approach to Swing including the renderer pattern.

com.codename1.ui.painter

allows us to draw arbitrary elements of graphics from


plain/scaled/tiled images to gradients and pretty much any form of
graphic drawing we can imagine.

com.codename1.ui.plaf

Look of the application can be fully customized via this package, it


represents a rendering layer that can be plugged in separately in runtime
and themed to provide any custom look.

com.codename1.ui.spinner

Spinners allows picking of simple sequential values similarly to combo


boxes but of a much wider value set.

com.codename1.ui.table

Table component for editing and viewing tabular data and arranging
Codename One components in a tabular form

com.codename1.ui.tree

Tree component for displaying hierarchy based information and its


related classes

com.codename1.ui.util

Utility features that are either too domain specific or don't "fit" into any
other packages including the Resource file format loading API.

com.codename1.ui.validation

The validation framework allows us to mark invalid input in text


components and disable components in the case of invalid input

com.codename1.util

General utilities classes

com.codename1.util.regex

A simple regular expression API that is portable across all platforms

com.codename1.xml

The XML package allows parsing XML documents into DOM objects.

Painter

java.io
java.lang
java.lang.annotation

Package com.codename1.ads Description

105

Overview (Codename One API)


java.lang.invoke
java.lang.ref
java.net
java.text
java.util

Codename One - Write Once Run Anywhere Native Mobile Apps Using
Java
Codename One allows Java developers to write their app once and have it work on all mobile devices (iOS,
Android etc.). It features a simulator, designer (visual theme/builder) and ports to multiple OS's.
Codename One is a mature open source project and its roots go back to Sun Microsystems (2006) where one
of its core underlying components was developed and open sourced.
Codename One is open source. This includes the libraries, native OS ports, resource editor & native VM
code. It also includes themes and separate related projects containing demos, skins etc.
You can understand more about how Codename One works and how the API fits into everything in this
stackoverflow answer.
Other Resources
Developer Guide
How Do I? - Get quick video answers and short tutorials for common questions
The Codename One Blog
cn1libs are extensions to Codename One that allow using device native functionality
Stack Overflow's Codename One Tag
Community Discussion Forum
The Open Source project on github
Build Codename One from source code

Codename One - Write Once Run Anywhere Native Mobile Apps Using Java

106

Overview (Codename One API)


java.util

Class Vector<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>

java.util.Vector<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, RandomAccess
Direct Known Subclasses:
Stack

public class
extends AbstractList<E>
implements List<E>, RandomAccess

Vector is a variable size contiguous indexable array of objects. The size of the vector is the number of
objects it contains. The capacity of the vector is the number of objects it can hold.
Objects may be inserted at any position up to the size of the vector, thus increasing the size of the
vector. Objects at any position in the vector may be removed, thus shrinking the size of the Vector.
Objects at any position in the Vector may be replaced, which does not affect the vector's size.
The capacity of a vector may be specified when the vector is created. If the capacity of the vector is
exceeded, the capacity is increased (doubled by default).
See Also:
StringBuffer

Field Summary
Modifier and
Type

Field and Description


capacityIncrement

protected int

protected int
protected
Object[]

How many elements should be added to the vector when it is detected that
it needs to grow to accommodate extra entries.
elementCount

The number of elements or the size of the vector.


elementData

The elements of the vector.

Fields inherited from class java.util.AbstractList


modCount

Constructor Summary
Constructor and Description
Vector()

Constructs a new vector using the default capacity.


Vector(Collection<? extends E> collection)
Constructs a new instance of Vector containing

the elements in collection.

Vector(int capacity)

Constructs a new vector using the specified capacity.


Vector(int capacity, int capacityIncrement)

Constructs a new vector using the specified capacity and capacity increment.

Class Vector<E>

107

Overview (Codename One API)

Method Summary
Modifier and
Type
boolean
void
boolean

Method and Description


add(E object)

Adds the specified object at the end of this vector.


add(int location, E object)

Adds the specified object into this vector at the specified location.
addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to the end of this vector.
addAll(int location, Collection<? extends E> collection)

boolean

void
int
void
boolean
boolean

Inserts the objects in the specified collection at the specified location in


this vector.
addElement(E object)

Adds the specified object at the end of this vector.


capacity()

Returns the number of elements this vector can hold without growing.
clear()

Removes all elements from this vector, leaving it empty.


contains(Object object)

Searches this vector for the specified object.


containsAll(Collection<?> collection)

Searches this vector for all objects in the specified collection.


copyInto(Object[] elements)

void

E
Enumeration<E>

Attempts to copy elements contained by this Vector into the


corresponding elements of the supplied Object array.
elementAt(int location)

Returns the element at the specified location in this vector.


elements()

Returns an enumeration on the elements of this vector.


ensureCapacity(int minimumCapacity)

void

boolean
E
E
int
int
int
void
boolean
E
int
int
E

Method Summary

Ensures that this vector can hold the specified number of elements
without growing.
equals(Object object)

Compares the specified object to this vector and returns if they are equal.
firstElement()

Returns the first element in this vector.


get(int location)

Returns the element at the specified location in this vector.


hashCode()

Returns an integer hash code for the receiver.


indexOf(Object object)

Searches in this vector for the index of the specified object.


indexOf(Object object, int location)

Searches in this vector for the index of the specified object.


insertElementAt(E object, int location)

Inserts the specified object into this vector at the specified location.
isEmpty()

Returns if this vector has no elements, a size of zero.


lastElement()

Returns the last element in this vector.


lastIndexOf(Object object)

Searches in this vector for the index of the specified object.


lastIndexOf(Object object, int location)

Searches in this vector for the index of the specified object.


remove(int location)

Removes the object at the specified location from this vector.

108

Overview (Codename One API)

remove(Object object)
boolean

Removes the first occurrence, starting at the beginning and moving


towards the end, of the specified object from this vector.
removeAll(Collection<?> collection)

boolean

Removes all occurrences in this vector of each object in the specified


Collection.
removeAllElements()

Removes all elements from this vector, leaving the size zero and the
capacity unchanged.

void

removeElement(Object object)
boolean

Removes the first occurrence, starting at the beginning and moving


towards the end, of the specified object from this vector.
removeElementAt(int location)

void

Removes the element found at index position location from this Vector.
removeRange(int start, int end)

protected void

Removes the objects in the specified range from the start to the, but not
including, end index.
retainAll(Collection<?> collection)

boolean

Removes all objects from this vector that are not contained in the
specified collection.
set(int location, E object)

Replaces the element at the specified location in this vector with the
specified object.

setElementAt(E object, int location)

Replaces the element at the specified location in this vector with the
specified object.

void

setSize(int length)

void

Sets the size of this vector to the specified size.


size()

int

Returns the number of elements in this vector.


subList(int start, int end)

List<E>

Object[]
<T> T[]

Returns a List of the specified portion of this vector from the start index to
one less than the end index.
toArray()

Returns a new array containing all elements contained in this vector.


toArray(T[] contents)

Returns an array containing all elements contained in this vector.


toString()

String

Returns the string representation of this vector.


trimToSize()

void

Sets the capacity of this vector to be the same as the size.

Methods inherited from class java.util.AbstractList


iterator, listIterator, listIterator

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


iterator, listIterator, listIterator

Field Detail

Methods inherited from class java.util.AbstractList

109

Overview (Codename One API)


elementCount
protected int elementCount

The number of elements or the size of the vector.


elementData
protected Object[] elementData

The elements of the vector.


capacityIncrement
protected int capacityIncrement

How many elements should be added to the vector when it is detected that it needs
to grow to accommodate extra entries. If this value is zero or negative the size will be
doubled if an increase is needed.

Constructor Detail
Vector
public Vector()

Constructs a new vector using the default capacity.


Vector
public Vector(int capacity)

Constructs a new vector using the specified capacity.


Parameters:
capacity - the initial capacity of the new vector.
Throws:
IllegalArgumentException - if capacity is negative.
Vector
public Vector(int capacity,
int capacityIncrement)

Constructs a new vector using the specified capacity and capacity increment.
Parameters:
capacity - the initial capacity of the new vector.
capacityIncrement - the amount to increase the capacity when this vector is
full.
Throws:
IllegalArgumentException - if capacity is negative.
Vector
public Vector(Collection<? extends E> collection)

Constructs a new instance of Vector containing the elements in collection. The


order of the elements in the new Vector is dependent on the iteration order of the
seed collection.
Parameters:
collection - the collection of elements to add.

Method Detail

add
public void add(int location,
E object)

Field Detail

110

Overview (Codename One API)


Adds the specified object into this vector at the specified location. The object is
inserted before any element with the same or a higher index increasing their index by
1. If the location is equal to the size of this vector, the object is added at the end.
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
location - the index at which to insert the element.
object - the object to insert in this vector.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location > size().
See Also:
addElement(E), size()
add
public boolean add(E object)

Adds the specified object at the end of this vector.


Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
object - the object to add to the vector.
Returns:
true

addAll
public boolean addAll(int location,
Collection<? extends E> collection)

Inserts the objects in the specified collection at the specified location in this vector.
The objects are inserted in the order in which they are returned from the Collection
iterator. The elements with an index equal or higher than location have their index
increased by the size of the added collection.
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractList<E>
Parameters:
location - the location to insert the objects.
collection - the collection of objects.
Returns:
true if this vector is modified, false otherwise.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 or location > size().
addAll
public boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to the end of this vector.
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects.
Returns:
true if this vector is modified, false otherwise.

Method Detail

111

Overview (Codename One API)


addElement
public void addElement(E object)

Adds the specified object at the end of this vector.


Parameters:
object - the object to add to the vector.
capacity
public int capacity()

Returns the number of elements this vector can hold without growing.
Returns:
the capacity of this vector.
See Also:
ensureCapacity(int), size()
clear
public void clear()

Removes all elements from this vector, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class AbstractList<E>
See Also:
isEmpty(), size()
contains
public boolean contains(Object object)

Searches this vector for the specified object.


Specified by:
contains in interface Collection<E>
Specified by:
contains in interface List<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to look for in this vector.
Returns:
true if object is an element of this vector, false otherwise.
See Also:
indexOf(Object), indexOf(Object, int), Object.equals(java.lang.Object)
containsAll
public boolean containsAll(Collection<?> collection)

Searches this vector for all objects in the specified collection.


Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface List<E>
Overrides:
containsAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects.
Returns:
true if all objects in the specified collection are elements of this vector, false
otherwise.

Method Detail

112

Overview (Codename One API)


copyInto
public void copyInto(Object[] elements)

Attempts to copy elements contained by this Vector into the corresponding elements
of the supplied Object array.
Parameters:
elements - the Object array into which the elements of this vector are copied.
Throws:
IndexOutOfBoundsException - if elements is not big enough.
See Also:
#clone

elementAt
public E elementAt(int location)

Returns the element at the specified location in this vector.


Parameters:
location - the index of the element to return in this vector.
Returns:
the element at the specified location.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location >= size().
See Also:
size()

elements
public Enumeration<E> elements()

Returns an enumeration on the elements of this vector. The results of the


enumeration may be affected if the contents of this vector is modified.
Returns:
an enumeration of the elements of this vector.
See Also:
elementAt(int), Enumeration
ensureCapacity
public void ensureCapacity(int minimumCapacity)

Ensures that this vector can hold the specified number of elements without growing.
Parameters:
minimumCapacity - the minimum number of elements that this vector will hold
before growing.
See Also:
capacity()

equals
public boolean equals(Object object)

Compares the specified object to this vector and returns if they are equal. The object
must be a List which contains the same objects in the same order.
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface List<E>
Overrides:
equals in class AbstractList<E>
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this vector, false otherwise.
See Also:
hashCode()

Method Detail

113

Overview (Codename One API)


firstElement
public E firstElement()

Returns the first element in this vector.


Returns:
the element at the first position.
Throws:
NoSuchElementException - if this vector is empty.
See Also:
elementAt(int), lastElement(), size()
get
public E get(int location)

Returns the element at the specified location in this vector.


Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>
Parameters:
location - the index of the element to return in this vector.
Returns:
the element at the specified location.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location >= size().
See Also:
size()

hashCode
public int hashCode()

Returns an integer hash code for the receiver. Objects which are equal return the
same value for this method.
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface List<E>
Overrides:
hashCode in class AbstractList<E>
Returns:
the receiver's hash.
See Also:
equals(java.lang.Object)

indexOf
public int indexOf(Object object)

Searches in this vector for the index of the specified object. The search for the object
starts at the beginning and moves towards the end of this vector.
Specified by:
indexOf in interface List<E>
Overrides:
indexOf in class AbstractList<E>
Parameters:
object - the object to find in this vector.
Returns:
the index in this vector of the specified element, -1 if the element isn't found.
See Also:
contains(java.lang.Object), lastIndexOf(Object), lastIndexOf(Object,
int)

indexOf
public int indexOf(Object object,
int location)

Method Detail

114

Overview (Codename One API)


Searches in this vector for the index of the specified object. The search for the object
starts at the specified location and moves towards the end of this vector.
Parameters:
object - the object to find in this vector.
location - the index at which to start searching.
Returns:
the index in this vector of the specified element, -1 if the element isn't found.
Throws:
ArrayIndexOutOfBoundsException - if location < 0.
See Also:
contains(java.lang.Object), lastIndexOf(Object), lastIndexOf(Object,
int)

insertElementAt
public void insertElementAt(E object,
int location)

Inserts the specified object into this vector at the specified location. This object is
inserted before any previous element at the specified location. All elements with an
index equal or greater than location have their index increased by 1. If the location is
equal to the size of this vector, the object is added at the end.
Parameters:
object - the object to insert in this vector.
location - the index at which to insert the element.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location > size().
See Also:
addElement(E), size()
isEmpty
public boolean isEmpty()

Returns if this vector has no elements, a size of zero.


Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface List<E>
Overrides:
isEmpty in class AbstractCollection<E>
Returns:
true if this vector has no elements, false otherwise.
See Also:
size()

lastElement
public E lastElement()

Returns the last element in this vector.


Returns:
the element at the last position.
Throws:
NoSuchElementException - if this vector is empty.
See Also:
elementAt(int), firstElement(), size()
lastIndexOf
public int lastIndexOf(Object object)

Searches in this vector for the index of the specified object. The search for the object
starts at the end and moves towards the start of this vector.
Specified by:
lastIndexOf in interface List<E>
Overrides:
lastIndexOf in class AbstractList<E>
Parameters:
object - the object to find in this vector.

Method Detail

115

Overview (Codename One API)


Returns:
the index in this vector of the specified element, -1 if the element isn't found.
See Also:
contains(java.lang.Object), indexOf(Object), indexOf(Object, int)
lastIndexOf
public int lastIndexOf(Object object,
int location)

Searches in this vector for the index of the specified object. The search for the object
starts at the specified location and moves towards the start of this vector.
Parameters:
object - the object to find in this vector.
location - the index at which to start searching.
Returns:
the index in this vector of the specified element, -1 if the element isn't found.
Throws:
ArrayIndexOutOfBoundsException - if location >= size().
See Also:
contains(java.lang.Object), indexOf(Object), indexOf(Object, int)
remove
public E remove(int location)

Removes the object at the specified location from this vector. All elements with an
index bigger than location have their index decreased by 1.
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractList<E>
Parameters:
location - the index of the object to remove.
Returns:
the removed object.
Throws:
IndexOutOfBoundsException - if location < 0 || location >= size().
remove
public boolean remove(Object object)

Removes the first occurrence, starting at the beginning and moving towards the end,
of the specified object from this vector. All elements with an index bigger than the
element that gets removed have their index decreased by 1.
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
object - the object to remove from this vector.
Returns:
true if the specified object was found, false otherwise.
See Also:
removeAllElements(), removeElementAt(int), size()
removeAll
public boolean removeAll(Collection<?> collection)

Removes all occurrences in this vector of each object in the specified Collection.
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface List<E>
Overrides:
removeAll in class AbstractCollection<E>

Method Detail

116

Overview (Codename One API)


Parameters:
collection

- the collection of objects to remove.

Returns:
true

if this vector is modified, false otherwise.

See Also:
remove(Object), contains(Object)

removeAllElements
public void removeAllElements()

Removes all elements from this vector, leaving the size zero and the capacity
unchanged.
See Also:
isEmpty(), size()
removeElement
public boolean removeElement(Object object)

Removes the first occurrence, starting at the beginning and moving towards the end,
of the specified object from this vector. All elements with an index bigger than the
element that gets removed have their index decreased by 1.
Parameters:
object - the object to remove from this vector.
Returns:
true if the specified object was found, false otherwise.
See Also:
removeAllElements(), removeElementAt(int), size()
removeElementAt
public void removeElementAt(int location)

Removes the element found at index position location from this Vector. All elements
with an index bigger than location have their index decreased by 1.
Parameters:
location - the index of the element to remove.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location >= size().
See Also:
removeElement(java.lang.Object), removeAllElements(), size()
removeRange
protected void removeRange(int start,
int end)

Removes the objects in the specified range from the start to the, but not including,
end index. All elements with an index bigger than or equal to end have their index
decreased by end - start.
Overrides:
removeRange in class AbstractList<E>
Parameters:
start - the index at which to start removing.
end - the index one past the end of the range to remove.
Throws:
IndexOutOfBoundsException - if start < 0, start > end or end > size().
retainAll
public boolean retainAll(Collection<?> collection)

Removes all objects from this vector that are not contained in the specified collection.
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface List<E>
Overrides:
retainAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects to retain.

Method Detail

117

Overview (Codename One API)


Returns:
true

if this vector is modified, false otherwise.

See Also:
remove(Object)

set
public E set(int location,
E object)

Replaces the element at the specified location in this vector with the specified object.
Specified by:
set in interface List<E>
Overrides:
set in class AbstractList<E>
Parameters:
location - the index at which to put the specified object.
object - the object to add to this vector.
Returns:
the previous element at the location.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location >= size().
See Also:
size()

setElementAt
public void setElementAt(E object,
int location)

Replaces the element at the specified location in this vector with the specified object.
Parameters:
object - the object to add to this vector.
location - the index at which to put the specified object.
Throws:
ArrayIndexOutOfBoundsException - if location < 0 || location >= size().
See Also:
size()

setSize
public void setSize(int length)

Sets the size of this vector to the specified size. If there are more than length
elements in this vector, the elements at end are lost. If there are less than length
elements in the vector, the additional elements contain null.
Parameters:
length - the new size of this vector.
See Also:
size()

size
public int size()

Returns the number of elements in this vector.


Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this vector.
See Also:
elementCount, lastElement()

Method Detail

118

Overview (Codename One API)


subList
public List<E> subList(int start,
int end)

Returns a List of the specified portion of this vector from the start index to one less
than the end index. The returned List is backed by this vector so changes to one are
reflected by the other.
Specified by:
subList in interface List<E>
Overrides:
subList in class AbstractList<E>
Parameters:
start - the index at which to start the sublist.
end - the index one past the end of the sublist.
Returns:
a List of a portion of this vector.
Throws:
IndexOutOfBoundsException - if start < 0 or end > size().
IllegalArgumentException - if start > end.
toArray
public Object[] toArray()

Returns a new array containing all elements contained in this vector.


Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Returns:
an array of the elements from this vector.
toArray
public <T> T[] toArray(T[] contents)

Returns an array containing all elements contained in this vector. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
vector, the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Parameters:
contents - the array to fill.
Returns:
an array of the elements from this vector.
Throws:
ArrayStoreException - if the type of an element in this vector cannot be
stored in the type of the specified array.
toString
public String toString()

Returns the string representation of this vector.


Overrides:
toString in class AbstractCollection<E>
Returns:
the string representation of this vector.
See Also:
elements()

Method Detail

119

Overview (Codename One API)


trimToSize
public void trimToSize()

Sets the capacity of this vector to be the same as the size.


See Also:
capacity(), ensureCapacity(int), size()

Method Detail

120

Overview (Codename One API)


java.util

Class TreeSet<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractSet<E>

java.util.TreeSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, NavigableSet<E>, Set<E>, SortedSet<E>

public class
extends AbstractSet<E>
implements NavigableSet<E>

TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are
supported. The elements can be any objects which are comparable to each other either using their
natural order or a specified Comparator.
Since:
1.2

Constructor Summary
Constructor and Description
TreeSet()

Constructs a new empty instance of TreeSet which uses natural ordering.


TreeSet(Collection<? extends E> collection)
Constructs a new instance of TreeSet which uses

natural ordering and containing the unique

elements in the specified collection.


TreeSet(Comparator<? super E> comparator)
Constructs a new empty instance of TreeSet which

uses the specified comparator.

TreeSet(SortedSet<E> set)

Constructs a new instance of TreeSet containing the elements of the specified SortedSet
and using the same Comparator.

Method Summary
Modifier and Type
boolean
boolean

Method and Description


add(E object)

Adds the specified object to this TreeSet.


addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to this TreeSet.


ceiling(E e)

void
Comparator<?
super E>
boolean
Iterator<E>
NavigableSet<E>

Class TreeSet<E>

Answers the smallest element bigger than or equal to the specified one,
or null if no such element.
clear()

Removes all elements from this TreeSet, leaving it empty.


comparator()

Returns the comparator used to compare elements in this TreeSet.


contains(Object object)
Searches this TreeSet for the

specified object.

descendingIterator()

Answers a descending iterator of this set.


descendingSet()

Answers a reverse order view of this set.

121

Overview (Codename One API)


first()

Answers the first element in this TreeSet.


floor(E e)

Answers the biggest element less than or equal to the specified one, or
null if no such element.

headSet(E end)
SortedSet<E>

Answers a SortedSet of the specified portion of this TreeSet which


contains elements less than the end element.
headSet(E end, boolean endInclusive)

NavigableSet<E>

Answers a NavigableSet of the specified portion of this set which


contains elements less than (or equal to, depends on endInclusive) the
end element.
higher(E e)

Answers the smallest element bigger than the specified one, or null if no
such element.

boolean
Iterator<E>

isEmpty()

Returns true if this TreeSet has no element, otherwise false.


iterator()

Returns an Iterator on the elements of this TreeSet.


last()

Answers the last element in this TreeSet.


lower(E e)

Answers the biggest element less than the specified one, or null if no
such element.

pollFirst()

Deletes and answers the smallest element, or null if the set is empty.
pollLast()

Deletes and answers the biggest element, or null if the set is empty.

boolean

remove(Object object)

Removes an occurrence of the specified object from this TreeSet.


size()

int

Returns the number of elements in this TreeSet.


subSet(E start, boolean startInclusive, E end,
boolean endInclusive)

NavigableSet<E>

Answers a NavigableSet of the specified portion of this set which


contains elements greater (or equal to, depends on startInclusive) the
start element but less than (or equal to, depends on endInclusive) the
end element.
subSet(E start, E end)

SortedSet<E>

Answers a SortedSet of the specified portion of this TreeSet which


contains elements greater or equal to the start element but less than the
end element.
tailSet(E start)

SortedSet<E>

Answers a SortedSet of the specified portion of this TreeSet which


contains elements greater or equal to the start element.
tailSet(E start, boolean startInclusive)

NavigableSet<E>

Answers a NavigableSet of the specified portion of this set which


contains elements greater (or equal to, depends on startInclusive) the
start element.

Methods inherited from class java.util.AbstractSet


equals, hashCode, removeAll

Methods inherited from class java.util.AbstractCollection


containsAll, retainAll, toArray, toArray, toString

Method Summary

122

Overview (Codename One API)


Methods

inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Set


containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray

Constructor Detail
TreeSet
public TreeSet()

Constructs a new empty instance of TreeSet which uses natural ordering.


TreeSet
public TreeSet(Collection<? extends E> collection)

Constructs a new instance of TreeSet which uses natural ordering and containing the
unique elements in the specified collection.
Parameters:
collection - the collection of elements to add.
Throws:
ClassCastException - when an element in the collection does not implement
the Comparable interface, or the elements in the collection cannot be
compared.
TreeSet
public TreeSet(Comparator<? super E> comparator)

Constructs a new empty instance of TreeSet which uses the specified comparator.
Parameters:
comparator - the comparator to use.
TreeSet
public TreeSet(SortedSet<E> set)

Constructs a new instance of TreeSet containing the elements of the specified


SortedSet and using the same Comparator.
Parameters:
set - the SortedSet of elements to add.

Method Detail

add
public boolean add(E object)

Adds the specified object to this TreeSet.


Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
object - the object to add.
Returns:
true when this TreeSet did not already contain the object, false otherwise.
Throws:

Methods inherited from class java.lang.Object

123

Overview (Codename One API)


ClassCastException - when the object cannot be compared with the
elements in this TreeSet.
NullPointerException - when the object is null and the comparator cannot

handle null.
addAll
public boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to this TreeSet.


Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects to add.
Returns:
true if this TreeSet was modified, false otherwise.
Throws:
ClassCastException - when an object in the collection cannot be compared
with the elements in this TreeSet.
NullPointerException - when an object in the collection is null and the
comparator cannot handle null.
clear
public void clear()

Removes all elements from this TreeSet, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class AbstractCollection<E>
See Also:
isEmpty(), size()
comparator
public Comparator<? super E> comparator()

Returns the comparator used to compare elements in this TreeSet.


Specified by:
comparator in interface SortedSet<E>
Returns:
a Comparator or null if the natural ordering is used
contains
public boolean contains(Object object)

Searches this TreeSet for the specified object.


Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this TreeSet, false otherwise.
Throws:
ClassCastException - when the object cannot be compared with the
elements in this TreeSet.
NullPointerException - when the object is null and the comparator cannot
handle null.

Method Detail

124

Overview (Codename One API)


isEmpty
public boolean isEmpty()

Returns true if this TreeSet has no element, otherwise false.


Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>
Overrides:
isEmpty in class AbstractCollection<E>
Returns:
true if this TreeSet has no element.
See Also:
size()

iterator
public Iterator<E> iterator()

Returns an Iterator on the elements of this TreeSet.


Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
an Iterator on the elements of this TreeSet.
See Also:
Iterator

descendingIterator
public Iterator<E> descendingIterator()

Answers a descending iterator of this set.


Specified by:
descendingIterator in interface NavigableSet<E>
Returns:
the descending iterator
Since:
1.6
See Also:
NavigableSet.descendingIterator()

remove
public boolean remove(Object object)

Removes an occurrence of the specified object from this TreeSet.


Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
object - the object to remove.
Returns:
true if this TreeSet was modified, false otherwise.
Throws:
ClassCastException - when the object cannot be compared with the
elements in this TreeSet.
NullPointerException - when the object is null and the comparator cannot
handle null.

Method Detail

125

Overview (Codename One API)


size
public int size()

Returns the number of elements in this TreeSet.


Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this TreeSet.
first
public E first()

Answers the first element in this TreeSet.


Specified by:
first in interface SortedSet<E>
Returns:
the first element
Throws:
NoSuchElementException - when this TreeSet is empty
last
public E last()

Answers the last element in this TreeSet.


Specified by:
last in interface SortedSet<E>
Returns:
the last element
Throws:
NoSuchElementException - when this TreeSet is empty
pollFirst
public E pollFirst()

Deletes and answers the smallest element, or null if the set is empty.
Specified by:
pollFirst in interface NavigableSet<E>
Returns:
the smallest element, or null if the set is empty
Since:
1.6
See Also:
NavigableSet.pollFirst()

pollLast
public E pollLast()

Deletes and answers the biggest element, or null if the set is empty.
Specified by:
pollLast in interface NavigableSet<E>
Returns:
the biggest element, or null if the set is empty
Since:
1.6
See Also:
NavigableSet.pollLast()

higher
public E higher(E e)

Method Detail

126

Overview (Codename One API)


Answers the smallest element bigger than the specified one, or null if no such
element.
Specified by:
higher in interface NavigableSet<E>
Parameters:
e - the specified element
Returns:
the smallest element bigger than the specified one, or null if no such element
Since:
1.6
See Also:
NavigableSet.higher(java.lang.Object)

lower
public E lower(E e)

Answers the biggest element less than the specified one, or null if no such element.
Specified by:
lower in interface NavigableSet<E>
Parameters:
e - the specified element
Returns:
the biggest element less than the specified one, or null if no such element
Since:
1.6
See Also:
NavigableSet.lower(java.lang.Object)

ceiling
public E ceiling(E e)

Answers the smallest element bigger than or equal to the specified one, or null if no
such element.
Specified by:
ceiling in interface NavigableSet<E>
Parameters:
e - the specified element
Returns:
the smallest element bigger than or equal to the specified one, or null if no
such element
Since:
1.6
See Also:
NavigableSet.ceiling(java.lang.Object)

floor
public E floor(E e)

Answers the biggest element less than or equal to the specified one, or null if no such
element.
Specified by:
floor in interface NavigableSet<E>
Parameters:
e - the specified element
Returns:
the biggest element less than or equal to the specified one, or null if no such
element
Since:
1.6
See Also:
NavigableSet.floor(java.lang.Object)

Method Detail

127

Overview (Codename One API)


descendingSet
public NavigableSet<E> descendingSet()

Answers a reverse order view of this set.


Specified by:
descendingSet in interface NavigableSet<E>
Returns:
the reverse order view
Since:
1.6
See Also:
NavigableSet.descendingSet()

subSet
public NavigableSet<E> subSet(E start,
boolean startInclusive,
E end,
boolean endInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
greater (or equal to, depends on startInclusive) the start element but less than (or
equal to, depends on endInclusive) the end element. The returned NavigableSet is
backed by this set so changes to one are reflected by the other.
Specified by:
subSet in interface NavigableSet<E>
Parameters:
start - the start element
startInclusive - true if the start element is in the returned set
end - the end element
endInclusive - true if the end element is in the returned set
Returns:
the subset
Since:
1.6
See Also:
NavigableSet.subSet(Object, boolean, Object, boolean)

headSet
public NavigableSet<E> headSet(E end,
boolean endInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
less than (or equal to, depends on endInclusive) the end element. The returned
NavigableSet is backed by this set so changes to one are reflected by the other.
Specified by:
headSet in interface NavigableSet<E>
Parameters:
end - the end element
endInclusive - true if the end element is in the returned set
Returns:
the subset
Since:
1.6
See Also:
NavigableSet.headSet(Object, boolean)

tailSet
public NavigableSet<E> tailSet(E start,
boolean startInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
greater (or equal to, depends on startInclusive) the start element. The returned
NavigableSet is backed by this set so changes to one are reflected by the other.
Specified by:

Method Detail

128

Overview (Codename One API)


tailSet

in interface NavigableSet<E>

Parameters:
start - the start
startInclusive

element
- true if the start element is in the returned set

Returns:
the subset
Since:
1.6
See Also:
NavigableSet.tailSet(Object, boolean)

subSet
public SortedSet<E> subSet(E start,
E end)

Answers a SortedSet of the specified portion of this TreeSet which contains elements
greater or equal to the start element but less than the end element. The returned
SortedSet is backed by this TreeSet so changes to one are reflected by the other.
Specified by:
subSet in interface SortedSet<E>
Parameters:
start - the start element
end - the end element
Returns:
a subset where the elements are greater or equal to start and less than end
Throws:
ClassCastException - when the start or end object cannot be compared with
the elements in this TreeSet
NullPointerException - when the start or end object is null and the
comparator cannot handle null
headSet
public SortedSet<E> headSet(E end)

Answers a SortedSet of the specified portion of this TreeSet which contains elements
less than the end element. The returned SortedSet is backed by this TreeSet so
changes to one are reflected by the other.
Specified by:
headSet in interface SortedSet<E>
Parameters:
end - the end element
Returns:
a subset where the elements are less than end
Throws:
ClassCastException - when the end object cannot be compared with the
elements in this TreeSet
NullPointerException - when the end object is null and the comparator
cannot handle null
tailSet
public SortedSet<E> tailSet(E start)

Answers a SortedSet of the specified portion of this TreeSet which contains elements
greater or equal to the start element. The returned SortedSet is backed by this
TreeSet so changes to one are reflected by the other.
Specified by:
tailSet in interface SortedSet<E>
Parameters:
start - the start element
Returns:
a subset where the elements are greater or equal to start
Throws:

Method Detail

129

Overview (Codename One API)


- when the start object cannot be compared with the
elements in this TreeSet
NullPointerException - when the start object is null and the comparator
cannot handle null
ClassCastException

Method Detail

130

Overview (Codename One API)


java.util

Class TreeMap<K,V>
java.lang.Object

java.util.AbstractMap<K,V>

java.util.TreeMap<K,V>
Type Parameters:
K - type of key
V - type of value
All Implemented Interfaces:
Map<K,V>, NavigableMap<K,V>, SortedMap<K,V>

public class
extends AbstractMap<K,V>
implements NavigableMap<K,V>

TreeMap is an implementation of SortedMap. All optional operations (adding and removing) are
supported. The values can be any objects. The keys can be any objects which are comparable to
each other either using their natural
Since:
1.2

Nested Class Summary

Nested classes/interfaces inherited from


class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

Constructor Summary
Constructor and Description
TreeMap()

Constructs a new empty TreeMap instance.


TreeMap(Comparator<? super K> comparator)
Constructs a new empty TreeMap instance with

the specified comparator.

TreeMap(Map<? extends K,? extends V> map)


Constructs a new TreeMap instance containing the

mappings from the specified map and

using natural ordering.


TreeMap(SortedMap<K,? extends V> map)
Constructs a new TreeMap instance containing

the mappings from the specified SortedMap

and using the same comparator.

Method Summary
Modifier and Type

Method and Description


ceilingEntry(K key)

Map.Entry<K,V>

Answers an entry related with the smallest key greater than or


equal to the specified key, or null if no such key.
ceilingKey(K key)

void

Class TreeMap<K,V>

Answers the smallest key greater than or equal to the specified key,
or null if no such key.
clear()

Removes all mappings from this TreeMap, leaving it empty.

131

Overview (Codename One API)


Comparator<? super K>
boolean
boolean
NavigableSet<K>
NavigableMap<K,V>
Set<Map.Entry<K,V>>
Map.Entry<K,V>
K

comparator()

Returns the comparator used to compare elements in this map.


containsKey(Object key)

Returns whether this map contains the specified key.


containsValue(Object value)

Returns whether this map contains the specified value.


descendingKeySet()

Answers a NavigableSet view of the keys in descending order.


descendingMap()

Answers a reverse order view of the map.


entrySet()

Returns a set containing all of the mappings in this map.


firstEntry()

Answers the entry with the smallest key, or null if the map is empty.
firstKey()

Returns the first key in this map.


floorEntry(K key)

Map.Entry<K,V>

Answers an entry related with the biggest key less than or equal to
the specified key, or null if no such key.
floorKey(K key)

Answers the biggest key less than or equal to the specified key, or
null if no such key.
get(Object key)

Returns the value of the mapping with the specified key.


headMap(K endKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys
that are less than the specified endKey.
headMap(K end, boolean inclusive)

NavigableMap<K,V>

Answers a view of the head of the map whose keys are smaller
than (or equal to, depends on inclusive argument) endKey.
higherEntry(K key)

Map.Entry<K,V>

Answers an entry related with the smallest key greater than the
specified key, or null if no such key.
higherKey(K key)

Set<K>
Map.Entry<K,V>
K

Answers the smallest key greater than the specified key, or null if
no such key.
keySet()

Returns a set of the keys contained in this map.


lastEntry()

Answers the entry with the biggest key, or null if the map is empty.
lastKey()

Returns the last key in this map.


lowerEntry(K key)

Map.Entry<K,V>

Answers an entry related with the biggest key less than the
specified key, or null if no such key.
lowerKey(K key)

NavigableSet<K>

Answers the biggest key less than the specified key, or null if no
such key.
navigableKeySet()

Answers a NavigableSet view of the keys in ascending order.


pollFirstEntry()

Map.Entry<K,V>

Deletes and answers the entry with the smallest key, or null if the
map is empty.
pollLastEntry()

Map.Entry<K,V>

V
void

Method Summary

Deletes and answers the entry with the biggest key, or null if the
map is empty.
put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> map)

132

Overview (Codename One API)


Copies all the mappings in the given map to this map.
remove(Object key)

Removes the mapping with the specified key from this map.
size()

int

Returns the number of mappings in this map.

NavigableMap<K,V>

subMap(K start, boolean startInclusive, K end,


boolean endInclusive)

Answers a view of part of the map whose keys is from startKey to


endKey.
subMap(K startKey, K endKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys
greater than or equal to the specified startKey and less than the
specified endKey.
tailMap(K startKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys
that are greater than or equal to the specified startKey.
tailMap(K start, boolean inclusive)

NavigableMap<K,V>

Collection<V>

Answers a view of the tail of the map whose keys are bigger than
(or equal to, depends on inclusive argument) startKey.
values()

Returns a collection of the values contained in this map.

Methods inherited from class java.util.AbstractMap


equals, hashCode, isEmpty, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Map


equals, hashCode, isEmpty

Constructor Detail
TreeMap
public TreeMap()

Constructs a new empty TreeMap instance.


TreeMap
public TreeMap(Comparator<? super K> comparator)

Constructs a new empty TreeMap instance with the specified comparator.


Parameters:
comparator - the comparator to compare keys with.
TreeMap
public TreeMap(Map<? extends K,? extends V> map)

Constructs a new TreeMap instance containing the mappings from the specified map
and using natural ordering.
Parameters:
map - the mappings to add.
Throws:
ClassCastException - if a key in the specified map does not implement the
Comparable interface, or if the keys in the map cannot be compared.

Methods inherited from class java.util.AbstractMap

133

Overview (Codename One API)


TreeMap
public TreeMap(SortedMap<K,? extends V> map)

Constructs a new TreeMap instance containing the mappings from the specified
SortedMap and using the same comparator.
Parameters:
map - the mappings to add.

Method Detail
clear
public void clear()

Removes all mappings from this TreeMap, leaving it empty.


Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMap<K,V>
See Also:
Map.isEmpty(), size()
comparator
public Comparator<? super K> comparator()

Returns the comparator used to compare elements in this map.


Specified by:
comparator in interface SortedMap<K,V>
Returns:
the comparator or null if the natural ordering is used.
containsKey
public boolean containsKey(Object key)

Returns whether this map contains the specified key.


Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>
Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.
Throws:
ClassCastException - if the specified key cannot be compared with the keys
in this map.
NullPointerException - if the specified key is null and the comparator
cannot handle null keys.
containsValue
public boolean containsValue(Object value)

Returns whether this map contains the specified value.


Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class AbstractMap<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.

Constructor Detail

134

Overview (Codename One API)


firstKey
public K firstKey()

Returns the first key in this map.


Specified by:
firstKey in interface SortedMap<K,V>
Returns:
the first key in this map.
Throws:
NoSuchElementException - if this map is empty.
get
public V get(Object key)

Returns the value of the mapping with the specified key.


Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys in this
map.
NullPointerException - if the key is null and the comparator cannot handle
null.
keySet
public Set<K> keySet()

Returns a set of the keys contained in this map. The set is backed by this map so
changes to one are reflected by the other. The set does not support adding.
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMap<K,V>
Returns:
a set of the keys.
lastKey
public K lastKey()

Returns the last key in this map.


Specified by:
lastKey in interface SortedMap<K,V>
Returns:
the last key in this map.
Throws:
NoSuchElementException - if this map is empty.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>
Parameters:
key - the key.
value - the value.
Returns:

Method Detail

135

Overview (Codename One API)


the value of any previous mapping with the specified key or null if there was
no mapping.
Throws:
ClassCastException

- if the specified key cannot be compared with the keys

in this map.
NullPointerException - if
cannot handle null keys.

the specified key is null and the comparator

putAll
public void putAll(Map<? extends K,? extends V> map)

Copies all the mappings in the given map to this map. These mappings will replace
all mappings that this map had for any of the keys currently in the given map.
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class AbstractMap<K,V>
Parameters:
map - the map to copy mappings from.
Throws:
ClassCastException - if a key in the specified map cannot be compared with
the keys in this map.
NullPointerException - if a key in the specified map is null and the
comparator cannot handle null keys.
remove
public V remove(Object key)

Removes the mapping with the specified key from this map.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
Throws:
ClassCastException - if the specified key cannot be compared with the keys
in this map.
NullPointerException - if the specified key is null and the comparator
cannot handle null keys.
size
public int size()

Returns the number of mappings in this map.


Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractMap<K,V>
Returns:
the number of mappings in this map.
values
public Collection<V> values()

Returns a collection of the values contained in this map. The collection is backed by
this map so changes to one are reflected by the other. The collection supports
remove, removeAll, retainAll and clear operations, and it does not support add or
addAll operations.
This method returns a collection which is the subclass of AbstractCollection. The
iterator method of this subclass returns a "wrapper object" over the iterator of map's
entrySet(). The size method wraps the map's size method and the contains method

Method Detail

136

Overview (Codename One API)


wraps the map's containsValue method.
The collection is created when this method is called for the first time and returned in
response to all subsequent calls. This method may return different collections when
multiple concurrent calls occur, since no synchronization is performed.
Specified by:
values

in interface Map<K,V>

Overrides:
values in class AbstractMap<K,V>
Returns:
a collection of the values contained in this map.
firstEntry
public Map.Entry<K,V> firstEntry()

Answers the entry with the smallest key, or null if the map is empty.
Specified by:
firstEntry in interface NavigableMap<K,V>
Returns:
the entry with the smallest key, or null if the map is empty
Since:
1.6
See Also:
NavigableMap.firstEntry()

lastEntry
public Map.Entry<K,V> lastEntry()

Answers the entry with the biggest key, or null if the map is empty.
Specified by:
lastEntry in interface NavigableMap<K,V>
Returns:
the entry with the biggest key, or null if the map is empty
Since:
1.6
See Also:
NavigableMap.lastEntry()

pollFirstEntry
public Map.Entry<K,V> pollFirstEntry()

Deletes and answers the entry with the smallest key, or null if the map is empty.
Specified by:
pollFirstEntry in interface NavigableMap<K,V>
Returns:
the entry with the smallest key, or null if the map is empty
Since:
1.6
See Also:
NavigableMap.pollFirstEntry()

pollLastEntry
public Map.Entry<K,V> pollLastEntry()

Deletes and answers the entry with the biggest key, or null if the map is empty.
Specified by:
pollLastEntry in interface NavigableMap<K,V>
Returns:
the entry with the biggest key, or null if the map is empty
Since:
1.6
See Also:
NavigableMap.pollLastEntry()

Method Detail

137

Overview (Codename One API)


higherEntry
public Map.Entry<K,V> higherEntry(K key)

Answers an entry related with the smallest key greater than the specified key, or null
if no such key.
Specified by:
higherEntry in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the entry, or null if no such key
Since:
1.6
See Also:
NavigableMap.higherEntry(Object)

higherKey
public K higherKey(K key)

Answers the smallest key greater than the specified key, or null if no such key.
Specified by:
higherKey in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the smallest key greater than key, or null if no such key
Since:
1.6
See Also:
NavigableMap.higherKey(Object)

lowerEntry
public Map.Entry<K,V> lowerEntry(K key)

Answers an entry related with the biggest key less than the specified key, or null if no
such key.
Specified by:
lowerEntry in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the entry, or null if no such key
Since:
1.6
See Also:
NavigableMap.lowerEntry(Object)

lowerKey
public K lowerKey(K key)

Answers the biggest key less than the specified key, or null if no such key.
Specified by:
lowerKey in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the biggest key less than key, or null if no such key
Since:
1.6
See Also:
NavigableMap.lowerKey(Object)

Method Detail

138

Overview (Codename One API)


ceilingEntry
public Map.Entry<K,V> ceilingEntry(K key)

Answers an entry related with the smallest key greater than or equal to the specified
key, or null if no such key.
Specified by:
ceilingEntry in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the entry, or null if no such key
Since:
1.6
See Also:
NavigableMap.ceilingEntry(java.lang.Object)

ceilingKey
public K ceilingKey(K key)

Answers the smallest key greater than or equal to the specified key, or null if no such
key.
Specified by:
ceilingKey in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the smallest key greater than or equal to key, or null if no such key
Since:
1.6
See Also:
NavigableMap.ceilingKey(java.lang.Object)

floorEntry
public Map.Entry<K,V> floorEntry(K key)

Answers an entry related with the biggest key less than or equal to the specified key,
or null if no such key.
Specified by:
floorEntry in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the entry, or null if no such key
Since:
1.6
See Also:
NavigableMap.floorEntry(Object)

floorKey
public K floorKey(K key)

Answers the biggest key less than or equal to the specified key, or null if no such key.
Specified by:
floorKey in interface NavigableMap<K,V>
Parameters:
key - the key
Returns:
the biggest key less than or equal to key, or null if no such key
Since:
1.6
See Also:
NavigableMap.floorKey(Object)

Method Detail

139

Overview (Codename One API)


entrySet
public Set<Map.Entry<K,V>> entrySet()

Returns a set containing all of the mappings in this map. Each mapping is an
instance of Map.Entry. As the set is backed by this map, changes in one will be
reflected in the other. It does not support adding operations.
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>
Returns:
a set of the mappings.
navigableKeySet
public NavigableSet<K> navigableKeySet()

Answers a NavigableSet view of the keys in ascending order.


Specified by:
navigableKeySet in interface NavigableMap<K,V>
Returns:
the navigable set view
Since:
1.6
See Also:
NavigableMap.navigableKeySet()

descendingKeySet
public NavigableSet<K> descendingKeySet()

Answers a NavigableSet view of the keys in descending order.


Specified by:
descendingKeySet in interface NavigableMap<K,V>
Returns:
the navigable set view
Since:
1.6
See Also:
NavigableMap.descendingKeySet()

descendingMap
public NavigableMap<K,V> descendingMap()

Answers a reverse order view of the map.


Specified by:
descendingMap in interface NavigableMap<K,V>
Returns:
the reverse order view of the map
Since:
1.6
See Also:
NavigableMap.descendingMap()

subMap
public NavigableMap<K,V> subMap(K start,
boolean startInclusive,
K end,
boolean endInclusive)

Answers a view of part of the map whose keys is from startKey to endKey.
Specified by:
subMap in interface NavigableMap<K,V>
Parameters:
start - the start key
startInclusive - true if the start key is in the returned map
end - the end key

Method Detail

140

Overview (Codename One API)


endInclusive - true if the end key is in the returned map
Returns:
the sub-map view
Since:
1.6
See Also:
NavigableMap.subMap(Object, boolean, Object, boolean)

headMap
public NavigableMap<K,V> headMap(K end,
boolean inclusive)

Answers a view of the head of the map whose keys are smaller than (or equal to,
depends on inclusive argument) endKey.
Specified by:
headMap in interface NavigableMap<K,V>
Parameters:
end - the end key
inclusive - true if the end key is in the returned map
Returns:
the head-map view
Since:
1.6
See Also:
NavigableMap.headMap(Object, boolean)

tailMap
public NavigableMap<K,V> tailMap(K start,
boolean inclusive)

Answers a view of the tail of the map whose keys are bigger than (or equal to,
depends on inclusive argument) startKey.
Specified by:
tailMap in interface NavigableMap<K,V>
Parameters:
start - the start key
inclusive - true if the start key is in the returned map
Returns:
the tail-map view
Since:
1.6
See Also:
NavigableMap.tailMap(Object, boolean)

subMap
public SortedMap<K,V> subMap(K startKey,
K endKey)

Returns a sorted map over a range of this sorted map with all keys greater than or
equal to the specified startKey and less than the specified endKey. Changes to the
returned sorted map are reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Specified by:
subMap

in interface SortedMap<K,V>

Parameters:
startKey - the low boundary of the range (inclusive).
endKey - the high boundary of the range (exclusive),

Returns:
a sorted map with the key from the specified range.
Throws:

Method Detail

141

Overview (Codename One API)


ClassCastException

- if the start or end key cannot be compared with the

keys in this map.


NullPointerException - if the start or end key is null and the comparator
cannot handle null keys.
IllegalArgumentException - if the start key is greater than the end key, or

if

this map is itself a sorted map over a range of another sorted map and the
specified range is outside of its range.
headMap
public SortedMap<K,V> headMap(K endKey)

Returns a sorted map over a range of this sorted map with all keys that are less than
the specified endKey. Changes to the returned sorted map are reflected in this sorted
map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Specified by:
headMap

in interface SortedMap<K,V>

Parameters:
endKey - the high boundary of the range specified.
Returns:
a sorted map where the keys are less than endKey.
Throws:
ClassCastException - if the specified key cannot be compared with the keys
in this map.
NullPointerException - if the specified key is null and the comparator
cannot handle null keys.
IllegalArgumentException - if this map is itself a sorted map over a range of
another map and the specified key is outside of its range.

tailMap
public SortedMap<K,V> tailMap(K startKey)

Returns a sorted map over a range of this sorted map with all keys that are greater
than or equal to the specified startKey. Changes to the returned sorted map are
reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Specified by:
tailMap

in interface SortedMap<K,V>

Parameters:
startKey - the low boundary of the range specified.
Returns:
a sorted map where the keys are greater or equal to startKey.
Throws:
ClassCastException - if the specified key cannot be compared with the keys
in this map.
NullPointerException - if the specified key is null and the comparator
cannot handle null keys.
IllegalArgumentException - if this map itself a sorted map over a range of
another map and the specified key is outside of its range.

Method Detail

142

Overview (Codename One API)


java.util

Class TimerTask
java.lang.Object

java.util.TimerTask
All Implemented Interfaces:
Runnable

public abstract class


extends Object
implements Runnable

Constructor Summary
Modifier Constructor and Description
protected TimerTask()

Method Summary
Modifier and Type

Method and Description

boolean

cancel()

long

scheduledExecutionTime()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.lang.Runnable


run

Constructor Detail
TimerTask
protected TimerTask()

Method Detail
cancel
public boolean cancel()

scheduledExecutionTime
public long scheduledExecutionTime()

Class TimerTask

143

Overview (Codename One API)


java.util

Class Timer
java.lang.Object

java.util.Timer

public class
extends Object

Constructor Summary
Constructor and Description
Timer()

Method Summary
Modifier and Type

Method and Description

void

cancel()

void

schedule(TimerTask task, Date time)

void

schedule(TimerTask task, Date firstTime, long period)

void

schedule(TimerTask task, long delay)

void

schedule(TimerTask task, long delay, long period)

void

scheduleAtFixedRate(TimerTask task, Date firstTime,


long period)

void

scheduleAtFixedRate(TimerTask task, long delay, long period)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Timer
public Timer()

Method Detail
cancel
public void cancel()

schedule
public void schedule(TimerTask task,
Date time)

schedule
public void schedule(TimerTask task,
Date firstTime,
long period)

Method Detail

144

Overview (Codename One API)


schedule
public void schedule(TimerTask task,
long delay)

schedule
public void schedule(TimerTask task,
long delay,
long period)

scheduleAtFixedRate
public void scheduleAtFixedRate(TimerTask task,
Date firstTime,
long period)

scheduleAtFixedRate
public void scheduleAtFixedRate(TimerTask task,
long delay,
long period)

Method Detail

145

Overview (Codename One API)


java.util

Class TimeZone
java.lang.Object

java.util.TimeZone

public abstract class


extends Object

TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
TimeZone using getDefault which creates a TimeZone based on the time zone where the program is
running. For example, for a program running in Japan, getDefault creates a TimeZone object based
on Japanese Standard Time. You can also get a TimeZone using getTimeZone along with a time
zone ID. For instance, the time zone ID for the Pacific Standard Time zone is "PST". So, you can get
a PST TimeZone object with: This class is a pure subset of the java.util.TimeZone class in JDK 1.3.
The only time zone ID that is required to be supported is "GMT". Apart from the methods and
variables being subset, the semantics of the getTimeZone() method may also be subset: custom IDs
such as "GMT-8:00" are not required to be supported. Version: CLDC 1.1 02/01/2002 (Based on JDK
1.3) See Also:Calendar, Date

Constructor Summary
Constructor and Description
TimeZone()

Method Summary
Modifier and
Type
static String[]
static TimeZone

Method and Description


getAvailableIDs()

Gets all the available IDs supported.


getDefault()

Gets the default TimeZone for this host.


getID()

String

Gets the ID of this time zone.

abstract int

getOffset(int era, int year, int month, int day, int dayOfWeek,
int millis)

Gets offset, for current date, modified in case of daylight savings.


abstract int
static TimeZone
abstract boolean

getRawOffset()

Gets the GMT offset for this time zone.


getTimeZone(String ID)

Gets the TimeZone for the given ID.


useDaylightTime()

Queries if this time zone uses Daylight Savings Time.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class TimeZone

146

Overview (Codename One API)


TimeZone
public TimeZone()

Method Detail
getAvailableIDs
public static String[] getAvailableIDs()

Gets all the available IDs supported.


getDefault
public static TimeZone getDefault()

Gets the default TimeZone for this host. The source of the default TimeZone may
vary with implementation.
getID
public String getID()

Gets the ID of this time zone.


getOffset
public abstract int getOffset(int
int
int
int
int
int

era,
year,
month,
day,
dayOfWeek,
millis)

Gets offset, for current date, modified in case of daylight savings. This is the offset to
add *to* GMT to get local time. Gets the time zone offset, for current date, modified in
case of daylight savings. This is the offset to add *to* GMT to get local time. Assume
that the start and end month are distinct. This method may return incorrect results for
rules that start at the end of February (e.g., last Sunday in February) or the beginning
of March (e.g., March 1).
getRawOffset
public abstract int getRawOffset()

Gets the GMT offset for this time zone.


getTimeZone
public static TimeZone getTimeZone(String ID)

Gets the TimeZone for the given ID.


useDaylightTime
public abstract boolean useDaylightTime()

Queries if this time zone uses Daylight Savings Time.

Constructor Detail

147

Overview (Codename One API)


java.util

Class StringTokenizer
java.lang.Object

java.util.StringTokenizer
All Implemented Interfaces:
Enumeration<Object>

public class
extends Object
implements Enumeration<Object>

The StringTokenizer class allows an application to break a string into tokens by performing code
point comparison. The StringTokenizer methods do not distinguish among identifiers, numbers, and
quoted strings, nor do they recognize and skip comments.
The set of delimiters (the codepoints that separate tokens) may be specified either at creation time or
on a per-token basis.
An instance of StringTokenizer behaves in one of three ways, depending on whether it was created
with the returnDelimiters flag having the value true or false:
If returnDelims is false, delimiter code points serve to separate tokens. A token is a maximal
sequence of consecutive code points that are not delimiters.
If returnDelims is true, delimiter code points are themselves considered to be tokens. In this
case a token will be received for each delimiter code point.
A token is thus either one delimiter code point, or a maximal sequence of consecutive code points
that are not delimiters.
A StringTokenizer object internally maintains a current position within the string to be tokenized.
Some operations advance this current position past the code point processed.
A token is returned by taking a substring of the string that was used to create the StringTokenizer
object.
Here's an example of the use of the default delimiter StringTokenizer :
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
println(st.nextToken());
}

This prints the following output:


this
is
a
test

Here's an example of how to use a StringTokenizer with a user specified delimiter:


StringTokenizer st = new StringTokenizer(
"this is a test with supplementary characters ?
"
");
while (st.hasMoreTokens()) {
println(st.nextToken());
}

?",

This prints the following output:


this
is
a

Method Detail

148

Overview (Codename One API)


test
with
supplementary
characters
?
?

Constructor Summary
Constructor and Description
StringTokenizer(String string)
Constructs a new StringTokenizer

for the parameter string using whitespace as the

delimiter.
StringTokenizer(String string, String delimiters)
Constructs a new StringTokenizer for the parameter string

using the specified delimiters.

StringTokenizer(String string, String delimiters, boolean returnDelimiters)


Constructs a new StringTokenizer for the parameter string using the specified delimiters,
returning the delimiters as tokens if the parameter returnDelimiters is true.

Method Summary
Modifier and Type

Method and Description


countTokens()

int

Returns the number of unprocessed tokens remaining in the string.

boolean

hasMoreElements()
Returns true if unprocessed

tokens remain.

boolean

hasMoreTokens()
Returns true if unprocessed

tokens remain.

Object
String
String

nextElement()

Returns the next token in the string as an Object.


nextToken()

Returns the next token in the string as a String.


nextToken(String delims)

Returns the next token in the string as a String.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
StringTokenizer
public StringTokenizer(String string)

Constructs a new StringTokenizer for the parameter string using whitespace as the
delimiter. The returnDelimiters flag is set to false.
Parameters:
string - the string to be tokenized.
StringTokenizer
public StringTokenizer(String string,
String delimiters)

Constructs a new StringTokenizer for the parameter string using the specified
delimiters. The returnDelimiters flag is set to false. If delimiters is null, this
constructor doesn't throw an Exception, but later calls to some methods might throw

Class StringTokenizer

149

Overview (Codename One API)


a NullPointerException.
Parameters:
string - the string to be tokenized.
delimiters - the delimiters to use.
StringTokenizer
public StringTokenizer(String string,
String delimiters,
boolean returnDelimiters)

Constructs a new StringTokenizer for the parameter string using the specified
delimiters, returning the delimiters as tokens if the parameter returnDelimiters is
true. If delimiters is null this constructor doesn't throw an Exception, but later calls
to some methods might throw a NullPointerException.
Parameters:
string - the string to be tokenized.
delimiters - the delimiters to use.
returnDelimiters - true to return each delimiter as a token.

Method Detail
countTokens
public int countTokens()

Returns the number of unprocessed tokens remaining in the string.


Returns:
number of tokens that can be retreived before an Exception will result from a
call to nextToken().
hasMoreElements
public boolean hasMoreElements()

Returns true if unprocessed tokens remain. This method is implemented in order to


satisfy the Enumeration interface.
Specified by:
hasMoreElements in interface Enumeration<Object>
Returns:
true if unprocessed tokens remain.
hasMoreTokens
public boolean hasMoreTokens()

Returns true if unprocessed tokens remain.


Returns:
true if unprocessed tokens remain.
nextElement
public Object nextElement()

Returns the next token in the string as an Object. This method is implemented in
order to satisfy the Enumeration interface.
Specified by:
nextElement in interface Enumeration<Object>
Returns:
next token in the string as an Object
Throws:
NoSuchElementException - if no tokens remain.
nextToken
public String nextToken()

Returns the next token in the string as a String.


Returns:
next token in the string as a String.
Throws:

Constructor Detail

150

Overview (Codename One API)


NoSuchElementException

- if no tokens remain.

nextToken
public String nextToken(String delims)

Returns the next token in the string as a String. The delimiters used are changed to
the specified delimiters.
Parameters:
delims - the new delimiters to use.
Returns:
next token in the string as a String.
Throws:
NoSuchElementException - if no tokens remain.

Method Detail

151

Overview (Codename One API)


java.util

Class Stack<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>

java.util.Vector<E>

java.util.Stack<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, RandomAccess

public class
extends Vector<E>

is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables users


to pop to and push from the stack, including null objects. There is no limit to the size of the stack.
Stack

Field Summary

Fields inherited from class java.util.Vector


capacityIncrement, elementCount, elementData

Fields inherited from class java.util.AbstractList


modCount

Constructor Summary
Constructor and Description
Stack()

Constructs a stack with the default size of Vector.

Method Summary
Modifier and
Type
boolean

Method and Description


empty()

Returns whether the stack is empty or not.


peek()

Returns the element at the top of the stack without removing it.
pop()

Returns the element at the top of the stack and removes it.
push(E object)

Pushes the specified object onto the top of the stack.


search(Object o)

Returns the index of the first occurrence of the object, starting from the
top of the stack.

int

Methods inherited from class java.util.Vector


add, add, addAll, addAll, addElement, capacity, clear, contains,
containsAll, copyInto, elementAt, elements, ensureCapacity, equals,
firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty,
lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll,
removeAllElements, removeElement, removeElementAt, removeRange, retainAll,

Class Stack<E>

152

Overview (Codename One API)


set, setElementAt, setSize, size, subList, toArray, toArray, toString,
trimToSize

Methods inherited from class java.util.AbstractList


iterator, listIterator, listIterator

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


iterator, listIterator, listIterator

Constructor Detail
Stack
public Stack()

Constructs a stack with the default size of Vector.

Method Detail
empty
public boolean empty()

Returns whether the stack is empty or not.


Returns:
true if the stack is empty, false otherwise.
peek
public E peek()

Returns the element at the top of the stack without removing it.
Returns:
the element at the top of the stack.
Throws:
EmptyStackException - if the stack is empty.
See Also:
pop()

pop
public E pop()

Returns the element at the top of the stack and removes it.
Returns:
the element at the top of the stack.
Throws:
EmptyStackException - if the stack is empty.
See Also:
peek(), push(E)
push
public E push(E object)

Pushes the specified object onto the top of the stack.


Parameters:
object - The object to be added on top of the stack.
Returns:

Methods inherited from class java.util.Vector

153

Overview (Codename One API)


the object argument.
See Also:
peek(), pop()
search
public int search(Object o)

Returns the index of the first occurrence of the object, starting from the top of the
stack.
Parameters:
o - the object to be searched.
Returns:
the index of the first occurrence of the object, assuming that the topmost
object on the stack has a distance of one.

Method Detail

154

Overview (Codename One API)


java.util

Interface SortedSet<E>
All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>
All Known Subinterfaces:
NavigableSet<E>
All Known Implementing Classes:
TreeSet

public interface
extends Set<E>

SortedSet is a Set which iterates over its elements in a sorted order. The order is determined either
by the elements natural ordering, or by a Comparator which is passed into a concrete implementation
at construction time. All elements in this set must be mutually comparable. The ordering in this set
must be consistent with equals of its elements.
See Also:
Comparator, Comparable

Method Summary
Modifier and
Type
Comparator<?
super E>

Method and Description


comparator()

Returns the comparator used to compare elements in this SortedSet.


first()

Returns the first element in this SortedSet.

SortedSet<E>

headSet(E end)
Returns a SortedSet

of the specified portion of this SortedSet which


contains elements less than the end element.
last()

Returns the last element in this SortedSet.

SortedSet<E>

SortedSet<E>

subSet(E start, E end)


Returns a SortedSet of the

specified portion of this SortedSet which


contains elements greater or equal to the start element but less than the
end element.
tailSet(E start)
Returns a SortedSet

of the specified portion of this SortedSet which


contains elements greater or equal to the start element.

Methods inherited from interface java.util.Set


add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty,
iterator, remove, removeAll, retainAll, size, toArray, toArray

Method Detail
comparator
Comparator<? super E> comparator()

Returns the comparator used to compare elements in this SortedSet.


Returns:
a comparator or null if the natural ordering is used.

Interface SortedSet<E>

155

Overview (Codename One API)


first
E first()

Returns the first element in this SortedSet. The first element is the lowest element.
Returns:
the first element.
Throws:
NoSuchElementException - when this SortedSet is empty.
headSet
SortedSet<E> headSet(E end)

Returns a SortedSet of the specified portion of this SortedSet which contains


elements less than the end element. The returned SortedSet is backed by this
SortedSet so changes to one set are reflected by the other.
Parameters:
end - the end element.
Returns:
a subset where the elements are less than end.
Throws:
ClassCastException - when the class of the end element is inappropriate for
this SubSet.
NullPointerException - when the end element is null and this SortedSet
does not support null elements.
last
E last()

Returns the last element in this SortedSet. The last element is the highest element.
Returns:
the last element.
Throws:
NoSuchElementException - when this SortedSet is empty.
subSet
SortedSet<E> subSet(E start,
E end)

Returns a SortedSet of the specified portion of this SortedSet which contains


elements greater or equal to the start element but less than the end element. The
returned SortedSet is backed by this SortedMap so changes to one set are reflected
by the other.
Parameters:
start - the start element.
end - the end element.
Returns:
a subset where the elements are greater or equal to start and less than end.
Throws:
ClassCastException - when the class of the start or end element is
inappropriate for this SubSet.
NullPointerException - when the start or end element is null and this
SortedSet does not support null elements.
IllegalArgumentException - when the start element is greater than the end
element.
tailSet
SortedSet<E> tailSet(E start)

Returns a SortedSet of the specified portion of this SortedSet which contains


elements greater or equal to the start element. The returned SortedSet is backed by
this SortedSet so changes to one set are reflected by the other.
Parameters:
start - the start element.

Method Detail

156

Overview (Codename One API)


Returns:
a subset where the elements are greater or equal to start .
Throws:
ClassCastException - when the class of the start element is inappropriate for
this SubSet.
NullPointerException - when the start element is null and this SortedSet
does not support null elements.

Method Detail

157

Overview (Codename One API)


java.util

Interface SortedMap<K,V>
All Superinterfaces:
Map<K,V>
All Known Subinterfaces:
NavigableMap<K,V>
All Known Implementing Classes:
TreeMap

public interface
extends Map<K,V>

A map that has its keys ordered. The sorting is according to either the natural ordering of its keys or
the ordering given by a specified comparator.

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Method Summary
Modifier and Type
Comparator<?
super K>

Method and Description


comparator()

Returns the comparator used to compare keys in this sorted map.


firstKey()

Returns the first key in this sorted map.


headMap(K endKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys that
are less than the specified endKey.
lastKey()

Returns the last key in this sorted map.


subMap(K startKey, K endKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys
greater than or equal to the specified startKey and less than the
specified endKey.
tailMap(K startKey)

SortedMap<K,V>

Returns a sorted map over a range of this sorted map with all keys that
are greater than or equal to the specified startKey.

Methods inherited from interface java.util.Map


clear, containsKey, containsValue, entrySet, equals, get, hashCode,
isEmpty, keySet, put, putAll, remove, size, values

Method Detail
comparator
Comparator<? super K> comparator()

Returns the comparator used to compare keys in this sorted map.


Returns:
the comparator or null if the natural order is used.

Interface SortedMap<K,V>

158

Overview (Codename One API)


firstKey
K firstKey()

Returns the first key in this sorted map.


Returns:
the first key in this sorted map.
Throws:
NoSuchElementException - if this sorted map is empty.
headMap
SortedMap<K,V> headMap(K endKey)

Returns a sorted map over a range of this sorted map with all keys that are less than
the specified endKey. Changes to the returned sorted map are reflected in this sorted
map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Parameters:
endKey - the high boundary of the range specified.
Returns:
a sorted map where the keys are less than endKey.
Throws:
ClassCastException - if the class of the end key is inappropriate for this
sorted map.
NullPointerException - if the end key is null and this sorted map does not
support null keys.
IllegalArgumentException - if this map is itself a sorted map over a range of
another map and the specified key is outside of its range.
lastKey
K lastKey()

Returns the last key in this sorted map.


Returns:
the last key in this sorted map.
Throws:
NoSuchElementException - if this sorted map is empty.
subMap
SortedMap<K,V> subMap(K startKey,
K endKey)

Returns a sorted map over a range of this sorted map with all keys greater than or
equal to the specified startKey and less than the specified endKey. Changes to the
returned sorted map are reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Parameters:
startKey - the low boundary of the range (inclusive).
endKey - the high boundary of the range (exclusive),

Returns:
a sorted map with the key from the specified range.
Throws:
ClassCastException - if the class of the start or end key is inappropriate for
this sorted map.
NullPointerException - if the start or end key is null and this sorted map
does not support null keys.
IllegalArgumentException - if the start key is greater than the end key, or if
this map is itself a sorted map over a range of another sorted map and the

Method Detail

159

Overview (Codename One API)


specified range is outside of its range.
tailMap
SortedMap<K,V> tailMap(K startKey)

Returns a sorted map over a range of this sorted map with all keys that are greater
than or equal to the specified startKey. Changes to the returned sorted map are
reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified
range.
Parameters:
startKey - the low boundary of the range specified.
Returns:
a sorted map where the keys are greater or equal to startKey.
Throws:
ClassCastException - if the class of the start key is inappropriate for this
sorted map.
NullPointerException - if the start key is null and this sorted map does not
support null keys.
IllegalArgumentException - if this map itself a sorted map over a range of
another map and the specified key is outside of its range.

Method Detail

160

Overview (Codename One API)


java.util

Interface Set<E>
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Subinterfaces:
NavigableSet<E>, SortedSet<E>
All Known Implementing Classes:
AbstractSet, HashSet, LinkedHashSet, TreeSet

public interface
extends Collection<E>

A Set is a data structure which does not allow duplicate elements.


Since:
1.2

Method Summary
Modifier and
Type
boolean
boolean
void
boolean
boolean

Method and Description


add(E object)

Adds the specified object to this set.


addAll(Collection<? extends E> collection)

Adds the objects in the specified collection which do not exist yet in this set.
clear()

Removes all elements from this set, leaving it empty.


contains(Object object)

Searches this set for the specified object.


containsAll(Collection<?> collection)

Searches this set for all objects in the specified collection.


equals(Object object)

boolean

int
boolean
Iterator<E>
boolean
boolean

Compares the specified object to this set, and returns true if they represent
the same object using a class specific comparison.
hashCode()

Returns the hash code for this set.


isEmpty()

Returns true if this set has no elements.


iterator()

Returns an iterator on the elements of this set.


remove(Object object)

Removes the specified object from this set.


removeAll(Collection<?> collection)

Removes all objects in the specified collection from this set.


retainAll(Collection<?> collection)

boolean

int
Object[]
<T> T[]

Interface Set<E>

Removes all objects from this set that are not contained in the specified
collection.
size()

Returns the number of elements in this set.


toArray()

Returns an array containing all elements contained in this set.


toArray(T[] array)

Returns an array containing all elements contained in this set.

161

Overview (Codename One API)

Method Detail

add
boolean add(E object)

Adds the specified object to this set. The set is not modified if it already contains the
object.
Specified by:
add in interface Collection<E>
Parameters:
object - the object to add.
Returns:
true if this set is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - when adding to this set is not
supported.
ClassCastException - when the class of the object is inappropriate for this
set.
IllegalArgumentException - when the object cannot be added to this set.
addAll
boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified collection which do not exist yet in this set.
Specified by:
addAll in interface Collection<E>
Parameters:
collection - the collection of objects.
Returns:
true if this set is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - when adding to this set is not
supported.
ClassCastException - when the class of an object is inappropriate for this set.
IllegalArgumentException - when an object cannot be added to this set.
clear
void clear()

Removes all elements from this set, leaving it empty.


Specified by:
clear in interface Collection<E>
Throws:
java.lang.UnsupportedOperationException - when removing from this set is
not supported.
See Also:
isEmpty(), size()
contains
boolean contains(Object object)

Searches this set for the specified object.


Specified by:
contains in interface Collection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this set, false otherwise.
containsAll
boolean containsAll(Collection<?> collection)

Searches this set for all objects in the specified collection.

Method Detail

162

Overview (Codename One API)


Specified by:
containsAll

in interface Collection<E>

Parameters:
collection

- the collection of objects.

Returns:
if all objects in the specified collection are elements of this set, false
otherwise.
true

equals
boolean equals(Object object)

Compares the specified object to this set, and returns true if they represent the same
object using a class specific comparison. Equality for a set means that both sets have
the same size and the same elements.
Specified by:
equals in interface Collection<E>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
boolean true if the object is the same as this object, and false if it is different
from this object.
See Also:
hashCode()

hashCode
int hashCode()

Returns the hash code for this set. Two set which are equal must return the same
value.
Specified by:
hashCode in interface Collection<E>
Overrides:
hashCode in class Object
Returns:
the hash code of this set.
See Also:
equals(java.lang.Object)

isEmpty
boolean isEmpty()

Returns true if this set has no elements.


Specified by:
isEmpty in interface Collection<E>
Returns:
true if this set has no elements, false otherwise.
See Also:
size()

iterator
Iterator<E> iterator()

Returns an iterator on the elements of this set. The elements are unordered.
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Iterable<E>
Returns:
an iterator on the elements of this set.
See Also:
Iterator

Method Detail

163

Overview (Codename One API)


remove
boolean remove(Object object)

Removes the specified object from this set.


Specified by:
remove in interface Collection<E>
Parameters:
object - the object to remove.
Returns:
true if this set was modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - when removing from this set is
not supported.
removeAll
boolean removeAll(Collection<?> collection)

Removes all objects in the specified collection from this set.


Specified by:
removeAll in interface Collection<E>
Parameters:
collection - the collection of objects to remove.
Returns:
true if this set was modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - when removing from this set is
not supported.
retainAll
boolean retainAll(Collection<?> collection)

Removes all objects from this set that are not contained in the specified collection.
Specified by:
retainAll in interface Collection<E>
Parameters:
collection - the collection of objects to retain.
Returns:
true if this set was modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - when removing from this set is
not supported.
size
int size()

Returns the number of elements in this set.


Specified by:
size in interface Collection<E>
Returns:
the number of elements in this set.
toArray
Object[] toArray()

Returns an array containing all elements contained in this set.


Specified by:
toArray in interface Collection<E>
Returns:
an array of the elements from this set.
toArray
<T> T[] toArray(T[] array)

Returns an array containing all elements contained in this set. If the specified array is
large enough to hold the elements, the specified array is used, otherwise an array of

Method Detail

164

Overview (Codename One API)

the same type is created. If the specified array is used and is larger than this set, the
array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Parameters:
array - the array.
Returns:
an array of the elements from this set.
Throws:
ArrayStoreException - when the type of an element in this set cannot be
stored in the type of the specified array.
See Also:
Collection.toArray(Object[])

Method Detail

165

Overview (Codename One API)


java.util

Interface RandomAccess
All Known Implementing Classes:
ArrayList, Stack, Vector

public interface

RandomAccess is implemented by List implementations that support fast (usually constant time)
random access.

Interface RandomAccess

166

Overview (Codename One API)


java.util

Class Random
java.lang.Object

java.util.Random

public class
extends Object

An instance of this class is used to generate a stream of pseudorandom numbers. The class uses a
48-bit seed, which is modified using a linear congruential formula. (See Donald Knuth, The Art of
Computer Programming, Volume 2, Section 3.2.1.) If two instances of Random are created with the
same seed, and the same sequence of method calls is made for each, they will generate and return
identical sequences of numbers. In order to guarantee this property, particular algorithms are
specified for the class Random. Java implementations must use all the algorithms shown here for the
class Random, for the sake of absolute portability of Java code. However, subclasses of class
Random are permitted to use other algorithms, so long as they adhere to the general contracts for all
the methods. The algorithms implemented by class Random use a protected utility method that on
each invocation can supply up to 32 pseudorandomly generated bits. Since: JDK1.0, CLDC 1.0
Version: 12/17/01 (CLDC 1.1)

Constructor Summary
Constructor and Description
Random()

Creates a new random number generator.


Random(long seed)

Creates a new random number generator using a single long seed: public Random(long
seed) { setSeed(seed); } Used by method next to hold the state of the pseudorandom
number generator.

Method Summary
Modifier and
Type
protected
int

Method and Description


next(int bits)

Generates the next pseudorandom number.


nextDouble()

double

Returns the next pseudorandom, uniformly distributed double value between


0.0 and 1.0 from this random number generator's sequence.
nextFloat()

float

Returns the next pseudorandom, uniformly distributed float value between 0.0
and 1.0 from this random number generator's sequence.
nextInt()

int

Returns the next pseudorandom, uniformly distributed int value from this
random number generator's sequence.
nextInt(int n)

int

Returns a pseudorandom, uniformly distributed int value between 0


(inclusive) and the specified value (exclusive), drawn from this random
number generator's sequence.
nextLong()

long

void

Class Random

Returns the next pseudorandom, uniformly distributed long value from this
random number generator's sequence.
setSeed(long seed)

Sets the seed of this random number generator using a single long seed.

167

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Random
public Random()

Creates a new random number generator. Its seed is initialized to a value based on
the current time: public Random() { this(System.currentTimeMillis()); } See
Also:System.currentTimeMillis()
Random
public Random(long seed)

Creates a new random number generator using a single long seed: public
Random(long seed) { setSeed(seed); } Used by method next to hold the state of the
pseudorandom number generator. Parameters:seed - the initial seed.See
Also:setSeed(long)

Method Detail
next
protected int next(int bits)

Generates the next pseudorandom number. Subclass should override this, as this is
used by all other methods. The general contract of next is that it returns an int value
and if the argument bits is between 1 and 32 (inclusive), then that many low-order
bits of the returned value will be (approximately) independently chosen bit values,
each of which is (approximately) equally likely to be 0 or 1. The method next is
implemented by class Random as follows: synchronized protected int next(int bits) {
seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1); return (int)(seed >>> (48
- bits)); } This is a linear congruential pseudorandom number generator, as defined by
D. H. Lehmer and described by Donald E. Knuth in Volume 2: , section 3.2.1.
nextDouble
public double nextDouble()

Returns the next pseudorandom, uniformly distributed double value between 0.0 and
1.0 from this random number generator's sequence. The general contract of
nextDouble is that one double value, chosen (approximately) uniformly from the
range 0.0d (inclusive) to 1.0d (exclusive), is pseudorandomly generated and
returned. All 253 possible float values of the form mx2-53 , where m is a positive
integer less than 253, are produced with (approximately) equal probability. The
method nextDouble is implemented by class Random as follows: public double
nextDouble() { return (((long)next(26) << 27) + next(27)) / (double)(1L << 53); } The
hedge "approximately" is used in the foregoing description only because the next
method is only approximately an unbiased source of independently chosen bits. If it
were a perfect source or randomly chosen bits, then the algorithm shown would
choose double values from the stated range with perfect uniformity. [In early versions
of Java, the result was incorrectly calculated as: return (((long)next(27) << 27) +
next(27)) / (double)(1L << 54); This might seem to be equivalent, if not better, but in
fact it introduced a large nonuniformity because of the bias in the rounding of
floating-point numbers: it was three times as likely that the low-order bit of the
significand would be 0 than that it would be 1! This nonuniformity probably doesn't
matter much in practice, but we strive for perfection.]

Methods inherited from class java.lang.Object

168

Overview (Codename One API)


nextFloat
public float nextFloat()

Returns the next pseudorandom, uniformly distributed float value between 0.0 and
1.0 from this random number generator's sequence. The general contract of
nextFloat is that one float value, chosen (approximately) uniformly from the range 0.0f
(inclusive) to 1.0f (exclusive), is pseudorandomly generated and returned. All 224
possible float values of the form mx&nbsp2-24, where m is a positive integer less
than 224 , are produced with (approximately) equal probability. The method nextFloat
is implemented by class Random as follows: public float nextFloat() { return next(24) /
((float)(1 << 24)); } The hedge "approximately" is used in the foregoing description
only because the next method is only approximately an unbiased source of
independently chosen bits. If it were a perfect source or randomly chosen bits, then
the algorithm shown would choose float values from the stated range with perfect
uniformity. [In early versions of Java, the result was incorrectly calculated as: return
next(30) / ((float)(1 << 30)); This might seem to be equivalent, if not better, but in fact
it introduced a slight nonuniformity because of the bias in the rounding of
floating-point numbers: it was slightly more likely that the low-order bit of the
significand would be 0 than that it would be 1.]
nextInt
public int nextInt()

Returns the next pseudorandom, uniformly distributed int value from this random
number generator's sequence. The general contract of nextInt is that one int value is
pseudorandomly generated and returned. All 232 possible int values are produced
with (approximately) equal probability. The method nextInt is implemented by class
Random as follows: public int nextInt() { return next(32); }
nextInt
public int nextInt(int n)

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and


the specified value (exclusive), drawn from this random number generator's
sequence. The general contract of nextInt is that one int value in the specified range
is pseudorandomly generated and returned. All n possible int values are produced
with (approximately) equal probability. The method nextInt(int n) is implemented by
class Random as follows: public int nextInt(int n) { if (n<=0) throw new
IllegalArgumentException("n must be positive"); if ((n & -n) == n) // i.e., n is a power of
2 return (int)((n * (long)next(31)) >> 31); int bits, val; do { bits = next(31); val = bits %
n; } while(bits - val + (n-1) < 0); return val; } The hedge "approximately" is used in the
foregoing description only because the next method is only approximately an
unbiased source of independently chosen bits. If it were a perfect source of randomly
chosen bits, then the algorithm shown would choose int values from the stated range
with perfect uniformity. The algorithm rejects values that would result in an uneven
distribution (due to the fact that 2^31 is not divisible by n). The probability of a value
being rejected depends on n. The worst case is n=2^30+1, for which the probability of
a reject is 1/2, and the expected number of iterations before the loop terminates is 2.
The algorithm treats the case where n is a power of two specially: it returns the
correct number of high-order bits from the underlying pseudo-random number
generator. In the absence of special treatment, the correct number of low-order bits
would be returned. Linear congruential pseudo-random number generators such as
the one implemented by this class are known to have short periods in the sequence
of values of their low-order bits. Thus, this special case greatly increases the length
of the sequence of values returned by successive calls to this method if n is a small
power of two.
nextLong
public long nextLong()

Returns the next pseudorandom, uniformly distributed long value from this random
number generator's sequence. The general contract of nextLong is that one long
value is pseudorandomly generated and returned. All 264 possible long values are
produced with (approximately) equal probability. The method nextLong is
implemented by class Random as follows: public long nextLong() { return

Method Detail

169

Overview (Codename One API)


((long)next(32) << 32) + next(32); }
setSeed
public void setSeed(long seed)

Sets the seed of this random number generator using a single long seed. The general
contract of setSeed is that it alters the state of this random number generator object
so as to be in exactly the same state as if it had just been created with the argument
seed as a seed. The method setSeed is implemented by class Random as follows:
synchronized public void setSeed(long seed) { this.seed = (seed ^ 0x5DEECE66DL)
& ((1L << 48) - 1); } The implementation of setSeed by class Random happens to use
only 48 bits of the given seed. In general, however, an overriding method may use all
64 bits of the long argument as a seed value.

Method Detail

170

Overview (Codename One API)


java.util

Interface Queue<E>
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Subinterfaces:
Deque<E>
All Known Implementing Classes:
AbstractQueue, ArrayDeque, LinkedList, PriorityQueue

public interface
extends Collection<E>

This kind of collection provides advanced operations compared to basic collections, such as insertion,
extraction, and inspection.
Generally, a queue orders its elements by means of first-in-first-out. However, a priority queue orders
its elements according to a comparator specified or the elements' natural order. Furthermore, a stack
orders its elements last-in-first out.
A typical queue does not allow null to be inserted as its element, while some implementations such
as LinkedList allow it. But null should not be inserted even in these implementations, since the
method poll returns null to indicate that there is no element left in the queue.
does not provide blocking queue methods, which would block until the operation of the method
is allowed. See the BlockingQueue interface for information about blocking queue methods.
Queue

Method Summary
Modifier and
Type

Method and Description


element()

Gets but does not remove the element at the head of the queue.
offer(E o)

boolean

Inserts the specified element into the queue provided that the condition
allows such an operation.
peek()

Gets but does not remove the element at the head of the queue.
poll()

Gets and removes the element at the head of the queue, or returns null if
there is no element in the queue.

remove()

Gets and removes the element at the head of the queue.

Methods inherited from interface java.util.Collection


add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty,
iterator, remove, removeAll, retainAll, size, toArray, toArray

Method Detail

offer
boolean offer(E o)

Interface Queue<E>

171

Overview (Codename One API)


Inserts the specified element into the queue provided that the condition allows such
an operation. The method is generally preferable to Collection.add(E), since the
latter might throw an exception if the operation fails.
Parameters:
o - the specified element to insert into the queue.
Returns:
true if the operation succeeds and false if it fails.
poll
E poll()

Gets and removes the element at the head of the queue, or returns null if there is no
element in the queue.
Returns:
the element at the head of the queue or null if there is no element in the
queue.
remove
E remove()

Gets and removes the element at the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Returns:
the element at the head of the queue.
Throws:
NoSuchElementException - if there is no element in the queue.
peek
E peek()

Gets but does not remove the element at the head of the queue.
Returns:
the element at the head of the queue or null if there is no element in the
queue.
element
E element()

Gets but does not remove the element at the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Returns:
the element at the head of the queue.
Throws:
NoSuchElementException - if there is no element in the queue.

Method Detail

172

Overview (Codename One API)


java.util

Class PriorityQueue<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractQueue<E>

java.util.PriorityQueue<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>

public class
extends AbstractQueue<E>

A PriorityQueue holds elements on a priority heap, which orders the elements according to their
natural order or according to the comparator specified at construction time. If the queue uses natural
ordering, only elements that are comparable are permitted to be inserted into the queue.
The least element of the specified ordering is stored at the head of the queue and the greatest
element is stored at the tail of the queue.
A PriorityQueue is not synchronized. If multiple threads will have to access it concurrently, use the
PriorityBlockingQueue.

Constructor Summary
Constructor and Description
PriorityQueue()

Constructs a priority queue with an initial capacity of 11 and natural ordering.


PriorityQueue(Collection<? extends E> c)

Constructs a priority queue that contains the elements of a collection.


PriorityQueue(int initialCapacity)

Constructs a priority queue with the specified capacity and natural ordering.
PriorityQueue(int initialCapacity, Comparator<? super E> comparator)

Constructs a priority queue with the specified capacity and comparator.


PriorityQueue(PriorityQueue<? extends E> c)

Constructs a priority queue that contains the elements of another priority queue.
PriorityQueue(SortedSet<? extends E> c)

Constructs a priority queue that contains the elements of a sorted set.

Method Summary
Modifier and Type
boolean
void
Comparator<?
super E>
boolean

Method and Description


add(E o)

Adds the specified object to the priority queue.


clear()

Removes all the elements of the priority queue.


comparator()

Gets the comparator of the priority queue.


contains(Object object)

Answers if there is an element in this queue equals to the object.


iterator()

Iterator<E>

boolean

Class PriorityQueue<E>

Gets the iterator of the priority queue, which will not return elements in
any specified ordering.
offer(E o)

Inserts the element to the priority queue.

173

Overview (Codename One API)


peek()

Gets but does not remove the head of the queue.


poll()

Gets and removes the head of the queue.

boolean

remove(Object o)

Removes the specified object from the priority queue.


size()

int

Gets the size of the priority queue.

Object[]

toArray()

Returns all the elements in an array.


toArray(T[] array)

<T> T[]

Returns all the elements in an array, and the type of the result array is
the type of the argument array.

Methods inherited from class java.util.AbstractQueue


addAll, element, remove

Methods inherited from class java.util.AbstractCollection


containsAll, isEmpty, removeAll, retainAll, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Collection


containsAll, equals, hashCode, isEmpty, removeAll, retainAll

Constructor Detail
PriorityQueue
public PriorityQueue()

Constructs a priority queue with an initial capacity of 11 and natural ordering.


PriorityQueue
public PriorityQueue(int initialCapacity)

Constructs a priority queue with the specified capacity and natural ordering.
Parameters:
initialCapacity - the specified capacity.
Throws:
IllegalArgumentException - if the initialCapacity is less than 1.
PriorityQueue
public PriorityQueue(int initialCapacity,
Comparator<? super E> comparator)

Constructs a priority queue with the specified capacity and comparator.


Parameters:
initialCapacity - the specified capacity.
comparator - the specified comparator. If it is null, the natural ordering will be
used.
Throws:
IllegalArgumentException - if the initialCapacity is less than 1.

Method Summary

174

Overview (Codename One API)


PriorityQueue
public PriorityQueue(Collection<? extends E> c)

Constructs a priority queue that contains the elements of a collection. The


constructed priority queue has the initial capacity of 110% of the size of the collection.
The queue uses natural ordering to order its elements.
Parameters:
c - the collection whose elements will be added to the priority queue to be
constructed.
Throws:
ClassCastException - if any of the elements in the collection are not
comparable.
NullPointerException - if any of the elements in the collection are null.
PriorityQueue
public PriorityQueue(PriorityQueue<? extends E> c)

Constructs a priority queue that contains the elements of another priority queue. The
constructed priority queue has the initial capacity of 110% of the specified one. Both
priority queues have the same comparator.
Parameters:
c - the priority queue whose elements will be added to the priority queue to
be constructed.
PriorityQueue
public PriorityQueue(SortedSet<? extends E> c)

Constructs a priority queue that contains the elements of a sorted set. The
constructed priority queue has the initial capacity of 110% of the size of the sorted
set. The priority queue will have the same comparator as the sorted set.
Parameters:
c - the sorted set whose elements will be added to the priority queue to be
constructed.

Method Detail
iterator
public Iterator<E> iterator()

Gets the iterator of the priority queue, which will not return elements in any specified
ordering.
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
the iterator of the priority queue.
size
public int size()

Gets the size of the priority queue. If the size of the queue is greater than the
Integer.MAX, then it returns Integer.MAX.
Specified by:
size in interface Collection<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the size of the priority queue.

Constructor Detail

175

Overview (Codename One API)


clear
public void clear()

Removes all the elements of the priority queue.


Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractQueue<E>
See Also:
AbstractCollection.iterator(), AbstractCollection.isEmpty(),
AbstractCollection.size()

offer
public boolean offer(E o)

Inserts the element to the priority queue.


Parameters:
o - the element to add to the priority queue.
Returns:
always true
Throws:
ClassCastException - if the element cannot be compared with the elements
in the priority queue using the ordering of the priority queue.
NullPointerException - if o is null.
poll
public E poll()

Gets and removes the head of the queue.


Returns:
the head of the queue or null if the queue is empty.
peek
public E peek()

Gets but does not remove the head of the queue.


Returns:
the head of the queue or null if the queue is empty.
comparator
public Comparator<? super E> comparator()

Gets the comparator of the priority queue.


Returns:
the comparator of the priority queue or null if the natural ordering is used.
remove
public boolean remove(Object o)

Removes the specified object from the priority queue.


Specified by:
remove in interface Collection<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
o - the object to be removed.
Returns:
true if the object was in the priority queue, false if the object was not in the
priority queue.
add
public boolean add(E o)

Adds the specified object to the priority queue.

Method Detail

176

Overview (Codename One API)


Specified by:
add in interface Collection<E>
Overrides:
add in class AbstractQueue<E>
Parameters:
o - the object to be added.
Returns:
always true.
Throws:
ClassCastException - if the element cannot be compared with the elements
in the priority queue using the ordering of the priority queue.
NullPointerException - if o is null.
contains
public boolean contains(Object object)

Answers if there is an element in this queue equals to the object.


Specified by:
contains in interface Collection<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this Collection, false otherwise.
See Also:
AbstractCollection.contains(java.lang.Object)

toArray
public Object[] toArray()

Returns all the elements in an array. The result is a copy of all the elements.
Specified by:
toArray in interface Collection<E>
Overrides:
toArray in class AbstractCollection<E>
Returns:
the Array of all the elements
See Also:
AbstractCollection.toArray()

toArray
public <T> T[] toArray(T[] array)

Returns all the elements in an array, and the type of the result array is the type of the
argument array. If the argument array is big enough, the elements from the queue will
be stored in it(element immediately following the end of the queue is set to null, if
any); otherwise, it will return a new array with the size of the argument array and size
of the queue.
Specified by:
toArray in interface Collection<E>
Overrides:
toArray in class AbstractCollection<E>
Type Parameters:
T - the type of elements in the array
Parameters:
array - the array stores all the elements from the queue, if it has enough
space; otherwise, a new array of the same type and the size of the queue will
be used
Returns:
the Array of all the elements
Throws:
ArrayStoreException - if the type of the argument array is not compatible
with every element in the queue
NullPointerException - if the argument array is null

Method Detail

177

Overview (Codename One API)


See Also:
java.util.AbstractCollection#toArray(T[])

Method Detail

178

Overview (Codename One API)


java.util

Interface Observer

public interface
Observer is
Observable

the interface to be implemented by objects that receive notification of updates on an


object.

See Also:
Observable

Method Summary
Modifier and
Type

update(Observable observable, Object data)


This method is called if the specified Observable object's notifyObservers
method is called (because the Observable object has been updated.

void

Method and Description

Method Detail
update
void update(Observable observable,
Object data)

This method is called if the specified Observable object's notifyObservers method is


called (because the Observable object has been updated.
Parameters:
observable - the Observable object.
data - the data passed to Observable.notifyObservers(Object).

Interface Observer

179

Overview (Codename One API)


java.util

Class Observable
java.lang.Object

java.util.Observable

public class
extends Object

Observable is used to notify a group of Observer objects when a change occurs. On creation, the set
of observers is empty. After a change occurred, the application can call the notifyObservers()
method. This will cause the invocation of the update() method of all registered Observers. The order
of invocation is not specified. This implementation will call the Observers in the order they registered.
Subclasses are completely free in what order they call the update methods.
See Also:
Observer

Constructor Summary
Constructor and Description
Observable()

Constructs a new Observable object.

Method Summary
Modifier and
Type

Method and Description


addObserver(Observer observer)

void

Adds the specified observer to the list of observers.

protected
void

clearChanged()

Clears the changed flag for this Observable.


countObservers()

int

Returns the number of observers registered to this Observable.


deleteObserver(Observer observer)

void

Removes the specified observer from the list of observers.


deleteObservers()

void

Removes all observers from the list of observers.

boolean

hasChanged()

Returns the changed flag for this Observable.

void

notifyObservers()
If hasChanged() returns true,

void

notifyObservers(Object data)
If hasChanged() returns true, calls

calls the update() method for every observer in


the list of observers using null as the argument.
the update() method for every Observer in
the list of observers using the specified argument.

protected
void

setChanged()

Sets the changed flag for this Observable.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

180

Overview (Codename One API)


Constructor

Detail

Observable
public Observable()

Constructs a new Observable object.

Method Detail
addObserver
public void addObserver(Observer observer)

Adds the specified observer to the list of observers. If it is already registered, it is not
added a second time.
Parameters:
observer - the Observer to add.
clearChanged
protected void clearChanged()

Clears the changed flag for this Observable. After calling clearChanged(),
hasChanged() will return false.
countObservers
public int countObservers()

Returns the number of observers registered to this Observable.


Returns:
the number of observers.
deleteObserver
public void deleteObserver(Observer observer)

Removes the specified observer from the list of observers. Passing null won't do
anything.
Parameters:
observer - the observer to remove.
deleteObservers
public void deleteObservers()

Removes all observers from the list of observers.


hasChanged
public boolean hasChanged()

Returns the changed flag for this Observable.


Returns:
true when the changed flag for this Observable is set, false otherwise.
notifyObservers
public void notifyObservers()

If hasChanged() returns true, calls the update() method for every observer in the list
of observers using null as the argument. Afterwards, calls clearChanged().
Equivalent to calling notifyObservers(null).
notifyObservers
public void notifyObservers(Object data)

If hasChanged() returns true, calls the update() method for every Observer in the list
of observers using the specified argument. Afterwards calls clearChanged().

Constructor Detail

181

Overview (Codename One API)

Parameters:
data

- the argument passed to update().

setChanged
protected void setChanged()

Sets the changed flag for this Observable. After calling setChanged(), hasChanged()
will return true.

Method Detail

182

Overview (Codename One API)


java.util

Class NoSuchElementException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.util.NoSuchElementException

public class
extends RuntimeException

Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in
the enumeration. Since: JDK1.0, CLDC 1.0 Version: 12/17/01 (CLDC 1.1) See Also:Enumeration,
Enumeration.nextElement()

Constructor Summary
Constructor and Description
NoSuchElementException()

Constructs a NoSuchElementException with null as its error message string.


NoSuchElementException(String s)

Constructs a NoSuchElementException, saving a reference to the error message string s for


later retrieval by the getMessage method.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NoSuchElementException
public NoSuchElementException()

Constructs a NoSuchElementException with null as its error message string.


NoSuchElementException
public NoSuchElementException(String s)

Constructs a NoSuchElementException, saving a reference to the error message


string s for later retrieval by the getMessage method. Parameters:s - the detail
message.

Class NoSuchElementException

183

Overview (Codename One API)


java.util

Interface NavigableSet<E>
Type Parameters:
E - the type of element
All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>, SortedSet<E>
All Known Implementing Classes:
TreeSet

public interface
extends SortedSet<E>

NavigableSet is a SortedSet with navigation methods answering the closest matches for specified
item.
Since:
1.6

Method Summary
Modifier and
Type

Method and Description


ceiling(E e)

Iterator<E>
NavigableSet<E>

Answers the smallest element bigger than or equal to the specified one,
or null if no such element.
descendingIterator()

Answers a descending iterator of this set.


descendingSet()

Answers a reverse order view of this set.


floor(E e)

Answers the biggest element less than or equal to the specified one, or
null if no such element.
headSet(E end, boolean endInclusive)

NavigableSet<E>

Answers a NavigableSet of the specified portion of this set which


contains elements less than (or equal to, depends on endInclusive) the
end element.
higher(E e)

Answers the smallest element bigger than the specified one, or null if no
such element.
lower(E e)

E
E

Answers the biggest element less than the specified one, or null if no
such element.
pollFirst()

Deletes and answers the smallest element, or null if the set is empty.
pollLast()

Deletes and answers the biggest element, or null if the set is empty.
subSet(E start, boolean startInclusive, E end,
boolean endInclusive)

NavigableSet<E>

Answers a NavigableSet of the specified portion of this set which


contains elements greater (or equal to, depends on startInclusive) the
start element but less than (or equal to, depends on endInclusive) the
end element.
tailSet(E start, boolean startInclusive)

NavigableSet<E>

Constructor Detail

Answers a NavigableSet of the specified portion of this set which


contains elements greater (or equal to, depends on startInclusive) the
start element.

184

Overview (Codename One API)


Methods

inherited from interface java.util.SortedSet

comparator, first, headSet, last, subSet, tailSet

Methods inherited from interface java.util.Set


add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty,
iterator, remove, removeAll, retainAll, size, toArray, toArray

Method Detail
pollFirst
E pollFirst()

Deletes and answers the smallest element, or null if the set is empty.
Returns:
the smallest element, or null if the set is empty
pollLast
E pollLast()

Deletes and answers the biggest element, or null if the set is empty.
Returns:
the biggest element, or null if the set is empty
higher
E higher(E e)

Answers the smallest element bigger than the specified one, or null if no such
element.
Parameters:
e - the specified element
Returns:
the smallest element bigger than the specified one, or null if no such element
Throws:
ClassCastException - if the element cannot be compared with the ones in the
set
NullPointerException - if the element is null and the set can not contain null
ceiling
E ceiling(E e)

Answers the smallest element bigger than or equal to the specified one, or null if no
such element.
Parameters:
e - the specified element
Returns:
the smallest element bigger than or equal to the specified one, or null if no
such element
Throws:
ClassCastException - if the element cannot be compared with the ones in the
set
NullPointerException - if the element is null and the set can not contain null
lower
E lower(E e)

Answers the biggest element less than the specified one, or null if no such element.
Parameters:
e - the specified element

Methods inherited from interface java.util.SortedSet

185

Overview (Codename One API)


Returns:
the biggest element less than the specified one, or null if no such element
Throws:
ClassCastException - if the element cannot be compared with the ones in the
set
NullPointerException - if the element is null and the set can not contain null
floor
E floor(E e)

Answers the biggest element less than or equal to the specified one, or null if no such
element.
Parameters:
e - the specified element
Returns:
the biggest element less than or equal to the specified one, or null if no such
element
Throws:
ClassCastException - if the element cannot be compared with the ones in the
set
NullPointerException - if the element is null and the set can not contain null
descendingIterator
Iterator<E> descendingIterator()

Answers a descending iterator of this set.


Returns:
the descending iterator
descendingSet
NavigableSet<E> descendingSet()

Answers a reverse order view of this set.


Returns:
the reverse order view
subSet
NavigableSet<E> subSet(E start,
boolean startInclusive,
E end,
boolean endInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
greater (or equal to, depends on startInclusive) the start element but less than (or
equal to, depends on endInclusive) the end element. The returned NavigableSet is
backed by this set so changes to one are reflected by the other.
Parameters:
start - the start element
startInclusive - true if the start element is in the returned set
end - the end element
endInclusive - true if the end element is in the returned set
Returns:
the subset
Throws:
ClassCastException - when the start or end object cannot be compared with
the elements in this set
NullPointerException - when the start or end object is null and the set
cannot contain null
IllegalArgumentException - when the start is bigger than end; or start or end
is out of range and the set has a range

Method Detail

186

Overview (Codename One API)


headSet
NavigableSet<E> headSet(E end,
boolean endInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
less than (or equal to, depends on endInclusive) the end element. The returned
NavigableSet is backed by this set so changes to one are reflected by the other.
Parameters:
end - the end element
endInclusive - true if the end element is in the returned set
Returns:
the subset
Throws:
ClassCastException - when the end object cannot be compared with the
elements in this set
NullPointerException - when the end object is null and the set cannot
contain handle null
IllegalArgumentException - when end is out of range and the set has a
range
tailSet
NavigableSet<E> tailSet(E start,
boolean startInclusive)

Answers a NavigableSet of the specified portion of this set which contains elements
greater (or equal to, depends on startInclusive) the start element. The returned
NavigableSet is backed by this set so changes to one are reflected by the other.
Parameters:
start - the start element
startInclusive - true if the start element is in the returned set
Returns:
the subset
Throws:
ClassCastException - when the start object cannot be compared with the
elements in this set
NullPointerException - when the start object is null and the set cannot
contain null
IllegalArgumentException - when start is out of range and the set has a
range

Method Detail

187

Overview (Codename One API)


java.util

Interface NavigableMap<K,V>
Type Parameters:
K - the type of key
V - the type of value
All Superinterfaces:
Map<K,V>, SortedMap<K,V>
All Known Implementing Classes:
TreeMap

public interface
extends SortedMap<K,V>

NavigableMap is a SortedMap with navigation methods answering the closest matches for specified
item.
Since:
1.6

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Method Summary
Modifier and Type

Method and Description


ceilingEntry(K key)

Map.Entry<K,V>

Answers an entry related with the smallest key greater than or equal to
the specified key, or null if no such key.
ceilingKey(K key)

NavigableSet<K>
NavigableMap<K,V>
Map.Entry<K,V>

Answers the smallest key greater than or equal to the specified key, or
null if no such key.
descendingKeySet()

Answers a NavigableSet view of the keys in descending order.


descendingMap()

Answers a reverse order view of the map.


firstEntry()

Answers the entry with the smallest key, or null if the map is empty.
floorEntry(K key)

Map.Entry<K,V>

Answers an entry related with the biggest key less than or equal to the
specified key, or null if no such key.
floorKey(K key)

Answers the biggest key less than or equal to the specified key, or null
if no such key.
headMap(K endKey, boolean inclusive)

NavigableMap<K,V>

Answers a view of the head of the map whose keys are smaller than
(or equal to, depends on inclusive argument) endKey.
higherEntry(K key)

Map.Entry<K,V>

Answers an entry related with the smallest key greater than the
specified key, or null if no such key.
higherKey(K key)

Answers the smallest key greater than the specified key, or null if no
such key.

Map.Entry<K,V>

lastEntry()

Interface NavigableMap<K,V>

188

Overview (Codename One API)


Answers the entry with the biggest key, or null if the map is empty.
lowerEntry(K key)
Map.Entry<K,V>

Answers an entry related with the biggest key less than the specified
key, or null if no such key.
lowerKey(K key)

Answers the biggest key less than the specified key, or null if no such
key.

NavigableSet<K>

navigableKeySet()

Answers a NavigableSet view of the keys in ascending order.


pollFirstEntry()

Map.Entry<K,V>

Deletes and answers the entry with the smallest key, or null if the map
is empty.
pollLastEntry()

Map.Entry<K,V>

NavigableMap<K,V>

Deletes and answers the entry with the biggest key, or null if the map
is empty.
subMap(K startKey, boolean startInclusive, K endKey,
boolean endInclusive)

Answers a view of part of the map whose keys is from startKey to


endKey.
tailMap(K startKey, boolean inclusive)

NavigableMap<K,V>

Answers a view of the tail of the map whose keys are bigger than (or
equal to, depends on inclusive argument) startKey.

Methods inherited from interface java.util.SortedMap


comparator, firstKey, headMap, lastKey, subMap, tailMap

Methods inherited from interface java.util.Map


clear, containsKey, containsValue, entrySet, equals, get, hashCode,
isEmpty, keySet, put, putAll, remove, size, values

Method Detail
firstEntry
Map.Entry<K,V> firstEntry()

Answers the entry with the smallest key, or null if the map is empty.
Returns:
the entry with the smallest key, or null if the map is empty
lastEntry
Map.Entry<K,V> lastEntry()

Answers the entry with the biggest key, or null if the map is empty.
Returns:
the entry with the biggest key, or null if the map is empty
pollFirstEntry
Map.Entry<K,V> pollFirstEntry()

Deletes and answers the entry with the smallest key, or null if the map is empty.
Returns:
the entry with the smallest key, or null if the map is empty
pollLastEntry
Map.Entry<K,V> pollLastEntry()

Deletes and answers the entry with the biggest key, or null if the map is empty.
Returns:
the entry with the biggest key, or null if the map is empty

Method Summary

189

Overview (Codename One API)


ceilingEntry
Map.Entry<K,V> ceilingEntry(K key)

Answers an entry related with the smallest key greater than or equal to the specified
key, or null if no such key.
Parameters:
key - the key
Returns:
the entry, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
ceilingKey
K ceilingKey(K key)

Answers the smallest key greater than or equal to the specified key, or null if no such
key.
Parameters:
key - the key
Returns:
the smallest key greater than or equal to key, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
higherEntry
Map.Entry<K,V> higherEntry(K key)

Answers an entry related with the smallest key greater than the specified key, or null
if no such key.
Parameters:
key - the key
Returns:
the entry, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
higherKey
K higherKey(K key)

Answers the smallest key greater than the specified key, or null if no such key.
Parameters:
key - the key
Returns:
the smallest key greater than key, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
floorEntry
Map.Entry<K,V> floorEntry(K key)

Answers an entry related with the biggest key less than or equal to the specified key,
or null if no such key.
Parameters:
key - the key
Returns:
the entry, or null if no such key

Method Detail

190

Overview (Codename One API)


Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key

floorKey
K floorKey(K key)

Answers the biggest key less than or equal to the specified key, or null if no such key.
Parameters:
key - the key
Returns:
the biggest key less than or equal to key, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
lowerEntry
Map.Entry<K,V> lowerEntry(K key)

Answers an entry related with the biggest key less than the specified key, or null if no
such key.
Parameters:
key - the key
Returns:
the entry, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
lowerKey
K lowerKey(K key)

Answers the biggest key less than the specified key, or null if no such key.
Parameters:
key - the key
Returns:
the biggest key less than key, or null if no such key
Throws:
ClassCastException - if the key cannot be compared with the keys in the map
NullPointerException - if the key is null and the map can not contain null key
navigableKeySet
NavigableSet<K> navigableKeySet()

Answers a NavigableSet view of the keys in ascending order.


Returns:
the navigable set view
descendingMap
NavigableMap<K,V> descendingMap()

Answers a reverse order view of the map.


Returns:
the reverse order view of the map
descendingKeySet
NavigableSet<K> descendingKeySet()

Answers a NavigableSet view of the keys in descending order.


Returns:
the navigable set view

Method Detail

191

Overview (Codename One API)


subMap
NavigableMap<K,V> subMap(K startKey,
boolean startInclusive,
K endKey,
boolean endInclusive)

Answers a view of part of the map whose keys is from startKey to endKey.
Parameters:
startKey - the start key
startInclusive - true if the start key is in the returned map
endKey - the end key
endInclusive - true if the end key is in the returned map
Returns:
the sub-map view
Throws:
ClassCastException - when the class of the start or end key is inappropriate
for this SubMap
NullPointerException - when the start or end key is null and this SortedMap
does not support null keys
IllegalArgumentException - when the start key is greater than the end key
headMap
NavigableMap<K,V> headMap(K endKey,
boolean inclusive)

Answers a view of the head of the map whose keys are smaller than (or equal to,
depends on inclusive argument) endKey.
Parameters:
endKey - the end key
inclusive - true if the end key is in the returned map
Returns:
the head-map view
Throws:
ClassCastException - when the class of the end key is inappropriate for this
SubMap
NullPointerException - when the end key is null and this SortedMap does
not support null keys
IllegalArgumentException - when the map is range-limited and end key is
out of the range of the map
tailMap
NavigableMap<K,V> tailMap(K startKey,
boolean inclusive)

Answers a view of the tail of the map whose keys are bigger than (or equal to,
depends on inclusive argument) startKey.
Parameters:
startKey - the start key
inclusive - true if the start key is in the returned map
Returns:
the tail-map view
Throws:
ClassCastException - when the class of the start key is inappropriate for this
SubMap
NullPointerException - when the start key is null and this SortedMap does
not support null keys
IllegalArgumentException - when the map is range-limited and start key is
out of the range of the map

Method Detail

192

Overview (Codename One API)


java.util

Interface Map<K,V>
All Known Subinterfaces:
NavigableMap<K,V>, SortedMap<K,V>
All Known Implementing Classes:
AbstractMap, HashMap, Hashtable, IdentityHashMap, LinkedHashMap, Properties, TreeMap,
WeakHashMap

public interface

A Map is a data structure consisting of a set of keys and values in which each key is mapped to a
single value. The class of the objects used as keys is declared when the Map is declared, as is the
class of the corresponding values.
A Map provides helper methods to iterate through all of the keys contained in it, as well as various
methods to access and update the key/value pairs.

Nested Class Summary


Modifier and Type
static interface

Interface and Description


Map.Entry<K,V>
Map.Entry is a key/value

mapping contained in a Map.

Method Summary
Modifier and Type
void

Method and Description


clear()

Removes all elements from this Map, leaving it empty.

boolean

containsKey(Object key)
Returns whether this Map contains

the specified key.

boolean

containsValue(Object value)
Returns whether this Map contains

the specified value.

Set<Map.Entry<K,V>>

entrySet()
Returns a Set

containing all of the mappings in this Map.

equals(Object object)
boolean

V
int
boolean
Set<K>
V
void
V
int
Collection<V>

Interface Map<K,V>

Compares the argument to the receiver, and returns true if the


specified object is a Map and both Maps contain the same mappings.
get(Object key)

Returns the value of the mapping with the specified key.


hashCode()

Returns an integer hash code for the receiver.


isEmpty()

Returns whether this map is empty.


keySet()

Returns a set of the keys contained in this Map.


put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> map)
Copies every mapping in the specified Map to this Map.
remove(Object key)

Removes a mapping with the specified key from this Map.


size()

Returns the number of mappings in this Map.


values()

193

Overview (Codename One API)


Returns a Collection of the values contained in this Map.

Method Detail
clear
void clear()

Removes all elements from this Map, leaving it empty.


Throws:
java.lang.UnsupportedOperationException - if removing elements from this
Map is not supported.
See Also:
isEmpty(), size()
containsKey
boolean containsKey(Object key)

Returns whether this Map contains the specified key.


Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.
containsValue
boolean containsValue(Object value)

Returns whether this Map contains the specified value.


Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.
entrySet
Set<Map.Entry<K,V>> entrySet()

Returns a Set containing all of the mappings in this Map. Each mapping is an instance
of Map.Entry. As the Set is backed by this Map, changes in one will be reflected in the
other.
Returns:
a set of the mappings
equals
boolean equals(Object object)

Compares the argument to the receiver, and returns true if the specified object is a
Map and both Maps contain the same mappings.
Overrides:
equals in class Object
Parameters:
object - the Object to compare with this Object.
Returns:
boolean true if the Object is the same as this Object false if it is different
from this Object.
See Also:
hashCode(), entrySet()
get
V get(Object key)

Returns the value of the mapping with the specified key.


Parameters:
key - the key.
Returns:

Method Summary

194

Overview (Codename One API)


the value of the mapping with the specified key, or null if no mapping for the
specified key is found.
hashCode
int hashCode()

Returns an integer hash code for the receiver. Objects which are equal return the
same value for this method.
Overrides:
hashCode in class Object
Returns:
the receiver's hash.
See Also:
equals(Object)

isEmpty
boolean isEmpty()

Returns whether this map is empty.


Returns:
true if this map has no elements, false otherwise.
See Also:
size()

keySet
Set<K> keySet()

Returns a set of the keys contained in this Map. The Set is backed by this Map so
changes to one are reflected by the other. The Set does not support adding.
Returns:
a set of the keys.
put
V put(K key,
V value)

Maps the specified key to the specified value.


Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no mapping.
Throws:
java.lang.UnsupportedOperationException - if adding to this Map is not
supported.
ClassCastException - if the class of the key or value is inappropriate for this
Map.
IllegalArgumentException - if the key or value cannot be added to this Map.
NullPointerException - if the key or value is null and this Map does not
support null keys or values.
putAll
void putAll(Map<? extends K,? extends V> map)

Copies every mapping in the specified Map to this Map.


Parameters:
map - the Map to copy mappings from.
Throws:
java.lang.UnsupportedOperationException - if adding to this Map is not
supported.
ClassCastException - if the class of a key or a value of the specified Map is
inappropriate for this Map.
IllegalArgumentException - if a key or value cannot be added to this Map.
NullPointerException - if a key or value is null and this Map does not
support null keys or values.

Method Detail

195

Overview (Codename One API)


remove
V remove(Object key)

Removes a mapping with the specified key from this Map.


Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
Throws:
java.lang.UnsupportedOperationException - if removing from this Map is not
supported.
size
int size()

Returns the number of mappings in this Map.


Returns:
the number of mappings in this Map.
values
Collection<V> values()

Returns a Collection of the values contained in this Map. The Collection is backed
by this Map so changes to one are reflected by the other. The Collection supports
Collection.remove(java.lang.Object),
Collection.removeAll(java.util.Collection<?>),
Collection.retainAll(java.util.Collection<?>), and Collection.clear()
operations, and it does not support Collection.add(E) or
Collection.addAll(java.util.Collection<? extends E>) operations.
This method returns a Collection which is the subclass of AbstractCollection. The
AbstractCollection.iterator() method of this subclass returns a "wrapper object"
over the iterator of this Map's entrySet(). The AbstractCollection.size() method
wraps this Map's size() method and the
AbstractCollection.contains(java.lang.Object) method wraps this Map's
containsValue(java.lang.Object) method.
The collection is created when this method is called at first time and returned in
response to all subsequent calls. This method may return different Collection when
multiple calls to this method, since it has no synchronization performed.
Returns:
a collection of the values contained in this map.

Method Detail

196

Overview (Codename One API)


java.util

Interface Map.Entry<K,V>
All Known Implementing Classes:
AbstractMap.SimpleEntry, AbstractMap.SimpleImmutableEntry
Enclosing interface:
Map<K,V>

public static interface


Map.Entry

is a key/value mapping contained in a Map.

Method Summary
Modifier and
Type

Method and Description


equals(Object object)

Compares the specified object to this Map.Entry and returns if they are
equal.

boolean

getKey()

Returns the key.


getValue()

Returns the value.


hashCode()

int

Returns an integer hash code for the receiver.


setValue(V object)

Sets the value of this entry to the specified value, replacing any existing
value.

Method Detail
equals
boolean equals(Object object)

Compares the specified object to this Map.Entry and returns if they are equal. To be
equal, the object must be an instance of Map.Entry and have the same key and
value.
Overrides:
equals in class Object
Parameters:
object - the Object to compare with this Object.
Returns:
true if the specified Object is equal to this Map.Entry, false otherwise.
See Also:
hashCode()

getKey
K getKey()

Returns the key.


Returns:
the key

Interface Map.Entry<K,V>

197

Overview (Codename One API)


getValue
V getValue()

Returns the value.


Returns:
the value
hashCode
int hashCode()

Returns an integer hash code for the receiver. Object which are equal return the
same value for this method.
Overrides:
hashCode in class Object
Returns:
the receiver's hash code.
See Also:
equals(Object)

setValue
V setValue(V object)

Sets the value of this entry to the specified value, replacing any existing value.
Parameters:
object - the new value to set.
Returns:
object the replaced value of this entry.

Method Detail

198

Overview (Codename One API)


java.util

Interface ListIterator<E>
All Superinterfaces:
Iterator<E>

public interface
extends Iterator<E>

An ListIterator is used to sequence over a List of objects. ListIterator can move backwards or forwards
through the list.

Method Summary
Modifier and
Type

Method and Description


add(E object)

void

Inserts the specified object into the list between next and previous.

boolean
boolean

hasNext()

Returns whether there are more elements to iterate.


hasPrevious()

Returns whether there are previous elements to iterate.


next()

Returns the next object in the iteration.


nextIndex()

int

Returns the index of the next object in the iteration.


previous()

Returns the previous object in the iteration.


previousIndex()

int

Returns the index of the previous object in the iteration.


remove()

void

Removes the last object returned by next or previous from the list.
set(E object)

Replaces the last object returned by next or previous with the specified
object.

void

Method Detail

add
void add(E object)

Inserts the specified object into the list between next and previous. The object
inserted will be the previous object.
Parameters:
object - the object to insert.
Throws:
java.lang.UnsupportedOperationException - if adding is not supported by
the list being iterated.
ClassCastException - if the class of the object is inappropriate for the list.
IllegalArgumentException - if the object cannot be added to the list.

Interface ListIterator<E>

199

Overview (Codename One API)


hasNext
boolean hasNext()

Returns whether there are more elements to iterate.


Specified by:
hasNext in interface Iterator<E>
Returns:
true if there are more elements, false otherwise.
See Also:
next()

hasPrevious
boolean hasPrevious()

Returns whether there are previous elements to iterate.


Returns:
true if there are previous elements, false otherwise.
See Also:
previous()

next
E next()

Returns the next object in the iteration.


Specified by:
next in interface Iterator<E>
Returns:
the next object.
Throws:
NoSuchElementException - if there are no more elements.
See Also:
hasNext()

nextIndex
int nextIndex()

Returns the index of the next object in the iteration.


Returns:
the index of the next object, or the size of the list if the iterator is at the end.
Throws:
NoSuchElementException - if there are no more elements.
See Also:
next()

previous
E previous()

Returns the previous object in the iteration.


Returns:
the previous object.
Throws:
NoSuchElementException - if there are no previous elements.
See Also:
hasPrevious()

previousIndex
int previousIndex()

Returns the index of the previous object in the iteration.


Returns:
the index of the previous object, or -1 if the iterator is at the beginning.
Throws:
NoSuchElementException - if there are no previous elements.
See Also:
previous()

Method Detail

200

Overview (Codename One API)


remove
void remove()

Removes the last object returned by next or previous from the list.
Specified by:
remove in interface Iterator<E>
Throws:
java.lang.UnsupportedOperationException - if removing is not supported by
the list being iterated.
IllegalStateException - if next or previous have not been called, or remove
or add have already been called after the last call to next or previous.
set
void set(E object)

Replaces the last object returned by next or previous with the specified object.
Parameters:
object - the object to set.
Throws:
java.lang.UnsupportedOperationException - if setting is not supported by
the list being iterated
ClassCastException - if the class of the object is inappropriate for the list.
IllegalArgumentException - if the object cannot be added to the list.
IllegalStateException - if next or previous have not been called, or remove
or add have already been called after the last call to next or previous.

Method Detail

201

Overview (Codename One API)


java.util

Interface List<E>
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Implementing Classes:
AbstractList, AbstractSequentialList, ArrayList, LinkedList, Stack, Vector

public interface
extends Collection<E>

A List is a collection which maintains an ordering for its elements. Every element in the List has an
index. Each element can thus be accessed by its index, with the first index being zero. Normally,
Lists allow duplicate elements, as compared to Sets, where elements have to be unique.

Method Summary
Modifier and
Type
boolean
void
boolean

Method and Description


add(E object)

Adds the specified object at the end of this List.


add(int location, E object)

Inserts the specified object into this List at the specified location.
addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to the end of this List.
addAll(int location, Collection<? extends E> collection)

boolean

void
boolean

boolean

Inserts the objects in the specified collection at the specified location in


this List.
clear()

Removes all elements from this List, leaving it empty.


contains(Object object)
Tests whether this List contains

the specified object.

containsAll(Collection<?> collection)
Tests whether this List contains all objects

contained in the specified

collection.
equals(Object object)
boolean

E
int

int

Compares the given object with the List, and returns true if they
represent the same object using a class specific comparison.
get(int location)

Returns the element at the specified location in this List.


hashCode()

Returns the hash code for this List.


indexOf(Object object)
Searches this List for the

specified object and returns the index of the

first occurrence.
boolean
Iterator<E>

int

isEmpty()

Returns whether this List contains no elements.


iterator()

Returns an iterator on the elements of this List.


lastIndexOf(Object object)
Searches this List for the specified

object and returns the index of the

last occurrence.
ListIterator<E>
ListIterator<E>

Interface List<E>

listIterator()
Returns a List iterator

on the elements of this List.

listIterator(int location)

Returns a list iterator on the elements of this List.

202

Overview (Codename One API)


remove(int location)

Removes the object at the specified location from this List.


remove(Object object)

boolean

Removes the first occurrence of the specified object from this List.
removeAll(Collection<?> collection)
Removes all occurrences in this List of

boolean

each object in the specified

collection.
retainAll(Collection<?> collection)
Removes all objects from this List that are

boolean

not contained in the specified

collection.
set(int location, E object)

Replaces the element at the specified location in this List with the
specified object.

size()

int

Returns the number of elements in this List.


subList(int start, int end)
Returns a List of the specified

portion of this List from the given start


index to the end index minus one.

List<E>

toArray()

Object[]

Returns an array containing all elements contained in this List.


toArray(T[] array)

<T> T[]

Returns an array containing all elements contained in this List.

Method Detail

add
void add(int location,
E object)

Inserts the specified object into this List at the specified location. The object is
inserted before the current element at the specified location. If the location is equal to
the size of this List, the object is added at the end. If the location is smaller than the
size of this List, then all elements beyond the specified location are moved by one
position towards the end of the List.
Parameters:
location - the index at which to insert.
object - the object to add.
Throws:
java.lang.UnsupportedOperationException - if adding to this List is not
supported.
ClassCastException - if the class of the object is inappropriate for this List.
IllegalArgumentException - if the object cannot be added to this List.
IndexOutOfBoundsException - if location < 0 || location > size()
add
boolean add(E object)

Adds the specified object at the end of this List.


Specified by:
add in interface Collection<E>
Parameters:
object - the object to add.
Returns:
always true.
Throws:
java.lang.UnsupportedOperationException

- if adding to this List is not

supported.
ClassCastException

Method Summary

- if the class of the object is inappropriate for this List.

203

Overview (Codename One API)


IllegalArgumentException

- if the object cannot be added to this List.

addAll
boolean addAll(int location,
Collection<? extends E> collection)

Inserts the objects in the specified collection at the specified location in this List. The
objects are added in the order they are returned from the collection's iterator.
Parameters:
location - the index at which to insert.
collection - the collection of objects to be inserted.
Returns:
true if this List has been modified through the insertion, false otherwise (i.e.
if the passed collection was empty).
Throws:
java.lang.UnsupportedOperationException - if adding to this List is not
supported.
ClassCastException - if the class of an object is inappropriate for this List.
IllegalArgumentException - if an object cannot be added to this List.
IndexOutOfBoundsException - if location < 0 || > size()
addAll
boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to the end of this List. The objects are
added in the order in which they are returned from the collection's iterator.
Specified by:
addAll in interface Collection<E>
Parameters:
collection - the collection of objects.
Returns:
true if this List is modified, false otherwise (i.e. if the passed collection was
empty).
Throws:
java.lang.UnsupportedOperationException - if adding to this List is not
supported.
ClassCastException - if the class of an object is inappropriate for this List.
IllegalArgumentException - if an object cannot be added to this List.
clear
void clear()

Removes all elements from this List, leaving it empty.


Specified by:
clear in interface Collection<E>
Throws:
java.lang.UnsupportedOperationException - if removing from this List is
not supported.
See Also:
isEmpty(), size()
contains
boolean contains(Object object)

Tests whether this List contains the specified object.


Specified by:
contains in interface Collection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this List, false otherwise
containsAll
boolean containsAll(Collection<?> collection)

Tests whether this List contains all objects contained in the specified collection.
Specified by:

Method Detail

204

Overview (Codename One API)


containsAll

in interface Collection<E>

Parameters:
collection

- the collection of objects

Returns:
if all objects in the specified collection are elements of this List, false
otherwise.
true

equals
boolean equals(Object object)

Compares the given object with the List, and returns true if they represent the same
object using a class specific comparison. For Lists, this means that they contain the
same elements in exactly the same order.
Specified by:
equals in interface Collection<E>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
boolean true if the object is the same as this object, and false if it is different
from this object.
See Also:
hashCode()

get
E get(int location)

Returns the element at the specified location in this List.


Parameters:
location - the index of the element to return.
Returns:
the element at the specified location.
Throws:
IndexOutOfBoundsException - if location < 0 || >= size()
hashCode
int hashCode()

Returns the hash code for this List. It is calculated by taking each element' hashcode
and its position in the List into account.
Specified by:
hashCode in interface Collection<E>
Overrides:
hashCode in class Object
Returns:
the hash code of the List.
See Also:
Collection.equals(java.lang.Object)

indexOf
int indexOf(Object object)

Searches this List for the specified object and returns the index of the first
occurrence.
Parameters:
object - the object to search for.
Returns:
the index of the first occurrence of the object or -1 if the object was not found.
isEmpty
boolean isEmpty()

Returns whether this List contains no elements.


Specified by:
isEmpty in interface Collection<E>
Returns:

Method Detail

205

Overview (Codename One API)


true

if this List has no elements, false otherwise.

See Also:
size()

iterator
Iterator<E> iterator()

Returns an iterator on the elements of this List. The elements are iterated in the
same order as they occur in the List.
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Iterable<E>
Returns:
an iterator on the elements of this List.
See Also:
Iterator

lastIndexOf
int lastIndexOf(Object object)

Searches this List for the specified object and returns the index of the last
occurrence.
Parameters:
object - the object to search for.
Returns:
the index of the last occurrence of the object, or -1 if the object was not
found.
listIterator
ListIterator<E> listIterator()

Returns a List iterator on the elements of this List. The elements are iterated in the
same order that they occur in the List.
Returns:
a List iterator on the elements of this List
See Also:
ListIterator

listIterator
ListIterator<E> listIterator(int location)

Returns a list iterator on the elements of this List. The elements are iterated in the
same order as they occur in the List. The iteration starts at the specified location.
Parameters:
location - the index at which to start the iteration.
Returns:
a list iterator on the elements of this List.
Throws:
IndexOutOfBoundsException - if location < 0 || location > size()
See Also:
ListIterator

remove
E remove(int location)

Removes the object at the specified location from this List.


Parameters:
location - the index of the object to remove.
Returns:
the removed object.
Throws:
java.lang.UnsupportedOperationException - if removing from this List is
not supported.
IndexOutOfBoundsException - if location < 0 || >= size()

Method Detail

206

Overview (Codename One API)


remove
boolean remove(Object object)

Removes the first occurrence of the specified object from this List.
Specified by:
remove in interface Collection<E>
Parameters:
object - the object to remove.
Returns:
true if this List was modified by this operation, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this List is
not supported.
removeAll
boolean removeAll(Collection<?> collection)

Removes all occurrences in this List of each object in the specified collection.
Specified by:
removeAll in interface Collection<E>
Parameters:
collection - the collection of objects to remove.
Returns:
true if this List is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this List is
not supported.
retainAll
boolean retainAll(Collection<?> collection)

Removes all objects from this List that are not contained in the specified collection.
Specified by:
retainAll in interface Collection<E>
Parameters:
collection - the collection of objects to retain.
Returns:
true if this List is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this List is
not supported.
set
E set(int location,
E object)

Replaces the element at the specified location in this List with the specified object.
This operation does not change the size of the List.
Parameters:
location - the index at which to put the specified object.
object - the object to insert.
Returns:
the previous element at the index.
Throws:
java.lang.UnsupportedOperationException - if replacing elements in this
List is not supported.
ClassCastException - if the class of an object is inappropriate for this List.
IllegalArgumentException - if an object cannot be added to this List.
IndexOutOfBoundsException - if location < 0 || >= size()
size
int size()

Returns the number of elements in this List.


Specified by:

Method Detail

207

Overview (Codename One API)


size in interface Collection<E>
Returns:
the number of elements in this List.
subList
List<E> subList(int start,
int end)

Returns a List of the specified portion of this List from the given start index to the
end index minus one. The returned List is backed by this List so changes to it are
reflected by the other.
Parameters:
start - the index at which to start the sublist.
end - the index one past the end of the sublist.
Returns:
a list of a portion of this List.
Throws:
IndexOutOfBoundsException - if start < 0, start > end or end > size()
toArray
Object[] toArray()

Returns an array containing all elements contained in this List.


Specified by:
toArray in interface Collection<E>
Returns:
an array of the elements from this List.
toArray
<T> T[] toArray(T[] array)

Returns an array containing all elements contained in this List. If the specified array
is large enough to hold the elements, the specified array is used, otherwise an array
of the same type is created. If the specified array is used and is larger than this List,
the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Parameters:
array - the array.
Returns:
an array of the elements from this List.
Throws:
ArrayStoreException - if the type of an element in this List cannot be stored
in the type of the specified array.

Method Detail

208

Overview (Codename One API)


java.util

Class LinkedList<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>

java.util.AbstractSequentialList<E>

java.util.LinkedList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>

public class
extends AbstractSequentialList<E>
implements List<E>, Deque<E>

LinkedList is an implementation of List, backed by a linked list. All optional operations are supported,
adding, removing and replacing. The elements can be any objects.
Since:
1.2

Field Summary

Fields inherited from class java.util.AbstractList


modCount

Constructor Summary
Constructor and Description
LinkedList()

Constructs a new empty instance of LinkedList.


LinkedList(Collection<? extends E> collection)
Constructs a new instance of LinkedList that holds all
specified collection.

of the elements contained in the

Method Summary
Modifier and
Type
boolean
void
boolean

Method and Description


add(E object)

Adds the specified object at the end of this LinkedList.


add(int location, E object)

Inserts the specified object into this LinkedList at the specified location.
addAll(Collection<? extends E> collection)

Adds the objects in the specified Collection to this LinkedList.


addAll(int location, Collection<? extends E> collection)

boolean

void
void
void

Class LinkedList<E>

Inserts the objects in the specified collection at the specified location in


this LinkedList.
addFirst(E object)

Adds the specified object at the beginning of this LinkedList.


addLast(E object)

Adds the specified object at the end of this LinkedList.


clear()

Removes all elements from this LinkedList, leaving it empty.

209

Overview (Codename One API)


boolean
Iterator<E>
E
E
E
E

contains(Object object)
Searches this LinkedList for

the specified object.

descendingIterator()

Returns the iterator in reverse order, from tail to head.


element()

Gets but does not remove the element at the head of the queue.
get(int location)

Returns the element at the specified location in this list.


getFirst()

Returns the first element in this LinkedList.


getLast()

Returns the last element in this LinkedList.


indexOf(Object object)

int

int

Searches this list for the specified object and returns the index of the first
occurrence.
lastIndexOf(Object object)
Searches this LinkedList for the

specified object and returns the index

of the last occurrence.


ListIterator<E>

listIterator(int location)

Returns a ListIterator on the elements of this LinkedList.


offer(E o)

boolean

Inserts the specified element into the queue provided that the condition
allows such an operation.
offerFirst(E e)

boolean

Inserts an element at the head of this deque unless it would violate size
limit.
offerLast(E e)

boolean

E
E
E

Inserts an element at the tail of this deque unless it would violate size
limit.
peek()

Gets but does not remove the element at the head of the queue.
peekFirst()

Gets but not removes the head element of this deque.


peekLast()

Gets but not removes the tail element of this deque.


poll()

E
E
E

Gets and removes the element at the head of the queue, or returns null
if there is no element in the queue.
pollFirst()

Gets and removes the head element of this deque.


pollLast()

Gets and removes the tail element of this deque.


pop()

Pops the head element of the deque, just same as removeFirst().


push(E e)

void

E
E

Pushes the element to the deque(at the head of the deque), just same
as addFirst(E).
remove()

Gets and removes the element at the head of the queue.


remove(int location)

Removes the object at the specified location from this LinkedList.


remove(Object object)

boolean

E
boolean

Method Summary

Removes one instance of the specified object from this Collection if


one is contained (optional).
removeFirst()

Removes the first object from this LinkedList.


removeFirstOccurrence(Object o)

Removes the first equivalent element of the specified object.

210

Overview (Codename One API)


removeLast()

Removes the last object from this LinkedList.

boolean

removeLastOccurrence(Object o)

Removes the last equivalent element of the specified object.


set(int location, E object)

Replaces the element at the specified location in this LinkedList with


the specified object.

size()

int

Returns the number of elements in this LinkedList.


toArray()

Object[]

<T> T[]

Returns a new array containing all elements contained in this


LinkedList.
toArray(T[] contents)

Returns an array containing all elements contained in this LinkedList.

Methods inherited from class java.util.AbstractSequentialList


iterator

Methods inherited from class java.util.AbstractList


equals, hashCode, listIterator, removeRange, subList

Methods inherited from class java.util.AbstractCollection


containsAll, isEmpty, removeAll, retainAll, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll,
retainAll, subList

Constructor Detail
LinkedList
public LinkedList()

Constructs a new empty instance of LinkedList.


LinkedList
public LinkedList(Collection<? extends E> collection)

Constructs a new instance of LinkedList that holds all of the elements contained in
the specified collection. The order of the elements in this new LinkedList will be
determined by the iteration order of collection.
Parameters:
collection - the collection of elements to add.

Method Detail

add
public void add(int location,
E object)

Methods inherited from class java.util.AbstractSequentialList

211

Overview (Codename One API)


Inserts the specified object into this LinkedList at the specified location. The object is
inserted before any previous element at the specified location. If the location is equal
to the size of this LinkedList, the object is added at the end.
Specified by:
add in interface List<E>
Overrides:
add in class AbstractSequentialList<E>
Parameters:
location - the index at which to insert.
object - the object to add.
Throws:
IndexOutOfBoundsException - if location < 0 || >= size()
add
public boolean add(E object)

Adds the specified object at the end of this LinkedList.


Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
object - the object to add.
Returns:
always true
addAll
public boolean addAll(int location,
Collection<? extends E> collection)

Inserts the objects in the specified collection at the specified location in this
LinkedList. The objects are added in the order they are returned from the collection's
iterator.
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractSequentialList<E>
Parameters:
location - the index at which to insert.
collection - the collection of objects
Returns:
true if this LinkedList is modified, false otherwise.
Throws:
ClassCastException - if the class of an object is inappropriate for this list.
IllegalArgumentException - if an object cannot be added to this list.
IndexOutOfBoundsException - if location < 0 || > size()
addAll
public boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified Collection to this LinkedList.


Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects.
Returns:
true if this LinkedList is modified, false otherwise.

Method Detail

212

Overview (Codename One API)


addFirst
public void addFirst(E object)

Adds the specified object at the beginning of this LinkedList.


Specified by:
addFirst in interface Deque<E>
Parameters:
object - the object to add.
addLast
public void addLast(E object)

Adds the specified object at the end of this LinkedList.


Specified by:
addLast in interface Deque<E>
Parameters:
object - the object to add.
clear
public void clear()

Removes all elements from this LinkedList, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class AbstractList<E>
See Also:
List.isEmpty(), size
contains
public boolean contains(Object object)

Searches this LinkedList for the specified object.


Specified by:
contains in interface Collection<E>
Specified by:
contains in interface List<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this LinkedList, false otherwise
get
public E get(int location)

Description copied from class: AbstractList


Returns the element at the specified location in this list.
Specified by:
get in interface List<E>
Overrides:
get in class AbstractSequentialList<E>
Parameters:
location - the index of the element to return.
Returns:
the element at the specified index.
getFirst
public E getFirst()

Returns the first element in this LinkedList.


Specified by:

Method Detail

213

Overview (Codename One API)


getFirst in interface Deque<E>
Returns:
the first element.
Throws:
NoSuchElementException - if this LinkedList is empty.
getLast
public E getLast()

Returns the last element in this LinkedList.


Specified by:
getLast in interface Deque<E>
Returns:
the last element
Throws:
NoSuchElementException - if this LinkedList is empty
indexOf
public int indexOf(Object object)

Description copied from class: AbstractList


Searches this list for the specified object and returns the index of the first occurrence.
Specified by:
indexOf in interface List<E>
Overrides:
indexOf in class AbstractList<E>
Parameters:
object - the object to search for.
Returns:
the index of the first occurrence of the object, or -1 if it was not found.
lastIndexOf
public int lastIndexOf(Object object)

Searches this LinkedList for the specified object and returns the index of the last
occurrence.
Specified by:
lastIndexOf in interface List<E>
Overrides:
lastIndexOf in class AbstractList<E>
Parameters:
object - the object to search for
Returns:
the index of the last occurrence of the object, or -1 if it was not found.
listIterator
public ListIterator<E> listIterator(int location)

Returns a ListIterator on the elements of this LinkedList. The elements are iterated
in the same order that they occur in the LinkedList. The iteration starts at the
specified location.
Specified by:
listIterator in interface List<E>
Specified by:
listIterator in class AbstractSequentialList<E>
Parameters:
location - the index at which to start the iteration
Returns:
a ListIterator on the elements of this LinkedList
Throws:
IndexOutOfBoundsException - if location < 0 || >= size()
See Also:
ListIterator

Method Detail

214

Overview (Codename One API)


remove
public E remove(int location)

Removes the object at the specified location from this LinkedList.


Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractSequentialList<E>
Parameters:
location - the index of the object to remove
Returns:
the removed object
Throws:
IndexOutOfBoundsException - if location < 0 || >= size()
remove
public boolean remove(Object object)

Description copied from class: AbstractCollection


Removes one instance of the specified object from this Collection if one is contained
(optional). This implementation iterates over this Collection and tests for each
element e returned by the iterator, whether e is equal to the given object. If object !=
null then this test is performed using object.equals(e), otherwise using object ==
null. If an element equal to the given object is found, then the remove method is
called on the iterator and true is returned, false otherwise. If the iterator does not
support removing elements, an UnsupportedOperationException is thrown.
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
object - the object to remove.
Returns:
true if this Collection is modified, false otherwise.
removeFirst
public E removeFirst()

Removes the first object from this LinkedList.


Specified by:
removeFirst in interface Deque<E>
Returns:
the removed object.
Throws:
NoSuchElementException - if this LinkedList is empty.
removeLast
public E removeLast()

Removes the last object from this LinkedList.


Specified by:
removeLast in interface Deque<E>
Returns:
the removed object.
Throws:
NoSuchElementException - if this LinkedList is empty.
descendingIterator
public Iterator<E> descendingIterator()

Returns the iterator in reverse order, from tail to head.


Specified by:
descendingIterator in interface Deque<E>

Method Detail

215

Overview (Codename One API)


Returns:
the iterator in reverse order
Since:
1.6
See Also:
Deque.descendingIterator()

offerFirst
public boolean offerFirst(E e)

Inserts an element at the head of this deque unless it would violate size limit. It is
better than the addFirst(E) method in a size-limited deque, because the latter one
may fail to add the element only by throwing an exception.
Specified by:
offerFirst in interface Deque<E>
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails.
Since:
1.6
See Also:
Deque.offerFirst(java.lang.Object)

offerLast
public boolean offerLast(E e)

Inserts an element at the tail of this deque unless it would violate size limit. It is better
than the addLast(E) method in a size-limited deque, because the latter one may fail
to add the element only by throwing an exception.
Specified by:
offerLast in interface Deque<E>
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails
Since:
1.6
See Also:
Deque.offerLast(java.lang.Object)

peekFirst
public E peekFirst()

Gets but not removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
peekFirst in interface Deque<E>
Returns:
the head element or null if the deque is empty
Since:
1.6
See Also:
Deque.peekFirst()

peekLast
public E peekLast()

Gets but not removes the tail element of this deque. This method returns null if the
deque is empty.
Specified by:
peekLast in interface Deque<E>
Returns:
the tail element or null if the deque is empty
Since:

Method Detail

216

Overview (Codename One API)


1.6
See Also:
Deque.peekLast()

pollFirst
public E pollFirst()

Gets and removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
pollFirst in interface Deque<E>
Returns:
the head element or null if the deque is empty
Since:
1.6
See Also:
Deque.pollFirst()

pollLast
public E pollLast()

Gets and removes the tail element of this deque. This method returns null if the
deque is empty.
Specified by:
pollLast in interface Deque<E>
Returns:
the tail element or null if the deque is empty
Since:
1.6
See Also:
Deque.pollLast()

pop
public E pop()

Pops the head element of the deque, just same as removeFirst().


Specified by:
pop in interface Deque<E>
Returns:
the head element
Since:
1.6
See Also:
Deque.pop()

push
public void push(E e)

Pushes the element to the deque(at the head of the deque), just same as addFirst(E).
Specified by:
push in interface Deque<E>
Parameters:
e - the element
Since:
1.6
See Also:
Deque.push(java.lang.Object)

removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)

Removes the first equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Specified by:
removeFirstOccurrence in interface Deque<E>
Parameters:

Method Detail

217

Overview (Codename One API)


o - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element.
Since:
1.6
See Also:
Deque.removeFirstOccurrence(java.lang.Object)

removeLastOccurrence
public boolean removeLastOccurrence(Object o)

Removes the last equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Specified by:
removeLastOccurrence in interface Deque<E>
Parameters:
o - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element.
Since:
1.6
See Also:
Deque.removeLastOccurrence(java.lang.Object)

set
public E set(int location,
E object)

Replaces the element at the specified location in this LinkedList with the specified
object.
Specified by:
set in interface List<E>
Overrides:
set in class AbstractSequentialList<E>
Parameters:
location - the index at which to put the specified object.
object - the object to add.
Returns:
the previous element at the index.
Throws:
ClassCastException - if the class of an object is inappropriate for this list.
IllegalArgumentException - if an object cannot be added to this list.
IndexOutOfBoundsException - if location < 0 || >= size()
size
public int size()

Returns the number of elements in this LinkedList.


Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this LinkedList.
offer
public boolean offer(E o)

Description copied from interface: Queue


Inserts the specified element into the queue provided that the condition allows such
an operation. The method is generally preferable to Collection.add(E), since the

Method Detail

218

Overview (Codename One API)


latter might throw an exception if the operation fails.
Specified by:
offer in interface Queue<E>
Parameters:
o - the specified element to insert into the queue.
Returns:
true if the operation succeeds and false if it fails.
poll
public E poll()

Description copied from interface: Queue


Gets and removes the element at the head of the queue, or returns null if there is no
element in the queue.
Specified by:
poll in interface Queue<E>
Returns:
the element at the head of the queue or null if there is no element in the
queue.
remove
public E remove()

Description copied from interface: Queue


Gets and removes the element at the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Specified by:
remove in interface Queue<E>
Returns:
the element at the head of the queue.
peek
public E peek()

Description copied from interface: Queue


Gets but does not remove the element at the head of the queue.
Specified by:
peek in interface Queue<E>
Returns:
the element at the head of the queue or null if there is no element in the
queue.
element
public E element()

Description copied from interface: Queue


Gets but does not remove the element at the head of the queue. Throws a
NoSuchElementException if there is no element in the queue.
Specified by:
element in interface Queue<E>
Returns:
the element at the head of the queue.
toArray
public Object[] toArray()

Returns a new array containing all elements contained in this LinkedList.


Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Returns:
an array of the elements from this LinkedList.

Method Detail

219

Overview (Codename One API)


toArray
public <T> T[] toArray(T[] contents)

Returns an array containing all elements contained in this LinkedList. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
LinkedList, the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Parameters:
contents - the array.
Returns:
an array of the elements from this LinkedList.
Throws:
ArrayStoreException - if the type of an element in this LinkedList cannot be
stored in the type of the specified array.

Method Detail

220

Overview (Codename One API)


java.util

Class LinkedHashSet<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractSet<E>

java.util.HashSet<E>

java.util.LinkedHashSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class
extends HashSet<E>
implements Set<E>

LinkedHashSet is a variant of HashSet. Its entries are kept in a doubly-linked list. The iteration order
is the order in which entries were inserted.
Null elements are allowed, and all the optional Set operations are supported.
Like HashSet, LinkedHashSet is not thread safe, so access by multiple threads must be synchronized
by an external mechanism such as Collections.synchronizedSet(Set).
Since:
1.4

Constructor Summary
Constructor and Description
LinkedHashSet()

Constructs a new empty instance of LinkedHashSet.


LinkedHashSet(Collection<? extends E> collection)
Constructs a new instance of LinkedHashSet containing

the unique elements in the specified

collection.
LinkedHashSet(int capacity)
Constructs a new instance of LinkedHashSet

with the specified capacity.

LinkedHashSet(int capacity, float loadFactor)


Constructs a new instance of LinkedHashSet with the

specified capacity and load factor.

Method Summary

Methods inherited from class java.util.HashSet


add, clear, contains, isEmpty, iterator, remove, size

Methods inherited from class java.util.AbstractSet


equals, hashCode, removeAll

Methods inherited from class java.util.AbstractCollection


addAll, containsAll, retainAll, toArray, toArray, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class LinkedHashSet<E>

221

Overview (Codename One API)


Methods

inherited from interface java.util.Set

add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty,


iterator, remove, removeAll, retainAll, size, toArray, toArray

Constructor Detail
LinkedHashSet
public LinkedHashSet()

Constructs a new empty instance of LinkedHashSet.


LinkedHashSet
public LinkedHashSet(int capacity)

Constructs a new instance of LinkedHashSet with the specified capacity.


Parameters:
capacity - the initial capacity of this LinkedHashSet.
LinkedHashSet
public LinkedHashSet(int capacity,
float loadFactor)

Constructs a new instance of LinkedHashSet with the specified capacity and load
factor.
Parameters:
capacity - the initial capacity.
loadFactor - the initial load factor.
LinkedHashSet
public LinkedHashSet(Collection<? extends E> collection)

Constructs a new instance of LinkedHashSet containing the unique elements in the


specified collection.
Parameters:
collection - the collection of elements to add.

Methods inherited from interface java.util.Set

222

Overview (Codename One API)


java.util

Class LinkedHashMap<K,V>
java.lang.Object

java.util.AbstractMap<K,V>

java.util.HashMap<K,V>

java.util.LinkedHashMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class
extends HashMap<K,V>
implements Map<K,V>

LinkedHashMap is a variant of HashMap. Its entries are kept in a doubly-linked list. The iteration order
is, by default, the order in which keys were inserted. Reinserting an already existing key doesn't
change the order. A key is existing if a call to containsKey would return true.
If the three argument constructor is used, and order is specified as true, the iteration will be in the
order that entries were accessed. The access order gets affected by put(), get(), putAll() operations,
but not by operations on the collection views.
Null elements are allowed, and all the optional map operations are supported.
Note: The implementation of LinkedHashMap is not synchronized. If one thread of several threads
accessing an instance modifies the map structurally, access to the map needs to be synchronized.
For insertion-ordered instances a structural modification is an operation that removes or adds an
entry. Access-ordered instances also are structurally modified by put(), get() and putAll() since these
methods change the order of the entries. Changes in the value of an entry are not structural changes.
The Iterator that can be created by calling the iterator method throws a
ConcurrentModificationException if the map is structurally changed while an iterator is used to
iterate over the elements. Only the remove method that is provided by the iterator allows for removal of
elements during iteration. It is not possible to guarantee that this mechanism works in all cases of
unsynchronized concurrent modification. It should only be used for debugging purposes.
Since:
1.4

Nested Class Summary

Nested classes/interfaces inherited from


class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Constructor Summary
Constructor and Description
LinkedHashMap()

Constructs a new empty LinkedHashMap instance.


LinkedHashMap(int s)
Constructs a new LinkedHashMap

Constructor Detail

instance with the specified capacity.

223

Overview (Codename One API)


LinkedHashMap(int s, float lf)
Constructs a new LinkedHashMap instance

with the specified capacity and load factor.

LinkedHashMap(int s, float lf, boolean order)


Constructs a new LinkedHashMap instance with the specified

capacity, load factor and a flag

specifying the ordering behavior.


LinkedHashMap(Map<? extends K,? extends V> m)
Constructs a new LinkedHashMap instance containing

the mappings from the specified map.

Method Summary
Modifier and Type

Method and Description


clear()

void

Removes all elements from this map, leaving it empty.

boolean
Set<Map.Entry<K,V>>

containsValue(Object value)

Returns whether this map contains the specified value.


entrySet()

Returns a set containing all of the mappings in this map.


get(Object key)

Returns the value of the mapping with the specified key.


keySet()

Set<K>

Returns a set of the keys contained in this map.


put(K key, V value)

Maps the specified key to the specified value.


remove(Object key)

Removes the mapping with the specified key from this map.
removeEldestEntry(Map.Entry<K,V> eldest)

protected boolean

Collection<V>

This method is queried from the put and putAll methods to check if
the eldest member of the map should be deleted before adding the
new member.
values()

Returns a collection of the values contained in this map.

Methods inherited from class java.util.HashMap


containsKey, isEmpty, putAll, size

Methods inherited from class java.util.AbstractMap


equals, hashCode, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Map


containsKey, equals, hashCode, isEmpty, putAll, size

Constructor Detail
LinkedHashMap
public LinkedHashMap()

Constructs a new empty LinkedHashMap instance.

Constructor Summary

224

Overview (Codename One API)


LinkedHashMap
public LinkedHashMap(int s)

Constructs a new LinkedHashMap instance with the specified capacity.


Parameters:
s - the initial capacity of this map.
Throws:
IllegalArgumentException - if the capacity is less than zero.
LinkedHashMap
public LinkedHashMap(int s,
float lf)

Constructs a new LinkedHashMap instance with the specified capacity and load factor.
Parameters:
s - the initial capacity of this map.
lf - the initial load factor.
Throws:
IllegalArgumentException - when the capacity is less than zero or the load
factor is less or equal to zero.
LinkedHashMap
public LinkedHashMap(int s,
float lf,
boolean order)

Constructs a new LinkedHashMap instance with the specified capacity, load factor and
a flag specifying the ordering behavior.
Parameters:
s - the initial capacity of this hash map.
lf - the initial load factor.
order - true if the ordering should be done based on the last access (from
least-recently accessed to most-recently accessed), and false if the ordering
should be the order in which the entries were inserted.
Throws:
IllegalArgumentException - when the capacity is less than zero or the load
factor is less or equal to zero.
LinkedHashMap
public LinkedHashMap(Map<? extends K,? extends V> m)

Constructs a new LinkedHashMap instance containing the mappings from the specified
map. The order of the elements is preserved.
Parameters:
m - the mappings to add.

Method Detail
containsValue
public boolean containsValue(Object value)

Description copied from class: HashMap


Returns whether this map contains the specified value.
Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class HashMap<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.

Constructor Detail

225

Overview (Codename One API)


get
public V get(Object key)

Returns the value of the mapping with the specified key.


Specified by:
get in interface Map<K,V>
Overrides:
get in class HashMap<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key, or null if no mapping for the
specified key is found.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Overrides:
put in class HashMap<K,V>
Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no such mapping.
entrySet
public Set<Map.Entry<K,V>> entrySet()

Returns a set containing all of the mappings in this map. Each mapping is an
instance of Map.Entry. As the set is backed by this map, changes in one will be
reflected in the other.
Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class HashMap<K,V>
Returns:
a set of the mappings.
keySet
public Set<K> keySet()

Returns a set of the keys contained in this map. The set is backed by this map so
changes to one are reflected by the other. The set does not support adding.
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class HashMap<K,V>
Returns:
a set of the keys.
values
public Collection<V> values()

Returns a collection of the values contained in this map. The collection is backed by
this map so changes to one are reflected by the other. The collection supports
remove, removeAll, retainAll and clear operations, and it does not support add or
addAll operations.
This method returns a collection which is the subclass of AbstractCollection. The
iterator method of this subclass returns a "wrapper object" over the iterator of map's

Method Detail

226

Overview (Codename One API)


entrySet(). The size method wraps the map's size method and the contains method
wraps the map's containsValue method.
The collection is created when this method is called for the first time and returned in
response to all subsequent calls. This method may return different collections when
multiple concurrent calls occur, since no synchronization is performed.
Specified by:
values

in interface Map<K,V>

Overrides:
values in class HashMap<K,V>
Returns:
a collection of the values contained in this map.
remove
public V remove(Object key)

Removes the mapping with the specified key from this map.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class HashMap<K,V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)

This method is queried from the put and putAll methods to check if the eldest
member of the map should be deleted before adding the new member. If this map
was created with accessOrder = true, then the result of removeEldestEntry is
assumed to be false.
Parameters:
eldest - the entry to check if it should be removed.
Returns:
true if the eldest member should be removed.
clear
public void clear()

Removes all elements from this map, leaving it empty.


Specified by:
clear in interface Map<K,V>
Overrides:
clear in class HashMap<K,V>
See Also:
HashMap.isEmpty(), HashMap.size()

Method Detail

227

Overview (Codename One API)


java.util

Interface Iterator<E>
Type Parameters:
E - the type of object returned by the iterator.
All Known Subinterfaces:
ListIterator<E>

public interface

An Iterator is used to sequence over a collection of objects. Conceptually, an iterator is always


positioned between two elements of a collection. A fresh iterator is always positioned in front of the
first element. If a collection has been changed since its creation, methods next and hasNext() may
throw a ConcurrentModificationException. Iterators with this behavior are called fail-fast iterators.

Method Summary
Modifier and Type
boolean

Returns whether there are more elements to iterate, i.e.


next()

Returns the next object in the iteration, i.e.


remove()

void

Method and Description


hasNext()

Removes the last object returned by next from the collection.

Method Detail
hasNext
boolean hasNext()

Returns whether there are more elements to iterate, i.e. whether the iterator is
positioned in front of an element.
Returns:
true if there are more elements, false otherwise.
See Also:
next()

next
E next()

Returns the next object in the iteration, i.e. returns the element in front of the iterator
and advances the iterator by one position.
Returns:
the next object.
Throws:
NoSuchElementException - if there are no more elements.
See Also:
hasNext()

remove
void remove()

Removes the last object returned by next from the collection. This method can only
be called once after next was called.
Throws:
java.lang.UnsupportedOperationException - if removing is not supported by
the collection being iterated.

Interface Iterator<E>

228

Overview (Codename One API)


- if next has not been called, or remove has already
been called after the last call to next.
IllegalStateException

Method Detail

229

Overview (Codename One API)


java.util

Class IdentityHashMap<K,V>
java.lang.Object

java.util.AbstractMap<K,V>

java.util.IdentityHashMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class
extends AbstractMap<K,V>
implements Map<K,V>

IdentityHashMap is a variant on HashMap which tests equality by reference instead of equality by


value. Basically, keys and values are compared for equality by checking if their references are equal
rather than by calling the "equals" function.
Note: This class intentionally violates the general contract of Map's on comparing objects by
their equals method.
IdentityHashMap uses open addressing (linear probing in particular) for collision resolution. This is
different from HashMap which uses Chaining.
Like HashMap, IdentityHashMap is not thread safe, so access by multiple threads must be
synchronized by an external mechanism such as Collections.synchronizedMap.
Since:
1.4

Nested Class Summary

Nested classes/interfaces inherited from


class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Constructor Summary
Constructor and Description
IdentityHashMap()

Creates an IdentityHashMap with default expected maximum size.


IdentityHashMap(int maxSize)

Creates an IdentityHashMap with the specified maximum size parameter.


IdentityHashMap(Map<? extends K,? extends V> map)

Creates an IdentityHashMap using the given map as initial values.

Method Summary
Modifier and Type
void

Class IdentityHashMap<K,V>

Method and Description


clear()

Removes all elements from this map, leaving it empty.

230

Overview (Codename One API)


boolean
boolean
Set<Map.Entry<K,V>>
boolean

containsKey(Object key)

Returns whether this map contains the specified key.


containsValue(Object value)

Returns whether this map contains the specified value.


entrySet()

Returns a set containing all of the mappings in this map.


equals(Object object)

Compares this map with other objects.


get(Object key)

Returns the value of the mapping with the specified key.

boolean

isEmpty()

Returns whether this IdentityHashMap has no elements.


keySet()

Set<K>

Returns a set of the keys contained in this map.


put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> map)

void

Copies all the mappings in the specified map to this map.


remove(Object key)

Removes the mapping with the specified key from this map.
size()

int

Returns the number of mappings in this IdentityHashMap.

Collection<V>

values()

Returns a collection of the values contained in this map.

Methods inherited from class java.util.AbstractMap


hashCode, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Map


hashCode

Constructor Detail
IdentityHashMap
public IdentityHashMap()

Creates an IdentityHashMap with default expected maximum size.


IdentityHashMap
public IdentityHashMap(int maxSize)

Creates an IdentityHashMap with the specified maximum size parameter.


Parameters:
maxSize - The estimated maximum number of entries that will be put in this
map.
IdentityHashMap
public IdentityHashMap(Map<? extends K,? extends V> map)

Creates an IdentityHashMap using the given map as initial values.


Parameters:
map - A map of (key,value) pairs to copy into the IdentityHashMap.

Method Summary

231

Overview (Codename One API)

Method Detail
clear
public void clear()

Removes all elements from this map, leaving it empty.


Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMap<K,V>
See Also:
isEmpty(), size()
containsKey
public boolean containsKey(Object key)

Returns whether this map contains the specified key.


Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>
Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.
containsValue
public boolean containsValue(Object value)

Returns whether this map contains the specified value.


Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class AbstractMap<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.
get
public V get(Object key)

Returns the value of the mapping with the specified key.


Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>
Parameters:
key - the key.

Method Detail

232

Overview (Codename One API)


value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no such mapping.
putAll
public void putAll(Map<? extends K,? extends V> map)

Copies all the mappings in the specified map to this map. These mappings will
replace all mappings that this map had for any of the keys currently in the given map.
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class AbstractMap<K,V>
Parameters:
map - the map to copy mappings from.
Throws:
NullPointerException - if map is null.
remove
public V remove(Object key)

Removes the mapping with the specified key from this map.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping, or null if no mapping for the specified key
was found.
entrySet
public Set<Map.Entry<K,V>> entrySet()

Returns a set containing all of the mappings in this map. Each mapping is an
instance of Map.Entry. As the set is backed by this map, changes in one will be
reflected in the other.
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>
Returns:
a set of the mappings.
keySet
public Set<K> keySet()

Returns a set of the keys contained in this map. The set is backed by this map so
changes to one are reflected by the other. The set does not support adding.
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMap<K,V>
Returns:
a set of the keys.
values
public Collection<V> values()

Returns a collection of the values contained in this map. The collection is backed by
this map so changes to one are reflected by the other. The collection supports
remove, removeAll, retainAll and clear operations, and it does not support add or
addAll operations.

Method Detail

233

Overview (Codename One API)

This method returns a collection which is the subclass of AbstractCollection. The


iterator method of this subclass returns a "wrapper object" over the iterator of map's
entrySet(). The size method wraps the map's size method and the contains method
wraps the map's containsValue method.
The collection is created when this method is called for the first time and returned in
response to all subsequent calls. This method may return different collections when
multiple concurrent calls occur, since no synchronization is performed.
Specified by:
values

in interface Map<K,V>

Overrides:
values in class AbstractMap<K,V>
Returns:
a collection of the values contained in this map.
equals
public boolean equals(Object object)

Compares this map with other objects. This map is equal to another map is it
represents the same set of mappings. With this map, two mappings are the same if
both the key and the value are equal by reference. When compared with a map that
is not an IdentityHashMap, the equals method is neither necessarily symmetric
(a.equals(b) implies b.equals(a)) nor transitive (a.equals(b) and b.equals(c) implies
a.equals(c)).
Specified by:
equals in interface Map<K,V>
Overrides:
equals in class AbstractMap<K,V>
Parameters:
object - the object to compare to.
Returns:
whether the argument object is equal to this object.
See Also:
AbstractMap.hashCode(), AbstractMap.entrySet()
isEmpty
public boolean isEmpty()

Returns whether this IdentityHashMap has no elements.


Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractMap<K,V>
Returns:
true if this IdentityHashMap has no elements, false otherwise.
See Also:
size()

size
public int size()

Returns the number of mappings in this IdentityHashMap.


Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractMap<K,V>
Returns:
the number of mappings in this IdentityHashMap.

Method Detail

234

Overview (Codename One API)


java.util

Class Hashtable<K,V>
java.lang.Object

java.util.Dictionary<K,V>

java.util.Hashtable<K,V>
All Implemented Interfaces:
Map<K,V>

public class
extends Dictionary<K,V>
implements Map<K,V>

Hashtable associates keys with values. Both keys and values cannot be null. The size of the
Hashtable is the number of key/value pairs it contains. The capacity is the number of key/value pairs
the Hashtable can hold. The load factor is a float value which determines how full the Hashtable gets
before expanding the capacity. If the load factor of the Hashtable is exceeded, the capacity is
doubled.
See Also:
Enumeration, Serializable, Object.equals(java.lang.Object), Object.hashCode()

Constructor Summary
Constructor and Description
Hashtable()

Constructs a new Hashtable using the default capacity and load factor.
Hashtable(int capacity)
Constructs a new Hashtable

using the specified capacity and the default load factor.

Hashtable(int capacity, float loadFactor)


Constructs a new Hashtable using the specified

capacity and load factor.

Hashtable(Map<? extends K,? extends V> map)


Constructs a new instance of Hashtable containing

the mappings from the specified map.

Method Summary
Modifier and Type

Method and Description


clear()

void

Removes all key/value pairs from this Hashtable, leaving the size
zero and the capacity unchanged.

boolean

contains(Object value)
Returns true if this Hashtable

boolean

containsKey(Object key)
Returns true if this Hashtable

contains the specified object as the


value of at least one of the key/value pairs.
contains the specified object as a key

of one of the key/value pairs.


boolean
Enumeration<V>
Set<Map.Entry<K,V>>

boolean

containsValue(Object value)
Searches this Hashtable for the

specified value.

elements()

Returns an enumeration on the values of this Hashtable.


entrySet()

Returns a set of the mappings contained in this Hashtable.


equals(Object object)
Compares this Hashtable

with the specified object and indicates if

they are equal.


V

Class Hashtable<K,V>

get(Object key)

235

Overview (Codename One API)


Returns the value associated with the specified key in this
Hashtable.
hashCode()

int

Returns a hash code value for the object.

boolean
Enumeration<K>

isEmpty()

Returns true if this Hashtable has no key/value pairs.


keys()

Returns an enumeration on the keys of this Hashtable instance.


keySet()

Set<K>

Returns a set of the keys contained in this Hashtable.


put(K key, V value)

Associate the specified value with the specified key in this


Hashtable.

putAll(Map<? extends K,? extends V> map)


Copies every mapping to this Hashtable from

void
protected void

the specified map.

rehash()

Increases the capacity of this Hashtable.


remove(Object key)

Removes the key/value pair with the specified key from this
Hashtable.

size()

int

Returns the number of key/value pairs in this Hashtable.


toString()

String

Returns the string representation of this Hashtable.

Collection<V>

values()

Returns a collection of the values contained in this Hashtable.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
Hashtable
public Hashtable()

Constructs a new Hashtable using the default capacity and load factor.
Hashtable
public Hashtable(int capacity)

Constructs a new Hashtable using the specified capacity and the default load factor.
Parameters:
capacity - the initial capacity.
Hashtable
public Hashtable(int capacity,
float loadFactor)

Constructs a new Hashtable using the specified capacity and load factor.
Parameters:
capacity - the initial capacity.
loadFactor - the initial load factor.
Hashtable
public Hashtable(Map<? extends K,? extends V> map)

Constructs a new instance of Hashtable containing the mappings from the specified
map.
Parameters:

Method Summary

236

Overview (Codename One API)


map

- the mappings to add.

Method Detail
clear
public void clear()

Removes all key/value pairs from this Hashtable, leaving the size zero and the
capacity unchanged.
Specified by:
clear in interface Map<K,V>
See Also:
isEmpty(), size()
contains
public boolean contains(Object value)

Returns true if this Hashtable contains the specified object as the value of at least
one of the key/value pairs.
Parameters:
value - the object to look for as a value in this Hashtable.
Returns:
true if object is a value in this Hashtable, false otherwise.
See Also:
containsKey(java.lang.Object), Object.equals(java.lang.Object)
containsKey
public boolean containsKey(Object key)

Returns true if this Hashtable contains the specified object as a key of one of the
key/value pairs.
Specified by:
containsKey in interface Map<K,V>
Parameters:
key - the object to look for as a key in this Hashtable.
Returns:
true if object is a key in this Hashtable, false otherwise.
See Also:
contains(java.lang.Object), Object.equals(java.lang.Object)
containsValue
public boolean containsValue(Object value)

Searches this Hashtable for the specified value.


Specified by:
containsValue in interface Map<K,V>
Parameters:
value - the object to search for.
Returns:
true if value is a value of this Hashtable, false otherwise.
elements
public Enumeration<V> elements()

Returns an enumeration on the values of this Hashtable. The results of the


Enumeration may be affected if the contents of this Hashtable are modified.
Specified by:
elements in class Dictionary<K,V>
Returns:
an enumeration of the values of this Hashtable.
See Also:
keys(), size(), Enumeration

Constructor Detail

237

Overview (Codename One API)


entrySet
public Set<Map.Entry<K,V>> entrySet()

Returns a set of the mappings contained in this Hashtable. Each element in the set is
a Map.Entry. The set is backed by this Hashtable so changes to one are reflected by
the other. The set does not support adding.
Specified by:
entrySet in interface Map<K,V>
Returns:
a set of the mappings.
equals
public boolean equals(Object object)

Compares this Hashtable with the specified object and indicates if they are equal. In
order to be equal, object must be an instance of Map and contain the same
key/value pairs.
Specified by:
equals in interface Map<K,V>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
true if the specified object is equal to this Map, false otherwise.
See Also:
hashCode()

get
public V get(Object key)

Returns the value associated with the specified key in this Hashtable.
Specified by:
get in interface Map<K,V>
Specified by:
get in class Dictionary<K,V>
Parameters:
key - the key of the value returned.
Returns:
the value associated with the specified key, or null if the specified key does
not exist.
See Also:
put(K, V)

hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Specified by:

Method Detail

238

Overview (Codename One API)


hashCode

in interface Map<K,V>

Overrides:
hashCode in class Object
Returns:
the receiver's hash.
See Also:
Map.equals(Object)

isEmpty
public boolean isEmpty()

Returns true if this Hashtable has no key/value pairs.


Specified by:
isEmpty in interface Map<K,V>
Specified by:
isEmpty in class Dictionary<K,V>
Returns:
true if this Hashtable has no key/value pairs, false otherwise.
See Also:
size()

keys
public Enumeration<K> keys()

Returns an enumeration on the keys of this Hashtable instance. The results of the
enumeration may be affected if the contents of this Hashtable are modified.
Specified by:
keys in class Dictionary<K,V>
Returns:
an enumeration of the keys of this Hashtable.
See Also:
elements(), size(), Enumeration
keySet
public Set<K> keySet()

Returns a set of the keys contained in this Hashtable. The set is backed by this
Hashtable so changes to one are reflected by the other. The set does not support
adding.
Specified by:
keySet in interface Map<K,V>
Returns:
a set of the keys.
put
public V put(K key,
V value)

Associate the specified value with the specified key in this Hashtable. If the key
already exists, the old value is replaced. The key and value cannot be null.
Specified by:
put in interface Map<K,V>
Specified by:
put in class Dictionary<K,V>
Parameters:
key - the key to add.
value - the value to add.
Returns:
the old value associated with the specified key, or null if the key did not
exist.
See Also:
elements(), get(java.lang.Object), keys(),
Object.equals(java.lang.Object)

Method Detail

239

Overview (Codename One API)


putAll
public void putAll(Map<? extends K,? extends V> map)

Copies every mapping to this Hashtable from the specified map.


Specified by:
putAll in interface Map<K,V>
Parameters:
map - the map to copy mappings from.
rehash
protected void rehash()

Increases the capacity of this Hashtable. This method is called when the size of this
Hashtable exceeds the load factor.
remove
public V remove(Object key)

Removes the key/value pair with the specified key from this Hashtable.
Specified by:
remove in interface Map<K,V>
Specified by:
remove in class Dictionary<K,V>
Parameters:
key - the key to remove.
Returns:
the value associated with the specified key, or null if the specified key did
not exist.
See Also:
get(java.lang.Object), put(K, V)
size
public int size()

Returns the number of key/value pairs in this Hashtable.


Specified by:
size in interface Map<K,V>
Specified by:
size in class Dictionary<K,V>
Returns:
the number of key/value pairs in this Hashtable.
See Also:
elements(), keys()
toString
public String toString()

Returns the string representation of this Hashtable.


Overrides:
toString in class Object
Returns:
the string representation of this Hashtable.
values
public Collection<V> values()

Returns a collection of the values contained in this Hashtable. The collection is


backed by this Hashtable so changes to one are reflected by the other. The collection
does not support adding.
Specified by:
values in interface Map<K,V>
Returns:
a collection of the values.

Method Detail

240

Overview (Codename One API)


java.util

Class HashSet<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractSet<E>

java.util.HashSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
LinkedHashSet

public class
extends AbstractSet<E>
implements Set<E>

HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
The elements can be any objects.

Constructor Summary
Constructor and Description
HashSet()

Constructs a new empty instance of HashSet.


HashSet(Collection<? extends E> collection)
Constructs a new instance of HashSet containing

the unique elements in the specified

collection.
HashSet(int capacity)

Constructs a new instance of HashSet with the specified capacity.


HashSet(int capacity, float loadFactor)
Constructs a new instance of HashSet with the

specified capacity and load factor.

Method Summary
Modifier and Type
boolean

Method and Description


add(E object)

Adds the specified object to this HashSet if not already present.


clear()

void

Removes all elements from this HashSet, leaving it empty.

boolean
boolean
Iterator<E>
boolean

contains(Object object)
Searches this HashSet for the

specified object.

isEmpty()

Returns true if this HashSet has no elements, false otherwise.


iterator()

Returns an Iterator on the elements of this HashSet.


remove(Object object)

Removes the specified object from this HashSet.


size()

int

Returns the number of elements in this HashSet.

Methods inherited from class java.util.AbstractSet


equals, hashCode, removeAll

Class HashSet<E>

241

Overview (Codename One API)


Methods

inherited from class java.util.AbstractCollection

addAll, containsAll, retainAll, toArray, toArray, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Set


addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray,
toArray

Constructor Detail
HashSet
public HashSet()

Constructs a new empty instance of HashSet.


HashSet
public HashSet(int capacity)

Constructs a new instance of HashSet with the specified capacity.


Parameters:
capacity - the initial capacity of this HashSet.
HashSet
public HashSet(int capacity,
float loadFactor)

Constructs a new instance of HashSet with the specified capacity and load factor.
Parameters:
capacity - the initial capacity.
loadFactor - the initial load factor.
HashSet
public HashSet(Collection<? extends E> collection)

Constructs a new instance of HashSet containing the unique elements in the specified
collection.
Parameters:
collection - the collection of elements to add.

Method Detail

add
public boolean add(E object)

Adds the specified object to this HashSet if not already present.


Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
object - the object to add.
Returns:
true when this HashSet did not already contain the object, false otherwise

Methods inherited from class java.util.AbstractCollection

242

Overview (Codename One API)


clear
public void clear()

Removes all elements from this HashSet, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class AbstractCollection<E>
See Also:
isEmpty(), size()
contains
public boolean contains(Object object)

Searches this HashSet for the specified object.


Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this HashSet, false otherwise.
isEmpty
public boolean isEmpty()

Returns true if this HashSet has no elements, false otherwise.


Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>
Overrides:
isEmpty in class AbstractCollection<E>
Returns:
true if this HashSet has no elements, false otherwise.
See Also:
size()

iterator
public Iterator<E> iterator()

Returns an Iterator on the elements of this HashSet.


Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
an Iterator on the elements of this HashSet.
See Also:
Iterator

remove
public boolean remove(Object object)

Removes the specified object from this HashSet.


Specified by:
remove in interface Collection<E>

Method Detail

243

Overview (Codename One API)


Specified by:
remove

in interface Set<E>

Overrides:
remove

in class AbstractCollection<E>

Parameters:
object

- the object to remove.

Returns:
true

if the object was removed, false otherwise.

size
public int size()

Returns the number of elements in this HashSet.


Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this HashSet.

Method Detail

244

Overview (Codename One API)


java.util

Class HashMap<K,V>
java.lang.Object

java.util.AbstractMap<K,V>

java.util.HashMap<K,V>
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
LinkedHashMap, Properties

public class
extends AbstractMap<K,V>
implements Map<K,V>

HashMap is an implementation of Map. All optional operations (adding and removing) are supported.
Keys and values can be any objects.

Nested Class Summary

Nested classes/interfaces inherited from


class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

Constructor Summary
Constructor and Description
HashMap()

Constructs a new empty HashMap instance.


HashMap(int capacity)
Constructs a new HashMap

instance with the specified capacity.

HashMap(int capacity, float loadFactor)


Constructs a new HashMap instance with the specified
HashMap(Map<? extends K,? extends V> map)
Constructs a new HashMap instance containing the

capacity and load factor.

mappings from the specified map.

Method Summary
Modifier and Type
void
boolean
boolean
Set<Map.Entry<K,V>>
V
boolean
Set<K>

Class HashMap<K,V>

Method and Description


clear()

Removes all mappings from this hash map, leaving it empty.


containsKey(Object key)

Returns whether this map contains the specified key.


containsValue(Object value)

Returns whether this map contains the specified value.


entrySet()

Returns a set containing all of the mappings in this map.


get(Object key)

Returns the value of the mapping with the specified key.


isEmpty()

Returns whether this map is empty.


keySet()

Returns a set of the keys contained in this map.

245

Overview (Codename One API)


put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> map)

void

Copies all the mappings in the specified map to this map.


remove(Object key)

Removes the mapping with the specified key from this map.
size()

int

Returns the number of elements in this map.

Collection<V>

values()

Returns a collection of the values contained in this map.

Methods inherited from class java.util.AbstractMap


equals, hashCode, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Map


equals, hashCode

Constructor Detail
HashMap
public HashMap()

Constructs a new empty HashMap instance.


HashMap
public HashMap(int capacity)

Constructs a new HashMap instance with the specified capacity.


Parameters:
capacity - the initial capacity of this hash map.
Throws:
IllegalArgumentException - when the capacity is less than zero.
HashMap
public HashMap(int capacity,
float loadFactor)

Constructs a new HashMap instance with the specified capacity and load factor.
Parameters:
capacity - the initial capacity of this hash map.
loadFactor - the initial load factor.
Throws:
IllegalArgumentException - when the capacity is less than zero or the load
factor is less or equal to zero.
HashMap
public HashMap(Map<? extends K,? extends V> map)

Constructs a new HashMap instance containing the mappings from the specified map.
Parameters:
map - the mappings to add.

Method Detail

Method Summary

246

Overview (Codename One API)


clear
public void clear()

Removes all mappings from this hash map, leaving it empty.


Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMap<K,V>
See Also:
isEmpty(), size()
containsKey
public boolean containsKey(Object key)

Returns whether this map contains the specified key.


Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>
Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.
containsValue
public boolean containsValue(Object value)

Returns whether this map contains the specified value.


Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class AbstractMap<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.
entrySet
public Set<Map.Entry<K,V>> entrySet()

Returns a set containing all of the mappings in this map. Each mapping is an
instance of Map.Entry. As the set is backed by this map, changes in one will be
reflected in the other.
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>
Returns:
a set of the mappings.
get
public V get(Object key)

Returns the value of the mapping with the specified key.


Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key, or null if no mapping for the
specified key is found.

Method Detail

247

Overview (Codename One API)


isEmpty
public boolean isEmpty()

Returns whether this map is empty.


Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractMap<K,V>
Returns:
true if this map has no elements, false otherwise.
See Also:
size()

keySet
public Set<K> keySet()

Returns a set of the keys contained in this map. The set is backed by this map so
changes to one are reflected by the other. The set does not support adding.
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMap<K,V>
Returns:
a set of the keys.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>
Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no such mapping.
putAll
public void putAll(Map<? extends K,? extends V> map)

Copies all the mappings in the specified map to this map. These mappings will
replace all mappings that this map had for any of the keys currently in the given map.
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class AbstractMap<K,V>
Parameters:
map - the map to copy mappings from.
Throws:
NullPointerException - if map is null.
remove
public V remove(Object key)

Removes the mapping with the specified key from this map.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>
Parameters:
key - the key of the mapping to remove.

Method Detail

248

Overview (Codename One API)


Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
size
public int size()

Returns the number of elements in this map.


Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractMap<K,V>
Returns:
the number of elements in this map.
values
public Collection<V> values()

Returns a collection of the values contained in this map. The collection is backed by
this map so changes to one are reflected by the other. The collection supports
remove, removeAll, retainAll and clear operations, and it does not support add or
addAll operations.
This method returns a collection which is the subclass of AbstractCollection. The
iterator method of this subclass returns a "wrapper object" over the iterator of map's
entrySet(). The size method wraps the map's size method and the contains method
wraps the map's containsValue method.
The collection is created when this method is called for the first time and returned in
response to all subsequent calls. This method may return different collections when
multiple concurrent calls occur, since no synchronization is performed.
Specified by:
values

in interface Map<K,V>

Overrides:
values in class AbstractMap<K,V>
Returns:
a collection of the values contained in this map.

Method Detail

249

Overview (Codename One API)


java.util

Class EventListenerProxy
java.lang.Object

java.util.EventListenerProxy
All Implemented Interfaces:
EventListener

public abstract class


extends Object
implements EventListener

This abstract class provides a simple wrapper for objects of type EventListener.

Constructor Summary
Constructor and Description
EventListenerProxy(EventListener listener)
Creates a new EventListener proxy instance.

Method Summary
Modifier and Type
EventListener

Method and Description


getListener()

Returns the wrapped EventListener.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
EventListenerProxy
public EventListenerProxy(EventListener listener)

Creates a new EventListener proxy instance.


Parameters:
listener - the listener wrapped by this proxy.

Method Detail
getListener
public EventListener getListener()

Returns the wrapped EventListener.


Returns:
the wrapped EventListener.

Class EventListenerProxy

250

Overview (Codename One API)


java.util

Interface EventListener
All Known Implementing Classes:
EventListenerProxy

public interface

EventListener is the superclass of all event listener interfaces.


See Also:
EventObject

Method Detail

251

Overview (Codename One API)


java.util

Interface Enumeration<T>
All Known Implementing Classes:
StringTokenizer

public interface

An object that implements the Enumeration interface generates a series of elements, one at a time.
Successive calls to the nextElement method return successive elements of the series. For example,
to print all elements of a vector v: Methods are provided to enumerate through the elements of a
vector, the keys of a hashtable, and the values in a hashtable. Since: JDK1.0, CLDC 1.0 Version:
12/17/01 (CLDC 1.1) See Also:nextElement(), Hashtable, Hashtable.elements(), Hashtable.keys(),
Vector, Vector.elements()

Method Summary
Modifier and
Type
boolean

Method and Description


hasMoreElements()

Tests if this enumeration contains more elements.


nextElement()

Returns the next element of this enumeration if this enumeration object has
at least one more element to provide.

Method Detail
hasMoreElements
boolean hasMoreElements()

Tests if this enumeration contains more elements.


nextElement
T nextElement()

Returns the next element of this enumeration if this enumeration object has at least
one more element to provide.

Interface EventListener

252

Overview (Codename One API)


java.util

Class EmptyStackException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.util.EmptyStackException

public class
extends RuntimeException

Thrown by methods in the Stack class to indicate that the stack is empty. Since: JDK1.0, CLDC 1.0
Version: 12/17/01 (CLDC 1.1) See Also:Stack

Constructor Summary
Constructor and Description
EmptyStackException()

Constructs a new EmptyStackException with null as its error message string.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
EmptyStackException
public EmptyStackException()

Constructs a new EmptyStackException with null as its error message string.

Method Detail

253

Overview (Codename One API)


java.util

Class Dictionary<K,V>
java.lang.Object

java.util.Dictionary<K,V>
Direct Known Subclasses:
Hashtable

public abstract class


extends Object

Note: Do not use this class since it is obsolete. Please use the Map interface for new
implementations.
Dictionary is an abstract class which is the superclass of all classes that associate keys with values,
such as Hashtable.
Since:
1.0
See Also:
Hashtable

Constructor Summary
Constructor and Description
Dictionary()

Constructs a new instance of this class.

Method Summary
Modifier and Type
abstract Enumeration<V>
abstract V
abstract boolean
abstract Enumeration<K>
abstract V

Method and Description


elements()

Returns an enumeration on the elements of this dictionary.


get(Object key)

Returns the value which is associated with key.


isEmpty()

Returns true if this dictionary has no key/value pairs.


keys()

Returns an enumeration on the keys of this dictionary.


put(K key, V value)
Associate key with value

in this dictionary.

remove(Object key)
abstract V

abstract int

Removes the key/value pair with the specified key from this
dictionary.
size()

Returns the number of key/value pairs in this dictionary.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Constructor Detail

254

Overview (Codename One API)


Dictionary
public Dictionary()

Constructs a new instance of this class.

Method Detail
elements
public abstract Enumeration<V> elements()

Returns an enumeration on the elements of this dictionary.


Returns:
an enumeration of the values of this dictionary.
See Also:
keys(), size(), Enumeration
get
public abstract V get(Object key)

Returns the value which is associated with key.


Parameters:
key - the key of the value returned.
Returns:
the value associated with key, or null if the specified key does not exist.
See Also:
put(K, V)

isEmpty
public abstract boolean isEmpty()

Returns true if this dictionary has no key/value pairs.


Returns:
true if this dictionary has no key/value pairs, false otherwise.
See Also:
size()

keys
public abstract Enumeration<K> keys()

Returns an enumeration on the keys of this dictionary.


Returns:
an enumeration of the keys of this dictionary.
See Also:
elements(), size(), Enumeration
put
public abstract V put(K key,
V value)

Associate key with value in this dictionary. If key exists in the dictionary before this
call, the old value in the dictionary is replaced by value.
Parameters:
key - the key to add.
value - the value to add.
Returns:
the old value previously associated with key or null if key is new to the
dictionary.
See Also:
elements(), get(java.lang.Object), keys()

Constructor Detail

255

Overview (Codename One API)


remove
public abstract V remove(Object key)

Removes the key/value pair with the specified key from this dictionary.
Parameters:
key - the key to remove.
Returns:
the associated value before the deletion or null if key was not known to this
dictionary.
See Also:
get(java.lang.Object), put(K, V)
size
public abstract int size()

Returns the number of key/value pairs in this dictionary.


Returns:
the number of key/value pairs in this dictionary.
See Also:
elements(), keys()

Method Detail

256

Overview (Codename One API)


java.util

Interface Deque<E>
Type Parameters:
E - the type of elements in this collection
All Superinterfaces:
Collection<E>, Iterable<E>, Queue<E>
All Known Implementing Classes:
ArrayDeque, LinkedList

public interface
extends Queue<E>

A kind of collection that can insert or remove element at both ends("double ended queue"). Mostly a
deque has no limit of its size. Extending from Queue, a deque can be used as a Queue which
behavior is first-in-first-out. Furthermore, a deque can also be used as a Stack(legacy class) which
behavior is last-in-first-out. A typical deque does not allow null to be inserted as its element, while
some implementations allow it. But null should not be inserted even in these implementations, since
method poll return null to indicate that there is no element left in the deque. A deque can also remove
interior elements by removeFirstOccurrence and removeLastOccurrence methods. A deque can not
access elements by index.
Since:
1.6

Method Summary
Modifier and
Type

Method and Description


addFirst(E e)

void

Inserts an element at the head of this deque if it dose not violate size limit
immediately.
addLast(E e)

void

Iterator<E>
E
E

Inserts an element at the tail of this deque if it dose not violate size limit
immediately.
descendingIterator()

Returns the iterator in reverse order, from tail to head.


getFirst()

Gets but not removes the head element of this deque.


getLast()

Gets but not removes the tail element of this deque.


offerFirst(E e)

boolean

Inserts an element at the head of this deque unless it would violate size
limit.
offerLast(E e)

boolean

E
E
E
E
E
void

Interface Deque<E>

Inserts an element at the tail of this deque unless it would violate size
limit.
peekFirst()

Gets but not removes the head element of this deque.


peekLast()

Gets but not removes the tail element of this deque.


pollFirst()

Gets and removes the head element of this deque.


pollLast()

Gets and removes the tail element of this deque.


pop()

Pops the head element of the deque, just same as removeFirst().


push(E e)

257

Overview (Codename One API)


Pushes the element to the deque(at the head of the deque), just same as
addFirst(E).
removeFirst()

Gets and removes the head element of this deque.

boolean

removeFirstOccurrence(Object o)

Removes the first equivalent element of the specified object.


removeLast()

Gets and removes the tail element of this deque.

boolean

removeLastOccurrence(Object o)

Removes the last equivalent element of the specified object.

Methods inherited from interface java.util.Queue


element, offer, peek, poll, remove

Methods inherited from interface java.util.Collection


add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty,
iterator, remove, removeAll, retainAll, size, toArray, toArray

Method Detail

addFirst
void addFirst(E e)

Inserts an element at the head of this deque if it dose not violate size limit
immediately. It is better to use offerFirst(E) if a deque is size-limited.
Parameters:
e - the element
Throws:
IllegalStateException - if it can not add now due to size limit
ClassCastException - if the class of element can not be added into this
deque
NullPointerException - if the element is null and the deque can not contain
null element
IllegalArgumentException - if the element can not be added due to some
property.
addLast
void addLast(E e)

Inserts an element at the tail of this deque if it dose not violate size limit immediately.
It is better to use offerLast(E) if a deque is size-limited.
Parameters:
e - the element
Throws:
IllegalStateException - if it can not add now due to size limit
ClassCastException - if the class of element can not be added into this
deque
NullPointerException - if the element is null and the deque can not contain
null element
IllegalArgumentException - if the element can not be added due to some
property.
offerFirst
boolean offerFirst(E e)

Method Summary

258

Overview (Codename One API)


Inserts an element at the head of this deque unless it would violate size limit. It is
better than the addFirst(E) method in a size-limited deque, because the latter one
may fail to add the element only by throwing an exception.
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails.
Throws:
ClassCastException - if the class of element can not be added into this
deque
NullPointerException - if the element is null and the deque can not contain
null element
IllegalArgumentException - if the element can not be added due to some
property.
offerLast
boolean offerLast(E e)

Inserts an element at the tail of this deque unless it would violate size limit. It is better
than the addLast(E) method in a size-limited deque, because the latter one may fail
to add the element only by throwing an exception.
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails
Throws:
ClassCastException - if the class of element can not be added into this
deque
NullPointerException - if the element is null and the deque can not contain
null element
IllegalArgumentException - if the element can not be added due to some
property
removeFirst
E removeFirst()

Gets and removes the head element of this deque. This method throws an exception
if the deque is empty.
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
removeLast
E removeLast()

Gets and removes the tail element of this deque. This method throws an exception if
the deque is empty.
Returns:
the tail element
Throws:
NoSuchElementException - if the deque is empty
pollFirst
E pollFirst()

Gets and removes the head element of this deque. This method returns null if the
deque is empty.
Returns:
the head element or null if the deque is empty
pollLast
E pollLast()

Method Detail

259

Overview (Codename One API)


Gets and removes the tail element of this deque. This method returns null if the
deque is empty.
Returns:
the tail element or null if the deque is empty
getFirst
E getFirst()

Gets but not removes the head element of this deque. This method throws an
exception if the deque is empty.
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
getLast
E getLast()

Gets but not removes the tail element of this deque. This method throws an exception
if the deque is empty.
Returns:
the tail element
Throws:
NoSuchElementException - if the deque is empty
peekFirst
E peekFirst()

Gets but not removes the head element of this deque. This method returns null if the
deque is empty.
Returns:
the head element or null if the deque is empty
peekLast
E peekLast()

Gets but not removes the tail element of this deque. This method returns null if the
deque is empty.
Returns:
the tail element or null if the deque is empty
removeFirstOccurrence
boolean removeFirstOccurrence(Object o)

Removes the first equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Parameters:
o - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element.
Throws:
ClassCastException - if the class of the element is incompatible with the
deque
NullPointerException - if the element is null and the deque can not contain
null element
removeLastOccurrence
boolean removeLastOccurrence(Object o)

Removes the last equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Parameters:
o - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element.

Method Detail

260

Overview (Codename One API)


Throws:
ClassCastException

- if the class of the element is incompatible with the

deque
NullPointerException

- if the element is null and the deque can not contain

null element
push
void push(E e)

Pushes the element to the deque(at the head of the deque), just same as addFirst(E).
Parameters:
e - the element
Throws:
IllegalStateException - if it can not add now due to size limit
ClassCastException - if the class of element can not be added into this
deque
NullPointerException - if the element is null and the deque can not contain
null element
IllegalArgumentException - if the element can not be added due to some
property.
pop
E pop()

Pops the head element of the deque, just same as removeFirst().


Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
descendingIterator
Iterator<E> descendingIterator()

Returns the iterator in reverse order, from tail to head.


Returns:
the iterator in reverse order

Method Detail

261

Overview (Codename One API)


java.util

Class Date
java.lang.Object

java.util.Date

public class
extends Object

The class Date represents a specific instant in time, with millisecond precision. This class has been
subset for the J2ME based on the JDK 1.3 Date class. Many methods and variables have been
pruned, and other methods simplified, in an effort to reduce the size of this class. Although the Date
class is intended to reflect coordinated universal time (UTC), it may not do so exactly, depending on
the host environment of the Java Virtual Machine. Nearly all modern operating systems assume that 1
day = 24x60x60 = 86400 seconds in all cases. In UTC, however, about once every year or two there
is an extra second, called a "leap second." The leap second is always added as the last second of the
day, and always on December 31 or June 30. For example, the last minute of the year 1995 was 61
seconds long, thanks to an added leap second. Most computer clocks are not accurate enough to be
able to reflect the leap-second distinction. Version: CLDC 1.1 03/13/2002 (Based on JDK 1.3) See
Also:TimeZone, Calendar

Constructor Summary
Constructor and Description
Date()

Allocates a Date object and initializes it to represent the current time specified number of
milliseconds since the standard base time known as "the epoch", namely January 1, 1970,
00:00:00 GMT.
Date(long date)

Allocates a Date object and initializes it to represent the specified number of milliseconds
since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00
GMT.

Method Summary
Modifier
and Type
boolean

Method and Description


equals(Object obj)

Compares two dates for equality.


getTime()

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT


represented by this Date object.

long

hashCode()

int

Returns a hash code value for this object.


setTime(long time)

Sets this Date object to represent a point in time that is time milliseconds after
January 1, 1970 00:00:00 GMT.

void

toString()
String

Converts this Date object to a String of the form: dow mon dd hh:mm:ss zzz
yyyy where: dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class Date

262

Overview (Codename One API)


Constructor

Detail

Date
public Date()

Allocates a Date object and initializes it to represent the current time specified
number of milliseconds since the standard base time known as "the epoch", namely
January 1, 1970, 00:00:00 GMT. See Also:System.currentTimeMillis()
Date
public Date(long date)

Allocates a Date object and initializes it to represent the specified number of


milliseconds since the standard base time known as "the epoch", namely January 1,
1970, 00:00:00 GMT. Parameters:date - the milliseconds since January 1, 1970,
00:00:00 GMT.See Also:System.currentTimeMillis()

Method Detail
equals
public boolean equals(Object obj)

Compares two dates for equality. The result is true if and only if the argument is not
null and is a Date object that represents the same point in time, to the millisecond, as
this object. Thus, two Date objects are equal if and only if the getTime method returns
the same long value for both.
Overrides:
equals in class Object
getTime
public long getTime()

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT


represented by this Date object.
hashCode
public int hashCode()

Returns a hash code value for this object. The result is the exclusive OR of the two
halves of the primitive long value returned by the method. That is, the hash code is
the value of the expression: (int)(this.getTime()^(this.getTime() >>> 32))
Overrides:
hashCode in class Object
setTime
public void setTime(long time)

Sets this Date object to represent a point in time that is time milliseconds after
January 1, 1970 00:00:00 GMT.
toString
public String toString()

Converts this Date object to a String of the form: dow mon dd hh:mm:ss zzz yyyy
where: dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat). mon is the
month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec). dd is the day of
the month (01 through 31), as two decimal digits. hh is the hour of the day (00
through 23), as two decimal digits. mm is the minute within the hour (00 through 59),
as two decimal digits. ss is the second within the minute (00 through 61, as two
decimal digits. zzz is the time zone (and may reflect daylight savings time). If time
zone information is not available, then zzz is empty - that is, it consists of no
characters at all. yyyy is the year, as four decimal digits.

Constructor Detail

263

Overview (Codename One API)

Overrides:
toString

Method Detail

in class Object

264

Overview (Codename One API)


java.util

Class ConcurrentModificationException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.util.ConcurrentModificationException

public class
extends RuntimeException

An ConcurrentModificationException is thrown when a Collection is modified and an existing iterator


on the Collection is used to modify the Collection as well.
See Also:
RuntimeException

Constructor Summary
Constructor and Description
ConcurrentModificationException()
Constructs a new ConcurrentModificationException

with the current stack trace filled in.

ConcurrentModificationException(String detailMessage)
Constructs a new ConcurrentModificationException with the

current stack trace and

message filled in.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ConcurrentModificationException
public ConcurrentModificationException()

Constructs a new ConcurrentModificationException with the current stack trace


filled in.
ConcurrentModificationException
public ConcurrentModificationException(String detailMessage)

Constructs a new ConcurrentModificationException with the current stack trace and


message filled in.
Parameters:
detailMessage - the detail message for the exception.

Class ConcurrentModificationException

265

Overview (Codename One API)


java.util

Interface Comparator<T>
All Known Implementing Classes:
CaseInsensitiveOrder

public interface

A Comparator is used to compare two objects to determine their ordering with respect to each other.
On a given Collection, a Comparator can be used to obtain a sorted Collection which is totally
ordered. For a Comparator to be consistent with equals, its {code #compare(Object, Object)} method
has to return zero for each pair of elements (a,b) where a.equals(b) holds true. It is recommended
that a Comparator implements Serializable.
Since:
1.2

Method Summary
Modifier and
Type

Method and Description


compare(T object1, T object2)

int

Compares the two specified objects to determine their relative ordering.

boolean

equals(Object object)
Compares this Comparator

with the specified Object and indicates whether

they are equal.

Method Detail

compare
int compare(T object1,
T object2)

Compares the two specified objects to determine their relative ordering. The ordering
implied by the return value of this method for all possible pairs of (object1, object2)
should form an equivalence relation. This means that
compare(a,a) returns zero for all a
the sign of compare(a,b) must be the opposite of the sign of compare(b,a) for
all pairs of (a,b)
From compare(a,b) > 0 and compare(b,c) > 0 it must follow compare(a,c) >
0 for all possible combinations of (a,b,c)
Parameters:
object1 - an Object.
object2 - a second Object to compare with object1.
Returns:
an integer < 0 if object1 is less than object2, 0 if they are equal, and > 0 if
object1 is greater than object2.
Throws:
ClassCastException - if objects are not of the correct type.
equals
boolean equals(Object object)

Compares this Comparator with the specified Object and indicates whether they are
equal. In order to be equal, object must represent the same object as this instance
using a class-specific comparison.

Constructor Detail

266

Overview (Codename One API)


A Comparator never needs to override this method, but may choose so for
performance reasons.
Overrides:
equals

in class Object

Parameters:
object - the Object to compare with this comparator.
Returns:
boolean true if specified Object is the same as this Object, and false
otherwise.
See Also:
Object.hashCode(), Object.equals(java.lang.Object)

Method Detail

267

Overview (Codename One API)


java.util

Class Collections
java.lang.Object

java.util.Collections

public class
extends Object
Collections

contains static methods which operate on Collection classes.

Since:
1.2

Field Summary
Modifier and Type
static List
static Map
static Set

Field and Description


EMPTY_LIST

An empty immutable instance of List.


EMPTY_MAP

An empty immutable instance of Map.


EMPTY_SET

An empty immutable instance of Set.

Method Summary
Modifier and Type
static <T> boolean
static <T> Queue<T>

static <T> int

static <T> int

static <E> Collection<E>

static <T> void

Method and Description


addAll(Collection<? super T> c, T... a)

Adds all the specified elements to the specified collection.


asLifoQueue(Deque<T> deque)

Answers a LIFO Queue as a view of a Deque.


binarySearch(List<? extends Comparable<? super T>> list,
T object)

Performs a binary search for the specified element in the


specified sorted list.
binarySearch(List<? extends T> list, T object,
Comparator<? super T> comparator)

Performs a binary search for the specified element in the


specified sorted list using the specified comparator.
checkedCollection(Collection<E> c, Class<E> type)

Returns a dynamically typesafe view of the specified collection.


copy(List<? super T> destination, List<? extends
T> source)

Copies the elements from the source list to the destination list.
disjoint(Collection<?> c1, Collection<?> c2)
static boolean

static <T> List<T>


static <K,V> Map<K,V>
static <T> Set<T>
static
<T> Enumeration<T>

Class Collections

Returns whether the specified collections have no elements in


common.
emptyList()

Returns a type-safe empty, immutable List.


emptyMap()

Returns a type-safe empty, immutable Map.


emptySet()

Returns a type-safe empty, immutable Set.


enumeration(Collection<T> collection)
Returns an Enumeration on the specified collection.

268

Overview (Codename One API)


static <T> void

static int

static int

fill(List<? super T> list, T object)

Fills the specified list with the specified element.


frequency(Collection<?> c, Object o)
Returns the number of elements in the Collection
the Object passed.

that match

indexOfSubList(List<?> list, List<?> sublist)


Searches the list for sublist and returns the beginning

index

of the first occurrence.


static int

lastIndexOfSubList(List<?> list, List<?> sublist)


Searches the list for sublist and returns the beginning

index

of the last occurrence.


static <T> ArrayList<T>

list(Enumeration<T> enumeration)
Returns an ArrayList with all the elements

in the enumeration.

static <T extends Object max(Collection<? extends T> collection)


& Comparable<? super T>>
Searches the specified collection for the maximum
T

static <T> T

max(Collection<? extends T> collection, Comparator<?


super T> comparator)

Searches the specified collection for the maximum element


using the specified comparator.

static <T extends Object min(Collection<? extends T> collection)


& Comparable<? super T>>
Searches the specified collection for the minimum
T

static <T> T

element.

element.

min(Collection<? extends T> collection, Comparator<?


super T> comparator)

Searches the specified collection for the minimum element


using the specified comparator.
nCopies(int length, T object)

static <T> List<T>

static <E> Set<E>


static <T> boolean

static void

Returns a list containing the specified number of the specified


element.
newSetFromMap(Map<E,Boolean> map)

Answers a set backed by a map.


replaceAll(List<T> list, T obj, T obj2)
Replaces all occurrences of Object obj in list
reverse(List<?> list)
Modifies the specified List

with newObj.

by reversing the order of the

elements.
static <T> Comparator<T>

static <T> Comparator<T>

reverseOrder()

A comparator which reverses the natural order of the elements.


reverseOrder(Comparator<T> c)
Returns a Comparator that reverses

the order of the Comparator

passed.
static void

rotate(List<?> lst, int dist)


Rotates the elements in list by the

distance dist

shuffle(List<?> list)
static void

Moves every element of the list to a random new position in the


list.
shuffle(List<?> list, Random random)

static void

static <E> Set<E>


static <E> List<E>
static <K,V> Map<K,V>
static <T extends
Comparable<? super T>>
void
static <T> void

Method Summary

Moves every element of the list to a random new position in the


list using the specified random number generator.
singleton(E object)

Returns a set containing the specified element.


singletonList(E object)

Returns a list containing the specified element.


singletonMap(K key, V value)

Returns a Map containing the specified key and value.


sort(List<T> list)

Sorts the specified list in ascending natural order.


sort(List<T> list, Comparator<? super T> comparator)

Sorts the specified list using the specified comparator.

269

Overview (Codename One API)


static void

swap(List<?> list, int index1, int index2)


Swaps the elements of list list at indices index1

and index2.

synchronizedCollection(Collection<T> collection)
static <T> Collection<T>

Returns a wrapper on the specified collection which


synchronizes all access to the collection.
synchronizedList(List<T> list)

static <T> List<T>

Returns a wrapper on the specified List which synchronizes all


access to the List.
synchronizedMap(Map<K,V> map)

static <K,V> Map<K,V>

Returns a wrapper on the specified map which synchronizes all


access to the map.
synchronizedSet(Set<E> set)

static <E> Set<E>

static
<K,V> SortedMap<K,V>

Returns a wrapper on the specified set which synchronizes all


access to the set.
synchronizedSortedMap(SortedMap<K,V> map)

Returns a wrapper on the specified sorted map which


synchronizes all access to the sorted map.
synchronizedSortedSet(SortedSet<E> set)

static <E> SortedSet<E>

Returns a wrapper on the specified sorted set which


synchronizes all access to the sorted set.
unmodifiableCollection(Collection<? extends
E> collection)

static <E> Collection<E>

Returns a wrapper on the specified collection which throws an


UnsupportedOperationException whenever an attempt is made
to modify the collection.
unmodifiableList(List<? extends E> list)

static <E> List<E>

Returns a wrapper on the specified list which throws an


UnsupportedOperationException whenever an attempt is made
to modify the list.
unmodifiableMap(Map<? extends K,? extends V> map)

static <K,V> Map<K,V>

Returns a wrapper on the specified map which throws an


UnsupportedOperationException whenever an attempt is made
to modify the map.
unmodifiableSet(Set<? extends E> set)

static <E> Set<E>

Returns a wrapper on the specified set which throws an


UnsupportedOperationException whenever an attempt is made
to modify the set.
unmodifiableSortedMap(SortedMap<K,? extends V> map)

static
<K,V> SortedMap<K,V>

Returns a wrapper on the specified sorted map which throws an


UnsupportedOperationException whenever an attempt is made
to modify the sorted map.
unmodifiableSortedSet(SortedSet<E> set)

static <E> SortedSet<E>

Returns a wrapper on the specified sorted set which throws an


UnsupportedOperationException whenever an attempt is made
to modify the sorted set.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
EMPTY_LIST
public static final List EMPTY_LIST

An empty immutable instance of List.

Methods inherited from class java.lang.Object

270

Overview (Codename One API)


EMPTY_SET
public static final Set EMPTY_SET

An empty immutable instance of Set.


EMPTY_MAP
public static final Map EMPTY_MAP

An empty immutable instance of Map.

Method Detail

binarySearch
public static <T> int binarySearch(List<? extends Comparable<? super T>> list,
T object)

Performs a binary search for the specified element in the specified sorted list. The list
needs to be already sorted in natural sorting order. Searching in an unsorted array
has an undefined result. It's also undefined which element is found if there are
multiple occurrences of the same element.
Parameters:
list - the sorted list to search.
object - the element to find.
Returns:
the non-negative index of the element, or a negative index which is the
-index - 1 where the element would be inserted
Throws:
ClassCastException - if an element in the List or the search element does not
implement Comparable, or cannot be compared to each other.
binarySearch
public static <T> int binarySearch(List<? extends T> list,
T object,
Comparator<? super T> comparator)

Performs a binary search for the specified element in the specified sorted list using
the specified comparator. The list needs to be already sorted according to the
comparator passed. Searching in an unsorted array has an undefined result. It's also
undefined which element is found if there are multiple occurrences of the same
element.
Type Parameters:
T - The element type
Parameters:
list - the sorted List to search.
object - the element to find.
comparator - the comparator. If the comparator is null then the search uses
the objects' natural ordering.
Returns:
the non-negative index of the element, or a negative index which is the
-index - 1 where the element would be inserted.
Throws:
ClassCastException - when an element in the list and the searched element
cannot be compared to each other using the comparator.
copy
public static <T> void copy(List<? super T> destination,
List<? extends T> source)

Copies the elements from the source list to the destination list. At the end both lists
will have the same objects at the same index. If the destination array is larger than
the source list, the elements in the destination list with index >= source.size() will
be unchanged.

Field Detail

271

Overview (Codename One API)


Parameters:
destination - the list whose elements are set from the source list.
source - the list with the elements to be copied into the destination.

Throws:
IndexOutOfBoundsException

- when the destination list is smaller than the

source list.
java.lang.UnsupportedOperationException

- when replacing an element in

the destination list is not supported.


enumeration
public static <T> Enumeration<T> enumeration(Collection<T> collection)

Returns an Enumeration on the specified collection.


Parameters:
collection - the collection to enumerate.
Returns:
an Enumeration.
fill
public static <T> void fill(List<? super T> list,
T object)

Fills the specified list with the specified element.


Parameters:
list - the list to fill.
object - the element to fill the list with.
Throws:
java.lang.UnsupportedOperationException

- when replacing an element in

the List is not supported.


max
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends

Searches the specified collection for the maximum element.


Parameters:
collection - the collection to search.
Returns:
the maximum element in the Collection.
Throws:
ClassCastException - when an element in the collection does not implement
Comparable or elements cannot be compared to each other.
max
public static <T> T max(Collection<? extends T> collection,
Comparator<? super T> comparator)

Searches the specified collection for the maximum element using the specified
comparator.
Parameters:
collection - the collection to search.
comparator - the comparator.
Returns:
the maximum element in the Collection.
Throws:
ClassCastException - when elements in the collection cannot be compared to
each other using the Comparator.
min
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends

Searches the specified collection for the minimum element.


Parameters:
collection - the collection to search.
Returns:
the minimum element in the collection.
Throws:

Method Detail

272

Overview (Codename One API)


ClassCastException - when an element in the collection does
Comparable or elements cannot be compared to each other.

not implement

min
public static <T> T min(Collection<? extends T> collection,
Comparator<? super T> comparator)

Searches the specified collection for the minimum element using the specified
comparator.
Parameters:
collection - the collection to search.
comparator - the comparator.
Returns:
the minimum element in the collection.
Throws:
ClassCastException - when elements in the collection cannot be compared to
each other using the Comparator.
nCopies
public static <T> List<T> nCopies(int length,
T object)

Returns a list containing the specified number of the specified element. The list
cannot be modified. The list is serializable.
Parameters:
length - the size of the returned list.
object - the element to be added length times to a list.
Returns:
a list containing length copies of the element.
Throws:
IllegalArgumentException - when length < 0.
reverse
public static void reverse(List<?> list)

Modifies the specified List by reversing the order of the elements.


Parameters:
list - the list to reverse.
Throws:
java.lang.UnsupportedOperationException - when replacing an element in
the List is not supported.
reverseOrder
public static <T> Comparator<T> reverseOrder()

A comparator which reverses the natural order of the elements. The Comparator that's
returned is Serializable.
Returns:
a Comparator instance.
See Also:
Comparator, Comparable, Serializable
reverseOrder
public static <T> Comparator<T> reverseOrder(Comparator<T> c)

Returns a Comparator that reverses the order of the Comparator passed. If the
Comparator passed is null, then this method is equivalent to reverseOrder().
The Comparator that's returned is Serializable if the Comparator passed is
serializable or null.
Parameters:
c - the Comparator to reverse or null.
Returns:
a Comparator instance.
Since:

Method Detail

273

Overview (Codename One API)


1.5
See Also:
Comparator

shuffle
public static void shuffle(List<?> list)

Moves every element of the list to a random new position in the list.
Parameters:
list - the List to shuffle.
Throws:
java.lang.UnsupportedOperationException - when replacing an element in
the List is not supported.
shuffle
public static void shuffle(List<?> list,
Random random)

Moves every element of the list to a random new position in the list using the
specified random number generator.
Parameters:
list - the list to shuffle.
random - the random number generator.
Throws:
java.lang.UnsupportedOperationException - when replacing an element in
the list is not supported.
singleton
public static <E> Set<E> singleton(E object)

Returns a set containing the specified element. The set cannot be modified. The set
is serializable.
Parameters:
object - the element.
Returns:
a set containing the element.
singletonList
public static <E> List<E> singletonList(E object)

Returns a list containing the specified element. The list cannot be modified. The list is
serializable.
Parameters:
object - the element.
Returns:
a list containing the element.
singletonMap
public static <K,V> Map<K,V> singletonMap(K key,
V value)

Returns a Map containing the specified key and value. The map cannot be modified.
The map is serializable.
Parameters:
key - the key.
value - the value.
Returns:
a Map containing the key and value.
sort
public static <T extends Comparable<? super T>> void sort(List<T> list)

Sorts the specified list in ascending natural order. The algorithm is stable which
means equal elements don't get reordered.

Method Detail

274

Overview (Codename One API)


Parameters:
list

- the list to be sorted.

Throws:
- when an element in the List does not implement
Comparable or elements cannot be compared to each other.
ClassCastException

sort
public static <T> void sort(List<T> list,
Comparator<? super T> comparator)

Sorts the specified list using the specified comparator. The algorithm is stable which
means equal elements don't get reordered.
Parameters:
list - the list to be sorted.
comparator - the comparator.
Throws:
ClassCastException - when elements in the list cannot be compared to each
other using the comparator.
swap
public static void swap(List<?> list,
int index1,
int index2)

Swaps the elements of list list at indices index1 and index2.


Parameters:
list - the list to manipulate.
index1 - position of the first element to swap with the element in index2.
index2 - position of the other element.
Throws:
IndexOutOfBoundsException - if index1 or index2 is out of range of this list.
Since:
1.4
replaceAll
public static <T> boolean replaceAll(List<T> list,
T obj,
T obj2)

Replaces all occurrences of Object obj in list with newObj. If the obj is null, then all
occurrences of null are replaced with newObj.
Parameters:
list - the list to modify.
obj - the object to find and replace occurrences of.
obj2 - the object to replace all occurrences of obj in list.
Returns:
true, if at least one occurrence of obj has been found in list.
Throws:
java.lang.UnsupportedOperationException - if the list does not support
setting elements.
rotate
public static void rotate(List<?> lst,
int dist)

Rotates the elements in list by the distance dist


e.g. for a given list with elements [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], calling rotate(list, 3) or
rotate(list, -7) would modify the list to look like this: [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]
Parameters:
lst - the list whose elements are to be rotated.
dist - is the distance the list is rotated. This can be any valid integer.
Negative values rotate the list backwards.

Method Detail

275

Overview (Codename One API)


indexOfSubList
public static int indexOfSubList(List<?> list,
List<?> sublist)

Searches the list for sublist and returns the beginning index of the first occurrence.
-1 is returned if the sublist does not exist in list.
Parameters:
list - the List to search sublist in.
sublist - the List to search in list.

Returns:
the beginning index of the first occurrence of sublist in list, or -1.
lastIndexOfSubList
public static int lastIndexOfSubList(List<?> list,
List<?> sublist)

Searches the list for sublist and returns the beginning index of the last occurrence.
-1 is returned if the sublist does not exist in list.
Parameters:
list - the list
sublist - the

to search sublist in.


list to search in list.

Returns:
the beginning index of the last occurrence of sublist in list, or -1.
list
public static <T> ArrayList<T> list(Enumeration<T> enumeration)

Returns an ArrayList with all the elements in the enumeration. The elements in the
returned ArrayList are in the same order as in the enumeration.
Parameters:
enumeration - the source Enumeration.
Returns:
an ArrayList from enumeration.
synchronizedCollection
public static <T> Collection<T> synchronizedCollection(Collection<T> collection)

Returns a wrapper on the specified collection which synchronizes all access to the
collection.
Parameters:
collection - the Collection to wrap in a synchronized collection.
Returns:
a synchronized Collection.
synchronizedList
public static <T> List<T> synchronizedList(List<T> list)

Returns a wrapper on the specified List which synchronizes all access to the List.
Parameters:
list - the List to wrap in a synchronized list.
Returns:
a synchronized List.
synchronizedMap
public static <K,V> Map<K,V> synchronizedMap(Map<K,V> map)

Returns a wrapper on the specified map which synchronizes all access to the map.
Parameters:
map - the map to wrap in a synchronized map.
Returns:
a synchronized Map.

Method Detail

276

Overview (Codename One API)


synchronizedSet
public static <E> Set<E> synchronizedSet(Set<E> set)

Returns a wrapper on the specified set which synchronizes all access to the set.
Parameters:
set - the set to wrap in a synchronized set.
Returns:
a synchronized set.
synchronizedSortedMap
public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> map)

Returns a wrapper on the specified sorted map which synchronizes all access to the
sorted map.
Parameters:
map - the sorted map to wrap in a synchronized sorted map.
Returns:
a synchronized sorted map.
synchronizedSortedSet
public static <E> SortedSet<E> synchronizedSortedSet(SortedSet<E> set)

Returns a wrapper on the specified sorted set which synchronizes all access to the
sorted set.
Parameters:
set - the sorted set to wrap in a synchronized sorted set.
Returns:
a synchronized sorted set.
unmodifiableCollection

public static <E> Collection<E> unmodifiableCollection(Collection<? extends E> colle

Returns a wrapper on the specified collection which throws an


UnsupportedOperationException whenever an attempt is made to modify the
collection.
Parameters:
collection - the collection to wrap in an unmodifiable collection.
Returns:
an unmodifiable collection.
unmodifiableList
public static <E> List<E> unmodifiableList(List<? extends E> list)

Returns a wrapper on the specified list which throws an


UnsupportedOperationException whenever an attempt is made to modify the list.
Parameters:
list - the list to wrap in an unmodifiable list.
Returns:
an unmodifiable List.
unmodifiableMap
public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> map)

Returns a wrapper on the specified map which throws an


UnsupportedOperationException whenever an attempt is made to modify the map.
Parameters:
map - the map to wrap in an unmodifiable map.
Returns:
a unmodifiable map.
unmodifiableSet
public static <E> Set<E> unmodifiableSet(Set<? extends E> set)

Returns a wrapper on the specified set which throws an


UnsupportedOperationException whenever an attempt is made to modify the set.
Parameters:

Method Detail

277

Overview (Codename One API)


set - the set to wrap in an unmodifiable set.
Returns:
a unmodifiable set
unmodifiableSortedMap

public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K,? extends V> ma

Returns a wrapper on the specified sorted map which throws an


UnsupportedOperationException whenever an attempt is made to modify the sorted
map.
Parameters:
map - the sorted map to wrap in an unmodifiable sorted map.
Returns:
a unmodifiable sorted map
unmodifiableSortedSet
public static <E> SortedSet<E> unmodifiableSortedSet(SortedSet<E> set)

Returns a wrapper on the specified sorted set which throws an


UnsupportedOperationException whenever an attempt is made to modify the sorted
set.
Parameters:
set - the sorted set to wrap in an unmodifiable sorted set.
Returns:
a unmodifiable sorted set.
frequency
public static int frequency(Collection<?> c,
Object o)

Returns the number of elements in the Collection that match the Object passed. If
the Object is null, then the number of null elements is returned.
Parameters:
c - the Collection to search.
o - the Object to search for.
Returns:
the number of matching elements.
Throws:
NullPointerException - if the Collection parameter is null.
Since:
1.5
emptyList
public static final <T> List<T> emptyList()

Returns a type-safe empty, immutable List.


Returns:
an empty List.
Since:
1.5
See Also:
EMPTY_LIST

emptySet
public static final <T> Set<T> emptySet()

Returns a type-safe empty, immutable Set.


Returns:
an empty Set.
Since:
1.5
See Also:
EMPTY_SET

Method Detail

278

Overview (Codename One API)


emptyMap
public static final <K,V> Map<K,V> emptyMap()

Returns a type-safe empty, immutable Map.


Returns:
an empty Map.
Since:
1.5
See Also:
EMPTY_MAP

checkedCollection
public static <E> Collection<E> checkedCollection(Collection<E> c,
Class<E> type)

Returns a dynamically typesafe view of the specified collection. Trying to insert an


element of the wrong type into this collection throws a ClassCastException. At
creation time the types in c are not checked for correct type.
Parameters:
c - the collection to be wrapped in a typesafe collection.
type - the type of the elements permitted to insert.
Returns:
a typesafe collection.
addAll
public static <T> boolean addAll(Collection<? super T> c,
T... a)

Adds all the specified elements to the specified collection.


Parameters:
c - the collection the elements are to be inserted into.
a - the elements to insert.
Returns:
true if the collection changed during insertion.
Throws:
java.lang.UnsupportedOperationException - when the method is not
supported.
NullPointerException - when c or a is null, or a contains one or more null
elements and c doesn't support null elements.
IllegalArgumentException - if at least one of the elements can't be inserted
into the collection.
disjoint
public static boolean disjoint(Collection<?> c1,
Collection<?> c2)

Returns whether the specified collections have no elements in common.


Parameters:
c1 - the first collection.
c2 - the second collection.
Returns:
true if the collections have no elements in common, false otherwise.
Throws:
NullPointerException - if one of the collections is null.
newSetFromMap
public static <E> Set<E> newSetFromMap(Map<E,Boolean> map)

Answers a set backed by a map. And the map must be empty when this method is
called.
Type Parameters:
E - type of elements in set
Parameters:
map - the backing map
Returns:

Method Detail

279

Overview (Codename One API)


the set from the map
Throws:
IllegalArgumentException

- if the map is not empty

Since:
1.6
asLifoQueue
public static <T> Queue<T> asLifoQueue(Deque<T> deque)

Answers a LIFO Queue as a view of a Deque. Methods in the returned Queue need
to be re-written to implement the LIFO feature.
Type Parameters:
T - type of elements
Parameters:
deque - the Deque
Returns:
the LIFO Queue
Since:
1.6

Method Detail

280

Overview (Codename One API)


java.util

Interface Collection<E>
All Superinterfaces:
Iterable<E>
All Known Subinterfaces:
Deque<E>, List<E>, NavigableSet<E>, Queue<E>, Set<E>, SortedSet<E>
All Known Implementing Classes:
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet,
ArrayDeque, ArrayList, HashSet, LinkedHashSet, LinkedList, PriorityQueue, Stack, TreeSet,
Vector

public interface
extends Iterable<E>

is the root of the collection hierarchy. It defines operations on data collections and the
behavior that they will have in all implementations of Collections. All direct or indirect
implementations of Collection should implement at least two constructors. One with no parameters
which creates an empty collection and one with a parameter of type Collection. This second
constructor can be used to create a collection of different type as the initial collection but with the
same elements. Implementations of Collection cannot be forced to implement these two constructors
but at least all implementations under java.util do. Methods that change the content of a collection
throw an UnsupportedOperationException if the underlying collection does not support that operation,
though it's not mandatory to throw such an Exception in cases where the requested operation would
not change the collection. In these cases it's up to the implementation whether it throws an
UnsupportedOperationException or not. Methods marked with (optional) can throw an
UnsupportedOperationException if the underlying collection doesn't support that method.
Collection

Method Summary
Modifier and
Type
boolean

boolean

void

Method and Description


add(E object)

Attempts to add object to the contents of this Collection (optional).


addAll(Collection<? extends E> collection)
Attempts to add all of the objects contained in Collection
this Collection (optional).

to the contents of

clear()

Removes all elements from this Collection, leaving it empty (optional).

boolean

contains(Object object)
Tests whether this Collection

boolean

containsAll(Collection<?> collection)
Tests whether this Collection contains all
specified Collection.

contains the specified object.


objects contained in the

equals(Object object)
boolean

int
boolean

Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
hashCode()

Returns an integer hash code for the receiver.


isEmpty()

Returns if this Collection contains no elements.


iterator()

Iterator<E>

Returns an instance of Iterator that may be used to access the objects


contained by this Collection.
remove(Object object)

boolean

Interface Collection<E>

Removes one instance of the specified object from this Collection if one is
contained (optional).

281

Overview (Codename One API)


boolean

removeAll(Collection<?> collection)
Removes all occurrences in this Collection
Collection (optional).

boolean

retainAll(Collection<?> collection)
Removes all objects from this Collection
Collection passed (optional).

that are not also found in the

size()

int

Returns a count of how many objects this Collection contains.

Object[]
<T> T[]

of each object in the specified

toArray()

Returns a new array containing all elements contained in this Collection.


toArray(T[] array)

Returns an array containing all elements contained in this Collection.

Method Detail

add
boolean add(E object)

Attempts to add object to the contents of this Collection (optional). After this
method finishes successfully it is guaranteed that the object is contained in the
collection. If the collection was modified it returns true, false if no changes were
made. An implementation of Collection may narrow the set of accepted objects, but
it has to specify this in the documentation. If the object to be added does not meet
this restriction, then an IllegalArgumentException is thrown. If a collection does not
yet contain an object that is to be added and adding the object fails, this method must
throw an appropriate unchecked Exception. Returning false is not permitted in this
case because it would violate the postcondition that the element will be part of the
collection after this method finishes.
Parameters:
object - the object to add.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if adding to this Collection is
not supported.
ClassCastException - if the class of the object is inappropriate for this
collection.
IllegalArgumentException - if the object cannot be added to this Collection.
NullPointerException - if null elements cannot be added to the Collection.
addAll
boolean addAll(Collection<? extends E> collection)

Attempts to add all of the objects contained in Collection to the contents of this
Collection (optional). If the passed Collection is changed during the process of
adding elements to this Collection, the behavior is not defined.
Parameters:
collection - the Collection of objects.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if adding to this Collection is
not supported.
ClassCastException - if the class of an object is inappropriate for this
Collection.
IllegalArgumentException - if an object cannot be added to this Collection.
NullPointerException - if collection is null, or if it contains null elements
and this Collection does not support such elements.

Method Summary

282

Overview (Codename One API)


clear
void clear()

Removes all elements from this Collection, leaving it empty (optional).


Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
See Also:
isEmpty(), size()
contains
boolean contains(Object object)

Tests whether this Collection contains the specified object. Returns true if and only
if at least one element elem in this Collection meets following requirement:
(object==null ? elem==null : object.equals(elem)).
Parameters:
object - the object to search for.
Returns:
true if object is an element of this Collection, false otherwise.
Throws:
ClassCastException - if the object to look for isn't of the correct type.
NullPointerException - if the object to look for is null and this Collection
doesn't support null elements.
containsAll
boolean containsAll(Collection<?> collection)

Tests whether this Collection contains all objects contained in the specified
Collection. If an element elem is contained several times in the specified
Collection, the method returns true even if elem is contained only once in this
Collection.
Parameters:
collection - the collection of objects.
Returns:
true if all objects in the specified Collection are elements of this Collection,
false otherwise.
Throws:
ClassCastException - if one or more elements of collection isn't of the
correct type.
NullPointerException - if collection contains at least one null element and
this Collection doesn't support null elements.
NullPointerException - if collection is null.
equals
boolean equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same
object using a class specific comparison.
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
true if the object is the same as this object and false if it is different from this
object.
See Also:
hashCode()

hashCode
int hashCode()

Returns an integer hash code for the receiver. Objects which are equal return the
same value for this method.
Overrides:
hashCode in class Object

Method Detail

283

Overview (Codename One API)


Returns:
the receiver's hash.
See Also:
equals(java.lang.Object)

isEmpty
boolean isEmpty()

Returns if this Collection contains no elements.


Returns:
true if this Collection has no elements, false otherwise.
See Also:
size()

iterator
Iterator<E> iterator()

Returns an instance of Iterator that may be used to access the objects contained by
this Collection. The order in which the elements are returned by the iterator is not
defined. Only if the instance of the Collection has a defined order the elements are
returned in that order.
Specified by:
iterator in interface Iterable<E>
Returns:
an iterator for accessing the Collection contents.
remove
boolean remove(Object object)

Removes one instance of the specified object from this Collection if one is contained
(optional). The element elem that is removed complies with (object==null ?
elem==null : object.equals(elem).
Parameters:
object - the object to remove.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if the object passed is not of the correct type.
NullPointerException - if object is null and this Collection doesn't support
null elements.
removeAll
boolean removeAll(Collection<?> collection)

Removes all occurrences in this Collection of each object in the specified


Collection (optional). After this method returns none of the elements in the passed
Collection can be found in this Collection anymore.
Parameters:
collection - the collection of objects to remove.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if one or more elements of collection isn't of the
correct type.
NullPointerException - if collection contains at least one null element and
this Collection doesn't support null elements.
NullPointerException - if collection is null.
retainAll
boolean retainAll(Collection<?> collection)

Removes all objects from this Collection that are not also found in the Collection
passed (optional). After this method returns this Collection will only contain

Method Detail

284

Overview (Codename One API)


elements that also can be found in the Collection passed to this method.
Parameters:
collection - the collection of objects to retain.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if one or more elements of collection isn't of the
correct type.
NullPointerException - if collection contains at least one null element and
this Collection doesn't support null elements.
NullPointerException - if collection is null.
size
int size()

Returns a count of how many objects this Collection contains.


Returns:
how many objects this Collection contains, or Integer.MAX_VALUE if there
are more than Integer.MAX_VALUE elements in this Collection.
toArray
Object[] toArray()

Returns a new array containing all elements contained in this Collection. If the
implementation has ordered elements it will return the element array in the same
order as an iterator would return them. The array returned does not reflect any
changes of the Collection. A new array is created even if the underlying data
structure is already an array.
Returns:
an array of the elements from this Collection.
toArray
<T> T[] toArray(T[] array)

Returns an array containing all elements contained in this Collection. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
Collection, the array element following the Collection elements is set to null. If the
implementation has ordered elements it will return the element array in the same
order as an iterator would return them. toArray(new Object[0]) behaves exactly the
same way as toArray() does.
Parameters:
array - the array.
Returns:
an array of the elements from this Collection.
Throws:
ArrayStoreException - if the type of an element in this Collection cannot be
stored in the type of the specified array.

Method Detail

285

Overview (Codename One API)


java.util

Class Calendar
java.lang.Object

java.util.Calendar

public abstract class


extends Object

Calendar is an abstract base class for converting between a Date object and a set of integer fields
such as YEAR, MONTH, DAY, HOUR, and so on. (A Date object represents a specific instant in time
with millisecond precision. See Date for information about the Date class.) Subclasses of Calendar
interpret a Date according to the rules of a specific calendar system. Like other locale-sensitive
classes, Calendar provides a class method, getInstance, for getting a generally useful object of this
type. A Calendar object can produce all the time field values needed to implement the date-time
formatting for a particular language and calendar style (for example, Japanese-Gregorian,
Japanese-Traditional). When computing a Date from time fields, there may be insufficient information
to compute the Date (such as only year and month but no day in the month). Insufficient information.
The calendar will use default information to specify the missing fields. This may vary by calendar; for
the Gregorian calendar, the default for a field is the same as that of the start of the epoch: i.e., YEAR
= 1970, MONTH = JANUARY, DATE = 1, etc. Note: The ambiguity in interpretation of what day
midnight belongs to, is resolved as so: midnight "belongs" to the following day. 23:59 on Dec 31, 1969
00:00 on Jan 1, 1970. 12:00 PM is midday, and 12:00 AM is midnight. 11:59 PM on Jan 1 12:00 AM
on Jan 2 12:01 AM on Jan 2. 11:59 AM on Mar 10 12:00 PM on Mar 10 12:01 PM on Mar 10. 24:00 or
greater are invalid. Hours greater than 12 are invalid in AM/PM mode. Setting the time will never
change the date. If equivalent times are entered in AM/PM or 24 hour mode, equality will be
determined by the actual time rather than the entered time. This class has been subset for J2ME
based on the JDK 1.3 Calendar class. Many methods and variables have been pruned, and other
methods simplified, in an effort to reduce the size of this class. Version: CLDC 1.1 02/01/2002 (based
on JDK 1.3) See Also:Date, TimeZone

Field Summary
Modifier and
Type

Field and Description


AM

static int

Value of the AM_PM field indicating the period of the day from midnight
to just before noon.
AM_PM

static int

static int
static int
static int
static int
static int
static int
static int
protected int[]

Class Calendar

Field number for get and set indicating whether the HOUR is before or
after noon.
APRIL

Value of the MONTH field indicating the fourth month of the year.
AUGUST

Value of the MONTH field indicating the eighth month of the year.
DATE

Field number for get and set indicating the day of the month.
DAY_OF_MONTH

Field number for get and set indicating the day of the month.
DAY_OF_WEEK

Field number for get and set indicating the day of the week.
DECEMBER

Value of the MONTH field indicating the twelfth month of the year.
FEBRUARY

Value of the MONTH field indicating the second month of the year.
fields

The field values for the currently set time for this calendar.

286

Overview (Codename One API)


static int

FRIDAY

Value of the DAY_OF_WEEK field indicating Friday.


HOUR

static int

static int
protected
boolean[]
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Field number for get and set indicating the hour of the morning or
afternoon.
HOUR_OF_DAY

Field number for get and set indicating the hour of the day.
isSet

The flags which tell if a specified time field for the calendar is set.
JANUARY

Value of the MONTH field indicating the first month of the year.
JULY

Value of the MONTH field indicating the seventh month of the year.
JUNE

Value of the MONTH field indicating the sixth month of the year.
MARCH

Value of the MONTH field indicating the third month of the year.
MAY

Value of the MONTH field indicating the fifth month of the year.
MILLISECOND

Field number for get and set indicating the millisecond within the second.
MINUTE

Field number for get and set indicating the minute within the hour.
MONDAY

Value of the DAY_OF_WEEK field indicating Monday.


MONTH

Field number for get and set indicating the month.


NOVEMBER

Value of the MONTH field indicating the eleventh month of the year.
OCTOBER

Value of the MONTH field indicating the tenth month of the year.
PM

static int

static int
static int
static int
static int
static int

Value of the AM_PM field indicating the period of the day from noon to
just before midnight.
SATURDAY

Value of the DAY_OF_WEEK field indicating Saturday.


SECOND

Field number for get and set indicating the second within the minute.
SEPTEMBER

Value of the MONTH field indicating the ninth month of the year.
SUNDAY

Value of the DAY_OF_WEEK field indicating Sunday.


THURSDAY

Value of the DAY_OF_WEEK field indicating Thursday.


time

protected long

static int
static int
static int

The currently set time for this calendar, expressed in milliseconds after
January 1, 1970, 0:00:00 GMT.
TUESDAY

Value of the DAY_OF_WEEK field indicating Tuesday.


WEDNESDAY

Value of the DAY_OF_WEEK field indicating Wednesday.


YEAR

Field number for get and set indicating the year.

Constructor Summary
Modifier

Field Summary

Constructor and Description

287

Overview (Codename One API)


protected

Calendar()

Constructs a Calendar with the default time zone.

Method Summary
Modifier and
Type

Method and Description


add(int field, int value)

void

Adds the specified amount to a Calendar field.

boolean
boolean
protected
abstract void
protected
abstract void
boolean

after(Object when)

Compares the time field records.


before(Object when)

Compares the time field records.


computeFields()

Converts the current millisecond time value time to field values in fields[].
computeTime()

Converts the current field values in fields[] to the millisecond time value
time.
equals(Object obj)

Compares this calendar to the specified object.


get(int field)

int

Gets the value for a given time field.

static Calendar
static Calendar

getInstance()

Gets a calendar using the default time zone.


getInstance(TimeZone zone)

Gets a calendar using the specified time zone.


getTime()

Date

Gets this Calendar's current time.


getTimeInMillis()

protected long

TimeZone

Gets this Calendar's current time as a long expressed in milliseconds


after January 1, 1970, 0:00:00 GMT (the epoch).
getTimeZone()

Gets the time zone.


set(int field, int value)

void

Sets the time field with the given value.


setTime(Date date)

void

Sets this Calendar's current time with the given Date.

protected void

setTimeInMillis(long millis)

Sets this Calendar's current time from the given long value.
setTimeZone(TimeZone value)

void

Sets the time zone with the given time zone value.

Methods inherited from class java.lang.Object


getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
AM
public static final int AM

Value of the AM_PM field indicating the period of the day from midnight to just before
noon. See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Summary

288

Overview (Codename One API)


AM_PM
public static final int AM_PM

Field number for get and set indicating whether the HOUR is before or after noon.
E.g., at 10:04:15.250 PM the AM_PM is PM. See Also:AM, PM, HOUR, Constant
Field Values
See Also:
Constant Field Values
APRIL
public static final int APRIL

Value of the MONTH field indicating the fourth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
AUGUST
public static final int AUGUST

Value of the MONTH field indicating the eighth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
DATE
public static final int DATE

Field number for get and set indicating the day of the month. This is a synonym for
DAY_OF_MONTH. See Also:DAY_OF_MONTH, Constant Field Values
See Also:
Constant Field Values
DAY_OF_MONTH
public static final int DAY_OF_MONTH

Field number for get and set indicating the day of the month. This is a synonym for
DATE. See Also:DATE, Constant Field Values
See Also:
Constant Field Values
DAY_OF_WEEK
public static final int DAY_OF_WEEK

Field number for get and set indicating the day of the week. See Also:Constant Field
Values
See Also:
Constant Field Values
DECEMBER
public static final int DECEMBER

Value of the MONTH field indicating the twelfth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
FEBRUARY
public static final int FEBRUARY

Value of the MONTH field indicating the second month of the year. See
Also:Constant Field Values
See Also:
Constant Field Values

Field Detail

289

Overview (Codename One API)


fields
protected int[] fields

The field values for the currently set time for this calendar.
FRIDAY
public static final int FRIDAY

Value of the DAY_OF_WEEK field indicating Friday. See Also:Constant Field Values
See Also:
Constant Field Values
HOUR
public static final int HOUR

Field number for get and set indicating the hour of the morning or afternoon. HOUR is
used for the 12-hour clock. E.g., at 10:04:15.250 PM the HOUR is 10. See
Also:AM_PM, HOUR_OF_DAY, Constant Field Values
See Also:
Constant Field Values
HOUR_OF_DAY
public static final int HOUR_OF_DAY

Field number for get and set indicating the hour of the day. HOUR_OF_DAY is used
for the 24-hour clock. E.g., at 10:04:15.250 PM the HOUR_OF_DAY is 22. See
Also:Constant Field Values
See Also:
Constant Field Values
isSet
protected boolean[] isSet

The flags which tell if a specified time field for the calendar is set. This is an array of
FIELD_COUNT booleans,
JANUARY
public static final int JANUARY

Value of the MONTH field indicating the first month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
JULY
public static final int JULY

Value of the MONTH field indicating the seventh month of the year. See
Also:Constant Field Values
See Also:
Constant Field Values
JUNE
public static final int JUNE

Value of the MONTH field indicating the sixth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
MARCH
public static final int MARCH

Value of the MONTH field indicating the third month of the year. See Also:Constant
Field Values
See Also:

Field Detail

290

Overview (Codename One API)


Constant Field Values
MAY
public static final int MAY

Value of the MONTH field indicating the fifth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
MILLISECOND
public static final int MILLISECOND

Field number for get and set indicating the millisecond within the second. E.g., at
10:04:15.250 PM the MILLISECOND is 250. See Also:Constant Field Values
See Also:
Constant Field Values
MINUTE
public static final int MINUTE

Field number for get and set indicating the minute within the hour. E.g., at
10:04:15.250 PM the MINUTE is 4. See Also:Constant Field Values
See Also:
Constant Field Values
MONDAY
public static final int MONDAY

Value of the DAY_OF_WEEK field indicating Monday. See Also:Constant Field


Values
See Also:
Constant Field Values
MONTH
public static final int MONTH

Field number for get and set indicating the month. This is a calendar-specific value.
See Also:Constant Field Values
See Also:
Constant Field Values
NOVEMBER
public static final int NOVEMBER

Value of the MONTH field indicating the eleventh month of the year. See
Also:Constant Field Values
See Also:
Constant Field Values
OCTOBER
public static final int OCTOBER

Value of the MONTH field indicating the tenth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
PM
public static final int PM

Value of the AM_PM field indicating the period of the day from noon to just before
midnight. See Also:Constant Field Values
See Also:
Constant Field Values

Field Detail

291

Overview (Codename One API)


SATURDAY
public static final int SATURDAY

Value of the DAY_OF_WEEK field indicating Saturday. See Also:Constant Field


Values
See Also:
Constant Field Values
SECOND
public static final int SECOND

Field number for get and set indicating the second within the minute. E.g., at
10:04:15.250 PM the SECOND is 15. See Also:Constant Field Values
See Also:
Constant Field Values
SEPTEMBER
public static final int SEPTEMBER

Value of the MONTH field indicating the ninth month of the year. See Also:Constant
Field Values
See Also:
Constant Field Values
SUNDAY
public static final int SUNDAY

Value of the DAY_OF_WEEK field indicating Sunday. See Also:Constant Field


Values
See Also:
Constant Field Values
THURSDAY
public static final int THURSDAY

Value of the DAY_OF_WEEK field indicating Thursday. See Also:Constant Field


Values
See Also:
Constant Field Values
time
protected long time

The currently set time for this calendar, expressed in milliseconds after January 1,
1970, 0:00:00 GMT.
TUESDAY
public static final int TUESDAY

Value of the DAY_OF_WEEK field indicating Tuesday. See Also:Constant Field


Values
See Also:
Constant Field Values
WEDNESDAY
public static final int WEDNESDAY

Value of the DAY_OF_WEEK field indicating Wednesday. See Also:Constant Field


Values
See Also:
Constant Field Values
YEAR
public static final int YEAR

Field Detail

292

Overview (Codename One API)


Field number for get and set indicating the year. This is a calendar-specific value.
See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Calendar
protected Calendar()

Constructs a Calendar with the default time zone. See Also:TimeZone.getDefault()

Method Detail
after
public boolean after(Object when)

Compares the time field records. Equivalent to comparing result of conversion to


UTC.
before
public boolean before(Object when)

Compares the time field records. Equivalent to comparing result of conversion to


UTC.
computeFields
protected abstract void computeFields()

Converts the current millisecond time value time to field values in fields[]. This allows
you to sync up the time field values with a new time that is set for the calendar.
computeTime
protected abstract void computeTime()

Converts the current field values in fields[] to the millisecond time value time.
equals
public boolean equals(Object obj)

Compares this calendar to the specified object. The result is true if and only if the
argument is not null and is a Calendar object that represents the same calendar as
this object.
Overrides:
equals in class Object
get
public final int get(int field)

Gets the value for a given time field.


getInstance
public static Calendar getInstance()

Gets a calendar using the default time zone.


getInstance
public static Calendar getInstance(TimeZone zone)

Gets a calendar using the specified time zone.

Constructor Detail

293

Overview (Codename One API)


getTime
public final Date getTime()

Gets this Calendar's current time.


getTimeInMillis
protected long getTimeInMillis()

Gets this Calendar's current time as a long expressed in milliseconds after January 1,
1970, 0:00:00 GMT (the epoch).
getTimeZone
public TimeZone getTimeZone()

Gets the time zone.


set
public final void set(int field,
int value)

Sets the time field with the given value.


add
public final void add(int field,
int value)

Adds the specified amount to a Calendar field.


Parameters:
field - the Calendar field to modify.
value - the amount to add to the field.
Throws:
IllegalArgumentException - if field is DST_OFFSET or ZONE_OFFSET.
setTime
public final void setTime(Date date)

Sets this Calendar's current time with the given Date. Note: Calling setTime() with
Date(Long.MAX_VALUE) or Date(Long.MIN_VALUE) may yield incorrect field values
from get().
setTimeInMillis
protected void setTimeInMillis(long millis)

Sets this Calendar's current time from the given long value.
setTimeZone
public void setTimeZone(TimeZone value)

Sets the time zone with the given time zone value.

Method Detail

294

Overview (Codename One API)


java.util

Class BitSet
java.lang.Object

java.util.BitSet

public class
extends Object

The BitSet class implements a bit field. Each element in a BitSet can be on(1) or off(0). A BitSet is
created with a given size and grows if this size is exceeded. Growth is always rounded to a 64 bit
boundary.

Constructor Summary
Constructor and Description
BitSet()

Create a new BitSet with size equal to 64 bits.


BitSet(int nbits)
Create a new BitSet

with size equal to nbits.

Method Summary
Modifier and
Type
void
void
int
void
void
void
boolean
void
void
boolean

Method and Description


and(BitSet bs)

Performs the logical AND of this BitSet with another BitSet.


andNot(BitSet bs)

Clears all bits in the receiver which are also set in the parameter BitSet.
cardinality()

Returns the number of bits that are true in this BitSet.


clear()

Clears all the bits in this BitSet.


clear(int pos)

Clears the bit at index pos.


clear(int pos1, int pos2)

Clears the bits starting from pos1 to pos2.


equals(Object obj)

Compares the argument to this BitSet and returns whether they are equal.
flip(int pos)

Flips the bit at index pos.


flip(int pos1, int pos2)
Flips the bits starting from pos1

to pos2.

get(int pos)

Retrieves the bit at index pos.


get(int pos1, int pos2)

BitSet

int

boolean

Retrieves the bits starting from pos1 to pos2 and returns back a new bitset
made of these bits.
hashCode()

Computes the hash code for this BitSet.


intersects(BitSet bs)
Checks if these two BitSets

have at least one bit set to true in the same

position.
boolean

Class BitSet

isEmpty()

295

Overview (Codename One API)


Returns true if all the bits in this BitSet are set to false.
length()

int

Returns the number of bits up to and including the highest bit set.
nextClearBit(int pos)

int

Returns the position of the first bit that is false on or after pos.
nextSetBit(int pos)

int

Returns the position of the first bit that is true on or after pos.
or(BitSet bs)

void

Performs the logical OR of this BitSet with another BitSet.


set(int pos)

void

Sets the bit at index pos to 1.


set(int pos, boolean val)
Sets the bit at index pos to val.

void

set(int pos1, int pos2)

void

Sets the bits starting from pos1 to pos2.


set(int pos1, int pos2, boolean val)
Sets the bits starting from pos1 to pos2 to

void

the given val.

size()

int

Returns the number of bits this BitSet has.


toString()

Returns a string containing a concise, human-readable description of the


receiver.

String

xor(BitSet bs)

void

Performs the logical XOR of this BitSet with another BitSet.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
BitSet
public BitSet()

Create a new BitSet with size equal to 64 bits.


See Also:
clear(int), set(int), clear(), clear(int, int), set(int, boolean),
set(int, int), set(int, int, boolean)
BitSet
public BitSet(int nbits)

Create a new BitSet with size equal to nbits. If nbits is not a multiple of 64, then
create a BitSet with size nbits rounded to the next closest multiple of 64.
Parameters:
nbits - the size of the bit set.
Throws:
NegativeArraySizeException - if nbits is negative.
See Also:
clear(int), set(int), clear(), clear(int, int), set(int, boolean),
set(int, int), set(int, int, boolean)

Method Detail

Method Summary

296

Overview (Codename One API)


equals
public boolean equals(Object obj)

Compares the argument to this BitSet and returns whether they are equal. The
object must be an instance of BitSet with the same bits set.
Overrides:
equals in class Object
Parameters:
obj - the BitSet object to compare.
Returns:
a boolean indicating whether or not this BitSet and obj are equal.
See Also:
hashCode()

hashCode
public int hashCode()

Computes the hash code for this BitSet. If two BitSets are equal the have to return
the same result for hashCode().
Overrides:
hashCode in class Object
Returns:
the int representing the hash code for this bit set.
See Also:
equals(java.lang.Object), Hashtable
get
public boolean get(int pos)

Retrieves the bit at index pos. Grows the BitSet if pos > size.
Parameters:
pos - the index of the bit to be retrieved.
Returns:
true if the bit at pos is set, false otherwise.
Throws:
IndexOutOfBoundsException - if pos is negative.
See Also:
clear(int), set(int), clear(), clear(int, int), set(int, boolean),
set(int, int), set(int, int, boolean)
get
public BitSet get(int pos1,
int pos2)

Retrieves the bits starting from pos1 to pos2 and returns back a new bitset made of
these bits. Grows the BitSet if pos2 > size.
Parameters:
pos1 - beginning position.
pos2 - ending position.
Returns:
new bitset of the range specified.
Throws:
IndexOutOfBoundsException - if pos1 or pos2 is negative, or if pos2 is smaller
than pos1.
See Also:
get(int)

set
public void set(int pos)

Sets the bit at index pos to 1. Grows the BitSet if pos > size.
Parameters:
pos - the index of the bit to set.
Throws:
IndexOutOfBoundsException - if pos is negative.
See Also:

Method Detail

297

Overview (Codename One API)


clear(int), clear(), clear(int, int)

set
public void set(int pos,
boolean val)

Sets the bit at index pos to val. Grows the BitSet if pos > size.
Parameters:
pos - the index of the bit to set.
val - value to set the bit.
Throws:
IndexOutOfBoundsException - if pos is negative.
See Also:
set(int)

set
public void set(int pos1,
int pos2)

Sets the bits starting from pos1 to pos2. Grows the BitSet if pos2 > size.
Parameters:
pos1 - beginning position.
pos2 - ending position.
Throws:
IndexOutOfBoundsException - if pos1 or pos2 is negative, or if pos2 is smaller
than pos1.
See Also:
set(int)

set
public void set(int pos1,
int pos2,
boolean val)

Sets the bits starting from pos1 to pos2 to the given val. Grows the BitSet if pos2 >
size.
Parameters:
pos1 - beginning position.
pos2 - ending position.
val - value to set these bits.
Throws:
IndexOutOfBoundsException - if pos1 or pos2 is negative, or if pos2 is smaller
than pos1.
See Also:
set(int,int)

clear
public void clear()

Clears all the bits in this BitSet.


See Also:
clear(int), clear(int, int)
clear
public void clear(int pos)

Clears the bit at index pos. Grows the BitSet if pos > size.
Parameters:
pos - the index of the bit to clear.
Throws:
IndexOutOfBoundsException - if pos is negative.
See Also:
clear(int, int)

clear
public void clear(int pos1,
int pos2)

Method Detail

298

Overview (Codename One API)


Clears the bits starting from pos1 to pos2. Grows the BitSet if pos2 > size.
Parameters:
pos1 - beginning position.
pos2 - ending position.
Throws:
IndexOutOfBoundsException - if pos1 or pos2 is negative, or if pos2 is smaller
than pos1.
See Also:
clear(int)

flip
public void flip(int pos)

Flips the bit at index pos. Grows the BitSet if pos > size.
Parameters:
pos - the index of the bit to flip.
Throws:
IndexOutOfBoundsException - if pos is negative.
See Also:
flip(int, int)

flip
public void flip(int pos1,
int pos2)

Flips the bits starting from pos1 to pos2. Grows the BitSet if pos2 > size.
Parameters:
pos1 - beginning position.
pos2 - ending position.
Throws:
IndexOutOfBoundsException - if pos1 or pos2 is negative, or if pos2 is smaller
than pos1.
See Also:
flip(int)

intersects
public boolean intersects(BitSet bs)

Checks if these two BitSets have at least one bit set to true in the same position.
Parameters:
bs - BitSet used to calculate the intersection.
Returns:
true if bs intersects with this BitSet, false otherwise.
and
public void and(BitSet bs)

Performs the logical AND of this BitSet with another BitSet. The values of this
BitSet are changed accordingly.
Parameters:
bs - BitSet to AND with.
See Also:
or(java.util.BitSet), xor(java.util.BitSet)
andNot
public void andNot(BitSet bs)

Clears all bits in the receiver which are also set in the parameter BitSet. The values
of this BitSet are changed accordingly.
Parameters:
bs - BitSet to ANDNOT with.
or
public void or(BitSet bs)

Performs the logical OR of this BitSet with another BitSet. The values of this BitSet
are changed accordingly.

Method Detail

299

Overview (Codename One API)


Parameters:
bs - BitSet to OR with.
See Also:
xor(java.util.BitSet), and(java.util.BitSet)

xor
public void xor(BitSet bs)

Performs the logical XOR of this BitSet with another BitSet. The values of this
BitSet are changed accordingly.
Parameters:
bs - BitSet to XOR with.
See Also:
or(java.util.BitSet), and(java.util.BitSet)
size
public int size()

Returns the number of bits this BitSet has.


Returns:
the number of bits contained in this BitSet.
See Also:
length()

length
public int length()

Returns the number of bits up to and including the highest bit set.
Returns:
the length of the BitSet.
toString
public String toString()

Returns a string containing a concise, human-readable description of the receiver.


Overrides:
toString in class Object
Returns:
a comma delimited list of the indices of all bits that are set.
nextSetBit
public int nextSetBit(int pos)

Returns the position of the first bit that is true on or after pos.
Parameters:
pos - the starting position (inclusive).
Returns:
-1 if there is no bits that are set to true on or after pos.
nextClearBit
public int nextClearBit(int pos)

Returns the position of the first bit that is false on or after pos.
Parameters:
pos - the starting position (inclusive).
Returns:
the position of the next bit set to false, even if it is further than this BitSet's
size.
isEmpty
public boolean isEmpty()

Returns true if all the bits in this BitSet are set to false.
Returns:
true if the BitSet is empty, false otherwise.

Method Detail

300

Overview (Codename One API)


cardinality
public int cardinality()

Returns the number of bits that are true in this BitSet.


Returns:
the number of true bits in the set.

Method Detail

301

Overview (Codename One API)


java.util

Class Arrays
java.lang.Object

java.util.Arrays

public class
extends Object
Arrays

contains static methods which operate on arrays.

Since:
1.2

Method Summary
Modifier and
Type
static
<T> List<T>

Method and Description


asList(T... array)
Returns a List of the

objects in the specified array.

binarySearch(byte[] array, byte value)


static int

static int

Performs a binary search for the specified element in the specified


ascending sorted array.
binarySearch(byte[] array, int startIndex, int endIndex,
byte value)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(char[] array, char value)

static int

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(char[] array, int startIndex, int endIndex,
char value)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(double[] array, double value)

static int

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(double[] array, int startIndex, int endIndex,
double value)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(float[] array, float value)

static int

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(float[] array, int startIndex, int endIndex,
float value)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(int[] array, int value)

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(int[] array, int startIndex, int endIndex, int value)

static int

static int

Class Arrays

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(long[] array, int startIndex, int endIndex,
long value)

Performs a binary search for the specified element in a part of the specified
sorted array.

302

Overview (Codename One API)


binarySearch(long[] array, long value)
static int

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(Object[] array, int startIndex, int endIndex,
Object object)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(Object[] array, Object object)

static int

static int

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(short[] array, int startIndex, int endIndex,
short value)

Performs a binary search for the specified element in a part of the specified
sorted array.
binarySearch(short[] array, short value)

static int

static <T> int

static <T> int

static
boolean[]

Performs a binary search for the specified element in the specified sorted
array.
binarySearch(T[] array, int startIndex, int endIndex, T object,
Comparator<? super T> comparator)

Performs a binary search for the specified element in a part of the specified
sorted array using the Comparator to compare elements.
binarySearch(T[] array, T object, Comparator<? super
T> comparator)

Performs a binary search for the specified element in the specified sorted
array using the Comparator to compare elements.
copyOfRange(boolean[] original, int start, int end)

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(byte[] original, int start, int end)

static byte[]

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(char[] original, int start, int end)

static char[]

static
double[]

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(double[] original, int start, int end)

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(float[] original, int start, int end)

static float[]

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(int[] original, int start, int end)

static int[]

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(long[] original, int start, int end)

static long[]

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
copyOfRange(short[] original, int start, int end)

static short[]

static boolean
static int

static String

Copies elements in original array to a new array, from index start(inclusive)


to end(exclusive).
deepEquals(Object[] array1, Object[] array2)
Returns true if the two given arrays are deeply equal

to one another.

deepHashCode(Object[] array)

Returns a hash code based on the "deep contents" of the given array.
deepToString(Object[] array)
Creates a "deep" String representation of the Object[] passed, such that
if the array contains other arrays, the String representation of those arrays

is generated as well.
static boolean
static boolean

Method Summary

equals(boolean[] array1, boolean[] array2)

Compares the two arrays.


equals(byte[] array1, byte[] array2)

Compares the two arrays.

303

Overview (Codename One API)


static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static int
static int
static int
static int

Method Summary

equals(char[] array1, char[] array2)

Compares the two arrays.


equals(double[] array1, double[] array2)

Compares the two arrays.


equals(float[] array1, float[] array2)

Compares the two arrays.


equals(int[] array1, int[] array2)

Compares the two arrays.


equals(long[] array1, long[] array2)

Compares the two arrays.


equals(Object[] array1, Object[] array2)

Compares the two arrays.


equals(short[] array1, short[] array2)

Compares the two arrays.


fill(boolean[] array, boolean value)

Fills the specified array with the specified element.


fill(boolean[] array, int start, int end, boolean value)

Fills the specified range in the array with the specified element.
fill(byte[] array, byte value)

Fills the specified array with the specified element.


fill(byte[] array, int start, int end, byte value)

Fills the specified range in the array with the specified element.
fill(char[] array, char value)

Fills the specified array with the specified element.


fill(char[] array, int start, int end, char value)

Fills the specified range in the array with the specified element.
fill(double[] array, double value)

Fills the specified array with the specified element.


fill(double[] array, int start, int end, double value)

Fills the specified range in the array with the specified element.
fill(float[] array, float value)

Fills the specified array with the specified element.


fill(float[] array, int start, int end, float value)

Fills the specified range in the array with the specified element.
fill(int[] array, int value)

Fills the specified array with the specified element.


fill(int[] array, int start, int end, int value)

Fills the specified range in the array with the specified element.
fill(long[] array, int start, int end, long value)

Fills the specified range in the array with the specified element.
fill(long[] array, long value)

Fills the specified array with the specified element.


fill(Object[] array, int start, int end, Object value)

Fills the specified range in the array with the specified element.
fill(Object[] array, Object value)

Fills the specified array with the specified element.


fill(short[] array, int start, int end, short value)

Fills the specified range in the array with the specified element.
fill(short[] array, short value)

Fills the specified array with the specified element.


hashCode(boolean[] array)

Returns a hash code based on the contents of the given array.


hashCode(byte[] array)

Returns a hash code based on the contents of the given array.


hashCode(char[] array)

Returns a hash code based on the contents of the given array.


hashCode(double[] array)

Returns a hash code based on the contents of the given array.

304

Overview (Codename One API)


static int
static int
static int
static int
static int
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void

hashCode(float[] array)

Returns a hash code based on the contents of the given array.


hashCode(int[] array)

Returns a hash code based on the contents of the given array.


hashCode(long[] array)

Returns a hash code based on the contents of the given array.


hashCode(Object[] array)

Returns a hash code based on the contents of the given array.


hashCode(short[] array)

Returns a hash code based on the contents of the given array.


sort(byte[] array)

Sorts the specified array in ascending numerical order.


sort(byte[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(char[] array)

Sorts the specified array in ascending numerical order.


sort(char[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(double[] array)

Sorts the specified array in ascending numerical order.


sort(double[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(float[] array)

Sorts the specified array in ascending numerical order.


sort(float[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(int[] array)

Sorts the specified array in ascending numerical order.


sort(int[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(long[] array)

Sorts the specified array in ascending numerical order.


sort(long[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.


sort(Object[] array)

Sorts the specified array in ascending natural order.


sort(Object[] array, int start, int end)

Sorts the specified range in the array in ascending natural order.


sort(short[] array)

Sorts the specified array in ascending numerical order.


sort(short[] array, int start, int end)

Sorts the specified range in the array in ascending numerical order.

static
<T> void

sort(T[] array, Comparator<? super T> comparator)


Sorts the specified array using the specified Comparator.

static
<T> void

sort(T[] array, int start, int end, Comparator<? super


T> comparator)
Sorts the specified range in the array using the specified Comparator.

static String

toString(boolean[] array)
Creates a String representation

of the boolean[] passed.

static String

toString(byte[] array)
Creates a String representation

of the byte[] passed.

static String

toString(char[] array)
Creates a String representation

of the char[] passed.

static String

toString(double[] array)
Creates a String representation

of the double[] passed.

static String

toString(float[] array)
Creates a String representation

of the float[] passed.

static String

toString(int[] array)

Method Summary

305

Overview (Codename One API)


Creates a String representation of the int[] passed.
static String

toString(long[] array)
Creates a String representation

of the long[] passed.

static String

toString(Object[] array)
Creates a String representation

of the Object[] passed.

static String

toString(short[] array)
Creates a String representation

of the short[] passed.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

asList
public static <T> List<T> asList(T... array)

Returns a List of the objects in the specified array. The size of the List cannot be
modified, i.e. adding and removing are unsupported, but the elements can be set.
Setting an element modifies the underlying array.
Parameters:
array - the array.
Returns:
a List of the elements of the specified array.
binarySearch
public static int binarySearch(byte[] array,
byte value)

Performs a binary search for the specified element in the specified ascending sorted
array. Searching in an unsorted array has an undefined result. It's also undefined
which element is found if there are multiple occurrences of the same element.
Parameters:
array - the sorted byte array to search.
value - the byte element to find.
Returns:
the non-negative index of the element, or a negative index which is -index 1 where the element would be inserted.
binarySearch
public static int binarySearch(char[] array,
char value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted char array to search
value - the char element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(double[] array,
double value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted double array to search
value - the double element to find
Returns:

Methods inherited from class java.lang.Object

306

Overview (Codename One API)


the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(float[] array,
float value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted float array to search
value - the float element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(int[] array,
int value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted int array to search
value - the int element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(long[] array,
long value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted long array to search
value - the long element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(Object[] array,
Object object)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted Object array to search
object - the Object element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
ClassCastException - when an element in the array or the search element
does not implement Comparable, or cannot be compared to each other
binarySearch
public static <T> int binarySearch(T[] array,
T object,
Comparator<? super T> comparator)

Performs a binary search for the specified element in the specified sorted array using
the Comparator to compare elements.
Type Parameters:
T - type of object
Parameters:
array - the sorted Object array to search
object - the char element to find

Method Detail

307

Overview (Codename One API)


comparator - the Comparator
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
ClassCastException - when an element in the array and the search element
cannot be compared to each other using the Comparator
binarySearch
public static int binarySearch(short[] array,
short value)

Performs a binary search for the specified element in the specified sorted array.
Parameters:
array - the sorted short array to search
value - the short element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
binarySearch
public static int binarySearch(byte[] array,
int startIndex,
int endIndex,
byte value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted byte array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the byte element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static int binarySearch(char[] array,
int startIndex,
int endIndex,
char value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted char array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the char element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6

Method Detail

308

Overview (Codename One API)


binarySearch
public static int binarySearch(double[] array,
int startIndex,
int endIndex,
double value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted double array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the double element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static int binarySearch(float[] array,
int startIndex,
int endIndex,
float value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted float array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the float element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static int binarySearch(int[] array,
int startIndex,
int endIndex,
int value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted int array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the int element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:

Method Detail

309

Overview (Codename One API)


1.6
binarySearch
public static int binarySearch(long[] array,
int startIndex,
int endIndex,
long value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted long array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the long element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static int binarySearch(Object[] array,
int startIndex,
int endIndex,
Object object)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted Object array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
object - the object element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
ClassCastException - when an element in the array or the search element
does not implement Comparable, or cannot be compared to each other
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static <T> int binarySearch(T[] array,
int startIndex,
int endIndex,
T object,
Comparator<? super T> comparator)

Performs a binary search for the specified element in a part of the specified sorted
array using the Comparator to compare elements.
Type Parameters:
T - type of object
Parameters:
array - the sorted Object array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
object - the value element to find
comparator - the Comparator

Method Detail

310

Overview (Codename One API)


Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
ClassCastException - when an element in the array and the search element
cannot be compared to each other using the Comparator
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
binarySearch
public static int binarySearch(short[] array,
int startIndex,
int endIndex,
short value)

Performs a binary search for the specified element in a part of the specified sorted
array.
Parameters:
array - the sorted short array to search
startIndex - the inclusive start index
endIndex - the exclusive end index
value - the short element to find
Returns:
the non-negative index of the element, or a negative index which is the -index
- 1 where the element would be inserted
Throws:
IllegalArgumentException - - if startIndex is bigger than endIndex
ArrayIndexOutOfBoundsException - - if startIndex is smaller than zero or or
endIndex is bigger than length of array
Since:
1.6
fill
public static void fill(byte[] array,
byte value)

Fills the specified array with the specified element.


Parameters:
array - the byte array to fill.
value - the byte element.
fill
public static void fill(byte[] array,
int start,
int end,
byte value)

Fills the specified range in the array with the specified element.
Parameters:
array - the byte array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the byte element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(short[] array,
short value)

Fills the specified array with the specified element.


Parameters:
array - the short array to fill.
value - the short element.

Method Detail

311

Overview (Codename One API)


fill
public static void fill(short[] array,
int start,
int end,
short value)

Fills the specified range in the array with the specified element.
Parameters:
array - the short array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the short element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(char[] array,
char value)

Fills the specified array with the specified element.


Parameters:
array - the char array to fill.
value - the char element.
fill
public static void fill(char[] array,
int start,
int end,
char value)

Fills the specified range in the array with the specified element.
Parameters:
array - the char array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the char element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(int[] array,
int value)

Fills the specified array with the specified element.


Parameters:
array - the int array to fill.
value - the int element.
fill
public static void fill(int[] array,
int start,
int end,
int value)

Fills the specified range in the array with the specified element.
Parameters:
array - the int array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the int element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.

Method Detail

312

Overview (Codename One API)


fill
public static void fill(long[] array,
long value)

Fills the specified array with the specified element.


Parameters:
array - the long array to fill.
value - the long element.
fill
public static void fill(long[] array,
int start,
int end,
long value)

Fills the specified range in the array with the specified element.
Parameters:
array - the long array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the long element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(float[] array,
float value)

Fills the specified array with the specified element.


Parameters:
array - the float array to fill.
value - the float element.
fill
public static void fill(float[] array,
int start,
int end,
float value)

Fills the specified range in the array with the specified element.
Parameters:
array - the float array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the float element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(double[] array,
double value)

Fills the specified array with the specified element.


Parameters:
array - the double array to fill.
value - the double element.
fill
public static void fill(double[] array,
int start,
int end,
double value)

Fills the specified range in the array with the specified element.
Parameters:
array - the double array to fill.

Method Detail

313

Overview (Codename One API)


start - the first index to fill.
end - the last + 1 index to fill.
value - the double element.

Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0

or end > array.length.

fill
public static void fill(boolean[] array,
boolean value)

Fills the specified array with the specified element.


Parameters:
array - the boolean array to fill.
value - the boolean element.
fill
public static void fill(boolean[] array,
int start,
int end,
boolean value)

Fills the specified range in the array with the specified element.
Parameters:
array - the boolean array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the boolean element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
fill
public static void fill(Object[] array,
Object value)

Fills the specified array with the specified element.


Parameters:
array - the Object array to fill.
value - the Object element.
fill
public static void fill(Object[] array,
int start,
int end,
Object value)

Fills the specified range in the array with the specified element.
Parameters:
array - the Object array to fill.
start - the first index to fill.
end - the last + 1 index to fill.
value - the Object element.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
hashCode
public static int hashCode(boolean[] array)

Returns a hash code based on the contents of the given array. For any two boolean
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Boolean} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.

Method Detail

314

Overview (Codename One API)


Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(int[] array)

Returns a hash code based on the contents of the given array. For any two not-null
int arrays a and b, if Arrays.equals(a, b) returns true, it means that the return
value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Integer} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(short[] array)

Returns a hash code based on the contents of the given array. For any two short
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Short} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(char[] array)

Returns a hash code based on the contents of the given array. For any two char
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Character} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(byte[] array)

Returns a hash code based on the contents of the given array. For any two byte
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Byte} instances
representing the elements of array in the same order. If the array is null, the return

Method Detail

315

Overview (Codename One API)


value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(long[] array)

Returns a hash code based on the contents of the given array. For any two long
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Long} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(float[] array)

Returns a hash code based on the contents of the given array. For any two float
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Float} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(double[] array)

Returns a hash code based on the contents of the given array. For any two double
arrays a and b, if Arrays.equals(a, b) returns true, it means that the return value of
Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the List.hashCode()}
method which is invoked on a List} containing a sequence of Double} instances
representing the elements of array in the same order. If the array is null, the return
value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
hashCode
public static int hashCode(Object[] array)

Returns a hash code based on the contents of the given array. If the array contains
other arrays as its elements, the hash code is based on their identities not their
contents. So it is acceptable to invoke this method on an array that contains itself as
an element, either directly or indirectly.

Method Detail

316

Overview (Codename One API)


For any two arrays a and b, if Arrays.equals(a, b) returns true, it means that the
return value of Arrays.hashCode(a) equals Arrays.hashCode(b).
The value returned by this method is the same value as the method
Arrays.asList(array).hashCode(). If the array is null, the return value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
deepHashCode
public static int deepHashCode(Object[] array)

Returns a hash code based on the "deep contents" of the given array. If the array
contains other arrays as its elements, the hash code is based on their contents not
their identities. So it is not acceptable to invoke this method on an array that contains
itself as an element, either directly or indirectly.
For any two arrays a and b, if Arrays.deepEquals(a, b) returns true, it means that
the return value of Arrays.deepHashCode(a) equals Arrays.deepHashCode(b).
The computation of the value returned by this method is similar to that of the value
returned by List.hashCode()} invoked on a List} containing a sequence of instances
representing the elements of array in the same order. The difference is: If an element
e of array is itself an array, its hash code is computed by calling the appropriate
overloading of Arrays.hashCode(e) if e is an array of a primitive type, or by calling
Arrays.deepHashCode(e) recursively if e is an array of a reference type. The value
returned by this method is the same value as the method
Arrays.asList(array).hashCode(). If the array is null, the return value is 0.
Parameters:
array - the array whose hash code to compute.
Returns:
the hash code for array.
equals
public static boolean equals(byte[] array1,
byte[] array2)

Compares the two arrays.


Parameters:
array1 - the first byte array.
array2 - the second byte array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
equals
public static boolean equals(short[] array1,
short[] array2)

Compares the two arrays.


Parameters:
array1 - the first short array.
array2 - the second short array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
equals
public static boolean equals(char[] array1,
char[] array2)

Compares the two arrays.


Parameters:
array1 - the first char array.

Method Detail

317

Overview (Codename One API)


array2

- the second char array.

Returns:
if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
true

equals
public static boolean equals(int[] array1,
int[] array2)

Compares the two arrays.


Parameters:
array1 - the first int array.
array2 - the second int array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
equals
public static boolean equals(long[] array1,
long[] array2)

Compares the two arrays.


Parameters:
array1 - the first long array.
array2 - the second long array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
equals
public static boolean equals(float[] array1,
float[] array2)

Compares the two arrays. The values are compared in the same manner as
Float.equals().
Parameters:
array1 - the first float array.
array2 - the second float array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
See Also:
Float.equals(Object)

equals
public static boolean equals(double[] array1,
double[] array2)

Compares the two arrays. The values are compared in the same manner as
Double.equals().
Parameters:
array1 - the first double array.
array2 - the second double array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
See Also:
Double.equals(Object)

equals
public static boolean equals(boolean[] array1,
boolean[] array2)

Compares the two arrays.


Parameters:
array1 - the first boolean array.
array2 - the second boolean array.
Returns:

Method Detail

318

Overview (Codename One API)


if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal, false otherwise.
true

equals
public static boolean equals(Object[] array1,
Object[] array2)

Compares the two arrays.


Parameters:
array1 - the first Object array.
array2 - the second Object array.
Returns:
true if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal according to equals(),
false otherwise.
deepEquals
public static boolean deepEquals(Object[] array1,
Object[] array2)

Returns true if the two given arrays are deeply equal to one another. Unlike the
method equals(Object[] array1, Object[] array2), this method is appropriate for
use for nested arrays of arbitrary depth.
Two array references are considered deeply equal if they are both null, or if they
refer to arrays that have the same length and the elements at each index in the two
arrays are equal.
Two null elements element1 and element2 are possibly deeply equal if any of the
following conditions satisfied:
element1 and element2 are both arrays of object reference types,
Arrays.deepEquals(element1, element2) would return true.

and

and element2 are arrays of the same primitive type, and the appropriate
overloading of Arrays.equals(element1, element2) would return true.
element1

element1 == element2
element1.equals(element2)

would return true.

Note that this definition permits null elements at any depth.


If either of the given arrays contain themselves as elements, the behavior of this
method is uncertain.
Parameters:
array1
array2

- the first Object array.


- the second Object array.

Returns:
if both arrays are null or if the arrays have the same length and the
elements at each index in the two arrays are equal according to equals(),
false otherwise.
true

sort
public static void sort(byte[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the byte array to be sorted.
sort
public static void sort(byte[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order.

Method Detail

319

Overview (Codename One API)


Parameters:
array - the byte array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.

Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0

or end > array.length.

sort
public static void sort(char[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the char array to be sorted.
sort
public static void sort(char[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order.


Parameters:
array - the char array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
sort
public static void sort(double[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the double array to be sorted.
See Also:
sort(double[], int, int)

sort
public static void sort(double[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order. The values are
sorted according to the order imposed by Double.compareTo().
Parameters:
array - the double array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
See Also:
Double#compareTo(Double)

sort
public static void sort(float[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the float array to be sorted.
See Also:
sort(float[], int, int)

sort
public static void sort(float[] array,
int start,
int end)

Method Detail

320

Overview (Codename One API)


Sorts the specified range in the array in ascending numerical order. The values are
sorted according to the order imposed by Float.compareTo().
Parameters:
array - the float array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
See Also:
Float#compareTo(Float)

sort
public static void sort(int[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the int array to be sorted.
sort
public static void sort(int[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order.


Parameters:
array - the int array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
sort
public static void sort(long[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the long array to be sorted.
sort
public static void sort(long[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order.


Parameters:
array - the long array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
sort
public static void sort(Object[] array)

Sorts the specified array in ascending natural order.


Parameters:
array - the Object array to be sorted.
Throws:
ClassCastException - if an element in the array does not implement
Comparable or if some elements cannot be compared to each other.
See Also:
sort(Object[], int, int)

Method Detail

321

Overview (Codename One API)


sort
public static void sort(Object[] array,
int start,
int end)

Sorts the specified range in the array in ascending natural order. All elements must
implement the Comparable interface and must be comparable to each other without a
ClassCastException being thrown.
Parameters:
array - the Object array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
Throws:
ClassCastException - if an element in the array does not implement
Comparable or some elements cannot be compared to each other.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
sort
public static <T> void sort(T[] array,
int start,
int end,
Comparator<? super T> comparator)

Sorts the specified range in the array using the specified Comparator. All elements
must be comparable to each other without a ClassCastException being thrown.
Parameters:
array - the Object array to be sorted.
start - the start index to sort.
end - the last + 1 index to sort.
comparator - the Comparator.
Throws:
ClassCastException - if elements in the array cannot be compared to each
other using the Comparator.
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0 or end > array.length.
sort
public static <T> void sort(T[] array,
Comparator<? super T> comparator)

Sorts the specified array using the specified Comparator. All elements must be
comparable to each other without a ClassCastException being thrown.
Parameters:
array - the Object array to be sorted.
comparator - the Comparator.
Throws:
ClassCastException - if elements in the array cannot be compared to each
other using the Comparator.
sort
public static void sort(short[] array)

Sorts the specified array in ascending numerical order.


Parameters:
array - the short array to be sorted.
sort
public static void sort(short[] array,
int start,
int end)

Sorts the specified range in the array in ascending numerical order.


Parameters:
array - the short array to be sorted.

Method Detail

322

Overview (Codename One API)


start - the start index to sort.
end - the last + 1 index to sort.

Throws:
IllegalArgumentException - if start > end.
ArrayIndexOutOfBoundsException - if start < 0

or end > array.length.

toString
public static String toString(boolean[] array)

Creates a String representation of the boolean[] passed. The result is surrounded


by brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(boolean) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the boolean array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(byte[] array)

Creates a String representation of the byte[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(int) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the byte array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(char[] array)

Creates a String representation of the char[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(char) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the char array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(double[] array)

Creates a String representation of the double[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(double) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the double array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(float[] array)

Method Detail

323

Overview (Codename One API)


Creates a String representation of the float[] passed. The result is surrounded by
brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(float) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the float array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(int[] array)

Creates a String representation of the int[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(int) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the int array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(long[] array)

Creates a String representation of the long[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(long) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the long array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(short[] array)

Creates a String representation of the short[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(int) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the short array to convert.
Returns:
the String representation of array.
Since:
1.5
toString
public static String toString(Object[] array)

Creates a String representation of the Object[] passed. The result is surrounded by


brackets (&quot;[]&quot;), each element is converted to a String via the
String.valueOf(Object) and separated by &quot;, &quot;. If the array is null, then
&quot;null&quot; is returned.
Parameters:
array - the Object array to convert.
Returns:
the String representation of array.
Since:
1.5

Method Detail

324

Overview (Codename One API)


deepToString
public static String deepToString(Object[] array)

Creates a "deep" String representation of the Object[] passed, such that if the array
contains other arrays, the String representation of those arrays is generated as well.
If any of the elements are primitive arrays, the generation is delegated to the other
toString methods in this class. If any element contains a reference to the original
array, then it will be represented as "[...]". If an element is an Object[], then its
representation is generated by a recursive call to this method. All other elements are
converted via the String.valueOf(Object) method.
Parameters:
array - the Object array to convert.
Returns:
the String representation of array.
Since:
1.5
copyOfRange
public static boolean[] copyOfRange(boolean[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is false.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6
copyOfRange
public static byte[] copyOfRange(byte[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is (byte)0.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6

Method Detail

325

Overview (Codename One API)


copyOfRange
public static char[] copyOfRange(char[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is '\\u000'.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6
copyOfRange
public static double[] copyOfRange(double[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is 0d.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6
copyOfRange
public static float[] copyOfRange(float[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is 0f.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null

Method Detail

326

Overview (Codename One API)


Since:
1.6
copyOfRange
public static int[] copyOfRange(int[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is 0.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6
copyOfRange
public static long[] copyOfRange(long[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is 0L.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length
IllegalArgumentException - if start is bigger than end
NullPointerException - if original is null
Since:
1.6
copyOfRange
public static short[] copyOfRange(short[] original,
int start,
int end)

Copies elements in original array to a new array, from index start(inclusive) to


end(exclusive). The first element (if any) in the new array is original[from], and other
elements in the new array are in the original order. The padding value whose index is
bigger than or equal to original.length - start is (short)0.
Parameters:
original - the original array
start - the start index, inclusive
end - the end index, exclusive, may bigger than length of the array
Returns:
the new copied array
Throws:
ArrayIndexOutOfBoundsException - if start is smaller than 0 or bigger than
original.length

Method Detail

327

Overview (Codename One API)


IllegalArgumentException - if start is bigger
NullPointerException - if original is null

than end

Since:
1.6

Method Detail

328

Overview (Codename One API)


java.util

Class ArrayList<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>

java.util.ArrayList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, RandomAccess

public class
extends AbstractList<E>
implements List<E>, RandomAccess

ArrayList is an implementation of List, backed by an array. All optional operations adding, removing,
and replacing are supported. The elements can be any objects.
Since:
1.2

Field Summary

Fields inherited from class java.util.AbstractList


modCount

Constructor Summary
Constructor and Description
ArrayList()

Constructs a new instance of ArrayList with ten capacity.


ArrayList(Collection<? extends E> collection)
Constructs a new instance of ArrayList containing

the elements of the specified collection.

ArrayList(int capacity)

Constructs a new instance of ArrayList with the specified capacity.

Method Summary
Modifier and
Type
boolean
void
boolean

Method and Description


add(E object)

Adds the specified object at the end of this ArrayList.


add(int location, E object)

Inserts the specified object into this ArrayList at the specified location.
addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to this ArrayList.


addAll(int location, Collection<? extends E> collection)

boolean

void

Inserts the objects in the specified collection at the specified location in this
List.
clear()

Removes all elements from this ArrayList, leaving it empty.

boolean

contains(Object object)
Searches this ArrayList for

void

ensureCapacity(int minimumCapacity)

Class ArrayList<E>

the specified object.

329

Overview (Codename One API)


Ensures that after this operation the ArrayList can hold the specified
number of elements without further growing.
get(int location)

Returns the element at the specified location in this list.


indexOf(Object object)

Searches this list for the specified object and returns the index of the first
occurrence.

int

boolean

isEmpty()

Returns if this Collection contains no elements.


lastIndexOf(Object object)

Searches this list for the specified object and returns the index of the last
occurrence.

int

remove(int location)

Removes the object at the specified location from this list.


remove(Object object)

boolean

protected
void

Removes one instance of the specified object from this Collection if one is
contained (optional).
removeRange(int start, int end)

Removes the objects in the specified range from the start to the end, but not
including the end index.
set(int location, E object)

Replaces the element at the specified location in this ArrayList with the
specified object.

size()

int

Returns the number of elements in this ArrayList.

Object[]
<T> T[]

toArray()

Returns a new array containing all elements contained in this ArrayList.


toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList.


trimToSize()

void

Sets the capacity of this ArrayList to be the same as the current size.

Methods inherited from class java.util.AbstractList


equals, hashCode, iterator, listIterator, listIterator, subList

Methods inherited from class java.util.AbstractCollection


containsAll, removeAll, retainAll, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


containsAll, equals, hashCode, iterator, listIterator, listIterator,
removeAll, retainAll, subList

Constructor Detail
ArrayList
public ArrayList()

Constructs a new instance of ArrayList with ten capacity.

Method Summary

330

Overview (Codename One API)


ArrayList
public ArrayList(int capacity)

Constructs a new instance of ArrayList with the specified capacity.


Parameters:
capacity - the initial capacity of this ArrayList.
ArrayList
public ArrayList(Collection<? extends E> collection)

Constructs a new instance of ArrayList containing the elements of the specified


collection. The initial size of the ArrayList will be 10% larger than the size of the
specified collection.
Parameters:
collection - the collection of elements to add.

Method Detail

add
public void add(int location,
E object)

Inserts the specified object into this ArrayList at the specified location. The object is
inserted before any previous element at the specified location. If the location is equal
to the size of this ArrayList, the object is added at the end.
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
location - the index at which to insert the object.
object - the object to add.
Throws:
IndexOutOfBoundsException - when location < 0 || > size()
add
public boolean add(E object)

Adds the specified object at the end of this ArrayList.


Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
object - the object to add.
Returns:
always true
addAll
public boolean addAll(int location,
Collection<? extends E> collection)

Inserts the objects in the specified collection at the specified location in this List. The
objects are added in the order they are returned from the collection's iterator.
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractList<E>
Parameters:

Constructor Detail

331

Overview (Codename One API)


location - the index at which to insert.
collection - the collection of objects.

Returns:
true

if this ArrayList is modified, false otherwise.

Throws:
IndexOutOfBoundsException

- when location < 0 || > size()

addAll
public boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified collection to this ArrayList.


Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects.
Returns:
true if this ArrayList is modified, false otherwise.
clear
public void clear()

Removes all elements from this ArrayList, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class AbstractList<E>
See Also:
isEmpty(), size
contains
public boolean contains(Object object)

Searches this ArrayList for the specified object.


Specified by:
contains in interface Collection<E>
Specified by:
contains in interface List<E>
Overrides:
contains in class AbstractCollection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this ArrayList, false otherwise
ensureCapacity
public void ensureCapacity(int minimumCapacity)

Ensures that after this operation the ArrayList can hold the specified number of
elements without further growing.
Parameters:
minimumCapacity - the minimum capacity asked for.
get
public E get(int location)

Description copied from class: AbstractList


Returns the element at the specified location in this list.
Specified by:
get in interface List<E>
Specified by:

Method Detail

332

Overview (Codename One API)


get in class AbstractList<E>
Parameters:
location - the index of the element to return.
Returns:
the element at the specified index.
indexOf
public int indexOf(Object object)

Description copied from class: AbstractList


Searches this list for the specified object and returns the index of the first occurrence.
Specified by:
indexOf in interface List<E>
Overrides:
indexOf in class AbstractList<E>
Parameters:
object - the object to search for.
Returns:
the index of the first occurrence of the object, or -1 if it was not found.
isEmpty
public boolean isEmpty()

Description copied from class: AbstractCollection


Returns if this Collection contains no elements. This implementation tests, whether
size returns 0.
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface List<E>
Overrides:
isEmpty in class AbstractCollection<E>
Returns:
true if this Collection has no elements, false otherwise.
See Also:
AbstractCollection.size()

lastIndexOf
public int lastIndexOf(Object object)

Description copied from class: AbstractList


Searches this list for the specified object and returns the index of the last occurrence.
Specified by:
lastIndexOf in interface List<E>
Overrides:
lastIndexOf in class AbstractList<E>
Parameters:
object - the object to search for.
Returns:
the index of the last occurrence of the object, or -1 if the object was not
found.
remove
public E remove(int location)

Removes the object at the specified location from this list.


Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractList<E>
Parameters:
location - the index of the object to remove.
Returns:
the removed object.
Throws:
IndexOutOfBoundsException - when location < 0 || >= size()

Method Detail

333

Overview (Codename One API)


remove
public boolean remove(Object object)

Description copied from class: AbstractCollection


Removes one instance of the specified object from this Collection if one is contained
(optional). This implementation iterates over this Collection and tests for each
element e returned by the iterator, whether e is equal to the given object. If object !=
null then this test is performed using object.equals(e), otherwise using object ==
null. If an element equal to the given object is found, then the remove method is
called on the iterator and true is returned, false otherwise. If the iterator does not
support removing elements, an UnsupportedOperationException is thrown.
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
object - the object to remove.
Returns:
true if this Collection is modified, false otherwise.
removeRange
protected void removeRange(int start,
int end)

Removes the objects in the specified range from the start to the end, but not including
the end index.
Overrides:
removeRange in class AbstractList<E>
Parameters:
start - the index at which to start removing.
end - the index one after the end of the range to remove.
Throws:
IndexOutOfBoundsException - when start < 0, start > end or end >
size()

set
public E set(int location,
E object)

Replaces the element at the specified location in this ArrayList with the specified
object.
Specified by:
set in interface List<E>
Overrides:
set in class AbstractList<E>
Parameters:
location - the index at which to put the specified object.
object - the object to add.
Returns:
the previous element at the index.
Throws:
IndexOutOfBoundsException - when location < 0 || >= size()
size
public int size()

Returns the number of elements in this ArrayList.


Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

Method Detail

334

Overview (Codename One API)


Returns:
the number of elements in this ArrayList.
toArray
public Object[] toArray()

Returns a new array containing all elements contained in this ArrayList.


Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Returns:
an array of the elements from this ArrayList
toArray
public <T> T[] toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
ArrayList, the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractList<E>
Parameters:
contents - the array.
Returns:
an array of the elements from this ArrayList.
Throws:
ArrayStoreException - when the type of an element in this ArrayList cannot
be stored in the type of the specified array.
trimToSize
public void trimToSize()

Sets the capacity of this ArrayList to be the same as the current size.
See Also:
size

Method Detail

335

Overview (Codename One API)


java.util

Class ArrayDeque<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.ArrayDeque<E>
Type Parameters:
E - the type of elements in this collection
All Implemented Interfaces:
Iterable<E>, Collection<E>, Deque<E>, Queue<E>

public class
extends AbstractCollection<E>
implements Deque<E>

An implementation of Deque, backed by an array. ArrayDeques have no size limit, can not contain
null element, and they are not thread-safe. All optional operations are supported, and the elements
can be any objects.
Since:
1.6

Constructor Summary
Constructor and Description
ArrayDeque()

Constructs a new empty instance of ArrayDeque big enough for 16 elements.


ArrayDeque(Collection<? extends E> c)

Constructs a new instance of ArrayDeque containing the elements of the specified collection,
with the order returned by the collection's iterator.
ArrayDeque(int minSize)

Constructs a new empty instance of ArrayDeque big enough for specified number of
elements.

Method Summary
Modifier and
Type
boolean

Method and Description


add(E e)

Inserts the element to the tail of the deque.


addFirst(E e)

void

Inserts an element at the head of this deque if it dose not violate size limit
immediately.
addLast(E e)

void

void
boolean
Iterator<E>
E
E

Class ArrayDeque<E>

Inserts an element at the tail of this deque if it dose not violate size limit
immediately.
clear()

Empty the deque.


contains(Object obj)

Returns true if the specified element is in the deque.


descendingIterator()

Returns the iterator in reverse order, from tail to head.


element()

Gets but does not remove the head element of this deque.
getFirst()

Gets but not removes the head element of this deque.

336

Overview (Codename One API)


getLast()

Gets but not removes the tail element of this deque.

boolean
Iterator<E>
boolean

isEmpty()

Returns true if the deque has no elements.


iterator()

Returns the iterator of the deque.


offer(E e)

Inserts the element at the tail of the deque.


offerFirst(E e)

boolean

Inserts an element at the head of this deque unless it would violate size
limit.
offerLast(E e)

boolean

Inserts an element at the tail of this deque unless it would violate size
limit.
peek()

Gets but not removes the head element of this deque.


peekFirst()

Gets but not removes the head element of this deque.


peekLast()

Gets but not removes the tail element of this deque.


poll()

Gets and removes the head element of this deque.


pollFirst()

Gets and removes the head element of this deque.


pollLast()

Gets and removes the tail element of this deque.


pop()

Pops the head element of the deque, just same as removeFirst().


push(E e)

Pushes the element to the deque(at the head of the deque), just same as
addFirst(E).

void

remove()

Gets and removes the head element of this deque.

boolean

remove(Object obj)

Removes the first equivalent element of the specified object.


removeFirst()

Gets and removes the head element of this deque.

boolean

removeFirstOccurrence(Object obj)

Removes the first equivalent element of the specified object.


removeLast()

Gets and removes the tail element of this deque.

boolean

removeLastOccurrence(Object obj)

Removes the last equivalent element of the specified object.


size()

int

Returns the size of the deque.

Methods inherited from class java.util.AbstractCollection


addAll, containsAll, removeAll, retainAll, toArray, toArray, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Collection


addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray,
toArray

Method Summary

337

Overview (Codename One API)


Constructor

Detail

ArrayDeque
public ArrayDeque()

Constructs a new empty instance of ArrayDeque big enough for 16 elements.


ArrayDeque
public ArrayDeque(int minSize)

Constructs a new empty instance of ArrayDeque big enough for specified number of
elements.
Parameters:
minSize - the smallest size of the ArrayDeque
ArrayDeque
public ArrayDeque(Collection<? extends E> c)

Constructs a new instance of ArrayDeque containing the elements of the specified


collection, with the order returned by the collection's iterator.
Parameters:
c - the source of the elements
Throws:
NullPointerException - if the collection is null

Method Detail

addFirst
public void addFirst(E e)

Inserts an element at the head of this deque if it dose not violate size limit
immediately. It is better to use offerFirst(E) if a deque is size-limited.
Specified by:
addFirst in interface Deque<E>
Parameters:
e - the element
Throws:
NullPointerException - if the element is null
See Also:
Deque.addFirst(java.lang.Object)

addLast
public void addLast(E e)

Inserts an element at the tail of this deque if it dose not violate size limit immediately.
It is better to use offerLast(E) if a deque is size-limited.
Specified by:
addLast in interface Deque<E>
Parameters:
e - the element
Throws:
NullPointerException - if the element is null
See Also:
Deque.addLast(java.lang.Object)

offerFirst
public boolean offerFirst(E e)

Inserts an element at the head of this deque unless it would violate size limit. It is

Constructor Detail

338

Overview (Codename One API)


better than the addFirst(E) method in a size-limited deque, because the latter one
may fail to add the element only by throwing an exception.
Specified by:
offerFirst in interface Deque<E>
Parameters:
e - the element
Returns:
true
Throws:
NullPointerException - if the element is null
See Also:
Deque.offerFirst(java.lang.Object)

offerLast
public boolean offerLast(E e)

Inserts an element at the tail of this deque unless it would violate size limit. It is better
than the addLast(E) method in a size-limited deque, because the latter one may fail
to add the element only by throwing an exception.
Specified by:
offerLast in interface Deque<E>
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails
Throws:
NullPointerException - if the element is null
See Also:
Deque.offerLast(java.lang.Object)

offer
public boolean offer(E e)

Inserts the element at the tail of the deque.


Specified by:
offer in interface Queue<E>
Parameters:
e - the element
Returns:
true if the operation succeeds or false if it fails.
Throws:
NullPointerException - if the element is null
See Also:
Queue.offer(java.lang.Object)

add
public boolean add(E e)

Inserts the element to the tail of the deque.


Specified by:
add in interface Collection<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
e - the element
Returns:
true
See Also:
AbstractCollection.add(java.lang.Object)

Method Detail

339

Overview (Codename One API)


push
public void push(E e)

Pushes the element to the deque(at the head of the deque), just same as addFirst(E).
Specified by:
push in interface Deque<E>
Parameters:
e - the element to push
Throws:
NullPointerException - if the element is null
See Also:
Deque.push(java.lang.Object)

removeFirst
public E removeFirst()

Gets and removes the head element of this deque. This method throws an exception
if the deque is empty.
Specified by:
removeFirst in interface Deque<E>
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Deque.removeFirst()

remove
public E remove()

Gets and removes the head element of this deque. This method throws an exception
if the deque is empty.
Specified by:
remove in interface Queue<E>
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Queue.remove()

pop
public E pop()

Pops the head element of the deque, just same as removeFirst().


Specified by:
pop in interface Deque<E>
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Deque.pop()

removeLast
public E removeLast()

Gets and removes the tail element of this deque. This method throws an exception if
the deque is empty.
Specified by:
removeLast in interface Deque<E>
Returns:
the tail element
Throws:
NoSuchElementException - if the deque is empty
See Also:

Method Detail

340

Overview (Codename One API)


Deque.removeLast()

pollFirst
public E pollFirst()

Gets and removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
pollFirst in interface Deque<E>
Returns:
the head element or null if the deque is empty
See Also:
Deque.pollFirst()

poll
public E poll()

Gets and removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
poll in interface Queue<E>
Returns:
the head element or null if the deque is empty
See Also:
Queue.poll()

pollLast
public E pollLast()

Gets and removes the tail element of this deque. This method returns null if the
deque is empty.
Specified by:
pollLast in interface Deque<E>
Returns:
the tail element or null if the deque is empty
See Also:
Deque.pollLast()

getFirst
public E getFirst()

Gets but not removes the head element of this deque. This method throws an
exception if the deque is empty.
Specified by:
getFirst in interface Deque<E>
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Deque.getFirst()

element
public E element()

Gets but does not remove the head element of this deque. It throws an exception if
the deque is empty.
Specified by:
element in interface Queue<E>
Returns:
the head element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Queue.element()

Method Detail

341

Overview (Codename One API)


getLast
public E getLast()

Gets but not removes the tail element of this deque. This method throws an exception
if the deque is empty.
Specified by:
getLast in interface Deque<E>
Returns:
the tail element
Throws:
NoSuchElementException - if the deque is empty
See Also:
Deque.getLast()

peekFirst
public E peekFirst()

Gets but not removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
peekFirst in interface Deque<E>
Returns:
the head element or null if the deque is empty
See Also:
Deque.peekFirst()

peek
public E peek()

Gets but not removes the head element of this deque. This method returns null if the
deque is empty.
Specified by:
peek in interface Queue<E>
Returns:
the head element or null if the deque is empty
See Also:
Queue.peek()

peekLast
public E peekLast()

Gets but not removes the tail element of this deque. This method returns null if the
deque is empty.
Specified by:
peekLast in interface Deque<E>
Returns:
the tail element or null if the deque is empty
See Also:
Deque.peekLast()

removeFirstOccurrence
public boolean removeFirstOccurrence(Object obj)

Removes the first equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Specified by:
removeFirstOccurrence in interface Deque<E>
Parameters:
obj - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element
See Also:
Deque.removeFirstOccurrence(java.lang.Object)

Method Detail

342

Overview (Codename One API)


remove
public boolean remove(Object obj)

Removes the first equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Specified by:
remove in interface Collection<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
obj - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element
See Also:
AbstractCollection.remove(java.lang.Object)

removeLastOccurrence
public boolean removeLastOccurrence(Object obj)

Removes the last equivalent element of the specified object. If the deque does not
contain the element, it is unchanged and returns false.
Specified by:
removeLastOccurrence in interface Deque<E>
Parameters:
obj - the element to be removed
Returns:
true if the operation succeeds or false if the deque does not contain the
element.
See Also:
Deque.removeLastOccurrence(java.lang.Object)

size
public int size()

Returns the size of the deque.


Specified by:
size in interface Collection<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the size of the deque
See Also:
AbstractCollection.size()

isEmpty
public boolean isEmpty()

Returns true if the deque has no elements.


Specified by:
isEmpty in interface Collection<E>
Overrides:
isEmpty in class AbstractCollection<E>
Returns:
true if the deque has no elements, false otherwise
See Also:
AbstractCollection.isEmpty()

contains
public boolean contains(Object obj)

Returns true if the specified element is in the deque.


Specified by:
contains in interface Collection<E>
Overrides:
contains in class AbstractCollection<E>

Method Detail

343

Overview (Codename One API)

Parameters:
obj - the element
Returns:
true if the element is in the deque, false otherwise
See Also:
AbstractCollection.contains(java.lang.Object)

clear
public void clear()

Empty the deque.


Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractCollection<E>
See Also:
AbstractCollection.clear()

iterator
public Iterator<E> iterator()

Returns the iterator of the deque. The elements will be ordered from head to tail.
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
the iterator
See Also:
AbstractCollection.iterator()

descendingIterator
public Iterator<E> descendingIterator()

Returns the iterator in reverse order, from tail to head.


Specified by:
descendingIterator in interface Deque<E>
Returns:
the reverse order Iterator
See Also:
Deque.descendingIterator()

Method Detail

344

Overview (Codename One API)


java.util

Class AbstractSet<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
HashSet, TreeSet

public abstract class


extends AbstractCollection<E>
implements Set<E>

An AbstractSet is an abstract implementation of the Set interface. This implementation does not
support adding. A subclass must implement the abstract methods iterator() and size().
Since:
1.2

Constructor Summary
Modifier
protected

Constructor and Description


AbstractSet()

Constructs a new instance of this AbstractSet.

Method Summary
Modifier and
Type
boolean

Method and Description


equals(Object object)

Compares the specified object to this Set and returns true if they are equal.
hashCode()

int

Returns the hash code for this set.


removeAll(Collection<?> collection)

boolean

Removes all occurrences in this collection which are contained in the


specified collection.

Methods inherited from class java.util.AbstractCollection


add, addAll, clear, contains, containsAll, isEmpty, iterator, remove,
retainAll, size, toArray, toArray, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Set


add, addAll, clear, contains, containsAll, isEmpty, iterator, remove,
retainAll, size, toArray, toArray

Constructor Detail

Class AbstractSet<E>

345

Overview (Codename One API)


AbstractSet
protected AbstractSet()

Constructs a new instance of this AbstractSet.

Method Detail
equals
public boolean equals(Object object)

Compares the specified object to this Set and returns true if they are equal. The
object must be an instance of Set and contain the same objects.
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface Set<E>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this set.
Returns:
true if the specified object is equal to this set, false otherwise
See Also:
hashCode()

hashCode
public int hashCode()

Returns the hash code for this set. Two set which are equal must return the same
value. This implementation calculates the hash code by adding each element's hash
code.
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface Set<E>
Overrides:
hashCode in class Object
Returns:
the hash code of this set.
See Also:
equals(java.lang.Object)

removeAll
public boolean removeAll(Collection<?> collection)

Removes all occurrences in this collection which are contained in the specified
collection.
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>
Overrides:
removeAll in class AbstractCollection<E>
Parameters:
collection - the collection of objects to remove.
Returns:
true if this collection was modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this collection
is not supported.

Constructor Detail

346

Overview (Codename One API)


java.util

Class AbstractSequentialList<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>

java.util.AbstractSequentialList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>
Direct Known Subclasses:
LinkedList

public abstract class


extends AbstractList<E>

AbstractSequentialList is an abstract implementation of the List interface. This implementation does


not support adding. A subclass must implement the abstract method listIterator().
Since:
1.2

Field Summary

Fields inherited from class java.util.AbstractList


modCount

Constructor Summary
Modifier
protected

Constructor and Description


AbstractSequentialList()

Constructs a new instance of this AbstractSequentialList.

Method Summary
Modifier and Type
void

Method and Description


add(int location, E object)

Inserts the specified object into this List at the specified location.
addAll(int location, Collection<? extends E> collection)

boolean

E
Iterator<E>
abstract
ListIterator<E>
E

Inserts the objects in the specified Collection at the specified


location in this List.
get(int location)

Returns the element at the specified location in this list.


iterator()

Returns an iterator on the elements of this list.


listIterator(int location)

Returns a list iterator on the elements of this list.


remove(int location)

Removes the object at the specified location from this list.


set(int location, E object)

Method Detail

Replaces the element at the specified location in this list with the
specified object.

347

Overview (Codename One API)


Methods

inherited from class java.util.AbstractList

add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator,


removeRange, subList, toArray, toArray

Methods inherited from class java.util.AbstractCollection


addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size,
toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size

Constructor Detail
AbstractSequentialList
protected AbstractSequentialList()

Constructs a new instance of this AbstractSequentialList.

Method Detail

add
public void add(int location,
E object)

Description copied from class: AbstractList


Inserts the specified object into this List at the specified location. The object is
inserted before any previous element at the specified location. If the location is equal
to the size of this List, the object is added at the end.
Concrete implementations that would like to support the add functionality must
override this method.
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>
Parameters:
location - the index at which to insert.
object - the object to add.
addAll
public boolean addAll(int location,
Collection<? extends E> collection)

Description copied from class: AbstractList


Inserts the objects in the specified Collection at the specified location in this List. The
objects are added in the order they are returned from the collection's iterator.
Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractList<E>
Parameters:
location - the index at which to insert.

Methods inherited from class java.util.AbstractList

348

Overview (Codename One API)


collection

- the Collection of objects

Returns:
true

if this List is modified, false otherwise.

get
public E get(int location)

Description copied from class: AbstractList


Returns the element at the specified location in this list.
Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>
Parameters:
location - the index of the element to return.
Returns:
the element at the specified index.
iterator
public Iterator<E> iterator()

Description copied from class: AbstractList


Returns an iterator on the elements of this list. The elements are iterated in the same
order as they occur in the list.
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface List<E>
Overrides:
iterator in class AbstractList<E>
Returns:
an iterator on the elements of this list.
See Also:
Iterator

listIterator
public abstract ListIterator<E> listIterator(int location)

Description copied from class: AbstractList


Returns a list iterator on the elements of this list. The elements are iterated in the
same order as they occur in the list. The iteration starts at the specified location.
Specified by:
listIterator in interface List<E>
Overrides:
listIterator in class AbstractList<E>
Parameters:
location - the index at which to start the iteration.
Returns:
a ListIterator on the elements of this list.
See Also:
ListIterator

remove
public E remove(int location)

Description copied from class: AbstractList


Removes the object at the specified location from this list.
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractList<E>
Parameters:
location - the index of the object to remove.
Returns:
the removed object.

Method Detail

349

Overview (Codename One API)


set
public E set(int location,
E object)

Description copied from class: AbstractList


Replaces the element at the specified location in this list with the specified object.
Specified by:
set in interface List<E>
Overrides:
set in class AbstractList<E>
Parameters:
location - the index at which to put the specified object.
object - the object to add.
Returns:
the previous element at the index.

Method Detail

350

Overview (Codename One API)


java.util

Class AbstractQueue<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractQueue<E>
Type Parameters:
E - the type of the element in the collection.
All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>
Direct Known Subclasses:
PriorityQueue

public abstract class


extends AbstractCollection<E>
implements Queue<E>

AbstractQueue is an abstract class which implements some of the methods in Queue. The provided
implementations of add, remove and element are based on offer, poll, and peek except that they
throw exceptions to indicate some error instead of returning true or false.

Constructor Summary
Modifier
protected

Constructor and Description


AbstractQueue()

Constructor to be used by subclasses.

Method Summary
Modifier and Type
boolean
boolean

Method and Description


add(E o)

Adds an element to the queue.


addAll(Collection<? extends E> c)

Adds all the elements of a collection to the queue.


clear()

void

Removes all elements of the queue, leaving it empty.


element()

Returns but does not remove the element at the head of the queue.
remove()

Removes the element at the head of the queue and returns it.

Methods inherited from class java.util.AbstractCollection


contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll,
size, toArray, toArray, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Queue


offer, peek, poll

Class AbstractQueue<E>

351

Overview (Codename One API)


Methods

inherited from interface java.util.Collection

contains, containsAll, equals, hashCode, isEmpty, iterator, remove,


removeAll, retainAll, size, toArray, toArray

Constructor Detail
AbstractQueue
protected AbstractQueue()

Constructor to be used by subclasses.

Method Detail

add
public boolean add(E o)

Adds an element to the queue.


Specified by:
add in interface Collection<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
o - the element to be added to the queue.
Returns:
true if the operation succeeds, otherwise false.
Throws:
IllegalStateException - if the element is not allowed to be added to the
queue.
addAll
public boolean addAll(Collection<? extends E> c)

Adds all the elements of a collection to the queue. If the collection is the queue itself,
then an IllegalArgumentException will be thrown. If during the process, some runtime
exception is thrown, then those elements in the collection which have already
successfully been added will remain in the queue. The result of the method is
undefined if the collection is modified during the process of the method.
Specified by:
addAll in interface Collection<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
c - the collection to be added to the queue.
Returns:
true if the operation succeeds, otherwise false.
Throws:
NullPointerException - if the collection or any element of it is null.
IllegalArgumentException - If the collection to be added to the queue is the
queue itself.
remove
public E remove()

Removes the element at the head of the queue and returns it.
Specified by:
remove in interface Queue<E>
Returns:
the element at the head of the queue.
Throws:

Methods inherited from interface java.util.Collection

352

Overview (Codename One API)


NoSuchElementException

- if the queue is empty.

element
public E element()

Returns but does not remove the element at the head of the queue.
Specified by:
element in interface Queue<E>
Returns:
the element at the head of the queue.
Throws:
NoSuchElementException - if the queue is empty.
clear
public void clear()

Removes all elements of the queue, leaving it empty.


Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractCollection<E>
See Also:
AbstractCollection.iterator(), AbstractCollection.isEmpty(),
AbstractCollection.size()

Method Detail

353

Overview (Codename One API)


java.util

Class AbstractMap<K,V>
java.lang.Object

java.util.AbstractMap<K,V>
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
HashMap, IdentityHashMap, TreeMap

public abstract class


extends Object
implements Map<K,V>

This class is an abstract implementation of the Map interface. This implementation does not support
adding. A subclass must implement the abstract method entrySet().
Since:
1.2

Nested Class Summary


Modifier and Type
static class
static class

Class and Description


AbstractMap.SimpleEntry<K,V>

A key-value mapping.
AbstractMap.SimpleImmutableEntry<K,V>

An immutable key-value mapping.

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Constructor Summary
Modifier
protected

Constructor and Description


AbstractMap()

Constructs a new instance of this AbstractMap.

Method Summary
Modifier and Type
void
boolean
boolean
abstract
Set<Map.Entry<K,V>>

Method and Description


clear()

Removes all elements from this map, leaving it empty.


containsKey(Object key)

Returns whether this map contains the specified key.


containsValue(Object value)

Returns whether this map contains the specified value.


entrySet()

Returns a set containing all of the mappings in this map.


equals(Object object)

boolean

Class AbstractMap<K,V>

Compares the specified object to this instance, and returns true


if the specified object is a map and both maps contain the same
mappings.
get(Object key)

Returns the value of the mapping with the specified key.

354

Overview (Codename One API)


hashCode()

int

Returns the hash code for this object.

boolean

isEmpty()

Returns whether this map is empty.


keySet()

Set<K>

Returns a set of the keys contained in this map.


put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> map)

void

Copies every mapping in the specified map to this map.


remove(Object key)

Removes a mapping with the specified key from this Map.


size()

int

Returns the number of elements in this map.


toString()

String

Returns the string representation of this map.

Collection<V>

values()

Returns a collection of the values contained in this map.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
AbstractMap
protected AbstractMap()

Constructs a new instance of this AbstractMap.

Method Detail
clear
public void clear()

Removes all elements from this map, leaving it empty.


Specified by:
clear in interface Map<K,V>
Throws:
java.lang.UnsupportedOperationException - if removing from this map is not
supported.
See Also:
isEmpty(), size()
containsKey
public boolean containsKey(Object key)

Returns whether this map contains the specified key.


Specified by:
containsKey in interface Map<K,V>
Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.

Method Summary

355

Overview (Codename One API)


containsValue
public boolean containsValue(Object value)

Returns whether this map contains the specified value.


Specified by:
containsValue in interface Map<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.
entrySet
public abstract Set<Map.Entry<K,V>> entrySet()

Returns a set containing all of the mappings in this map. Each mapping is an
instance of Map.Entry. As the set is backed by this map, changes in one will be
reflected in the other.
Specified by:
entrySet in interface Map<K,V>
Returns:
a set of the mappings.
equals
public boolean equals(Object object)

Compares the specified object to this instance, and returns true if the specified
object is a map and both maps contain the same mappings.
Specified by:
equals in interface Map<K,V>
Overrides:
equals in class Object
Parameters:
object - the object to compare with this object.
Returns:
boolean true if the object is the same as this object, and false if it is different
from this object.
See Also:
hashCode(), entrySet()
get
public V get(Object key)

Returns the value of the mapping with the specified key.


Specified by:
get in interface Map<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key, or null if no mapping for the
specified key is found.
hashCode
public int hashCode()

Returns the hash code for this object. Objects which are equal must return the same
value for this method.
Specified by:
hashCode in interface Map<K,V>
Overrides:
hashCode in class Object
Returns:
the hash code of this object.
See Also:
equals(Object)

Method Detail

356

Overview (Codename One API)


isEmpty
public boolean isEmpty()

Returns whether this map is empty.


Specified by:
isEmpty in interface Map<K,V>
Returns:
true if this map has no elements, false otherwise.
See Also:
size()

keySet
public Set<K> keySet()

Returns a set of the keys contained in this map. The set is backed by this map so
changes to one are reflected by the other. The returned set does not support adding.
Specified by:
keySet in interface Map<K,V>
Returns:
a set of the keys.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no mapping.
Throws:
java.lang.UnsupportedOperationException - if adding to this map is not
supported.
ClassCastException - if the class of the key or value is inappropriate for this
map.
IllegalArgumentException - if the key or value cannot be added to this map.
NullPointerException - if the key or value is null and this Map does not
support null keys or values.
putAll
public void putAll(Map<? extends K,? extends V> map)

Copies every mapping in the specified map to this map.


Specified by:
putAll in interface Map<K,V>
Parameters:
map - the map to copy mappings from.
Throws:
java.lang.UnsupportedOperationException - if adding to this map is not
supported.
ClassCastException - if the class of a key or value is inappropriate for this
map.
IllegalArgumentException - if a key or value cannot be added to this map.
NullPointerException - if a key or value is null and this map does not
support null keys or values.
remove
public V remove(Object key)

Removes a mapping with the specified key from this Map.


Specified by:

Method Detail

357

Overview (Codename One API)


remove in interface Map<K,V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
Throws:
java.lang.UnsupportedOperationException - if removing from this map is not
supported.
size
public int size()

Returns the number of elements in this map.


Specified by:
size in interface Map<K,V>
Returns:
the number of elements in this map.
toString
public String toString()

Returns the string representation of this map.


Overrides:
toString in class Object
Returns:
the string representation of this map.
values
public Collection<V> values()

Returns a collection of the values contained in this map. The collection is backed by
this map so changes to one are reflected by the other. The collection supports
remove, removeAll, retainAll and clear operations, and it does not support add or
addAll operations.
This method returns a collection which is the subclass of AbstractCollection. The
iterator method of this subclass returns a "wrapper object" over the iterator of map's
entrySet(). The size method wraps the map's size method and the contains method
wraps the map's containsValue method.
The collection is created when this method is called for the first time and returned in
response to all subsequent calls. This method may return different collections when
multiple concurrent calls occur to this method, since no synchronization is performed.
Specified by:
values in interface Map<K,V>
Returns:
a collection of the values contained in this map.

Method Detail

358

Overview (Codename One API)


java.util

Class AbstractMap.SimpleImmutableEntry<K,V>
java.lang.Object

java.util.AbstractMap.SimpleImmutableEntry<K,V>
Type Parameters:
K - the type of key
V - the type of value
All Implemented Interfaces:
Map.Entry<K,V>
Enclosing class:
AbstractMap<K,V>

public static class


extends Object
implements Map.Entry<K,V>

An immutable key-value mapping.


Since:
1.6

Constructor Summary
Constructor and Description
SimpleImmutableEntry(K theKey, V theValue)

Constructs a new instance by key and value.


SimpleImmutableEntry(Map.Entry<? extends K,? extends V> entry)

Constructs a new instance by an entry

Method Summary
Modifier and Type
boolean

Method and Description


equals(Object object)

Answers whether the object is equal to this entry.


getKey()

Returns the key.


getValue()

Returns the value.


hashCode()

int

Answers the hash code of this entry.


setValue(V object)

Throws an UnsupportedOperationException.

String

toString()

Answers a String representation of this entry.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Class AbstractMap.SimpleImmutableEntry<K,V>

359

Overview (Codename One API)


SimpleImmutableEntry
public SimpleImmutableEntry(K theKey,
V theValue)

Constructs a new instance by key and value.


Parameters:
theKey - the key
theValue - the value
SimpleImmutableEntry
public SimpleImmutableEntry(Map.Entry<? extends K,? extends V> entry)

Constructs a new instance by an entry


Parameters:
entry - the entry

Method Detail
getKey
public K getKey()

Returns the key.


Specified by:
getKey in interface Map.Entry<K,V>
Returns:
the key
See Also:
Map.Entry.getKey()

getValue
public V getValue()

Returns the value.


Specified by:
getValue in interface Map.Entry<K,V>
Returns:
the value
See Also:
Map.Entry.getValue()

setValue
public V setValue(V object)

Throws an UnsupportedOperationException.
Specified by:
setValue in interface Map.Entry<K,V>
Parameters:
object - new value
Returns:
(Does not)
Throws:
java.lang.UnsupportedOperationException

- always

See Also:
Map.Entry.setValue(java.lang.Object)

equals
public boolean equals(Object object)

Answers whether the object is equal to this entry. This works across all kinds of the
Map.Entry interface.
Specified by:
equals in interface Map.Entry<K,V>
Overrides:

Constructor Detail

360

Overview (Codename One API)


equals

in class Object

Parameters:
object

- the Object to compare with this Object.

Returns:
true

if the specified Object is equal to this Map.Entry, false otherwise.

See Also:
Object.equals(java.lang.Object)

hashCode
public int hashCode()

Answers the hash code of this entry.


Specified by:
hashCode in interface Map.Entry<K,V>
Overrides:
hashCode in class Object
Returns:
the receiver's hash code.
See Also:
Object.hashCode()

toString
public String toString()

Answers a String representation of this entry.


Overrides:
toString in class Object
See Also:
Object.toString()

Method Detail

361

Overview (Codename One API)


java.util

Class AbstractMap.SimpleEntry<K,V>
java.lang.Object

java.util.AbstractMap.SimpleEntry<K,V>
Type Parameters:
K - the type of key
V - the type of value
All Implemented Interfaces:
Map.Entry<K,V>
Enclosing class:
AbstractMap<K,V>

public static class


extends Object
implements Map.Entry<K,V>

A key-value mapping.
Since:
1.6

Constructor Summary
Constructor and Description
SimpleEntry(K theKey, V theValue)

Constructs a new instance by key and value.


SimpleEntry(Map.Entry<? extends K,? extends V> entry)

Constructs a new instance by an entry

Method Summary
Modifier and
Type
boolean

Method and Description


equals(Object object)

Answers whether the object is equal to this entry.


getKey()

Returns the key.


getValue()

Returns the value.


hashCode()

int

Answers the hash code of this entry.


setValue(V object)

Sets the value of this entry to the specified value, replacing any existing
value.

String

toString()

Answers a String representation of this entry.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Class AbstractMap.SimpleEntry<K,V>

362

Overview (Codename One API)


SimpleEntry
public SimpleEntry(K theKey,
V theValue)

Constructs a new instance by key and value.


Parameters:
theKey - the key
theValue - the value
SimpleEntry
public SimpleEntry(Map.Entry<? extends K,? extends V> entry)

Constructs a new instance by an entry


Parameters:
entry - the entry

Method Detail
getKey
public K getKey()

Returns the key.


Specified by:
getKey in interface Map.Entry<K,V>
Returns:
the key
See Also:
Map.Entry.getKey()

getValue
public V getValue()

Returns the value.


Specified by:
getValue in interface Map.Entry<K,V>
Returns:
the value
See Also:
Map.Entry.getValue()

setValue
public V setValue(V object)

Sets the value of this entry to the specified value, replacing any existing value.
Specified by:
setValue in interface Map.Entry<K,V>
Parameters:
object - the new value to set.
Returns:
object the replaced value of this entry.
See Also:
Map.Entry.setValue(java.lang.Object)

equals
public boolean equals(Object object)

Answers whether the object is equal to this entry. This works across all kinds of the
Map.Entry interface.
Specified by:
equals in interface Map.Entry<K,V>
Overrides:
equals in class Object
Parameters:

Constructor Detail

363

Overview (Codename One API)


object

- the Object to compare with this Object.

Returns:
true

if the specified Object is equal to this Map.Entry, false otherwise.

See Also:
Object.equals(java.lang.Object)

hashCode
public int hashCode()

Answers the hash code of this entry.


Specified by:
hashCode in interface Map.Entry<K,V>
Overrides:
hashCode in class Object
Returns:
the receiver's hash code.
See Also:
Object.hashCode()

toString
public String toString()

Answers a String representation of this entry.


Overrides:
toString in class Object
See Also:
Object.toString()

Method Detail

364

Overview (Codename One API)


java.util

Class AbstractList<E>
java.lang.Object

java.util.AbstractCollection<E>

java.util.AbstractList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>
Direct Known Subclasses:
AbstractSequentialList, ArrayList, Vector

public abstract class


extends AbstractCollection<E>
implements List<E>

is an abstract implementation of the List interface, optimized for a backing store which
supports random access. This implementation does not support adding or replacing. A subclass must
implement the abstract methods get() and size(), and to create a modifiable List it's necessary to
override the add() method that currently throws an UnsupportedOperationException.
Since:
1.2
AbstractList

Field Summary
Modifier and Type
protected int

Field and Description


modCount

A counter for changes to the list.

Constructor Summary
Modifier
protected

Constructor and Description


AbstractList()

Constructs a new instance of this AbstractList.

Method Summary
Modifier and Type
boolean
void

Method and Description


add(E object)

Adds the specified object at the end of this List.


add(int location, E object)

Inserts the specified object into this List at the specified location.
addAll(int location, Collection<? extends E> collection)

boolean

void

Inserts the objects in the specified Collection at the specified location in


this List.
clear()

Removes all elements from this list, leaving it empty.


equals(Object object)

boolean

abstract E
int
int

Class AbstractList<E>

Compares the specified object to this list and return true if they are
equal.
get(int location)

Returns the element at the specified location in this list.


hashCode()

Returns the hash code of this list.


indexOf(Object object)

365

Overview (Codename One API)


Searches this list for the specified object and returns the index of the
first occurrence.
Iterator<E>

iterator()

Returns an iterator on the elements of this list.


lastIndexOf(Object object)

Searches this list for the specified object and returns the index of the
last occurrence.

int

ListIterator<E>
ListIterator<E>

listIterator()

Returns a ListIterator on the elements of this list.


listIterator(int location)

Returns a list iterator on the elements of this list.


remove(int location)

Removes the object at the specified location from this list.


removeRange(int start, int end)

protected void

Removes the objects in the specified range from the start to the end
index minus one.
set(int location, E object)

Replaces the element at the specified location in this list with the
specified object.

List<E>

subList(int start, int end)

Returns a part of consecutive elements of this list as a view.


toArray()

Object[]

<T> T[]

Returns a new array containing all elements contained in this


ArrayList.
toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList.

Methods inherited from class java.util.AbstractCollection


addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size,
toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List


addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size

Field Detail
modCount
protected transient int modCount

A counter for changes to the list.

Constructor Detail
AbstractList
protected AbstractList()

Constructs a new instance of this AbstractList.

Method Summary

366

Overview (Codename One API)

Method Detail

add
public void add(int location,
E object)

Inserts the specified object into this List at the specified location. The object is
inserted before any previous element at the specified location. If the location is equal
to the size of this List, the object is added at the end.
Concrete implementations that would like to support the add functionality must
override this method.
Specified by:
add in interface List<E>
Parameters:
location - the index at which to insert.
object - the object to add.
Throws:
java.lang.UnsupportedOperationException

- if adding to this List is not

supported.
ClassCastException - if the class of the object is inappropriate for this
IllegalArgumentException - if the object cannot be added to this List
IndexOutOfBoundsException - if location < 0 || >= size()

List

add
public boolean add(E object)

Adds the specified object at the end of this List.


Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
object - the object to add
Returns:
true
Throws:
java.lang.UnsupportedOperationException

- if adding to this List is not

supported
ClassCastException - if the class of the object is inappropriate for this
IllegalArgumentException - if the object cannot be added to this List

List

addAll
public boolean addAll(int location,
Collection<? extends E> collection)

Inserts the objects in the specified Collection at the specified location in this List. The
objects are added in the order they are returned from the collection's iterator.
Specified by:
addAll in interface List<E>
Parameters:
location - the index at which to insert.
collection - the Collection of objects
Returns:
true if this List is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if adding to this list is not
supported.
ClassCastException - if the class of an object is inappropriate for this list.

Method Detail

367

Overview (Codename One API)


IllegalArgumentException - if an object cannot be added to
IndexOutOfBoundsException - if location < 0 || > size()

this list.

clear
public void clear()

Removes all elements from this list, leaving it empty.


Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class AbstractCollection<E>
Throws:
java.lang.UnsupportedOperationException

- if removing from this list is not

supported.
See Also:
List.isEmpty(), List.size()

equals
public boolean equals(Object object)

Compares the specified object to this list and return true if they are equal. Two lists
are equal when they both contain the same objects in the same order.
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface List<E>
Overrides:
equals in class Object
Parameters:
object - the object to compare to this object.
Returns:
true if the specified object is equal to this list, false otherwise.
See Also:
hashCode()

get
public abstract E get(int location)

Returns the element at the specified location in this list.


Specified by:
get in interface List<E>
Parameters:
location - the index of the element to return.
Returns:
the element at the specified index.
Throws:
IndexOutOfBoundsException - if location < 0 || >= size()
hashCode
public int hashCode()

Returns the hash code of this list. The hash code is calculated by taking each
element's hashcode into account.
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface List<E>
Overrides:
hashCode in class Object
Returns:
the hash code.
See Also:
equals(java.lang.Object), List.hashCode()

Method Detail

368

Overview (Codename One API)


indexOf
public int indexOf(Object object)

Searches this list for the specified object and returns the index of the first occurrence.
Specified by:
indexOf in interface List<E>
Parameters:
object - the object to search for.
Returns:
the index of the first occurrence of the object, or -1 if it was not found.
iterator
public Iterator<E> iterator()

Returns an iterator on the elements of this list. The elements are iterated in the same
order as they occur in the list.
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface List<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
an iterator on the elements of this list.
See Also:
Iterator

lastIndexOf
public int lastIndexOf(Object object)

Searches this list for the specified object and returns the index of the last occurrence.
Specified by:
lastIndexOf in interface List<E>
Parameters:
object - the object to search for.
Returns:
the index of the last occurrence of the object, or -1 if the object was not
found.
listIterator
public ListIterator<E> listIterator()

Returns a ListIterator on the elements of this list. The elements are iterated in the
same order that they occur in the list.
Specified by:
listIterator in interface List<E>
Returns:
a ListIterator on the elements of this list
See Also:
ListIterator

listIterator
public ListIterator<E> listIterator(int location)

Returns a list iterator on the elements of this list. The elements are iterated in the
same order as they occur in the list. The iteration starts at the specified location.
Specified by:
listIterator in interface List<E>
Parameters:
location - the index at which to start the iteration.
Returns:
a ListIterator on the elements of this list.
Throws:
IndexOutOfBoundsException - if location < 0 || location > size()

Method Detail

369

Overview (Codename One API)


See Also:
ListIterator

remove
public E remove(int location)

Removes the object at the specified location from this list.


Specified by:
remove in interface List<E>
Parameters:
location - the index of the object to remove.
Returns:
the removed object.
Throws:
java.lang.UnsupportedOperationException - if removing from this list is not
supported.
IndexOutOfBoundsException - if location < 0 || >= size()
removeRange
protected void removeRange(int start,
int end)

Removes the objects in the specified range from the start to the end index minus one.
Parameters:
start - the index at which to start removing.
end - the index after the last element to remove.
Throws:
java.lang.UnsupportedOperationException - if removing from this list is not
supported.
IndexOutOfBoundsException - if start < 0 or start >= size().
set
public E set(int location,
E object)

Replaces the element at the specified location in this list with the specified object.
Specified by:
set in interface List<E>
Parameters:
location - the index at which to put the specified object.
object - the object to add.
Returns:
the previous element at the index.
Throws:
java.lang.UnsupportedOperationException - if replacing elements in this list
is not supported.
ClassCastException - if the class of an object is inappropriate for this list.
IllegalArgumentException - if an object cannot be added to this list.
IndexOutOfBoundsException - if location < 0 || >= size()
subList
public List<E> subList(int start,
int end)

Returns a part of consecutive elements of this list as a view. The returned view will be
of zero length if start equals end. Any change that occurs in the returned subList will
be reflected to the original list, and vice-versa. All the supported optional operations
by the original list will also be supported by this subList.
This method can be used as a handy method to do some operations on a sub range
of the original list, for example list.subList(from, to).clear();
If the original list is modified in other ways than through the returned subList, the
behavior of the returned subList becomes undefined.

Method Detail

370

Overview (Codename One API)

The returned subList is a subclass of AbstractList. The subclass stores offset, size of
itself, and modCount of the original list. If the original list implements RandomAccess
interface, the returned subList also implements RandomAccess interface.
The subList's set(int, Object), get(int), add(int, Object), remove(int), addAll(int,
Collection) and removeRange(int, int) methods first check the bounds, adjust offsets
and then call the corresponding methods of the original AbstractList.
addAll(Collection c) method of the returned subList calls the original addAll(offset +
size, c).
The listIterator(int) method of the subList wraps the original list iterator. The iterator()
method of the subList invokes the original listIterator() method, and the size() method
merely returns the size of the subList.
All methods will throw a ConcurrentModificationException if the modCount of the
original list is not equal to the expected value.
Specified by:
subList

in interface List<E>

Parameters:
start - start index of the subList (inclusive).
end - end index of the subList, (exclusive).

Returns:
a subList view of this list starting from start (inclusive), and ending with end
(exclusive)
Throws:
IndexOutOfBoundsException - if (start < 0 || end > size())
IllegalArgumentException - if (start > end)
toArray
public Object[] toArray()

Returns a new array containing all elements contained in this ArrayList.


Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractCollection<E>
Returns:
an array of the elements from this ArrayList
toArray
public <T> T[] toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
ArrayList, the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Specified by:
toArray in interface List<E>
Overrides:
toArray in class AbstractCollection<E>
Parameters:
contents - the array.
Returns:
an array of the elements from this ArrayList.
Throws:
ArrayStoreException - when the type of an element in this ArrayList cannot
be stored in the type of the specified array.

Method Detail

371

Overview (Codename One API)


java.util

Class AbstractCollection<E>
java.lang.Object

java.util.AbstractCollection<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>
Direct Known Subclasses:
AbstractList, AbstractQueue, AbstractSet, ArrayDeque

public abstract class


extends Object
implements Collection<E>

Class AbstractCollection is an abstract implementation of the Collection interface. A subclass must


implement the abstract methods iterator() and size() to create an immutable collection. To create
a modifiable collection it's necessary to override the add() method that currently throws an
UnsupportedOperationException.
Since:
1.2

Constructor Summary
Modifier
protected

Constructor and Description


AbstractCollection()

Constructs a new instance of this AbstractCollection.

Method Summary
Modifier and
Type
boolean

boolean

void

Method and Description


add(E object)

Attempts to add object to the contents of this Collection (optional).


addAll(Collection<? extends E> collection)
Attempts to add all of the objects contained in collection
contents of this Collection (optional).
clear()

Removes all elements from this Collection, leaving it empty (optional).

boolean

contains(Object object)
Tests whether this Collection

boolean

containsAll(Collection<?> collection)
Tests whether this Collection contains all
specified Collection.

boolean
abstract
Iterator<E>

to the

contains the specified object.


objects contained in the

isEmpty()

Returns if this Collection contains no elements.


iterator()

Returns an instance of Iterator that may be used to access the objects


contained by this Collection.
remove(Object object)

boolean

Removes one instance of the specified object from this Collection if


one is contained (optional).

boolean

removeAll(Collection<?> collection)
Removes all occurrences in this Collection
specified Collection (optional).

boolean

retainAll(Collection<?> collection)

Class AbstractCollection<E>

of each object in the

372

Overview (Codename One API)


Removes all objects from this Collection that are not also found in the
Collection passed (optional).
abstract int
Object[]
<T> T[]

size()

Returns a count of how many objects this Collection contains.


toArray()

Returns a new array containing all elements contained in this ArrayList.


toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList.


toString()

String

Returns the string representation of this Collection.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Collection


equals, hashCode

Constructor Detail
AbstractCollection
protected AbstractCollection()

Constructs a new instance of this AbstractCollection.

Method Detail

add
public boolean add(E object)

Description copied from interface: Collection


Attempts to add object to the contents of this Collection (optional). After this
method finishes successfully it is guaranteed that the object is contained in the
collection. If the collection was modified it returns true, false if no changes were
made. An implementation of Collection may narrow the set of accepted objects, but
it has to specify this in the documentation. If the object to be added does not meet
this restriction, then an IllegalArgumentException is thrown. If a collection does not
yet contain an object that is to be added and adding the object fails, this method must
throw an appropriate unchecked Exception. Returning false is not permitted in this
case because it would violate the postcondition that the element will be part of the
collection after this method finishes.
Specified by:
add in interface Collection<E>
Parameters:
object - the object to add.
Returns:
true if this Collection is modified, false otherwise.
addAll
public boolean addAll(Collection<? extends E> collection)

Attempts to add all of the objects contained in collection to the contents of this
Collection (optional). This implementation iterates over the given Collection and
calls add for each element. If any of these calls return true, then true is returned as
result of this method call, false otherwise. If this Collection does not support adding
elements, an UnsupportedOperationException is thrown.

Method Summary

373

Overview (Codename One API)


If the passed Collection is changed during the process of adding elements to this
Collection, the behavior depends on the behavior of the passed Collection.
Specified by:
addAll

in interface Collection<E>

Parameters:
collection

- the collection of objects.

Returns:
true

if this Collection is modified, false otherwise.

Throws:
java.lang.UnsupportedOperationException

- if adding to this Collection is

not supported.
ClassCastException - if the class of an object is inappropriate for this
Collection.
IllegalArgumentException - if an object cannot be added to this Collection.
NullPointerException - if collection is null, or if it contains null elements
and this Collection does not support such elements.

clear
public void clear()

Removes all elements from this Collection, leaving it empty (optional). This
implementation iterates over this Collection and calls the remove method on each
element. If the iterator does not support removal of elements, an
UnsupportedOperationException is thrown.
Concrete implementations usually can clear a Collection more efficiently and should
therefore overwrite this method.
Specified by:
clear

in interface Collection<E>

Throws:
java.lang.UnsupportedOperationException
removing elements from this Collection

- it the iterator does not support

See Also:
iterator(), isEmpty(), size()

contains
public boolean contains(Object object)

Tests whether this Collection contains the specified object. This implementation
iterates over this Collection and tests, whether any element is equal to the given
object. If object != null then object.equals(e) is called for each element e
returned by the iterator until the element is found. If object == null then each
element e returned by the iterator is compared with the test e == null.
Specified by:
contains in interface Collection<E>
Parameters:
object - the object to search for.
Returns:
true if object is an element of this Collection, false otherwise.
Throws:
ClassCastException - if the object to look for isn't of the correct type.
NullPointerException - if the object to look for is null and this Collection
doesn't support null elements.
containsAll
public boolean containsAll(Collection<?> collection)

Tests whether this Collection contains all objects contained in the specified
Collection. This implementation iterates over the specified Collection. If one
element returned by the iterator is not contained in this Collection, then false is
returned; true otherwise.
Specified by:
containsAll in interface Collection<E>
Parameters:

Method Detail

374

Overview (Codename One API)


collection

- the collection of objects.

Returns:
true if all objects
false otherwise.

in the specified Collection are elements of this Collection,

Throws:
ClassCastException

- if one or more elements of collection isn't of the

correct type.
NullPointerException - if collection contains at
this Collection doesn't support null elements.
NullPointerException - if collection is null.

least one null element and

isEmpty
public boolean isEmpty()

Returns if this Collection contains no elements. This implementation tests, whether


size returns 0.
Specified by:
isEmpty in interface Collection<E>
Returns:
true if this Collection has no elements, false otherwise.
See Also:
size()

iterator
public abstract Iterator<E> iterator()

Returns an instance of Iterator that may be used to access the objects contained by
this Collection. The order in which the elements are returned by the Iterator is not
defined unless the instance of the Collection has a defined order. In that case, the
elements are returned in that order.
In this class this method is declared abstract and has to be implemented by concrete
Collection implementations.
Specified by:
iterator

in interface Iterable<E>

Specified by:
iterator in interface Collection<E>
Returns:
an iterator for accessing the Collection contents.
remove
public boolean remove(Object object)

Removes one instance of the specified object from this Collection if one is contained
(optional). This implementation iterates over this Collection and tests for each
element e returned by the iterator, whether e is equal to the given object. If object !=
null then this test is performed using object.equals(e), otherwise using object ==
null. If an element equal to the given object is found, then the remove method is
called on the iterator and true is returned, false otherwise. If the iterator does not
support removing elements, an UnsupportedOperationException is thrown.
Specified by:
remove in interface Collection<E>
Parameters:
object - the object to remove.
Returns:
true if this Collection is modified, false otherwise.
Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if the object passed is not of the correct type.
NullPointerException - if object is null and this Collection doesn't support
null elements.

Method Detail

375

Overview (Codename One API)


removeAll
public boolean removeAll(Collection<?> collection)

Removes all occurrences in this Collection of each object in the specified


Collection (optional). After this method returns none of the elements in the passed
Collection can be found in this Collection anymore.
This implementation iterates over this Collection and tests for each element e
returned by the iterator, whether it is contained in the specified Collection. If this test
is positive, then the remove method is called on the iterator. If the iterator does not
support removing elements, an UnsupportedOperationException is thrown.
Specified by:
removeAll

in interface Collection<E>

Parameters:
collection

- the collection of objects to remove.

Returns:
true

if this Collection is modified, false otherwise.

Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if one or more elements of collection isn't of

the

correct type.
NullPointerException - if collection contains at
this Collection doesn't support null elements.
NullPointerException - if collection is null.

least one null element and

retainAll
public boolean retainAll(Collection<?> collection)

Removes all objects from this Collection that are not also found in the Collection
passed (optional). After this method returns this Collection will only contain
elements that also can be found in the Collection passed to this method.
This implementation iterates over this Collection and tests for each element e
returned by the iterator, whether it is contained in the specified Collection. If this test
is negative, then the remove method is called on the iterator. If the iterator does not
support removing elements, an UnsupportedOperationException is thrown.
Specified by:
retainAll

in interface Collection<E>

Parameters:
collection

- the collection of objects to retain.

Returns:
true

if this Collection is modified, false otherwise.

Throws:
java.lang.UnsupportedOperationException - if removing from this
Collection is not supported.
ClassCastException - if one or more elements of collection isn't of

the

correct type.
NullPointerException - if collection contains at
this Collection doesn't support null elements.
NullPointerException - if collection is null.

least one null element and

size
public abstract int size()

Returns a count of how many objects this Collection contains.


In this class this method is declared abstract and has to be implemented by concrete
Collection implementations.
Specified by:
size

in interface Collection<E>

Returns:

Method Detail

376

Overview (Codename One API)


how many objects this Collection contains, or Integer.MAX_VALUE if there
are more than Integer.MAX_VALUE elements in this Collection.
toString
public String toString()

Returns the string representation of this Collection. The presentation has a specific
format. It is enclosed by square brackets ("[]"). Elements are separated by ', ' (comma
and space).
Overrides:
toString in class Object
Returns:
the string representation of this Collection.
toArray
public Object[] toArray()

Returns a new array containing all elements contained in this ArrayList.


Specified by:
toArray in interface Collection<E>
Returns:
an array of the elements from this ArrayList
toArray
public <T> T[] toArray(T[] contents)

Returns an array containing all elements contained in this ArrayList. If the specified
array is large enough to hold the elements, the specified array is used, otherwise an
array of the same type is created. If the specified array is used and is larger than this
ArrayList, the array element following the collection elements is set to null.
Specified by:
toArray in interface Collection<E>
Parameters:
contents - the array.
Returns:
an array of the elements from this ArrayList.
Throws:
ArrayStoreException - when the type of an element in this ArrayList cannot
be stored in the type of the specified array.

Method Detail

377

Overview (Codename One API)


java.text

Class SimpleDateFormat
java.lang.Object

java.text.Format

java.text.DateFormat

java.text.SimpleDateFormat
All Implemented Interfaces:
Cloneable
Deprecated.
this class has many issues in iOS and other platforms, please use the L10NManager
public class
extends DateFormat

A class for parsing and formatting dates with a given pattern, compatible with the Java 6 API.
See Also:
http://docs.oracle.com/javase/6/docs/api/java/text/DateFormat.html

Field Summary

Fields inherited from class java.text.DateFormat


DEFAULT, FULL, LONG, MEDIUM, SHORT

Constructor Summary
Constructor and Description
SimpleDateFormat()

Deprecated.
Construct a SimpleDateFormat with no pattern.
SimpleDateFormat(String pattern)

Deprecated.
Construct a SimpleDateFormat with a given pattern.

Method Summary
Modifier and Type

Method and Description


applyPattern(String pattern)

void

Deprecated.
Apply a new pattern.
clone()

Object

Deprecated.
format(Date source)

String

Deprecated.
Format a given date.
getDateFormatSymbols()

DateFormatSymbols

Deprecated.
Get the date format symbols for parsing/formatting textual components
of dates in a localization sensitive way.
parse(String source)

Date

Deprecated.
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

void

setDateFormatSymbols(DateFormatSymbols newSymbols)

Class SimpleDateFormat

378

Overview (Codename One API)


Deprecated.
Apply new date format symbols for parsing/formatting textual
components of dates in a localisation sensitive way.
toPattern()

Deprecated.

String

Methods inherited from class java.text.DateFormat


equals, format, getDateInstance, getDateInstance, getDateTimeInstance,
getInstance, getTimeInstance, getTimeInstance, hashCode, parseObject

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SimpleDateFormat
public SimpleDateFormat()

Deprecated.
Construct a SimpleDateFormat with no pattern.
SimpleDateFormat
public SimpleDateFormat(String pattern)

Deprecated.
Construct a SimpleDateFormat with a given pattern.
Parameters:
pattern

Method Detail
toPattern
public String toPattern()

Deprecated.
Returns:
the pattern
getDateFormatSymbols
public DateFormatSymbols getDateFormatSymbols()

Deprecated.
Get the date format symbols for parsing/formatting textual components of dates in a
localization sensitive way.
Returns:
current symbols.
setDateFormatSymbols
public void setDateFormatSymbols(DateFormatSymbols newSymbols)

Deprecated.
Apply new date format symbols for parsing/formatting textual components of dates in
a localisation sensitive way.
Parameters:
newSymbols - new format symbols.

Method Summary

379

Overview (Codename One API)


applyPattern
public void applyPattern(String pattern)

Deprecated.
Apply a new pattern.
Parameters:
pattern - the pattern to set
clone
public Object clone()

Deprecated.
Overrides:
clone

in class DateFormat

format
public String format(Date source)

Deprecated.
Description copied from class: DateFormat
Format a given date.
Overrides:
format in class DateFormat
Parameters:
source - date to be formatted.
Returns:
formatted date.
parse
public Date parse(String source)
throws ParseException

Deprecated.
Description copied from class: DateFormat
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
Overrides:
parse in class DateFormat
Throws:
ParseException

Method Detail

380

Overview (Codename One API)


java.text

Class ParseException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.text.ParseException

public class
extends Exception

An error occurred during parsing.

Constructor Summary
Constructor and Description
ParseException(String s, int errorOffset)

Method Summary
Modifier and Type Method and Description
int

getErrorOffset()

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ParseException
public ParseException(String s,
int errorOffset)

Parameters:
errorOffset

Method Detail
getErrorOffset
public int getErrorOffset()

Returns:
the errorOffset

Class ParseException

381

Overview (Codename One API)


java.text

Class Format
java.lang.Object

java.text.Format
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
DateFormat

public abstract class


extends Object
implements Cloneable

An abstract class for parsing and formatting localisation sensitive information, compatible with JDK 6.
See Also:
http://docs.oracle.com/javase/6/docs/api/java/text/Format.html

Constructor Summary
Constructor and Description
Format()

Method Summary
Modifier and Type
abstract String
abstract Object

Method and Description


format(Object source)

Format an object.
parseObject(String source)

Parse an string to an object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Format
public Format()

Method Detail
format
public abstract String format(Object source)
throws IllegalArgumentException

Format an object.
Parameters:
source - object to be formatted to text.
Returns:
formatted text.
Throws:

Method Detail

382

Overview (Codename One API)


IllegalArgumentException

- if the source can not be formatted.

parseObject
public abstract Object parseObject(String source)
throws ParseException

Parse an string to an object.


Parameters:
source - document to be parsed.
Returns:
parsed object.
Throws:
ParseException - if the source could not be parsed.

Method Detail

383

Overview (Codename One API)


java.text

Class DateFormatSymbols
java.lang.Object

java.text.DateFormatSymbols
All Implemented Interfaces:
Cloneable

public class
extends Object
implements Cloneable

Field Summary
Modifier and Type Field and Description
static int

ZONE_ID

static int

ZONE_LONGNAME

static int

ZONE_LONGNAME_DST

static int

ZONE_SHORTNAME

static int

ZONE_SHORTNAME_DST

Constructor Summary
Constructor and Description
DateFormatSymbols()

Method Summary
Modifier and Type

Method and Description

Object

clone()

String[]

getAmPmStrings()

String[]

getEras()

String[]

getMonths()

Hashtable<String,String>

getResourceBundle()

String[]

getShortMonths()

String[]

getShortWeekdays()

String[]

getWeekdays()

String[][]

getZoneStrings()

void

setAmPmStrings(String[] newAmpms)

void

setEras(String[] newEras)

void

setMonths(String[] newMonths)

void

setResourceBundle(Hashtable<String,String> newResourceBundle)

void

setShortMonths(String[] newShortMonths)

void

setShortWeekdays(String[] newShortWeekdays)

void

setWeekdays(String[] newWeekdays)

void

setZoneStrings(String[][] newZoneStrings)

Class DateFormatSymbols

384

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ZONE_ID
public static final int ZONE_ID

See Also:
Constant Field Values
ZONE_LONGNAME
public static final int ZONE_LONGNAME

See Also:
Constant Field Values
ZONE_SHORTNAME
public static final int ZONE_SHORTNAME

See Also:
Constant Field Values
ZONE_LONGNAME_DST
public static final int ZONE_LONGNAME_DST

See Also:
Constant Field Values
ZONE_SHORTNAME_DST
public static final int ZONE_SHORTNAME_DST

See Also:
Constant Field Values

Constructor Detail
DateFormatSymbols
public DateFormatSymbols()

Method Detail
getAmPmStrings
public String[] getAmPmStrings()

setAmPmStrings
public void setAmPmStrings(String[] newAmpms)

getResourceBundle
public Hashtable<String,String> getResourceBundle()

setResourceBundle
public void setResourceBundle(Hashtable<String,String> newResourceBundle)

getZoneStrings
public String[][] getZoneStrings()

Methods inherited from class java.lang.Object

385

Overview (Codename One API)


setZoneStrings
public void setZoneStrings(String[][] newZoneStrings)

setShortWeekdays
public void setShortWeekdays(String[] newShortWeekdays)

getShortWeekdays
public String[] getShortWeekdays()

getWeekdays
public String[] getWeekdays()

setWeekdays
public void setWeekdays(String[] newWeekdays)

setShortMonths
public void setShortMonths(String[] newShortMonths)

getShortMonths
public String[] getShortMonths()

setMonths
public void setMonths(String[] newMonths)

getMonths
public String[] getMonths()

getEras
public String[] getEras()

setEras
public void setEras(String[] newEras)

clone
public Object clone()

Method Detail

386

Overview (Codename One API)


java.text

Class DateFormatPatterns
java.lang.Object

java.text.DateFormatPatterns

public class
extends Object

Common patterns for dates, times, and timestamps.

Field Summary
Modifier and Type
static String
static String
static String
static String
static String
static String
static String
static String

Field and Description


ISO8601

Pattern for parsing/formatting ISO8601 timestamp.


RFC2822

Pattern for parsing/formatting RFC-2822 timestamp.


RFC822

Pattern for parsing/formatting RFC-822 timestamp.


TWITTER_SEARCH

Pattern for parsing/formatting Twitter search timestamp.


TWITTER_TIMELINE

Pattern for parsing/formatting Twitter timeline timestamp.


VERBOSE_DATE

Pattern for a verbose date


VERBOSE_TIME

Pattern for a verbose time


VERBOSE_TIMESTAMP

Pattern for a verbose timestamp

Constructor Summary
Constructor and Description
DateFormatPatterns()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RFC2822
public static final String RFC2822

Pattern for parsing/formatting RFC-2822 timestamp.


See Also:
Constant Field Values

Class DateFormatPatterns

387

Overview (Codename One API)


RFC822
public static final String RFC822

Pattern for parsing/formatting RFC-822 timestamp.


See Also:
Constant Field Values
ISO8601
public static final String ISO8601

Pattern for parsing/formatting ISO8601 timestamp.


See Also:
Constant Field Values
TWITTER_TIMELINE
public static final String TWITTER_TIMELINE

Pattern for parsing/formatting Twitter timeline timestamp.


See Also:
Constant Field Values
TWITTER_SEARCH
public static final String TWITTER_SEARCH

Pattern for parsing/formatting Twitter search timestamp.


See Also:
Constant Field Values
VERBOSE_DATE
public static final String VERBOSE_DATE

Pattern for a verbose date


See Also:
Constant Field Values
VERBOSE_TIME
public static final String VERBOSE_TIME

Pattern for a verbose time


See Also:
Constant Field Values
VERBOSE_TIMESTAMP
public static final String VERBOSE_TIMESTAMP

Pattern for a verbose timestamp


See Also:
Constant Field Values

Constructor Detail
DateFormatPatterns
public DateFormatPatterns()

Field Detail

388

Overview (Codename One API)


java.text

Class DateFormat
java.lang.Object

java.text.Format

java.text.DateFormat
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
SimpleDateFormat
Deprecated.
this class has many issues in iOS and other platforms, please use the L10NManager
public class
extends Format

A class for parsing and formatting localisation sensitive dates, compatible with Jave 6 SDK. This
implementation uses the Codename One localization manager for handling formatting dates. Parsing
dates is not implemented in this class since the localization pattern is not exposed.
See Also:
http://docs.oracle.com/javase/6/docs/api/java/text/DateFormat.html

Field Summary
Modifier and Type

Field and Description


DEFAULT

static int

Deprecated.
Constant for default style (MEDIUM) parsing/formatting pattern.
FULL

static int

Deprecated.
Constant for full style parsing/formatting pattern.
LONG

static int

Deprecated.
Constant for long style parsing/formatting pattern.
MEDIUM

static int

Deprecated.
Constant for medium style parsing/formatting pattern.
SHORT

static int

Deprecated.
Constant for short style parsing/formatting pattern.

Method Summary
Modifier and
Type

Method and Description


clone()

Object

Deprecated.
equals(Object obj)

boolean

Deprecated.
Indicates whether some other object is "equal to" this one.
format(Date source)

String

Deprecated.
Format a given date.

String

format(Object obj)

Deprecated.

Constructor Detail

389

Overview (Codename One API)


Format a given object.
static
DateFormat
static
DateFormat
static
DateFormat

getDateInstance()

Deprecated.
Get a DateFormat instance with default style for date (SHORT).
getDateInstance(int style)

Deprecated.
Get a DateFormat instance that uses a given style for dates.
getDateTimeInstance(int dateStyle, int timeStyle)

Deprecated.
Get a DateFormat instance that uses a given style for dates and times.
getInstance()

static
DateFormat

static
DateFormat
static
DateFormat

Deprecated.
Get a DateFormat instance with default style for date/time
(SHORT/SHORT).
getTimeInstance()

Deprecated.
Get a DateFormat instance with default style for time (SHORT).
getTimeInstance(int style)

Deprecated.
Get a DateFormat instance that uses a given style for times.
hashCode()

Deprecated.
Returns a hash code value for the object.

int

parse(String source)

Deprecated.
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

Date

parseObject(String source)

Deprecated.
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

Object

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
FULL
public static final int FULL

Deprecated.
Constant for full style parsing/formatting pattern.
See Also:
Constant Field Values
LONG
public static final int LONG

Deprecated.
Constant for long style parsing/formatting pattern.
See Also:
Constant Field Values
MEDIUM
public static final int MEDIUM

Deprecated.
Constant for medium style parsing/formatting pattern.
See Also:
Constant Field Values

Method Summary

390

Overview (Codename One API)


SHORT
public static final int SHORT

Deprecated.
Constant for short style parsing/formatting pattern.
See Also:
Constant Field Values
DEFAULT
public static final int DEFAULT

Deprecated.
Constant for default style (MEDIUM) parsing/formatting pattern.
See Also:
Constant Field Values

Method Detail
format
public String format(Object obj)
throws IllegalArgumentException

Deprecated.
Format a given object.
Specified by:
format in class Format
Parameters:
obj - object to be formatted to text.
Returns:
formatted object.
Throws:
IllegalArgumentException - of the source can not be formatted.
format
public String format(Date source)

Deprecated.
Format a given date.
Parameters:
source - date to be formatted.
Returns:
formatted date.
parseObject
public Object parseObject(String source)
throws ParseException

Deprecated.
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
Specified by:
parseObject in class Format
Parameters:
source - document to be parsed.
Returns:
parsed object.
Throws:
ParseException - if the source could not be parsed.
parse
public Date parse(String source)
throws ParseException

Deprecated.
NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

Field Detail

391

Overview (Codename One API)


Throws:
ParseException

getInstance
public static final DateFormat getInstance()

Deprecated.
Get a DateFormat instance with default style for date/time (SHORT/SHORT).
Returns:
a DateFormat instance.
getDateInstance
public static final DateFormat getDateInstance()

Deprecated.
Get a DateFormat instance with default style for date (SHORT).
Returns:
a DateFormat instance.
getTimeInstance
public static final DateFormat getTimeInstance()

Deprecated.
Get a DateFormat instance with default style for time (SHORT).
Returns:
a DateFormat instance.
getDateInstance
public static final DateFormat getDateInstance(int style)

Deprecated.
Get a DateFormat instance that uses a given style for dates.
Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);
Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT
getTimeInstance
public static final DateFormat getTimeInstance(int style)

Deprecated.
Get a DateFormat instance that uses a given style for times.
Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);
Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT
getDateTimeInstance
public static final DateFormat getDateTimeInstance(int dateStyle,
int timeStyle)

Deprecated.
Get a DateFormat instance that uses a given style for dates and times.
Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);
Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT

Method Detail

392

Overview (Codename One API)


hashCode
public int hashCode()

Deprecated.
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)

Deprecated.
Description copied from class: Object
Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
clone
public Object clone()

Deprecated.

Method Detail

393

Overview (Codename One API)


java.net

Class URISyntaxException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.net.URISyntaxException

public class
extends Exception

Constructor Summary
Constructor and Description
URISyntaxException(String input, String reason)
URISyntaxException(String input, String reason, int index)

Method Summary
Modifier and Type

Method and Description

int

getIndex()

String

getInput()

String

getReason()

void

setIndex(int index)

void

setInput(String input)

void

setReason(String reason)

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
URISyntaxException
public URISyntaxException(String input,
String reason)

Parameters:
input reason -

URISyntaxException
public URISyntaxException(String input,
String reason,
int index)

Parameters:
input

Class URISyntaxException

394

Overview (Codename One API)


reason index -

Method Detail
getIndex
public int getIndex()

Returns:
the index
setIndex
public void setIndex(int index)

Parameters:
index

- the index to set

getInput
public String getInput()

Returns:
the input
setInput
public void setInput(String input)

Parameters:
input

- the input to set

getReason
public String getReason()

Returns:
the reason
setReason
public void setReason(String reason)

Parameters:
reason

Constructor Detail

- the reason to set

395

Overview (Codename One API)


java.net

Class URI
java.lang.Object

java.net.URI

public class
extends Object

An implementation of a Univeral Resource Identifier (URI). While the output is mostly compatible with
the Java 6 API, there are a few somewhat subtle differences:

1) For socket related URIs, the toString() methods use semicolon (;) as the
query marker instead of the normal question mark (?), and the parameters are separated
with a semicolon instead of the normal ampersand (&). With this, the URIs are compatible
with those used by J2ME socket connectors. (The Java 6 API treats socket URIs as URNs).
2) This implementation does not yet "rigorously parse IPv4" addresses like the Java 6 version doe
the host address is simply stored as provided by the caller. This will be enhanced using the
InetAddress class when available.
3) The characters defined as legal "other characters" are not all interpreted correctly, which
just means some unicode characters will get encoded that aren't required to be. The
method URIHelper.isLegalUnicode() needs to be inspected further.
4) Because of 3) toASCIIString() and toString() return the same value.
TODO: finish this list

See Also:
http://docs.oracle.com/javase/6/docs/api/java/net/URI.html,
http://en.wikipedia.org/wiki/Uniform_resource_identifier,
http://en.wikipedia.org/wiki/Uniform_resource_name,
http://www.ietf.org/rfc/rfc2396.txt, http://www.ietf.org/rfc/rfc2732.txt,
http://tools.ietf.org/html/rfc2141

Constructor Summary
Constructor and Description
URI(String uriString)

Constructor that parses its values from a URI string.


URI(String scheme, String ssp, String fragment)

Constructor for building URNs.


URI(String scheme, String userInfo, String host, int port, String path,
String query, String fragment)

Constructor to create a new URI object.


URI(String scheme, String authority, String path, String query, String fragment)

Constructor to create a new URI object.

Method Summary
Modifier and
Type

Method and Description


create(String uriString)

static URI

boolean

Method Detail

A convenience factory method, intended to be used when the URI string is


known to be valid (ie.
equals(Object that)

Indicates whether some other object is "equal to" this one.

String

getAuthority()

String

getFragment()

396

Overview (Codename One API)


Get the decoded fragment (otherwise known as the "reference" or "anchor")
part of the uri.
String
String
int
String
String

getHost()

Get the host name part of the URI.


getPath()

Get the decoded path part of the uri.


getPort()

Get the port number for this URI.


getQuery()

Get the decoded query part of the uri.


getRawAuthority()
getRawFragment()

String

String
String

Get the encoded fragment (otherwise known as the "reference" or "anchor")


part of the uri.
getRawPath()

Get the encoded path part of the uri.


getRawQuery()

Get the encoded query part of the uri.

String

getRawSchemeSpecificPart()

String

getRawUserInfo()

String

getScheme()

Get the scheme part of the URI.

String

getSchemeSpecificPart()

String

getUserInfo()

int

hashCode()

Returns a hash code value for the object.

boolean

isAbsolute()

boolean

isOpaque()

URI
protected
void
protected
void
protected
String
URI
URI
protected
void
protected
void

normalize()

Normalize a URI by removing any "./" segments, and "path/../" segments.


parseSchemeSpecificPart(String ssp, boolean encode)

Utility method used to parse a given scheme specific part.


parseURI(String uriString)

Rather than attempting to process the uri string in a linear fashion, this
implementation works its way from outside-in
rebuildSchemeSpecificPart()

Utility method to construct the scheme specific part from the uri segments
(less scheme and fragment)
relativize(URI uri)

Create a relative URI object against this URI, given the uri parameter.
resolve(URI uri)

Resolve a relative URI by merging it with this URI.


setAuthority(String newAuthority, boolean encode)

Utility method - set the part, ensuring valid format.


setAuthority(String host, int port, String userInfo,
boolean encode)

Utility method to construct the authority segment from given host, port, and
userinfo segments.

protected
void

setFragment(String fragment, boolean encode)

protected
void

setPath(String path, boolean encode)

protected
void

setQuery(String query, boolean encode)

protected
void

Method Summary

Utility method to set the fragment.


Utility method to set the path.
Utility method to set the query.
setScheme(String scheme)

Utility method - set the scheme, ensuring valid format, and determining the
query separator to use.

397

Overview (Codename One API)


protected
void

setSchemeSpecificPart(String ssp, boolean encode)

String

toASCIIString()

Utility method - set the scheme specific part, ensuring valid format.
toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
URI
public URI(String scheme,
String userInfo,
String host,
int port,
String path,
String query,
String fragment)
throws URISyntaxException

Constructor to create a new URI object. The userInfo, path, query and fragment
should be unencoded values - they will be encoded as required.
Parameters:
scheme - the scheme of the URI (for URLs, this would be the protocol), or null
for relative URIs.
userInfo - the unencoded userinfo segment (ie. username:password) or null.
host - the hostname or address, or null.
port - the host port, or -1.
path - the unencoded path segment.
query - the unencoded query segment.
fragment - the unencoded fragment (often referred to as the 'reference' or
'anchor'), or null.
Throws:
URISyntaxException - if any of the fragments are invalid.
URI
public URI(String scheme,
String authority,
String path,
String query,
String fragment)
throws URISyntaxException

Constructor to create a new URI object. The authority, path, query and fragment
should be unencoded values - they will be encoded as required.
Parameters:
scheme - the scheme of the URI (for URLs, this would be the protocol), or null
for relative URIs.
authority - the unencoded authority segment (ie.
username:password@host:port, or simply: host) or null.
path - the unencoded path segment.
query - the unencoded query segment.
fragment - the unencoded fragment (often referred to as the 'reference' or
'anchor'), or null.
Throws:
URISyntaxException - if any of the fragments are invalid.
URI
public URI(String scheme,
String ssp,
String fragment)
throws URISyntaxException

Methods inherited from class java.lang.Object

398

Overview (Codename One API)


Constructor for building URNs. The ssp and fragment should be unencoded values they will be encoded as required. Examples: mailto:user@codenameone.com
sms:+5555551212 tel:+5555551212 isbn:9781935182962
Parameters:
scheme ssp - the unencoded scheme specific part (everything except the scheme and
fragment)
fragment - the unencoded fragment, or null
Throws:
URISyntaxException - if any of the segments are invalid.
URI
public URI(String uriString)
throws URISyntaxException

Constructor that parses its values from a URI string. This method expects all
segments to be property encoded by the caller. The URIHelper class can be used to
encode segments.
Parameters:
uriString - a full encoded URI in string form to be parsed.
Throws:
URISyntaxException - if any of the parsed segments are invalid.

Method Detail
setScheme
protected void setScheme(String scheme)
throws URISyntaxException

Utility method - set the scheme, ensuring valid format, and determining the query
separator to use.
Throws:
URISyntaxException

See Also:
http://en.wikipedia.org/wiki/Uniform_resource_name

setSchemeSpecificPart
protected void setSchemeSpecificPart(String ssp,
boolean encode)
throws URISyntaxException

Utility method - set the scheme specific part, ensuring valid format. If encode=true,
then some elements will be run through the encoder (path, userinfo, query, fragment),
otherwise the elements will be validated for proper encoding.
Throws:
URISyntaxException

setAuthority
protected void setAuthority(String newAuthority,
boolean encode)
throws URISyntaxException

Utility method - set the part, ensuring valid format. If encode=true, then some
elements will be run through the encoder (path, userinfo, query, fragment), otherwise
the elements will be validated for proper encoding.
Throws:
URISyntaxException

setQuery
protected void setQuery(String query,
boolean encode)
throws URISyntaxException

Utility method to set the query. If parameter encode=true, then the result will be
encoded, otherwise the result will be validated to ensure encoding is valid. Typically
the multi-parameter constructors will call this method with encode=true, and the

Constructor Detail

399

Overview (Codename One API)


single parameter construct will pass encode=false.
Parameters:
query encode Throws:
URISyntaxException

setPath
protected void setPath(String path,
boolean encode)
throws URISyntaxException

Utility method to set the path. If parameter encode=true, then the result will be
encoded, otherwise the result will be validated to ensure encoding is valid. Typically
the multi-parameter constructors will call this method with encode=true, and the
single parameter construct will pass encode=false.
Parameters:
path encode Throws:
URISyntaxException

setAuthority
protected void setAuthority(String host,
int port,
String userInfo,
boolean encode)
throws URISyntaxException

Utility method to construct the authority segment from given host, port, and userinfo
segments. If parameter encode=true, then the userinfo segment will be encoded,
otherwise the it will be validated to ensure encoding is valid. Typically the
multi-parameter constructors will call this method with encode=true, and the single
parameter construct will pass encode=false.
Parameters:
host port userInfo encode Throws:
URISyntaxException

setFragment
protected void setFragment(String fragment,
boolean encode)

Utility method to set the fragment. If parameter encode=true, then the result will be
encoded, otherwise the result will be validated to ensure encoding is valid. Typically
the multi-parameter constructors will call this method with encode=true, and the
single parameter construct will pass encode=false.
Parameters:
fragment encode rebuildSchemeSpecificPart
protected String rebuildSchemeSpecificPart()

Utility method to construct the scheme specific part from the uri segments (less
scheme and fragment)
Returns:
create
public static URI create(String uriString)

A convenience factory method, intended to be used when the URI string is known to
be valid (ie. a static application URI), so it is not needed for the caller to handle
invalid syntax. NOTE: this is not away to avoid handling errors altogether - passing
an invalid URI string will result in an IllegalArgumentException being thrown. The

Method Detail

400

Overview (Codename One API)


benefit here is that the compiler will not complain if you don't explicitly handle the
error at compile time. When handling a user-editable URI, use the URI constructors
instead.
Parameters:
uriString - URI address as a string
Returns:
parsed URI object
parseURI
protected void parseURI(String uriString)
throws URISyntaxException

Rather than attempting to process the uri string in a linear fashion, this
implementation works its way from outside-in
Parameters:
uriString Throws:
URISyntaxException

parseSchemeSpecificPart
protected void parseSchemeSpecificPart(String ssp,
boolean encode)
throws URISyntaxException

Utility method used to parse a given scheme specific part. If parameter encode=true,
then the result will be encoded, otherwise the result will be validated to ensure
encoding is valid. Typically the multi-parameter constructors will call this method with
encode=true, and the single parameter construct will pass encode=false.
Parameters:
ssp - scheme specific part (the URI without the scheme or fragment
included).
encode - true if ssp needs to be encoded, false if ssp needs to be verified.
Throws:
URISyntaxException - if the ssp is invalid.
getScheme
public String getScheme()

Get the scheme part of the URI.


Returns:
the scheme part of the URI.
getHost
public String getHost()

Get the host name part of the URI.


Returns:
the host name part of the URI.
getPort
public int getPort()

Get the port number for this URI.


Returns:
the port number for this URI, or -1 if a port number was not specified.
getPath
public String getPath()

Get the decoded path part of the uri.


Returns:
the query part of the URI, or an empty string if no path is included in the URI.
getRawPath
public String getRawPath()

Get the encoded path part of the uri.

Method Detail

401

Overview (Codename One API)


Returns:
the query part of the URI, or an empty string if no path is included in the URI.
getQuery
public String getQuery()

Get the decoded query part of the uri. The query marker (?) itself is not included in
the result.
Returns:
the query part of the URI.
getRawQuery
public String getRawQuery()

Get the encoded query part of the uri. The query marker (?) itself is not included in
the result.
Returns:
the query part of the URI.
getFragment
public String getFragment()

Get the decoded fragment (otherwise known as the "reference" or "anchor") part of
the uri. The anchor marker (#) itself is not included in the result.
Returns:
the anchor part of the URI.
getRawFragment
public String getRawFragment()

Get the encoded fragment (otherwise known as the "reference" or "anchor") part of
the uri. The anchor marker (#) itself is not included in the result.
Returns:
the anchor part of the URI.
getSchemeSpecificPart
public String getSchemeSpecificPart()

Returns:
the schemeSpecificPart
getRawSchemeSpecificPart
public String getRawSchemeSpecificPart()

Returns:
the schemeSpecificPart
getAuthority
public String getAuthority()

Returns:
the authority
getRawAuthority
public String getRawAuthority()

Returns:
the authority
getUserInfo
public String getUserInfo()

Returns:
the userInfo

Method Detail

402

Overview (Codename One API)


getRawUserInfo
public String getRawUserInfo()

Returns:
the userInfo
isOpaque
public boolean isOpaque()

Returns:
true if this URI has a scheme and starts with a slash
isAbsolute
public boolean isAbsolute()

Returns:
true if the URI is not a relative URI.
toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
Returns:
the uri as a string
toASCIIString
public String toASCIIString()

Returns:
the uri as a string with parts encoded.
relativize
public URI relativize(URI uri)

Create a relative URI object against this URI, given the uri parameter.
Parameters:
uri Returns:
See Also:
://docs.oracle.com/javase/6/docs/api/java/net/URI.html#relativize
%28java.net.URI%29

resolve
public URI resolve(URI uri)

Resolve a relative URI by merging it with this URI.


Parameters:
uri - a URI to resolve against this URI.
Returns:
a new URI created by merging given URI with this URI.
See Also:
://docs.oracle.com/javase/6/docs/api/java/net/URI.html#resolve%28
java.net.URI%29

Method Detail

403

Overview (Codename One API)


normalize
public URI normalize()

Normalize a URI by removing any "./" segments, and "path/../" segments.


Returns:
a new URI instance with redundant segments removed.
See Also:
://docs.oracle.com/javase/6/docs/api/java/net/URI.html#normalize%
28%29

hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
equals
public boolean equals(Object that)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object

Method Detail

404

Overview (Codename One API)


java.lang.ref

Class WeakReference
java.lang.Object

java.lang.ref.Reference

java.lang.ref.WeakReference

public class
extends Reference

This class provides support for weak references. Weak references are most often used to implement
canonicalizing mappings. Suppose that the garbage collector determines at a certain point in time that
an object is weakly reachable. At that time it will atomically clear all the weak references to that object
and all weak references to any other weakly- reachable objects from which that object is reachable
through a chain of strong and weak references. Since: JDK1.2, CLDC 1.1

Constructor Summary
Constructor and Description
WeakReference(Object ref)

Creates a new weak reference that refers to the given object.

Method Summary

Methods inherited from class java.lang.ref.Reference


clear, get

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
WeakReference
public WeakReference(Object ref)

Creates a new weak reference that refers to the given object.

Class WeakReference

405

Overview (Codename One API)


java.lang.ref

Class Reference
java.lang.Object

java.lang.ref.Reference
Direct Known Subclasses:
WeakReference

public abstract class


extends Object

Abstract base class for reference objects. This class defines the operations common to all reference
objects. Because reference objects are implemented in close cooperation with the garbage collector,
this class may not be subclassed directly. Since: JDK1.2, CLDC 1.1

Constructor Summary
Constructor and Description
Reference()

Method Summary
Modifier and Type

Method and Description


clear()

void

Clears this reference object.


get()

Object

Returns this reference object's referent.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Reference
public Reference()

Method Detail
clear
public void clear()

Clears this reference object.


get
public Object get()

Returns this reference object's referent. If this reference object has been cleared,
either by the program or by the garbage collector, then this method returns null.

Constructor Detail

406

Overview (Codename One API)


java.lang.invoke

Class MethodType
java.lang.Object

java.lang.invoke.MethodType

Deprecated.
these classes are used internally for Lambda compatibility
public class
extends Object

Constructor Summary
Constructor and Description
MethodType()

Deprecated.

Method Summary
Modifier and Type

Method and Description


appendParameterTypes(Class<?>... a)

MethodType

Deprecated.
appendParameterTypes(List<Class<?>> a)

MethodType

Deprecated.
changeParameterType(int a, Class<?> b)

MethodType

Deprecated.
changeReturnType(Class<?> a)

MethodType

Deprecated.
dropParameterTypes(int a, int b)

MethodType

Deprecated.
erase()

MethodType

Deprecated.
generic()

MethodType

Deprecated.
genericMethodType(int a)

static MethodType

Deprecated.
genericMethodType(int a, boolean b)

static MethodType

Deprecated.
hasPrimitives()

boolean

Deprecated.
hasWrappers()

boolean

Method Detail

Deprecated.

407

Overview (Codename One API)


insertParameterTypes(int a, Class<?>... b)
MethodType

Deprecated.
insertParameterTypes(int a, List<Class<?>> b)

MethodType

Deprecated.
methodType(Class<?> a)

static MethodType

Deprecated.
methodType(Class<?> a, Class<?> b)

static MethodType

Deprecated.
methodType(Class<?> a, Class<?>[] b)

static MethodType

Deprecated.
methodType(Class<?> a, Class<?> b, Class<?>... c)

static MethodType

Deprecated.
methodType(Class<?> a, List<Class<?>> b)

static MethodType

Deprecated.
methodType(Class<?> a, MethodType b)

static MethodType

Deprecated.
parameterArray()

Class<?>[]

Deprecated.
parameterCount()

Deprecated.

int

parameterList()
List<Class<?>>

Deprecated.
parameterType(int a)

Class<?>

Deprecated.
returnType()

Class<?>

Deprecated.
unwrap()

MethodType

Deprecated.
wrap()

MethodType

Deprecated.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MethodType
public MethodType()

Deprecated.

Method Summary

408

Overview (Codename One API)

Method Detail
methodType
public static MethodType methodType(Class<?> a,
Class<?>[] b)

Deprecated.
methodType
public static MethodType methodType(Class<?> a,
List<Class<?>> b)

Deprecated.
methodType
public static MethodType methodType(Class<?> a,
Class<?> b,
Class<?>... c)

Deprecated.
methodType
public static MethodType methodType(Class<?> a)

Deprecated.
methodType
public static MethodType methodType(Class<?> a,
Class<?> b)

Deprecated.
methodType
public static MethodType methodType(Class<?> a,
MethodType b)

Deprecated.
genericMethodType
public static MethodType genericMethodType(int a,
boolean b)

Deprecated.
genericMethodType
public static MethodType genericMethodType(int a)

Deprecated.
changeParameterType
public MethodType changeParameterType(int a,
Class<?> b)

Deprecated.
insertParameterTypes
public MethodType insertParameterTypes(int a,
Class<?>... b)

Deprecated.
appendParameterTypes
public MethodType appendParameterTypes(Class<?>... a)

Deprecated.

Method Detail

409

Overview (Codename One API)


insertParameterTypes
public MethodType insertParameterTypes(int a,
List<Class<?>> b)

Deprecated.
appendParameterTypes
public MethodType appendParameterTypes(List<Class<?>> a)

Deprecated.
dropParameterTypes
public MethodType dropParameterTypes(int a,
int b)

Deprecated.
changeReturnType
public MethodType changeReturnType(Class<?> a)

Deprecated.
hasPrimitives
public boolean hasPrimitives()

Deprecated.
hasWrappers
public boolean hasWrappers()

Deprecated.
erase
public MethodType erase()

Deprecated.
generic
public MethodType generic()

Deprecated.
wrap
public MethodType wrap()

Deprecated.
unwrap
public MethodType unwrap()

Deprecated.
parameterType
public Class<?> parameterType(int a)

Deprecated.
parameterCount
public int parameterCount()

Deprecated.
returnType
public Class<?> returnType()

Deprecated.

Method Detail

410

Overview (Codename One API)

parameterList
public List<Class<?>> parameterList()

Deprecated.
parameterArray
public Class<?>[] parameterArray()

Deprecated.

Method Detail

411

Overview (Codename One API)


java.lang.invoke

Class MethodHandles
java.lang.Object

java.lang.invoke.MethodHandles

Deprecated.
these classes are used internally for Lambda compatibility
public abstract class
extends Object

Nested Class Summary


Modifier and Type Class and Description
MethodHandles.Lookup
static class

Deprecated.

Constructor Summary
Constructor and Description
MethodHandles()

Deprecated.

Method Summary
Modifier and Type

Method and Description


arrayElementGetter(Class<?> a)

static MethodHandle

Deprecated.
arrayElementSetter(Class<?> a)

static MethodHandle

static MethodHandle

Deprecated.
catchException(MethodHandle a, Class<? extends
Throwable> b, MethodHandle c)

Deprecated.
collectArguments(MethodHandle a, int b, MethodHandle c)

static MethodHandle

Deprecated.
constant(Class<?> a, Object b)

static MethodHandle

Deprecated.
dropArguments(MethodHandle a, int b, Class<?>... c)

static MethodHandle

Deprecated.
dropArguments(MethodHandle a, int b, List<Class<?>> c)

static MethodHandle

Deprecated.
exactInvoker(MethodType a)

static MethodHandle

Class MethodHandles

Deprecated.

412

Overview (Codename One API)


explicitCastArguments(MethodHandle a, MethodType b)
static MethodHandle

static MethodHandle

Deprecated.
filterArguments(MethodHandle a, int b,
MethodHandle... c)

Deprecated.
filterReturnValue(MethodHandle a, MethodHandle b)

static MethodHandle

Deprecated.
foldArguments(MethodHandle a, MethodHandle b)

static MethodHandle

static MethodHandle

Deprecated.
guardWithTest(MethodHandle a, MethodHandle b,
MethodHandle c)

Deprecated.
identity(Class<?> a)

static MethodHandle

Deprecated.
insertArguments(MethodHandle a, int b, Object... c)

static MethodHandle

Deprecated.
invoker(MethodType a)

static MethodHandle

static
MethodHandles.Lookup

Deprecated.
lookup()

Deprecated.
permuteArguments(MethodHandle a, MethodType b, int... c)

static MethodHandle

static
MethodHandles.Lookup

Deprecated.
publicLookup()

Deprecated.
reflectAs(Class<T> a, MethodHandle b)

static <T> T

Deprecated.
spreadInvoker(MethodType a, int b)

static MethodHandle

Deprecated.
throwException(Class<?> a, Class<? extends Throwable> b)

static MethodHandle

Deprecated.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MethodHandles
public MethodHandles()

Deprecated.

Method Summary

413

Overview (Codename One API)

Method Detail
lookup
public static MethodHandles.Lookup lookup()

Deprecated.
publicLookup
public static MethodHandles.Lookup publicLookup()

Deprecated.
reflectAs
public static <T> T reflectAs(Class<T> a,
MethodHandle b)

Deprecated.
arrayElementGetter
public static MethodHandle arrayElementGetter(Class<?> a)
throws IllegalArgumentException

Deprecated.
Throws:
IllegalArgumentException

arrayElementSetter
public static MethodHandle arrayElementSetter(Class<?> a)
throws IllegalArgumentException

Deprecated.
Throws:
IllegalArgumentException

spreadInvoker
public static MethodHandle spreadInvoker(MethodType a,
int b)

Deprecated.
exactInvoker
public static MethodHandle exactInvoker(MethodType a)

Deprecated.
invoker
public static MethodHandle invoker(MethodType a)

Deprecated.
explicitCastArguments
public static MethodHandle explicitCastArguments(MethodHandle a,
MethodType b)

Deprecated.
permuteArguments
public static MethodHandle permuteArguments(MethodHandle a,
MethodType b,
int... c)

Deprecated.

Method Detail

414

Overview (Codename One API)


constant
public static MethodHandle constant(Class<?> a,
Object b)

Deprecated.
identity
public static MethodHandle identity(Class<?> a)

Deprecated.
insertArguments
public static MethodHandle insertArguments(MethodHandle a,
int b,
Object... c)

Deprecated.
dropArguments
public static MethodHandle dropArguments(MethodHandle a,
int b,
List<Class<?>> c)

Deprecated.
dropArguments
public static MethodHandle dropArguments(MethodHandle a,
int b,
Class<?>... c)

Deprecated.
filterArguments
public static MethodHandle filterArguments(MethodHandle a,
int b,
MethodHandle... c)

Deprecated.
collectArguments
public static MethodHandle collectArguments(MethodHandle a,
int b,
MethodHandle c)

Deprecated.
filterReturnValue
public static MethodHandle filterReturnValue(MethodHandle a,
MethodHandle b)

Deprecated.
foldArguments
public static MethodHandle foldArguments(MethodHandle a,
MethodHandle b)

Deprecated.
guardWithTest
public static MethodHandle guardWithTest(MethodHandle a,
MethodHandle b,
MethodHandle c)

Deprecated.
catchException
public static MethodHandle catchException(MethodHandle a,
Class<? extends Throwable> b,
MethodHandle c)

Method Detail

415

Overview (Codename One API)

Deprecated.
throwException
public static MethodHandle throwException(Class<?> a,
Class<? extends Throwable> b)

Deprecated.

Method Detail

416

Overview (Codename One API)


java.lang.invoke

Class MethodHandles.Lookup
java.lang.Object

java.lang.invoke.MethodHandles.Lookup
Enclosing class:
MethodHandles

public static class


extends Object

Field Summary
Modifier and Type Field and Description
static int

PACKAGE

static int

PRIVATE

static int

PROTECTED

static int

PUBLIC

Constructor Summary
Constructor and Description
Lookup()

Method Summary
Modifier and Type

Method and Description

MethodHandle

bind(Object a, String b, MethodType c)

MethodHandle

findConstructor(Class<?> a, MethodType b)

MethodHandle

findGetter(Class<?> a, String b, Class<?> c)

MethodHandle

findSetter(Class<?> a, String b, Class<?> c)

MethodHandle

findSpecial(Class<?> a, String b, MethodType c,


Class<?> d)

MethodHandle

findStatic(Class<?> a, String b, MethodType c)

MethodHandle

findStaticGetter(Class<?> a, String b,
Class<?> c)

MethodHandle

findStaticSetter(Class<?> a, String b,
Class<?> c)

MethodHandle

findVirtual(Class<?> a, String b, MethodType c)

MethodHandles.Lookup

in(Class<?> a)

Class<?>

lookupClass()

int

lookupModes()

java.lang.invoke.MethodHandleInfo revealDirect(MethodHandle a)
MethodHandle

unreflect(Object a)

MethodHandle

unreflectConstructor(Object a)

MethodHandle

unreflectGetter(Object a)

MethodHandle

unreflectSetter(Object a)

Class MethodHandles.Lookup

417

Overview (Codename One API)


MethodHandle

unreflectSpecial(Object a, Class<?> b)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
PUBLIC
public static final int PUBLIC

See Also:
Constant Field Values
PRIVATE
public static final int PRIVATE

See Also:
Constant Field Values
PROTECTED
public static final int PROTECTED

See Also:
Constant Field Values
PACKAGE
public static final int PACKAGE

See Also:
Constant Field Values

Constructor Detail
Lookup
public Lookup()

Method Detail
lookupClass
public Class<?> lookupClass()

lookupModes
public int lookupModes()

in
public MethodHandles.Lookup in(Class<?> a)

findStatic
public MethodHandle findStatic(Class<?> a,
String b,
MethodType c)
throws java.lang.NoSuchMethodException,
IllegalAccessException

Throws:
java.lang.NoSuchMethodException
IllegalAccessException

Method Summary

418

Overview (Codename One API)


findVirtual
public MethodHandle findVirtual(Class<?> a,
String b,
MethodType c)
throws java.lang.NoSuchMethodException,
IllegalAccessException

Throws:
java.lang.NoSuchMethodException
IllegalAccessException

findConstructor
public MethodHandle findConstructor(Class<?> a,
MethodType b)
throws java.lang.NoSuchMethodException,
IllegalAccessException

Throws:
java.lang.NoSuchMethodException
IllegalAccessException

findSpecial
public MethodHandle findSpecial(Class<?> a,
String b,
MethodType c,
Class<?> d)
throws java.lang.NoSuchMethodException,
IllegalAccessException

Throws:
java.lang.NoSuchMethodException
IllegalAccessException

findGetter
public MethodHandle findGetter(Class<?> a,
String b,
Class<?> c)
throws java.lang.NoSuchFieldException,
IllegalAccessException

Throws:
java.lang.NoSuchFieldException
IllegalAccessException

findSetter
public MethodHandle findSetter(Class<?> a,
String b,
Class<?> c)
throws java.lang.NoSuchFieldException,
IllegalAccessException

Throws:
java.lang.NoSuchFieldException
IllegalAccessException

findStaticGetter
public MethodHandle findStaticGetter(Class<?> a,
String b,
Class<?> c)
throws java.lang.NoSuchFieldException,
IllegalAccessException

Throws:
java.lang.NoSuchFieldException
IllegalAccessException

findStaticSetter
public MethodHandle findStaticSetter(Class<?> a,
String b,
Class<?> c)
throws java.lang.NoSuchFieldException,
IllegalAccessException

Method Detail

419

Overview (Codename One API)


Throws:
java.lang.NoSuchFieldException
IllegalAccessException

bind
public MethodHandle bind(Object a,
String b,
MethodType c)
throws java.lang.NoSuchMethodException,
IllegalAccessException

Throws:
java.lang.NoSuchMethodException
IllegalAccessException

unreflect
public MethodHandle unreflect(Object a)
throws IllegalAccessException

Throws:
IllegalAccessException

unreflectSpecial
public MethodHandle unreflectSpecial(Object a,
Class<?> b)
throws IllegalAccessException

Throws:
IllegalAccessException

unreflectConstructor
public MethodHandle unreflectConstructor(Object a)
throws IllegalAccessException

Throws:
IllegalAccessException

unreflectGetter
public MethodHandle unreflectGetter(Object a)
throws IllegalAccessException

Throws:
IllegalAccessException

unreflectSetter
public MethodHandle unreflectSetter(Object a)
throws IllegalAccessException

Throws:
IllegalAccessException

revealDirect
public java.lang.invoke.MethodHandleInfo revealDirect(MethodHandle a)

Method Detail

420

Overview (Codename One API)


java.lang.invoke

Class MethodHandle
java.lang.Object

java.lang.invoke.MethodHandle

Deprecated.
these classes are used internally for Lambda compatibility
public abstract class
extends Object

Constructor Summary
Constructor and Description
MethodHandle()

Deprecated.

Method Summary
Modifier and Type

Method and Description


asCollector(Class<?> a, int b)

MethodHandle

Deprecated.
asFixedArity()

MethodHandle

Deprecated.
asSpreader(Class<?> a, int b)

MethodHandle

Deprecated.
asType(MethodType a)

MethodHandle

Deprecated.
asVarargsCollector(Class<?> a)

MethodHandle

Deprecated.
bindTo(Object a)

MethodHandle

Deprecated.
invoke(Object... a)

Object

Deprecated.
invokeExact(Object... a)

Object

Deprecated.
invokeWithArguments(List<?> a)

Object

Deprecated.
invokeWithArguments(Object... a)

Object

Deprecated.
isVarargsCollector()

boolean

Class MethodHandle

Deprecated.

421

Overview (Codename One API)


type()

Deprecated.

MethodType

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MethodHandle
public MethodHandle()

Deprecated.

Method Detail
type
public MethodType type()

Deprecated.
invokeExact
public final Object invokeExact(Object... a)
throws Throwable

Deprecated.
Throws:
Throwable

invoke
public final Object invoke(Object... a)
throws Throwable

Deprecated.
Throws:
Throwable

invokeWithArguments
public Object invokeWithArguments(Object... a)
throws Throwable

Deprecated.
Throws:
Throwable

invokeWithArguments
public Object invokeWithArguments(List<?> a)
throws Throwable

Deprecated.
Throws:
Throwable

asType
public MethodHandle asType(MethodType a)

Deprecated.

Method Summary

422

Overview (Codename One API)


asSpreader
public MethodHandle asSpreader(Class<?> a,
int b)

Deprecated.
asCollector
public MethodHandle asCollector(Class<?> a,
int b)

Deprecated.
asVarargsCollector
public MethodHandle asVarargsCollector(Class<?> a)

Deprecated.
isVarargsCollector
public boolean isVarargsCollector()

Deprecated.
asFixedArity
public MethodHandle asFixedArity()

Deprecated.
bindTo
public MethodHandle bindTo(Object a)

Deprecated.

Method Detail

423

Overview (Codename One API)


java.lang.invoke

Class LambdaMetafactory
java.lang.Object

java.lang.invoke.LambdaMetafactory

Deprecated.
these classes are used internally for Lambda compatibility
public class
extends Object

Field Summary
Modifier and Type Field and Description
FLAG_BRIDGES
static int

Deprecated.
FLAG_MARKERS

static int

Deprecated.
FLAG_SERIALIZABLE

static int

Deprecated.

Constructor Summary
Constructor and Description
LambdaMetafactory()

Deprecated.

Method Summary
Modifier and
Type
static
CallSite

static
CallSite

Method and Description


altMetafactory(MethodHandles.Lookup a, String b, MethodType c,
Object... d)

Deprecated.
metafactory(MethodHandles.Lookup a, String f, MethodType b,
MethodType c, MethodHandle d, MethodType e)

Deprecated.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Class LambdaMetafactory

424

Overview (Codename One API)


FLAG_SERIALIZABLE
public static final int FLAG_SERIALIZABLE

Deprecated.
See Also:
Constant Field Values
FLAG_MARKERS
public static final int FLAG_MARKERS

Deprecated.
See Also:
Constant Field Values
FLAG_BRIDGES
public static final int FLAG_BRIDGES

Deprecated.
See Also:
Constant Field Values

Constructor Detail
LambdaMetafactory
public LambdaMetafactory()

Deprecated.

Method Detail
metafactory
public static CallSite metafactory(MethodHandles.Lookup a,
String f,
MethodType b,
MethodType c,
MethodHandle d,
MethodType e)
throws java.lang.invoke.LambdaConversionException

Deprecated.
Throws:
java.lang.invoke.LambdaConversionException

altMetafactory
public static CallSite altMetafactory(MethodHandles.Lookup a,
String b,
MethodType c,
Object... d)
throws java.lang.invoke.LambdaConversionException

Deprecated.
Throws:
java.lang.invoke.LambdaConversionException

Field Detail

425

Overview (Codename One API)


java.lang.invoke

Class CallSite
java.lang.Object

java.lang.invoke.CallSite

Deprecated.
these classes are used internally for Lambda compatibility
public abstract class
extends Object

Constructor Summary
Constructor and Description
CallSite()

Deprecated.

Method Summary
Modifier and Type

Method and Description


dynamicInvoker()

abstract MethodHandle

Deprecated.
getTarget()

abstract MethodHandle

Deprecated.
setTarget(MethodHandle mh)

abstract void

Deprecated.
type()

MethodType

Deprecated.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CallSite
public CallSite()

Deprecated.

Method Detail
type
public MethodType type()

Deprecated.

Method Detail

426

Overview (Codename One API)


getTarget
public abstract MethodHandle getTarget()

Deprecated.
setTarget
public abstract void setTarget(MethodHandle mh)

Deprecated.
dynamicInvoker
public abstract MethodHandle dynamicInvoker()

Deprecated.

Method Detail

427

Overview (Codename One API)


java.lang.annotation

Annotation Type Target

@Documented
@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface

Required Element Summary


Modifier and Type Required Element and Description
ElementType[]

value

Element Detail
value
public abstract ElementType[] value

Annotation Type Target

428

Overview (Codename One API)


java.lang.annotation

Enum RetentionPolicy
java.lang.Object

java.lang.Enum<RetentionPolicy>

java.lang.annotation.RetentionPolicy
All Implemented Interfaces:
Comparable<RetentionPolicy>

public enum
extends Enum<RetentionPolicy>

A mirror of java.lang.annotation.RetentionPolicy.

Enum Constant Summary


Enum Constant and Description
CLASS
RUNTIME
SOURCE

Method Summary
Modifier and Type
static RetentionPolicy
static
RetentionPolicy[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in


the order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


CLASS
public static final RetentionPolicy CLASS

RUNTIME
public static final RetentionPolicy RUNTIME

SOURCE
public static final RetentionPolicy SOURCE

Method Detail

Element Detail

429

Overview (Codename One API)


values
public static RetentionPolicy[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (RetentionPolicy c : RetentionPolicy.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static RetentionPolicy valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Method Detail

430

Overview (Codename One API)


java.lang.annotation

Annotation Type Retention

@Documented
@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface

Required Element Summary


Modifier and Type Required Element and Description
RetentionPolicy

value

Element Detail
value
public abstract RetentionPolicy value

Annotation Type Retention

431

Overview (Codename One API)


java.lang.annotation

Annotation Type Inherited

@Documented
@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface

Element Detail

432

Overview (Codename One API)


java.lang.annotation

Class IncompleteAnnotationException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.annotation.IncompleteAnnotationException

public class
extends RuntimeException

A mirror of java.lang.annotation.IncompleteAnnotationException.

Constructor Summary
Constructor and Description
IncompleteAnnotationException(Class<? extends Annotation> annotationType,
String elementName)

Method Summary
Modifier and Type

Method and Description

Class<? extends Annotation>

annotationType()

String

elementName()

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IncompleteAnnotationException
public IncompleteAnnotationException(Class<? extends Annotation> annotationType,
String elementName)

Method Detail
annotationType
public Class<? extends Annotation> annotationType()

elementName
public String elementName()

Annotation Type Inherited

433

Overview (Codename One API)


java.lang.annotation

Enum ElementType
java.lang.Object

java.lang.Enum<ElementType>

java.lang.annotation.ElementType
All Implemented Interfaces:
Comparable<ElementType>

public enum
extends Enum<ElementType>

A mirror of java.lang.annotation.ElementType.

Enum Constant Summary


Enum Constant and Description
ANNOTATION_TYPE
CONSTRUCTOR
FIELD
LOCAL_VARIABLE
METHOD
PACKAGE
PARAMETER
TYPE

Method Summary
Modifier and Type
static ElementType
static
ElementType[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in the


order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


ANNOTATION_TYPE
public static final ElementType ANNOTATION_TYPE

Method Detail

434

Overview (Codename One API)


CONSTRUCTOR
public static final ElementType CONSTRUCTOR

FIELD
public static final ElementType FIELD

LOCAL_VARIABLE
public static final ElementType LOCAL_VARIABLE

METHOD
public static final ElementType METHOD

PACKAGE
public static final ElementType PACKAGE

PARAMETER
public static final ElementType PARAMETER

TYPE
public static final ElementType TYPE

Method Detail
values
public static ElementType[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (ElementType c : ElementType.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static ElementType valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Enum Constant Detail

435

Overview (Codename One API)


java.lang.annotation

Annotation Type Documented

@Documented
@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface

Method Detail

436

Overview (Codename One API)


java.lang.annotation

Class AnnotationFormatError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.annotation.AnnotationFormatError

public class
extends Error

A mirror of java.lang.annotation.AnnotationFormatError.

Constructor Summary
Constructor and Description
AnnotationFormatError(String message)
AnnotationFormatError(String message, Throwable cause)
AnnotationFormatError(Throwable cause)

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
AnnotationFormatError
public AnnotationFormatError(String message)

AnnotationFormatError
public AnnotationFormatError(String message,
Throwable cause)

AnnotationFormatError
public AnnotationFormatError(Throwable cause)

Annotation Type Documented

437

Overview (Codename One API)


java.lang.annotation

Interface Annotation
All Known Implementing Classes:
Deprecated, Documented, Inherited, Override, Retention, SuppressWarnings, Target

public interface

A mirror of java.lang.Annotation.

Method Summary
Modifier and Type
Class<? extends
Annotation>

Method and Description


annotationType()

Returns the annotation type of this annotation.


equals(Object obj)

boolean

hashCode()

int

Returns the hash code of this annotation, as defined below:


toString()

String

Returns true if the specified object represents an annotation that is


logically equivalent to this one.

Returns a string representation of this annotation.

Method Detail
annotationType
Class<? extends Annotation> annotationType()

Returns the annotation type of this annotation.


equals
boolean equals(Object obj)

Returns true if the specified object represents an annotation that is logically


equivalent to this one.
Overrides:
equals in class Object
hashCode
int hashCode()

Returns the hash code of this annotation, as defined below:


Overrides:
hashCode in class Object
toString
String toString()

Returns a string representation of this annotation.


Overrides:
toString in class Object

Constructor Detail

438

Overview (Codename One API)


java.lang

Class Void
java.lang.Object

java.lang.Void

public final class


extends Object

Field Summary
Modifier and Type Field and Description
static Class

TYPE

Constructor Summary
Constructor and Description
Void()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final Class TYPE

Constructor Detail
Void
public Void()

Method Detail

439

Overview (Codename One API)


java.lang

Class VirtualMachineError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.VirtualMachineError
Direct Known Subclasses:
OutOfMemoryError

public abstract class


extends Error

Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it
to continue operating. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
VirtualMachineError()

Constructs a VirtualMachineError with no detail message.


VirtualMachineError(String s)

Constructs a VirtualMachineError with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
VirtualMachineError
public VirtualMachineError()

Constructs a VirtualMachineError with no detail message.


VirtualMachineError
public VirtualMachineError(String s)

Constructs a VirtualMachineError with the specified detail message. s - the detail


message.

Constructor Detail

440

Overview (Codename One API)


java.lang

Class Throwable
java.lang.Object

java.lang.Throwable
Direct Known Subclasses:
Error, Exception

public class
extends Object

The Throwable class is the superclass of all errors and exceptions in the Java language. Only objects
that are instances of this class (or of one of its subclasses) are thrown by the Java Virtual Machine or
can be thrown by the Java throw statement. Similarly, only this class or one of its subclasses can be
the argument type in a catch clause. Instances of two subclasses, Error and Exception, are
conventionally used to indicate that exceptional situations have occurred. Typically, these instances
are freshly created in the context of the exceptional situation so as to include relevant information
(such as stack trace data). By convention, class Throwable and its subclasses have two constructors,
one that takes no arguments and one that takes a String argument that can be used to produce an
error message. A Throwable class contains a snapshot of the execution stack of its thread at the time
it was created. It can also contain a message string that gives more information about the error. Here
is one example of catching an exception: Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
Throwable()

Constructs a new Throwable with null as its error message string.


Throwable(String message)

Constructs a new Throwable with the specified error message.

Method Summary
Modifier and
Type
void

Method and Description


addSuppressed(Throwable exception)
getMessage()

String

Returns the error message string of this Throwable object.


initCause(Throwable cause)

Throwable

Deprecated.
DO NOT USE THIS METHOD, its here just to get the compiler working and
isn't intended for use
printStackTrace()

void

Prints this Throwable and its backtrace to the standard error stream.

String

toString()

Returns a short description of this Throwable object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

Constructor Detail

441

Overview (Codename One API)


Throwable
public Throwable()

Constructs a new Throwable with null as its error message string.


Throwable
public Throwable(String message)

Constructs a new Throwable with the specified error message. message - the error
message. The error message is saved for later retrieval by the method.

Method Detail
initCause
public Throwable initCause(Throwable cause)

Deprecated. DO NOT USE THIS METHOD, its here just to get the compiler working
and isn't intended for use
getMessage
public String getMessage()

Returns the error message string of this Throwable object.


printStackTrace
public void printStackTrace()

Prints this Throwable and its backtrace to the standard error stream. This method
prints a stack trace for this Throwable object on the error output stream that is the
value of the field System.err. The first line of output contains the result of the method
for this object. The format of the backtrace information depends on the
implementation.
toString
public String toString()

Returns a short description of this Throwable object. If this Throwable object was with
an error message string, then the result is the concatenation of three strings: The
name of the actual class of this object ": " (a colon and a space) The result of the
method for this object If this Throwable object was with no error message string, then
the name of the actual class of this object is returned.
Overrides:
toString in class Object
addSuppressed
public final void addSuppressed(Throwable exception)

Constructor Detail

442

Overview (Codename One API)


java.lang

Class Thread
java.lang.Object

java.lang.Thread
All Implemented Interfaces:
Runnable

public class
extends Object
implements Runnable

A thread is a thread of execution in a program. The Java Virtual Machine allows an application to
have multiple threads of execution running concurrently. Every thread has a priority. Threads with
higher priority are executed in preference to threads with lower priority. There are two ways to create
a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should
override the run method of class Thread. An instance of the subclass can then be allocated and
started. For example, a thread that computes primes larger than a stated value could be written as
follows:

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


MAX_PRIORITY

The maximum priority that a thread can have.


MIN_PRIORITY

The minimum priority that a thread can have.


NORM_PRIORITY

The default priority that is assigned to a thread.

Constructor Summary
Constructor and Description
Thread()

Allocates a new Thread object.


Thread(Runnable target)

Allocates a new Thread object with a specific target object whose run method is called.
Thread(Runnable target, String name)

Allocates a new Thread object with the given target and name.
Thread(String name)

Allocates a new Thread object with the given name.

Method Summary
Modifier
and Type
static int
static
Thread
String
int

Method Detail

Method and Description


activeCount()

Returns the current number of active threads in the virtual machine.


currentThread()

Returns a reference to the currently executing Thread object.


getName()

Returns this thread's name.


getPriority()

Returns this thread's priority.

443

Overview (Codename One API)


interrupt()

void

Interrupts this thread.

boolean

isAlive()

Tests if this thread is alive.


join()

void

Waits for this thread to die.


run()

If this thread was constructed using a separate Runnable run object, then that
Runnable object's run method is called; otherwise, this method does nothing
and returns.

void

setPriority(int newPriority)

void

Changes the priority of this thread.


sleep(long millis)

static void

Causes the currently executing thread to sleep (temporarily cease execution)


for the specified number of milliseconds.
start()

Causes this thread to begin execution; the Java Virtual Machine calls the run
method of this thread.

void

toString()

Returns a string representation of this thread, including the thread's name and
priority.

String

yield()
static void

Causes the currently executing thread object to temporarily pause and allow
other threads to execute.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
MAX_PRIORITY
public static final int MAX_PRIORITY

The maximum priority that a thread can have. See Also:Constant Field Values
See Also:
Constant Field Values
MIN_PRIORITY
public static final int MIN_PRIORITY

The minimum priority that a thread can have. See Also:Constant Field Values
See Also:
Constant Field Values
NORM_PRIORITY
public static final int NORM_PRIORITY

The default priority that is assigned to a thread. See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Thread
public Thread()

Method Summary

444

Overview (Codename One API)


Allocates a new Thread object. Threads created this way must have overridden their
run() method to actually do anything.
Thread
public Thread(Runnable target)

Allocates a new Thread object with a specific target object whose run method is
called. target - the object whose run method is called.
Thread
public Thread(Runnable target,
String name)

Allocates a new Thread object with the given target and name. target - the object
whose run method is called.name - the name of the new thread.
Thread
public Thread(String name)

Allocates a new Thread object with the given name. Threads created this way must
have overridden their run() method to actually do anything. name - the name of the
new thread.

Method Detail
activeCount
public static int activeCount()

Returns the current number of active threads in the virtual machine.


currentThread
public static Thread currentThread()

Returns a reference to the currently executing Thread object.


getName
public final String getName()

Returns this thread's name. Note that in CLDC the name of the thread can only be
set when creating the thread.
getPriority
public final int getPriority()

Returns this thread's priority.


interrupt
public void interrupt()

Interrupts this thread. In an implementation conforming to the CLDC Specification,


this operation is not required to cancel or clean up any pending I/O operations that
the thread may be waiting for.
isAlive
public final boolean isAlive()

Tests if this thread is alive. A thread is alive if it has been started and has not yet
died.
join
public final void join()
throws InterruptedException

Waits for this thread to die.


Throws:

Constructor Detail

445

Overview (Codename One API)


InterruptedException

run
public void run()

If this thread was constructed using a separate Runnable run object, then that
Runnable object's run method is called; otherwise, this method does nothing and
returns. Subclasses of Thread should override this method.
Specified by:
run in interface Runnable
setPriority
public final void setPriority(int newPriority)

Changes the priority of this thread.


sleep
public static void sleep(long millis)
throws InterruptedException

Causes the currently executing thread to sleep (temporarily cease execution) for the
specified number of milliseconds. The thread does not lose ownership of any
monitors.
Throws:
InterruptedException

start
public void start()

Causes this thread to begin execution; the Java Virtual Machine calls the run method
of this thread. The result is that two threads are running concurrently: the current
thread (which returns from the call to the start method) and the other thread (which
executes its run method).
toString
public String toString()

Returns a string representation of this thread, including the thread's name and
priority.
Overrides:
toString in class Object
yield
public static void yield()

Causes the currently executing thread object to temporarily pause and allow other
threads to execute.

Method Detail

446

Overview (Codename One API)


java.lang

Class System
java.lang.Object

java.lang.System

public final class


extends Object

The System class contains several useful class fields and methods. It cannot be instantiated. Since:
JDK1.0, CLDC 1.0

Field Summary
Modifier and Type
static PrintStream
static PrintStream

Field and Description


err

The "standard" error output stream.


out

The "standard" output stream.

Constructor Summary
Constructor and Description
System()

Method Summary
Modifier
and Type
static void

static long
static void
static void

Method and Description


arraycopy(Object src, int srcOffset, Object dst, int dstOffset,
int length)

Copies an array from the specified source array, beginning at the specified
position, to the specified position of the destination array.
currentTimeMillis()

Returns the current time in milliseconds.


exit(int status)

Terminates the currently running Java application.


gc()

Runs the garbage collector.


getProperty(String key)

static
String

Gets the system property indicated by the specified key.


identityHashCode(Object x)

static int

Returns the same hashcode for the given object as would be returned by the
default method hashCode(), whether or not the given object's class overrides
hashCode().

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class System

447

Overview (Codename One API)


Field

Detail
err
public static final PrintStream err

The "standard" error output stream. This stream is already open and ready to accept
output data. Typically this stream corresponds to display output or another output
destination specified by the host environment or user. By convention, this output
stream is used to display error messages or other information that should come to the
immediate attention of a user even if the principal output stream, the value of the
variable out, has been redirected to a file or other destination that is typically not
continuously monitored.
out
public static final PrintStream out

The "standard" output stream. This stream is already open and ready to accept
output data. Typically this stream corresponds to display output or another output
destination specified by the host environment or user. For simple stand-alone Java
applications, a typical way to write a line of output data is: System.out.println(data)
See the println methods in class PrintStream. See Also:PrintStream.println(),
PrintStream.println(boolean), PrintStream.println(char), PrintStream.println(char[]),
PrintStream.println(int), PrintStream.println(long),
PrintStream.println(java.lang.Object), PrintStream.println(java.lang.String)

Constructor Detail
System
public System()

Method Detail
arraycopy
public static void arraycopy(Object src,
int srcOffset,
Object dst,
int dstOffset,
int length)

Copies an array from the specified source array, beginning at the specified position,
to the specified position of the destination array. A subsequence of array components
are copied from the source array referenced by src to the destination array
referenced by dst. The number of components copied is equal to the length
argument. The components at positions srcOffset through srcOffset+length-1 in the
source array are copied into positions dstOffset through dstOffset+length-1,
respectively, of the destination array. If the src and dst arguments refer to the same
array object, then the copying is performed as if the components at positions
srcOffset through srcOffset+length-1 were first copied to a temporary array with
length components and then the contents of the temporary array were copied into
positions dstOffset through dstOffset+length-1 of the destination array. If dst is null,
then a NullPointerException is thrown. If src is null, then a NullPointerException is
thrown and the destination array is not modified. Otherwise, if any of the following is
true, an ArrayStoreException is thrown and the destination is not modified: The src
argument refers to an object that is not an array. The dst argument refers to an object
that is not an array. The src argument and dst argument refer to arrays whose
component types are different primitive types. The src argument refers to an array
with a primitive component type and the dst argument refers to an array with a
reference component type. The src argument refers to an array with a reference
component type and the dst argument refers to an array with a primitive component
type. Otherwise, if any of the following is true, an IndexOutOfBoundsException is

Field Detail

448

Overview (Codename One API)

thrown and the destination is not modified: The srcOffset argument is negative. The
dstOffset argument is negative. The length argument is negative. srcOffset+length is
greater than src.length, the length of the source array. dstOffset+length is greater
than dst.length, the length of the destination array. Otherwise, if any actual
component of the source array from position srcOffset through srcOffset+length-1
cannot be converted to the component type of the destination array by assignment
conversion, an ArrayStoreException is thrown. In this case, let k be the smallest
nonnegative integer less than length such that src[srcOffset+k] cannot be converted
to the component type of the destination array; when the exception is thrown, source
array components from positions srcOffset through srcOffset+k-1 will already have
been copied to destination array positions dstOffset through dstOffset+k-1 and no
other positions of the destination array will have been modified. (Because of the
restrictions already itemized, this paragraph effectively applies only to the situation
where both arrays have component types that are reference types.)
currentTimeMillis
public static long currentTimeMillis()

Returns the current time in milliseconds.


exit
public static void exit(int status)

Terminates the currently running Java application. The argument serves as a status
code; by convention, a nonzero status code indicates abnormal termination. This
method calls the exit method in class Runtime. This method never returns normally.
The call System.exit(n) is effectively equivalent to the call:
Runtime.getRuntime().exit(n)
gc
public static void gc()

Runs the garbage collector. Calling the gc method suggests that the Java Virtual
Machine expend effort toward recycling unused objects in order to make the memory
they currently occupy available for quick reuse. When control returns from the
method call, the Java Virtual Machine has made a best effort to reclaim space from
all discarded objects. The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()
getProperty
public static String getProperty(String key)

Gets the system property indicated by the specified key.


identityHashCode
public static int identityHashCode(Object x)

Returns the same hashcode for the given object as would be returned by the default
method hashCode(), whether or not the given object's class overrides hashCode().
The hashcode for the null reference is zero.

Method Detail

449

Overview (Codename One API)


java.lang

Annotation Type SuppressWarnings

@Target(value={TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
@Retention(value=SOURCE)
public @interface

An annotation that indicates a compiler should suppress any warnings of the type specified in the
value().
Since:
1.5

Required Element Summary


Modifier and Type Required Element and Description
String[]

value

Element Detail
value
public abstract String[] value

Annotation Type SuppressWarnings

450

Overview (Codename One API)


java.lang

Class StringIndexOutOfBoundsException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IndexOutOfBoundsException

java.lang.StringIndexOutOfBoundsException

public class
extends IndexOutOfBoundsException

Thrown by the charAt method in class String and by other String methods to indicate that an index is
either negative or greater than or equal to the size of the string. Since: JDK1.0, CLDC 1.0 See
Also:String.charAt(int)

Constructor Summary
Constructor and Description
StringIndexOutOfBoundsException()

Constructs a StringIndexOutOfBoundsException with no detail message.


StringIndexOutOfBoundsException(int index)

Constructs a new StringIndexOutOfBoundsException class with an argument indicating the


illegal index.
StringIndexOutOfBoundsException(String s)

Constructs a StringIndexOutOfBoundsException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
StringIndexOutOfBoundsException
public StringIndexOutOfBoundsException()

Constructs a StringIndexOutOfBoundsException with no detail message. JDK1.0.


StringIndexOutOfBoundsException
public StringIndexOutOfBoundsException(int index)

Constructs a new StringIndexOutOfBoundsException class with an argument


indicating the illegal index. index - the illegal index.
StringIndexOutOfBoundsException
public StringIndexOutOfBoundsException(String s)

Element Detail

451

Overview (Codename One API)


Constructs a StringIndexOutOfBoundsException with the specified detail message. s
- the detail message.

Constructor Detail

452

Overview (Codename One API)


java.lang

Class StringBuilder
java.lang.Object

java.lang.StringBuilder

public final class


extends Object

A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can
be modified. At any point in time it contains some particular sequence of characters, but the length
and content of the sequence can be changed through certain method calls. String buffers are safe for
use by multiple threads. The methods are synchronized where necessary so that all the operations on
any particular instance behave as if they occur in some serial order that is consistent with the order of
the method calls made by each of the individual threads involved. String buffers are used by the
compiler to implement the binary string concatenation operator +. For example, the code: is compiled
to the equivalent of: The principal operations on a StringBuffer are the append and insert methods,
which are overloaded so as to accept data of any type. Each effectively converts a given datum to a
string and then appends or inserts the characters of that string to the string buffer. The append
method always adds these characters at the end of the buffer; the insert method adds the characters
at a specified point. For example, if z refers to a string buffer object whose current contents are
"start", then the method call z.append("le") would cause the string buffer to contain "startle", whereas
z.insert(4, "le") would alter the string buffer to contain "starlet". In general, if sb refers to an instance of
a StringBuffer, then sb.append(x) has the same effect as sb.insert(sb.length(),x). Every string buffer
has a capacity. As long as the length of the character sequence contained in the string buffer does
not exceed the capacity, it is not necessary to allocate a new internal buffer array. If the internal buffer
overflows, it is automatically made larger. Since: JDK1.0, CLDC 1.0 See
Also:ByteArrayOutputStream, String

Constructor Summary
Constructor and Description
StringBuilder()

Constructs a string buffer with no characters in it and an initial capacity of 16 characters.


StringBuilder(int length)

Constructs a string buffer with no characters in it and an initial capacity specified by the
length argument.
StringBuilder(String str)

Constructs a string buffer so that it represents the same sequence of characters as the string
argument; in other words, the initial contents of the string buffer is a copy of the argument
string.

Method Summary
Modifier and
Type

Method and Description


append(boolean b)

StringBuilder

Appends the string representation of the boolean argument to the string


buffer.
append(char c)

StringBuilder

Appends the string representation of the char argument to this string


buffer.
append(char[] str, int offset, int len)

StringBuilder

Appends the string representation of a subarray of the char array


argument to this string buffer.

StringBuilder

append(CharSequence cs)

Class StringBuilder

453

Overview (Codename One API)


StringBuilder

append(CharSequence cs, int start, int end)


append(double d)

StringBuilder

Appends the string representation of the double argument to this string


buffer.
append(float f)

StringBuilder

StringBuilder

Appends the string representation of the float argument to this string


buffer.
append(int i)

Appends the string representation of the int argument to this string buffer.
append(long l)

StringBuilder

Appends the string representation of the long argument to this string


buffer.
append(Object obj)

StringBuilder

StringBuilder
int

Appends the string representation of the Object argument to this string


buffer.
append(String str)

Appends the string to this string buffer.


capacity()

Returns the current capacity of the String buffer.


charAt(int index)

char

StringBuilder

The specified character of the sequence currently represented by the


string buffer, as indicated by the index argument, is returned.
delete(int start, int end)

Removes the characters in a substring of this StringBuffer.


deleteCharAt(int index)

StringBuilder

Removes the character at the specified position in this StringBuffer


(shortening the StringBuffer by one character).
ensureCapacity(int minimumCapacity)

void

Ensures that the capacity of the buffer is at least equal to the specified
minimum.
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

void

Characters are copied from this string buffer into the destination character
array dst.
insert(int offset, boolean b)

StringBuilder

Inserts the string representation of the boolean argument into this string
buffer.
insert(int offset, char c)

StringBuilder

Inserts the string representation of the char argument into this string
buffer.

StringBuilder

insert(int offset, CharSequence cs)

StringBuilder

insert(int offset, CharSequence cs, int start, int end)


insert(int offset, double d)

StringBuilder

StringBuilder

Inserts the string representation of the double argument into this string
buffer.
insert(int offset, float f)

Inserts the string representation of the float argument into this string buffer.
insert(int offset, int i)

StringBuilder

StringBuilder

Inserts the string representation of the second int argument into this string
buffer.
insert(int offset, long l)

Inserts the string representation of the long argument into this string buffer.
insert(int offset, Object obj)

StringBuilder

StringBuilder
int

Method Summary

Inserts the string representation of the Object argument into this string
buffer.
insert(int offset, String str)

Inserts the string into this string buffer.


length()

Returns the length (character count) of this string buffer.

454

Overview (Codename One API)


reverse()
StringBuilder

The character sequence contained in this string buffer is replaced by the


reverse of the sequence.
setCharAt(int index, char ch)

void

The character at the specified index of this string buffer is set to ch.
setLength(int newLength)

void

Sets the length of this string buffer.

StringBuilder

StringBuffer(CharSequence cs)
toString()

String

Converts to a string representing the data in this string buffer.

void

trimToSize()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
StringBuilder
public StringBuilder()

Constructs a string buffer with no characters in it and an initial capacity of 16


characters.
StringBuilder
public StringBuilder(int length)

Constructs a string buffer with no characters in it and an initial capacity specified by


the length argument. length - the initial capacity. - if the length argument is less than
0.
StringBuilder
public StringBuilder(String str)

Constructs a string buffer so that it represents the same sequence of characters as


the string argument; in other words, the initial contents of the string buffer is a copy of
the argument string. The initial capacity of the string buffer is 16 plus the length of the
string argument. str - the initial contents of the buffer.

Method Detail
append
public StringBuilder append(boolean b)

Appends the string representation of the boolean argument to the string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(char c)

Appends the string representation of the char argument to this string buffer. The
argument is appended to the contents of this string buffer. The length of this string
buffer increases by 1. The overall effect is exactly as if the argument were converted
to a string by the method String.valueOf(char) and the character in that string were
then appended to this StringBuffer object.

Methods inherited from class java.lang.Object

455

Overview (Codename One API)


append
public StringBuilder append(char[] str,
int offset,
int len)

Appends the string representation of a subarray of the char array argument to this
string buffer. Characters of the character array str, starting at index offset, are
appended, in order, to the contents of this string buffer. The length of this string buffer
increases by the value of len. The overall effect is exactly as if the arguments were
converted to a string by the method String.valueOf(char[],int,int) and the characters of
that string were then appended to this StringBuffer object.
append
public StringBuilder append(double d)

Appends the string representation of the double argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(float f)

Appends the string representation of the float argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(int i)

Appends the string representation of the int argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(long l)

Appends the string representation of the long argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(Object obj)

Appends the string representation of the Object argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuilder append(String str)

Appends the string to this string buffer. The characters of the String argument are
appended, in order, to the contents of this string buffer, increasing the length of this
string buffer by the length of the argument. If str is null, then the four characters "null"
are appended to this string buffer. Let n be the length of the old character sequence,
the one contained in the string buffer just prior to execution of the append method.
Then the character at index k in the new character sequence is equal to the character
at index k in the old character sequence, if k is less than n; otherwise, it is equal to
the character at index k-n in the argument str.
capacity
public int capacity()

Returns the current capacity of the String buffer. The capacity is the amount of
storage available for newly inserted characters; beyond which an allocation will occur.

Method Detail

456

Overview (Codename One API)


charAt
public char charAt(int index)

The specified character of the sequence currently represented by the string buffer, as
indicated by the index argument, is returned. The first character of a string buffer is at
index 0, the next at index 1, and so on, for array indexing. The index argument must
be greater than or equal to 0, and less than the length of this string buffer.
delete
public StringBuilder delete(int start,
int end)

Removes the characters in a substring of this StringBuffer. The substring begins at


the specified start and extends to the character at index end - 1 or to the end of the
StringBuffer if no such character exists. If start is equal to end, no changes are made.
deleteCharAt
public StringBuilder deleteCharAt(int index)

Removes the character at the specified position in this StringBuffer (shortening the
StringBuffer by one character).
ensureCapacity
public void ensureCapacity(int minimumCapacity)

Ensures that the capacity of the buffer is at least equal to the specified minimum. If
the current capacity of this string buffer is less than the argument, then a new internal
buffer is allocated with greater capacity. The new capacity is the larger of: The
minimumCapacity argument. Twice the old capacity, plus 2. If the minimumCapacity
argument is nonpositive, this method takes no action and simply returns.
getChars
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)

Characters are copied from this string buffer into the destination character array dst.
The first character to be copied is at index srcBegin; the last character to be copied is
at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin.
The characters are copied into the subarray of dst starting at index dstBegin and
ending at index: dstbegin + (srcEnd-srcBegin) - 1
insert
public StringBuilder insert(int offset,
boolean b)

Inserts the string representation of the boolean argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuilder insert(int offset,
char c)

Inserts the string representation of the char argument into this string buffer. The
second argument is inserted into the contents of this string buffer at the position
indicated by offset. The length of this string buffer increases by one. The overall
effect is exactly as if the argument were converted to a string by the method
String.valueOf(char) and the character in that string were then inserted into this
StringBuffer object at the position indicated by offset. The offset argument must be
greater than or equal to 0, and less than or equal to the length of this string buffer.

Method Detail

457

Overview (Codename One API)


insert
public StringBuilder insert(int offset,
double d)

Inserts the string representation of the double argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuilder insert(int offset,
float f)

Inserts the string representation of the float argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuilder insert(int offset,
int i)

Inserts the string representation of the second int argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuilder insert(int offset,
long l)

Inserts the string representation of the long argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the position
indicated by offset. The offset argument must be greater than or equal to 0, and less
than or equal to the length of this string buffer.
insert
public StringBuilder insert(int offset,
Object obj)

Inserts the string representation of the Object argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuilder insert(int offset,
String str)

Inserts the string into this string buffer. The characters of the String argument are
inserted, in order, into this string buffer at the indicated offset, moving up any
characters originally above that position and increasing the length of this string buffer
by the length of the argument. If str is null, then the four characters "null" are inserted
into this string buffer. The character at index k in the new character sequence is
equal to: the character at index k in the old character sequence, if k is less than offset
the character at index k-offset in the argument str, if k is not less than offset but is
less than offset+str.length() the character at index k-str.length() in the old character
sequence, if k is not less than offset+str.length() The offset argument must be greater
than or equal to 0, and less than or equal to the length of this string buffer.

Method Detail

458

Overview (Codename One API)


length
public int length()

Returns the length (character count) of this string buffer.


reverse
public StringBuilder reverse()

The character sequence contained in this string buffer is replaced by the reverse of
the sequence. Let n be the length of the old character sequence, the one contained in
the string buffer just prior to execution of the reverse method. Then the character at
index k in the new character sequence is equal to the character at index n-k-1 in the
old character sequence.
setCharAt
public void setCharAt(int index,
char ch)

The character at the specified index of this string buffer is set to ch. The string buffer
is altered to represent a new character sequence that is identical to the old character
sequence, except that it contains the character ch at position index. The offset
argument must be greater than or equal to 0, and less than the length of this string
buffer.
setLength
public void setLength(int newLength)

Sets the length of this string buffer. This string buffer is altered to represent a new
character sequence whose length is specified by the argument. For every
nonnegative index less than newLength, the character at index in the new character
sequence is the same as the character at index in the old sequence if is less than the
length of the old character sequence; otherwise, it is the null character ''. In other
words, if the newLength argument is less than the current length of the string buffer,
the string buffer is truncated to contain exactly the number of characters given by the
newLength argument. If the newLength argument is greater than or equal to the
current length, sufficient null characters ('u0000') are appended to the string buffer so
that length becomes the newLength argument. The newLength argument must be
greater than or equal to 0.
toString
public String toString()

Converts to a string representing the data in this string buffer. A new String object is
allocated and initialized to contain the character sequence currently represented by
this string buffer. This String is then returned. Subsequent changes to the string
buffer do not affect the contents of the String. Implementation advice: This method
can be coded so as to create a new String object without allocating new memory to
hold a copy of the character sequence. Instead, the string can share the memory
used by the string buffer. Any subsequent operation that alters the content or
capacity of the string buffer must then make a copy of the internal buffer at that time.
This strategy is effective for reducing the amount of memory allocated by a string
concatenation operation when it is implemented using a string buffer.
Overrides:
toString in class Object
StringBuffer
public StringBuilder StringBuffer(CharSequence cs)

trimToSize
public void trimToSize()

append
public StringBuilder append(CharSequence cs)

Method Detail

459

Overview (Codename One API)


append
public StringBuilder append(CharSequence cs,
int start,
int end)

insert
public StringBuilder insert(int offset,
CharSequence cs)

insert
public StringBuilder insert(int offset,
CharSequence cs,
int start,
int end)

Method Detail

460

Overview (Codename One API)


java.lang

Class StringBuffer
java.lang.Object

java.lang.StringBuffer

public final class


extends Object

A string buffer implements a mutable sequence of characters. A string buffer is like a String, but can
be modified. At any point in time it contains some particular sequence of characters, but the length
and content of the sequence can be changed through certain method calls. String buffers are safe for
use by multiple threads. The methods are synchronized where necessary so that all the operations on
any particular instance behave as if they occur in some serial order that is consistent with the order of
the method calls made by each of the individual threads involved. String buffers are used by the
compiler to implement the binary string concatenation operator +. For example, the code: is compiled
to the equivalent of: The principal operations on a StringBuffer are the append and insert methods,
which are overloaded so as to accept data of any type. Each effectively converts a given datum to a
string and then appends or inserts the characters of that string to the string buffer. The append
method always adds these characters at the end of the buffer; the insert method adds the characters
at a specified point. For example, if z refers to a string buffer object whose current contents are
"start", then the method call z.append("le") would cause the string buffer to contain "startle", whereas
z.insert(4, "le") would alter the string buffer to contain "starlet". In general, if sb refers to an instance of
a StringBuffer, then sb.append(x) has the same effect as sb.insert(sb.length(),x). Every string buffer
has a capacity. As long as the length of the character sequence contained in the string buffer does
not exceed the capacity, it is not necessary to allocate a new internal buffer array. If the internal buffer
overflows, it is automatically made larger. Since: JDK1.0, CLDC 1.0 See
Also:ByteArrayOutputStream, String

Constructor Summary
Constructor and Description
StringBuffer()

Constructs a string buffer with no characters in it and an initial capacity of 16 characters.


StringBuffer(int length)

Constructs a string buffer with no characters in it and an initial capacity specified by the
length argument.
StringBuffer(String str)

Constructs a string buffer so that it represents the same sequence of characters as the string
argument; in other words, the initial contents of the string buffer is a copy of the argument
string.

Method Summary
Modifier and
Type

Method and Description


append(boolean b)

StringBuffer

StringBuffer

Appends the string representation of the boolean argument to the string


buffer.
append(char c)

Appends the string representation of the char argument to this string buffer.
append(char[] str, int offset, int len)

StringBuffer

Appends the string representation of a subarray of the char array argument


to this string buffer.

StringBuffer

append(CharSequence cs)

Class StringBuffer

461

Overview (Codename One API)


StringBuffer

append(CharSequence cs, int start, int end)


append(double d)

StringBuffer

StringBuffer
StringBuffer
StringBuffer

Appends the string representation of the double argument to this string


buffer.
append(float f)

Appends the string representation of the float argument to this string buffer.
append(int i)

Appends the string representation of the int argument to this string buffer.
append(long l)

Appends the string representation of the long argument to this string buffer.
append(Object obj)

StringBuffer

StringBuffer
int

Appends the string representation of the Object argument to this string


buffer.
append(String str)

Appends the string to this string buffer.


capacity()

Returns the current capacity of the String buffer.


charAt(int index)

char

StringBuffer

The specified character of the sequence currently represented by the string


buffer, as indicated by the index argument, is returned.
delete(int start, int end)

Removes the characters in a substring of this StringBuffer.


deleteCharAt(int index)

StringBuffer

Removes the character at the specified position in this StringBuffer


(shortening the StringBuffer by one character).
ensureCapacity(int minimumCapacity)

void

Ensures that the capacity of the buffer is at least equal to the specified
minimum.
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

void

Characters are copied from this string buffer into the destination character
array dst.
insert(int offset, boolean b)

StringBuffer

StringBuffer

Inserts the string representation of the boolean argument into this string
buffer.
insert(int offset, char c)

Inserts the string representation of the char argument into this string buffer.

StringBuffer

insert(int offset, CharSequence cs)

StringBuffer

insert(int offset, CharSequence cs, int start, int end)


insert(int offset, double d)

StringBuffer

StringBuffer

Inserts the string representation of the double argument into this string
buffer.
insert(int offset, float f)

Inserts the string representation of the float argument into this string buffer.
insert(int offset, int i)

StringBuffer

StringBuffer

Inserts the string representation of the second int argument into this string
buffer.
insert(int offset, long l)

Inserts the string representation of the long argument into this string buffer.
insert(int offset, Object obj)

StringBuffer

StringBuffer
int

Inserts the string representation of the Object argument into this string
buffer.
insert(int offset, String str)

Inserts the string into this string buffer.


length()

Returns the length (character count) of this string buffer.


reverse()

StringBuffer

Method Summary

The character sequence contained in this string buffer is replaced by the


reverse of the sequence.

462

Overview (Codename One API)


setCharAt(int index, char ch)

void

The character at the specified index of this string buffer is set to ch.
setLength(int newLength)

void

Sets the length of this string buffer.

StringBuffer

StringBuffer(CharSequence cs)
toString()

String

Converts to a string representing the data in this string buffer.

void

trimToSize()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
StringBuffer
public StringBuffer()

Constructs a string buffer with no characters in it and an initial capacity of 16


characters.
StringBuffer
public StringBuffer(int length)

Constructs a string buffer with no characters in it and an initial capacity specified by


the length argument. length - the initial capacity. - if the length argument is less than
0.
StringBuffer
public StringBuffer(String str)

Constructs a string buffer so that it represents the same sequence of characters as


the string argument; in other words, the initial contents of the string buffer is a copy of
the argument string. The initial capacity of the string buffer is 16 plus the length of the
string argument. str - the initial contents of the buffer.

Method Detail
append
public StringBuffer append(boolean b)

Appends the string representation of the boolean argument to the string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(char c)

Appends the string representation of the char argument to this string buffer. The
argument is appended to the contents of this string buffer. The length of this string
buffer increases by 1. The overall effect is exactly as if the argument were converted
to a string by the method String.valueOf(char) and the character in that string were
then appended to this StringBuffer object.
append
public StringBuffer append(char[] str,
int offset,
int len)

Methods inherited from class java.lang.Object

463

Overview (Codename One API)


Appends the string representation of a subarray of the char array argument to this
string buffer. Characters of the character array str, starting at index offset, are
appended, in order, to the contents of this string buffer. The length of this string buffer
increases by the value of len. The overall effect is exactly as if the arguments were
converted to a string by the method String.valueOf(char[],int,int) and the characters of
that string were then appended to this StringBuffer object.
append
public StringBuffer append(double d)

Appends the string representation of the double argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(float f)

Appends the string representation of the float argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(int i)

Appends the string representation of the int argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(long l)

Appends the string representation of the long argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(Object obj)

Appends the string representation of the Object argument to this string buffer. The
argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then appended to this string buffer.
append
public StringBuffer append(String str)

Appends the string to this string buffer. The characters of the String argument are
appended, in order, to the contents of this string buffer, increasing the length of this
string buffer by the length of the argument. If str is null, then the four characters "null"
are appended to this string buffer. Let n be the length of the old character sequence,
the one contained in the string buffer just prior to execution of the append method.
Then the character at index k in the new character sequence is equal to the character
at index k in the old character sequence, if k is less than n; otherwise, it is equal to
the character at index k-n in the argument str.
capacity
public int capacity()

Returns the current capacity of the String buffer. The capacity is the amount of
storage available for newly inserted characters; beyond which an allocation will occur.
charAt
public char charAt(int index)

The specified character of the sequence currently represented by the string buffer, as
indicated by the index argument, is returned. The first character of a string buffer is at
index 0, the next at index 1, and so on, for array indexing. The index argument must
be greater than or equal to 0, and less than the length of this string buffer.

Method Detail

464

Overview (Codename One API)


delete
public StringBuffer delete(int start,
int end)

Removes the characters in a substring of this StringBuffer. The substring begins at


the specified start and extends to the character at index end - 1 or to the end of the
StringBuffer if no such character exists. If start is equal to end, no changes are made.
deleteCharAt
public StringBuffer deleteCharAt(int index)

Removes the character at the specified position in this StringBuffer (shortening the
StringBuffer by one character).
ensureCapacity
public void ensureCapacity(int minimumCapacity)

Ensures that the capacity of the buffer is at least equal to the specified minimum. If
the current capacity of this string buffer is less than the argument, then a new internal
buffer is allocated with greater capacity. The new capacity is the larger of: The
minimumCapacity argument. Twice the old capacity, plus 2. If the minimumCapacity
argument is nonpositive, this method takes no action and simply returns.
getChars
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)

Characters are copied from this string buffer into the destination character array dst.
The first character to be copied is at index srcBegin; the last character to be copied is
at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin.
The characters are copied into the subarray of dst starting at index dstBegin and
ending at index: dstbegin + (srcEnd-srcBegin) - 1
insert
public StringBuffer insert(int offset,
boolean b)

Inserts the string representation of the boolean argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuffer insert(int offset,
char c)

Inserts the string representation of the char argument into this string buffer. The
second argument is inserted into the contents of this string buffer at the position
indicated by offset. The length of this string buffer increases by one. The overall
effect is exactly as if the argument were converted to a string by the method
String.valueOf(char) and the character in that string were then inserted into this
StringBuffer object at the position indicated by offset. The offset argument must be
greater than or equal to 0, and less than or equal to the length of this string buffer.
insert
public StringBuffer insert(int offset,
double d)

Inserts the string representation of the double argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.

Method Detail

465

Overview (Codename One API)


insert
public StringBuffer insert(int offset,
float f)

Inserts the string representation of the float argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuffer insert(int offset,
int i)

Inserts the string representation of the second int argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuffer insert(int offset,
long l)

Inserts the string representation of the long argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the position
indicated by offset. The offset argument must be greater than or equal to 0, and less
than or equal to the length of this string buffer.
insert
public StringBuffer insert(int offset,
Object obj)

Inserts the string representation of the Object argument into this string buffer. The
second argument is converted to a string as if by the method String.valueOf, and the
characters of that string are then inserted into this string buffer at the indicated offset.
The offset argument must be greater than or equal to 0, and less than or equal to the
length of this string buffer.
insert
public StringBuffer insert(int offset,
String str)

Inserts the string into this string buffer. The characters of the String argument are
inserted, in order, into this string buffer at the indicated offset, moving up any
characters originally above that position and increasing the length of this string buffer
by the length of the argument. If str is null, then the four characters "null" are inserted
into this string buffer. The character at index k in the new character sequence is
equal to: the character at index k in the old character sequence, if k is less than offset
the character at index k-offset in the argument str, if k is not less than offset but is
less than offset+str.length() the character at index k-str.length() in the old character
sequence, if k is not less than offset+str.length() The offset argument must be greater
than or equal to 0, and less than or equal to the length of this string buffer.
length
public int length()

Returns the length (character count) of this string buffer.


reverse
public StringBuffer reverse()

The character sequence contained in this string buffer is replaced by the reverse of
the sequence. Let n be the length of the old character sequence, the one contained in
the string buffer just prior to execution of the reverse method. Then the character at
index k in the new character sequence is equal to the character at index n-k-1 in the

Method Detail

466

Overview (Codename One API)


old character sequence.
setCharAt
public void setCharAt(int index,
char ch)

The character at the specified index of this string buffer is set to ch. The string buffer
is altered to represent a new character sequence that is identical to the old character
sequence, except that it contains the character ch at position index. The offset
argument must be greater than or equal to 0, and less than the length of this string
buffer.
setLength
public void setLength(int newLength)

Sets the length of this string buffer. This string buffer is altered to represent a new
character sequence whose length is specified by the argument. For every
nonnegative index less than newLength, the character at index in the new character
sequence is the same as the character at index in the old sequence if is less than the
length of the old character sequence; otherwise, it is the null character ''. In other
words, if the newLength argument is less than the current length of the string buffer,
the string buffer is truncated to contain exactly the number of characters given by the
newLength argument. If the newLength argument is greater than or equal to the
current length, sufficient null characters ('u0000') are appended to the string buffer so
that length becomes the newLength argument. The newLength argument must be
greater than or equal to 0.
toString
public String toString()

Converts to a string representing the data in this string buffer. A new String object is
allocated and initialized to contain the character sequence currently represented by
this string buffer. This String is then returned. Subsequent changes to the string
buffer do not affect the contents of the String. Implementation advice: This method
can be coded so as to create a new String object without allocating new memory to
hold a copy of the character sequence. Instead, the string can share the memory
used by the string buffer. Any subsequent operation that alters the content or
capacity of the string buffer must then make a copy of the internal buffer at that time.
This strategy is effective for reducing the amount of memory allocated by a string
concatenation operation when it is implemented using a string buffer.
Overrides:
toString in class Object
StringBuffer
public StringBuffer StringBuffer(CharSequence cs)

trimToSize
public void trimToSize()

append
public StringBuffer append(CharSequence cs)

append
public StringBuffer append(CharSequence cs,
int start,
int end)

insert
public StringBuffer insert(int offset,
CharSequence cs)

insert
public StringBuffer insert(int offset,
CharSequence cs,
int start,
int end)

Method Detail

467

Overview (Codename One API)


java.lang

Class String
java.lang.Object

java.lang.String

public final class


extends Object

The String class represents character strings. All string literals in Java programs, such as "abc", are
implemented as instances of this class. Strings are constant; their values cannot be changed after
they are created. String buffers support mutable strings. Because String objects are immutable they
can be shared. For example: is equivalent to: Here are some more examples of how strings can be
used: The class String includes methods for examining individual characters of the sequence, for
comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string
with all characters translated to uppercase or to lowercase. The Java language provides special
support for the string concatenation operator (+), and for conversion of other objects to strings. String
concatenation is implemented through the StringBuffer class and its append method. String
conversions are implemented through the method toString, defined by Object and inherited by all
classes in Java. For additional information on string concatenation and conversion, see Gosling, Joy,
and Steele, The Java Language Specification. Since: JDK1.0, CLDC 1.0 See Also:Object.toString(),
StringBuffer, StringBuffer.append(boolean), StringBuffer.append(char), StringBuffer.append(char[]),
StringBuffer.append(char[], int, int), StringBuffer.append(int), StringBuffer.append(long),
StringBuffer.append(java.lang.Object), StringBuffer.append(java.lang.String)

Constructor Summary
Constructor and Description
String()

Initializes a newly created String object so that it represents an empty character sequence.
String(byte[] bytes)

Construct a new String by converting the specified array of bytes using the platform's default
character encoding.
String(byte[] bytes, int off, int len)

Construct a new String by converting the specified subarray of bytes using the platform's
default character encoding.
String(byte[] bytes, int off, int len, String enc)

Construct a new String by converting the specified subarray of bytes using the specified
character encoding.
String(byte[] bytes, String enc)

Construct a new String by converting the specified array of bytes using the specified
character encoding.
String(char[] value)

Allocates a new String so that it represents the sequence of characters currently contained
in the character array argument.
String(char[] value, int offset, int count)

Allocates a new String that contains characters from a subarray of the character array
argument.
String(String value)

Initializes a newly created String object so that it represents the same sequence of
characters as the argument; in other words, the newly created string is a copy of the
argument string.
String(StringBuffer buffer)

Allocates a new string that contains the sequence of characters currently contained in the
string buffer argument.

Class String

468

Overview (Codename One API)

Method Summary
Modifier
and Type
char
int
String
boolean
boolean
boolean

Method and Description


charAt(int index)

Returns the character at the specified index.


compareTo(String anotherString)

Compares two strings lexicographically.


concat(String str)

Concatenates the specified string to the end of this string.


endsWith(String suffix)

Tests if this string ends with the specified suffix.


equals(Object anObject)

Compares this string to the specified object.


equalsIgnoreCase(String anotherString)

Compares this String to another String, ignoring case considerations.


getBytes()

byte[]

Convert this String into bytes according to the platform's default character
encoding, storing the result into a new byte array.
getBytes(String enc)

byte[]

void
int

Convert this String into bytes according to the specified character encoding,
storing the result into a new byte array.
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

Copies characters from this string into the destination character array.
hashCode()

Returns a hashcode for this string.


indexOf(int ch)

int

Returns the index within this string of the first occurrence of the specified
character.
indexOf(int ch, int fromIndex)

int

Returns the index within this string of the first occurrence of the specified
character, starting the search at the specified index.
indexOf(String str)

int

Returns the index within this string of the first occurrence of the specified
substring.
indexOf(String str, int fromIndex)

int

String

Returns the index within this string of the first occurrence of the specified
substring, starting at the specified index.
intern()

Returns a canonical representation for the string object.


lastIndexOf(int ch)

int

Returns the index within this string of the last occurrence of the specified
character.
lastIndexOf(int ch, int fromIndex)

int

int
int
int

boolean

Returns the index within this string of the last occurrence of the specified
character, searching backward starting at the specified index.
lastIndexOf(String string)

Searches in this string for the last index of the specified string.
lastIndexOf(String subString, int start)

Searches in this string for the index of the specified string.


length()

Returns the length of this string.


regionMatches(boolean ignoreCase, int toffset, String other,
int ooffset, int len)

Tests if two string regions are equal.


replace(char oldChar, char newChar)
String

Method Summary

Returns a new string resulting from replacing all occurrences of oldChar in this
string with newChar.

469

Overview (Codename One API)

boolean

startsWith(String prefix)

Tests if this string starts with the specified prefix.


startsWith(String prefix, int toffset)

boolean

String
String
char[]
String
String
String
String

Tests if this string starts with the specified prefix beginning at the specified
index.
substring(int beginIndex)

Returns a new string that is a substring of this string.


substring(int beginIndex, int endIndex)

Returns a new string that is a substring of this string.


toCharArray()

Converts this string to a new character array.


toLowerCase()

Converts all of the characters in this String to lower case.


toString()

This object (which is already a string!) is itself returned.


toUpperCase()

Converts all of the characters in this String to upper case.


trim()

Removes white space from both ends of this string.

static
String

valueOf(boolean b)

static
String

valueOf(char c)

static
String

Returns the string representation of the boolean argument.


Returns the string representation of the char argument.
valueOf(char[] data, int offset, int count)

Returns the string representation of a specific subarray of the char array


argument.

static
String

valueOf(double d)

static
String

valueOf(float f)

static
String

valueOf(int i)

static
String

valueOf(long l)

static
String

valueOf(Object obj)

Returns the string representation of the double argument.


Returns the string representation of the float argument.
Returns the string representation of the int argument.
Returns the string representation of the long argument.
Returns the string representation of the Object argument.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
String
public String()

Initializes a newly created String object so that it represents an empty character


sequence.
String
public String(byte[] bytes)

Construct a new String by converting the specified array of bytes using the platform's
default character encoding. The length of the new String is a function of the encoding,
and hence may not be equal to the length of the byte array. bytes - The bytes to be
converted into characters JDK1.1

Methods inherited from class java.lang.Object

470

Overview (Codename One API)


String
public String(byte[] bytes,
int off,
int len)

Construct a new String by converting the specified subarray of bytes using the
platform's default character encoding. The length of the new String is a function of the
encoding, and hence may not be equal to the length of the subarray. bytes - The
bytes to be converted into charactersoff - Index of the first byte to convertlen Number of bytes to convert JDK1.1
String
public String(byte[] bytes,
int off,
int len,
String enc)
throws UnsupportedEncodingException

Construct a new String by converting the specified subarray of bytes using the
specified character encoding. The length of the new String is a function of the
encoding, and hence may not be equal to the length of the subarray. bytes - The
bytes to be converted into charactersoff - Index of the first byte to convertlen Number of bytes to convertenc - The name of a character encoding - If the named
encoding is not supported JDK1.1
Throws:
UnsupportedEncodingException

String
public String(byte[] bytes,
String enc)
throws UnsupportedEncodingException

Construct a new String by converting the specified array of bytes using the specified
character encoding. The length of the new String is a function of the encoding, and
hence may not be equal to the length of the byte array. bytes - The bytes to be
converted into charactersenc - The name of a supported character encoding - If the
named encoding is not supported JDK1.1
Throws:
UnsupportedEncodingException

String
public String(char[] value)

Allocates a new String so that it represents the sequence of characters currently


contained in the character array argument. The contents of the character array are
copied; subsequent modification of the character array does not affect the newly
created string. value - the initial value of the string. - if value is null.
String
public String(char[] value,
int offset,
int count)

Allocates a new String that contains characters from a subarray of the character array
argument. The offset argument is the index of the first character of the subarray and
the count argument specifies the length of the subarray. The contents of the subarray
are copied; subsequent modification of the character array does not affect the newly
created string. value - array that is the source of characters.offset - the initial
offset.count - the length. - if the offset and count arguments index characters outside
the bounds of the value array. - if value is null.
String
public String(String value)

Initializes a newly created String object so that it represents the same sequence of
characters as the argument; in other words, the newly created string is a copy of the
argument string. value - a String.

Constructor Detail

471

Overview (Codename One API)


String
public String(StringBuffer buffer)

Allocates a new string that contains the sequence of characters currently contained in
the string buffer argument. The contents of the string buffer are copied; subsequent
modification of the string buffer does not affect the newly created string. buffer - a
StringBuffer. - If buffer is null.

Method Detail
charAt
public char charAt(int index)

Returns the character at the specified index. An index ranges from 0 to length() - 1.
The first character of the sequence is at index 0, the next at index 1, and so on, as for
array indexing.
compareTo
public int compareTo(String anotherString)

Compares two strings lexicographically. The comparison is based on the Unicode


value of each character in the strings. The character sequence represented by this
String object is compared lexicographically to the character sequence represented by
the argument string. The result is a negative integer if this String object
lexicographically precedes the argument string. The result is a positive integer if this
String object lexicographically follows the argument string. The result is zero if the
strings are equal; compareTo returns 0 exactly when the method would return true.
This is the definition of lexicographic ordering. If two strings are different, then either
they have different characters at some index that is a valid index for both strings, or
their lengths are different, or both. If they have different characters at one or more
index positions, let k be the smallest such index; then the string whose character at
position k has the smaller value, as determined by using the < operator,
lexicographically precedes the other string. In this case, compareTo returns the
difference of the two character values at position k in the two string -- that is, the
value: this.charAt(k)-anotherString.charAt(k) If there is no index position at which they
differ, then the shorter string lexicographically precedes the longer string. In this case,
compareTo returns the difference of the lengths of the strings -- that is, the value:
this.length()-anotherString.length()
concat
public String concat(String str)

Concatenates the specified string to the end of this string. If the length of the
argument string is 0, then this String object is returned. Otherwise, a new String
object is created, representing a character sequence that is the concatenation of the
character sequence represented by this String object and the character sequence
represented by the argument string. Examples: "cares".concat("s") returns "caress"
"to".concat("get").concat("her") returns "together"
endsWith
public boolean endsWith(String suffix)

Tests if this string ends with the specified suffix.


equals
public boolean equals(Object anObject)

Compares this string to the specified object. The result is true if and only if the
argument is not null and is a String object that represents the same sequence of
characters as this object.
Overrides:
equals in class Object

Constructor Detail

472

Overview (Codename One API)


equalsIgnoreCase
public boolean equalsIgnoreCase(String anotherString)

Compares this String to another String, ignoring case considerations. Two strings are
considered equal ignoring case if they are of the same length, and corresponding
characters in the two strings are equal ignoring case. Two characters c1 and c2 are
considered the same, ignoring case if at least one of the following is true: The two
characters are the same (as compared by the == operator). Applying the method
Character.toUpperCase(char) to each character produces the same result. Applying
the method Character.toLowerCase(char) to each character produces the same
result.
getBytes
public byte[] getBytes()

Convert this String into bytes according to the platform's default character encoding,
storing the result into a new byte array.
getBytes
public byte[] getBytes(String enc)
throws UnsupportedEncodingException

Convert this String into bytes according to the specified character encoding, storing
the result into a new byte array.
Throws:
UnsupportedEncodingException

getChars
public void getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)

Copies characters from this string into the destination character array. The first
character to be copied is at index srcBegin; the last character to be copied is at index
srcEnd-1 (thus the total number of characters to be copied is srcEnd-srcBegin). The
characters are copied into the subarray of dst starting at index dstBegin and ending
at index: dstbegin + (srcEnd-srcBegin) - 1
hashCode
public int hashCode()

Returns a hashcode for this string. The hashcode for a String object is computed as
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] using int arithmetic, where s[i] is the th
character of the string, n is the length of the string, and ^ indicates exponentiation.
(The hash value of the empty string is zero.)
Overrides:
hashCode in class Object
indexOf
public int indexOf(int ch)

Returns the index within this string of the first occurrence of the specified character. If
a character with value ch occurs in the character sequence represented by this String
object, then the index of the first such occurrence is returned -- that is, the smallest
value such that: this.charAt( ) == ch is true. If no such character occurs in this string,
then -1 is returned.
indexOf
public int indexOf(int ch,
int fromIndex)

Returns the index within this string of the first occurrence of the specified character,
starting the search at the specified index. If a character with value ch occurs in the
character sequence represented by this String object at an index no smaller than
fromIndex, then the index of the first such occurrence is returned--that is, the smallest
value k such that: (this.charAt( ) == ch) && ( >= fromIndex) is true. If no such

Method Detail

473

Overview (Codename One API)


character occurs in this string at or after position fromIndex, then -1 is returned. There
is no restriction on the value of fromIndex. If it is negative, it has the same effect as if
it were zero: this entire string may be searched. If it is greater than the length of this
string, it has the same effect as if it were equal to the length of this string: -1 is
returned.
indexOf
public int indexOf(String str)

Returns the index within this string of the first occurrence of the specified substring.
The integer returned is the smallest value such that: this.startsWith(str, ) is true.
indexOf
public int indexOf(String str,
int fromIndex)

Returns the index within this string of the first occurrence of the specified substring,
starting at the specified index. The integer returned is the smallest value such that:
this.startsWith(str, ) && ( >= fromIndex) is true. There is no restriction on the value of
fromIndex. If it is negative, it has the same effect as if it were zero: this entire string
may be searched. If it is greater than the length of this string, it has the same effect
as if it were equal to the length of this string: -1 is returned.
intern
public String intern()

Returns a canonical representation for the string object. A pool of strings, initially
empty, is maintained privately by the class String. When the intern method is invoked,
if the pool already contains a string equal to this String object as determined by the
equals(Object) method, then the string from the pool is returned. Otherwise, this
String object is added to the pool and a reference to this String object is returned. It
follows that for any two strings s and t, s.intern()==t.intern() is true if and only if
s.equals(t) is true. All literal strings and string-valued constant expressions are
interned. String literals are defined in Section 3.10.5 of the Java Language
Specification
lastIndexOf
public int lastIndexOf(int ch)

Returns the index within this string of the last occurrence of the specified character.
That is, the index returned is the largest value such that: this.charAt( ) == ch is true.
The String is searched backwards starting at the last character.
lastIndexOf
public int lastIndexOf(int ch,
int fromIndex)

Returns the index within this string of the last occurrence of the specified character,
searching backward starting at the specified index. That is, the index returned is the
largest value such that: (this.charAt(k) == ch) && (k <= fromIndex) is true.
lastIndexOf
public int lastIndexOf(String string)

Searches in this string for the last index of the specified string. The search for the
string starts at the end and moves towards the beginning of this string.
Parameters:
string - the string to find.
Returns:
the index of the first character of the specified string in this string, -1 if the
specified string is not a substring.
Throws:
NullPointerException - if string is null.

Method Detail

474

Overview (Codename One API)


lastIndexOf
public int lastIndexOf(String subString,
int start)

Searches in this string for the index of the specified string. The search for the string
starts at the specified offset and moves towards the beginning of this string.
Parameters:
subString - the string to find.
start - the starting offset.
Returns:
the index of the first character of the specified string in this string , -1 if the
specified string is not a substring.
Throws:
NullPointerException - if subString is null.
length
public int length()

Returns the length of this string. The length is equal to the number of 16-bit Unicode
characters in the string.
regionMatches
public boolean regionMatches(boolean ignoreCase,
int toffset,
String other,
int ooffset,
int len)

Tests if two string regions are equal. A substring of this String object is compared to a
substring of the argument other. The result is true if these substrings represent
character sequences that are the same, ignoring case if and only if ignoreCase is
true. The substring of this String object to be compared begins at index toffset and
has length len. The substring of other to be compared begins at index ooffset and has
length len. The result is false if and only if at least one of the following is true: toffset
is negative. ooffset is negative. toffset+len is greater than the length of this String
object. ooffset+len is greater than the length of the other argument. There is some
nonnegative integer k less than len such that: this.charAt(toffset+k) !=
other.charAt(ooffset+k) ignoreCase is true and there is some nonnegative integer
less than len such that: Character.toLowerCase(this.charAt(toffset+k)) !=
Character.toLowerCase(other.charAt(ooffset+k)) and:
Character.toUpperCase(this.charAt(toffset+k)) !=
Character.toUpperCase(other.charAt(ooffset+k))
replace
public String replace(char oldChar,
char newChar)

Returns a new string resulting from replacing all occurrences of oldChar in this string
with newChar. If the character oldChar does not occur in the character sequence
represented by this String object, then a reference to this String object is returned.
Otherwise, a new String object is created that represents a character sequence
identical to the character sequence represented by this String object, except that
every occurrence of oldChar is replaced by an occurrence of newChar. Examples:
"mesquite in your cellar".replace('e', 'o') returns "mosquito in your collar" "the war of
baronets".replace('r', 'y') returns "the way of bayonets" "sparring with a purple
porpoise".replace('p', 't') returns "starring with a turtle tortoise" "JonL".replace('q', 'x')
returns "JonL" (no change)
startsWith
public boolean startsWith(String prefix)

Tests if this string starts with the specified prefix.

Method Detail

475

Overview (Codename One API)


startsWith
public boolean startsWith(String prefix,
int toffset)

Tests if this string starts with the specified prefix beginning at the specified index.
substring
public String substring(int beginIndex)

Returns a new string that is a substring of this string. The substring begins with the
character at the specified index and extends to the end of this string. Examples:
"unhappy".substring(2) returns "happy" "Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)
substring
public String substring(int beginIndex,
int endIndex)

Returns a new string that is a substring of this string. The substring begins at the
specified beginIndex and extends to the character at index endIndex - 1. Thus the
length of the substring is endIndex-beginIndex. Examples: "hamburger".substring(4,
8) returns "urge" "smiles".substring(1, 5) returns "mile"
toCharArray
public char[] toCharArray()

Converts this string to a new character array.


toLowerCase
public String toLowerCase()

Converts all of the characters in this String to lower case.


toString
public String toString()

This object (which is already a string!) is itself returned.


Overrides:
toString in class Object
toUpperCase
public String toUpperCase()

Converts all of the characters in this String to upper case.


trim
public String trim()

Removes white space from both ends of this string. If this String object represents an
empty character sequence, or the first and last characters of character sequence
represented by this String object both have codes greater than 'u0020' (the space
character), then a reference to this String object is returned. Otherwise, if there is no
character with a code greater than 'u0020' in the string, then a new String object
representing an empty string is created and returned. Otherwise, let k be the index of
the first character in the string whose code is greater than 'u0020', and let m be the
index of the last character in the string whose code is greater than 'u0020'. A new
String object is created, representing the substring of this string that begins with the
character at index k and ends with the character at index m-that is, the result of
this.substring(k,m+1). This method may be used to trim whitespace from the
beginning and end of a string; in fact, it trims all ASCII control characters as well.
valueOf
public static String valueOf(boolean b)

Returns the string representation of the boolean argument.

Method Detail

476

Overview (Codename One API)


valueOf
public static String valueOf(char c)

Returns the string representation of the char argument.


valueOf
public static String valueOf(char[] data,
int offset,
int count)

Returns the string representation of a specific subarray of the char array argument.
The offset argument is the index of the first character of the subarray. The count
argument specifies the length of the subarray. The contents of the subarray are
copied; subsequent modification of the character array does not affect the newly
created string.
valueOf
public static String valueOf(double d)

Returns the string representation of the double argument. The representation is


exactly the one returned by the Double.toString method of one argument.
valueOf
public static String valueOf(float f)

Returns the string representation of the float argument. The representation is exactly
the one returned by the Float.toString method of one argument.
valueOf
public static String valueOf(int i)

Returns the string representation of the int argument. The representation is exactly
the one returned by the Integer.toString method of one argument.
valueOf
public static String valueOf(long l)

Returns the string representation of the long argument. The representation is exactly
the one returned by the Long.toString method of one argument.
valueOf
public static String valueOf(Object obj)

Returns the string representation of the Object argument.

Method Detail

477

Overview (Codename One API)


java.lang

Class Short
java.lang.Object

java.lang.Short

public final class


extends Object

The Short class is the standard wrapper for short values. Since: JDK1.1, CLDC 1.0

Field Summary
Modifier and Type

Field and Description


MAX_VALUE

static short

The maximum value a Short can have.


MIN_VALUE

static short

The minimum value a Short can have.

Constructor Summary
Constructor and Description
Short(short value)

Constructs a Short object initialized to the specified short value.

Method Summary
Modifier and
Type
boolean

Method and Description


equals(Object obj)

Compares this object to the specified object.


hashCode()

int

Returns a hashcode for this Short.

static short

parseShort(String s)

Assuming the specified String represents a short, returns that short's value.
parseShort(String s, int radix)

static short

Assuming the specified String represents a short, returns that short's value in
the radix specified by the second argument.
shortValue()

short

Returns the value of this Short as a short.


toString()

String

Returns a String object representing this Short's value.

static Short

valueOf(short i)

Returns the object instance of i

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail

Class Short

478

Overview (Codename One API)


MAX_VALUE
public static final short MAX_VALUE

The maximum value a Short can have. See Also:Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final short MIN_VALUE

The minimum value a Short can have. See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Short
public Short(short value)

Constructs a Short object initialized to the specified short value. value - the initial
value of the Short

Method Detail
equals
public boolean equals(Object obj)

Compares this object to the specified object.


Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hashcode for this Short.


Overrides:
hashCode in class Object
parseShort
public static short parseShort(String s)
throws NumberFormatException

Assuming the specified String represents a short, returns that short's value. Throws
an exception if the String cannot be parsed as a short. The radix is assumed to be
10.
Throws:
NumberFormatException

parseShort
public static short parseShort(String s,
int radix)
throws NumberFormatException

Assuming the specified String represents a short, returns that short's value in the
radix specified by the second argument. Throws an exception if the String cannot be
parsed as a short.
Throws:
NumberFormatException

Field Detail

479

Overview (Codename One API)


shortValue
public short shortValue()

Returns the value of this Short as a short.


toString
public String toString()

Returns a String object representing this Short's value.


Overrides:
toString in class Object
valueOf
public static Short valueOf(short i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance

Method Detail

480

Overview (Codename One API)


java.lang

Class SecurityException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.SecurityException

public class
extends RuntimeException

Thrown by the system to indicate a security violation. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
SecurityException()

Constructs a SecurityException with no detail message.


SecurityException(String s)

Constructs a SecurityException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
SecurityException
public SecurityException()

Constructs a SecurityException with no detail message.


SecurityException
public SecurityException(String s)

Constructs a SecurityException with the specified detail message. s - the detail


message.

Class SecurityException

481

Overview (Codename One API)


java.lang

Class RuntimeException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException
Direct Known Subclasses:
ArithmeticException, ArrayStoreException, ClassCastException,
ConcurrentModificationException, EmptyStackException, IllegalArgumentException,
IllegalMonitorStateException, IllegalStateException, IncompleteAnnotationException,
IndexOutOfBoundsException, NegativeArraySizeException, NoSuchElementException,
NullPointerException, RESyntaxException, SecurityException

public class
extends Exception

RuntimeException is the superclass of those exceptions that can be thrown during the normal
operation of the Java Virtual Machine. A method is not required to declare in its throws clause any
subclasses of RuntimeException that might be thrown during the execution of the method but not
caught. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
RuntimeException()

Constructs a RuntimeException with no detail message.


RuntimeException(String s)

Constructs a RuntimeException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
RuntimeException
public RuntimeException()

Constructs a RuntimeException with no detail message.


RuntimeException
public RuntimeException(String s)

Constructs a RuntimeException with the specified detail message. s - the detail


message.

Constructor Detail

482

Overview (Codename One API)


java.lang

Class Runtime
java.lang.Object

java.lang.Runtime

public class
extends Object

Every Java application has a single instance of class Runtime that allows the application to interface
with the environment in which the application is running. The current runtime can be obtained from the
getRuntime method. An application cannot create its own instance of this class. Since: JDK1.0, CLDC
1.0 See Also:getRuntime()

Constructor Summary
Constructor and Description
Runtime()

Method Summary
Modifier and Type

Method and Description


exit(int status)

void

Terminates the currently running Java application.


freeMemory()

long

Returns the amount of free memory in the system.


gc()

void

Runs the garbage collector.

static Runtime

getRuntime()

Returns the runtime object associated with the current Java application.
totalMemory()

long

Returns the total amount of memory in the Java Virtual Machine.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Runtime
public Runtime()

Method Detail
exit
public void exit(int status)

Terminates the currently running Java application. This method never returns
normally. The argument serves as a status code; by convention, a nonzero status
code indicates abnormal termination.

Constructor Detail

483

Overview (Codename One API)


freeMemory
public long freeMemory()

Returns the amount of free memory in the system. Calling the gc method may result
in increasing the value returned by freeMemory.
gc
public void gc()

Runs the garbage collector. Calling this method suggests that the Java Virtual
Machine expend effort toward recycling unused objects in order to make the memory
they currently occupy available for quick reuse. When control returns from the
method call, the Java Virtual Machine has made its best effort to recycle all discarded
objects. The name gc stands for "garbage collector". The Java Virtual Machine
performs this recycling process automatically as needed even if the gc method is not
invoked explicitly. The method System.gc() is the conventional and convenient
means of invoking this method.
getRuntime
public static Runtime getRuntime()

Returns the runtime object associated with the current Java application. Most of the
methods of class Runtime are instance methods and must be invoked with respect to
the current runtime object.
totalMemory
public long totalMemory()

Returns the total amount of memory in the Java Virtual Machine. The value returned
by this method may vary over time, depending on the host environment. Note that the
amount of memory required to hold an object of any given type may be
implementation-dependent.

Method Detail

484

Overview (Codename One API)


java.lang

Interface Runnable
All Known Implementing Classes:
Thread, TimerTask

public interface

The Runnable interface should be implemented by any class whose instances are intended to be
executed by a thread. The class must define a method of no arguments called run. This interface is
designed to provide a common protocol for objects that wish to execute code while they are active.
For example, Runnable is implemented by class Thread. Being active simply means that a thread has
been started and has not yet been stopped. In addition, Runnable provides the means for a class to
be active while not subclassing Thread. A class that implements Runnable can run without
subclassing Thread by instantiating a Thread instance and passing itself in as the target. In most
cases, the Runnable interface should be used if you are only planning to override the run() method
and no other Thread methods. This is important because classes should not be subclassed unless
the programmer intends on modifying or enhancing the fundamental behavior of the class. Since:
JDK1.0, CLDC 1.0 See Also:Thread

Method Summary
Modifier
and Type

Method and Description


run()

When an object implementing interface Runnable is used to create a thread,


starting the thread causes the object's run method to be called in that
separately executing thread.

void

Method Detail
run
void run()

When an object implementing interface Runnable is used to create a thread, starting


the thread causes the object's run method to be called in that separately executing
thread. The general contract of the method run is that it may take any action
whatsoever.

Interface Runnable

485

Overview (Codename One API)


java.lang

Annotation Type Override

@Target(value=METHOD)
@Retention(value=SOURCE)
public @interface

An annotation to indicate that a method is intended to override a superclass method. This provides a
compile-time assertion that a method actually overrides the superclass method.
Since:
1.5

Method Detail

486

Overview (Codename One API)


java.lang

Class OutOfMemoryError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.VirtualMachineError

java.lang.OutOfMemoryError

public class
extends VirtualMachineError

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no
more memory could be made available by the garbage collector. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
OutOfMemoryError()

Constructs an OutOfMemoryError with no detail message.


OutOfMemoryError(String s)

Constructs an OutOfMemoryError with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
OutOfMemoryError
public OutOfMemoryError()

Constructs an OutOfMemoryError with no detail message.


OutOfMemoryError
public OutOfMemoryError(String s)

Constructs an OutOfMemoryError with the specified detail message. s - the detail


message.

Annotation Type Override

487

Overview (Codename One API)


java.lang

Class Object
java.lang.Object

public class

Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects,
including arrays, implement the methods of this class. Since: JDK1.0, CLDC 1.0 See Also:Class

Constructor Summary
Constructor and Description
Object()

Method Summary
Modifier
and Type
boolean

Method and Description


equals(Object obj)

Indicates whether some other object is "equal to" this one.


getClass()

Class

Returns the runtime class of an object.


hashCode()

int

Returns a hash code value for the object.


notify()

void

Wakes up a single thread that is waiting on this object's monitor.


notifyAll()

void

Wakes up all threads that are waiting on this object's monitor.

String

toString()

Returns a string representation of the object.


wait()

void

Causes current thread to wait until another thread invokes the method or the
method for this object.
wait(long timeout)

void

Causes current thread to wait until either another thread invokes the method or
the method for this object, or a specified amount of time has elapsed.
wait(long timeout, int nanos)

void

Causes current thread to wait until another thread invokes the method or the
method for this object, or some other thread interrupts the current thread, or a
certain amount of real time has elapsed.

Constructor Detail
Object
public Object()

Method Detail

Constructor Detail

488

Overview (Codename One API)


equals
public boolean equals(Object obj)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
getClass
public final Class getClass()

Returns the runtime class of an object. That Class object is the object that is locked
by static synchronized methods of the represented class.
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
notify
public final void notify()

Wakes up a single thread that is waiting on this object's monitor. If any threads are
waiting on this object, one of them is chosen to be awakened. The choice is arbitrary
and occurs at the discretion of the implementation. A thread waits on an object's
monitor by calling one of the wait methods. The awakened thread will not be able to
proceed until the current thread relinquishes the lock on this object. The awakened
thread will compete in the usual manner with any other threads that might be actively
competing to synchronize on this object; for example, the awakened thread enjoys no
reliable privilege or disadvantage in being the next thread to lock this object. This
method should only be called by a thread that is the owner of this object's monitor. A
thread becomes the owner of the object's monitor in one of three ways: By executing
a synchronized instance method of that object. By executing the body of a
synchronized statement that synchronizes on the object. For objects of type Class, by
executing a synchronized static method of that class. Only one thread at a time can
own an object's monitor.
notifyAll
public final void notifyAll()

Method Detail

489

Overview (Codename One API)


Wakes up all threads that are waiting on this object's monitor. A thread waits on an
object's monitor by calling one of the wait methods. The awakened threads will not be
able to proceed until the current thread relinquishes the lock on this object. The
awakened threads will compete in the usual manner with any other threads that might
be actively competing to synchronize on this object; for example, the awakened
threads enjoy no reliable privilege or disadvantage in being the next thread to lock
this object. This method should only be called by a thread that is the owner of this
object's monitor. See the notify method for a description of the ways in which a thread
can become the owner of a monitor.
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
wait
public final void wait()
throws InterruptedException

Causes current thread to wait until another thread invokes the method or the method
for this object. In other word's this method behaves exactly as if it simply performs the
call wait(0). The current thread must own this object's monitor. The thread releases
ownership of this monitor and waits until another thread notifies threads waiting on
this object's monitor to wake up either through a call to the notify method or the
notifyAll method. The thread then waits until it can re-obtain ownership of the monitor
and resumes execution. This method should only be called by a thread that is the
owner of this object's monitor. See the notify method for a description of the ways in
which a thread can become the owner of a monitor.
Throws:
InterruptedException

wait
public final void wait(long timeout)
throws InterruptedException

Causes current thread to wait until either another thread invokes the method or the
method for this object, or a specified amount of time has elapsed. The current thread
must own this object's monitor. This method causes the current thread (call it T) to
place itself in the wait set for this object and then to relinquish any and all
synchronization claims on this object. Thread T becomes disabled for thread
scheduling purposes and lies dormant until one of four things happens: Some other
thread invokes the notify method for this object and thread T happens to be arbitrarily
chosen as the thread to be awakened. Some other thread invokes the notifyAll
method for this object. Some other thread interrupts thread T. The specified amount
of real time has elapsed, more or less. If timeout is zero, however, then real time is
not taken into consideration and the thread simply waits until notified. The thread T is
then removed from the wait set for this object and re-enabled for thread scheduling. It
then competes in the usual manner with other threads for the right to synchronize on
the object; once it has gained control of the object, all its synchronization claims on
the object are restored to the status quo ante - that is, to the situation as of the time
that the wait method was invoked. Thread T then returns from the invocation of the
wait method. Thus, on return from the wait method, the synchronization state of the
object and of thread T is exactly as it was when the wait method was invoked. If the
current thread is interrupted by another thread while it is waiting, then an
InterruptedException is thrown. This exception is not thrown until the lock status of
this object has been restored as described above. Note that the wait method, as it
places the current thread into the wait set for this object, unlocks only this object; any
other objects on which the current thread may be synchronized remain locked while
the thread waits. This method should only be called by a thread that is the owner of

Method Detail

490

Overview (Codename One API)


this object's monitor. See the notify method for a description of the ways in which a
thread can become the owner of a monitor.
Throws:
InterruptedException

wait
public final void wait(long timeout,
int nanos)
throws InterruptedException

Causes current thread to wait until another thread invokes the method or the method
for this object, or some other thread interrupts the current thread, or a certain amount
of real time has elapsed. This method is similar to the wait method of one argument,
but it allows finer control over the amount of time to wait for a notification before
giving up. The amount of real time, measured in nanoseconds, is given by:
1000000*timeout+nanos In all other respects, this method does the same thing as the
method wait(long) of one argument. In particular, wait(0, 0) means the same thing as
wait(0). The current thread must own this object's monitor. The thread releases
ownership of this monitor and waits until either of the following two conditions has
occurred: Another thread notifies threads waiting on this object's monitor to wake up
either through a call to the notify method or the notifyAll method. The timeout period,
specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes
execution This method should only be called by a thread that is the owner of this
object's monitor. See the notify method for a description of the ways in which a thread
can become the owner of a monitor.
Throws:
InterruptedException

Method Detail

491

Overview (Codename One API)


java.lang

Class NumberFormatException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IllegalArgumentException

java.lang.NumberFormatException

public class
extends IllegalArgumentException

Thrown to indicate that the application has attempted to convert a string to one of the numeric types,
but that the string does not have the appropriate format. Since: JDK1.0, CLDC 1.0 See
Also:Integer.toString()

Constructor Summary
Constructor and Description
NumberFormatException()

Constructs a NumberFormatException with no detail message.


NumberFormatException(String s)

Constructs a NumberFormatException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NumberFormatException
public NumberFormatException()

Constructs a NumberFormatException with no detail message.


NumberFormatException
public NumberFormatException(String s)

Constructs a NumberFormatException with the specified detail message. s - the


detail message.

Class NumberFormatException

492

Overview (Codename One API)


java.lang

Class NullPointerException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.NullPointerException

public class
extends RuntimeException

Thrown when an application attempts to use null in a case where an object is required. These include:
Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking
the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array.
Throwing null as if it were a Throwable value. Applications should throw instances of this class to
indicate other illegal uses of the null object. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
NullPointerException()

Constructs a NullPointerException with no detail message.


NullPointerException(String s)

Constructs a NullPointerException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NullPointerException
public NullPointerException()

Constructs a NullPointerException with no detail message.


NullPointerException
public NullPointerException(String s)

Constructs a NullPointerException with the specified detail message. s - the detail


message.

Constructor Detail

493

Overview (Codename One API)


java.lang

Class NoSuchFieldError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.LinkageError

java.lang.IncompatibleClassChangeError

java.lang.NoSuchFieldError

public class
extends IncompatibleClassChangeError

Thrown when the virtual machine notices that a program tries to reference, on a class or object, a field
that does not exist.
Note that this can only occur when inconsistent class files are being loaded.

Constructor Summary
Constructor and Description
NoSuchFieldError()
Constructs a new NoSuchFieldError

that includes the current stack trace.

NoSuchFieldError(String detailMessage)
Constructs a new NoSuchFieldError with the

current stack trace and the specified detail

message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NoSuchFieldError
public NoSuchFieldError()

Constructs a new NoSuchFieldError that includes the current stack trace.


NoSuchFieldError
public NoSuchFieldError(String detailMessage)

Constructs a new NoSuchFieldError with the current stack trace and the specified
detail message.
Parameters:
detailMessage - the detail message for this error.

Constructor Detail

494

Overview (Codename One API)


java.lang

Class NoClassDefFoundError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.NoClassDefFoundError

public class
extends Error

Thrown if the Java Virtual Machine tries to load in the definition of a class (as part of a normal method
call or as part of creating a new instance using the new expression) and no definition of the class
could be found. The searched-for class definition existed when the currently executing class was
compiled, but the definition can no longer be found. Since: JDK1.0, CLDC 1.1

Constructor Summary
Constructor and Description
NoClassDefFoundError()

Constructs a NoClassDefFoundError with no detail message.


NoClassDefFoundError(String s)

Constructs a NoClassDefFoundError with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NoClassDefFoundError
public NoClassDefFoundError()

Constructs a NoClassDefFoundError with no detail message.


NoClassDefFoundError
public NoClassDefFoundError(String s)

Constructs a NoClassDefFoundError with the specified detail message. s - the detail


message.

Constructor Detail

495

Overview (Codename One API)


java.lang

Class NegativeArraySizeException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.NegativeArraySizeException

public class
extends RuntimeException

Thrown if an application tries to create an array with negative size. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
NegativeArraySizeException()

Constructs a NegativeArraySizeException with no detail message.


NegativeArraySizeException(String s)

Constructs a NegativeArraySizeException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NegativeArraySizeException
public NegativeArraySizeException()

Constructs a NegativeArraySizeException with no detail message.


NegativeArraySizeException
public NegativeArraySizeException(String s)

Constructs a NegativeArraySizeException with the specified detail message. s - the


detail message.

Constructor Detail

496

Overview (Codename One API)


java.lang

Class Math
java.lang.Object

java.lang.Math

public final class


extends Object

The class Math contains methods for performing basic numeric operations. Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and
Type

Field and Description


E

static double

The double value that is closer than any other to e, the base of the natural
logarithms.
PI

static double

The double value that is closer than any other to , the ratio of the
circumference of a circle to its diameter.

Constructor Summary
Constructor and Description
Math()

Method Summary
Modifier and
Type
static
double
static float
static int
static long
static
double
static
double
static
double
static
double
static float
static int

Constructor Detail

Method and Description


abs(double a)

Returns the absolute value of a double value.


abs(float a)

Returns the absolute value of a float value.


abs(int a)

Returns the absolute value of an int value.


abs(long a)

Returns the absolute value of a long value.


ceil(double a)

Returns the smallest (closest to negative infinity) double value that is not less
than the argument and is equal to a mathematical integer.
cos(double a)

Returns the trigonometric cosine of an angle.


floor(double a)

Returns the largest (closest to positive infinity) double value that is not greater
than the argument and is equal to a mathematical integer.
max(double a, double b)

Returns the greater of two double values.


max(float a, float b)

Returns the greater of two float values.


max(int a, int b)

Returns the greater of two int values.

497

Overview (Codename One API)


static long

max(long a, long b)

Returns the greater of two long values.


min(double a, double b)

static
double

Returns the smaller of two double values.

static float
static int
static long
static long
static int

min(float a, float b)

Returns the smaller of two float values.


min(int a, int b)

Returns the smaller of two int values.


min(long a, long b)

Returns the smaller of two long values.


round(double d)

Returns the result of rounding the argument to an integer.


round(float f)

Returns the result of rounding the argument to an integer.

static
double

sin(double a)

static
double

sqrt(double a)

static
double

tan(double a)

Returns the trigonometric sine of an angle.


Returns the correctly rounded positive square root of a double value.
Returns the trigonometric tangent of an angle.
toDegrees(double angrad)

static
double

Converts an angle measured in radians to the equivalent angle measured in


degrees.
toRadians(double angdeg)

static
double

Converts an angle measured in degrees to the equivalent angle measured in


radians.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
E
public static final double E

The double value that is closer than any other to e, the base of the natural logarithms.
Since: CLDC 1.1 See Also:Constant Field Values
See Also:
Constant Field Values
PI
public static final double PI

The double value that is closer than any other to , the ratio of the circumference of a
circle to its diameter. Since: CLDC 1.1 See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Math
public Math()

Method Summary

498

Overview (Codename One API)

Method Detail
abs
public static double abs(double a)

Returns the absolute value of a double value. If the argument is not negative, the
argument is returned. If the argument is negative, the negation of the argument is
returned. Special cases: If the argument is positive zero or negative zero, the result is
positive zero. If the argument is infinite, the result is positive infinity. If the argument is
NaN, the result is NaN. In other words, the result is equal to the value of the
expression: Double.longBitsToDouble((Double.doubleToLongBits(a)<>>1)
abs
public static float abs(float a)

Returns the absolute value of a float value. If the argument is not negative, the
argument is returned. If the argument is negative, the negation of the argument is
returned. Special cases: If the argument is positive zero or negative zero, the result is
positive zero. If the argument is infinite, the result is positive infinity. If the argument is
NaN, the result is NaN. In other words, the result is equal to the value of the
expression: Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))
abs
public static int abs(int a)

Returns the absolute value of an int value. If the argument is not negative, the
argument is returned. If the argument is negative, the negation of the argument is
returned. Note that if the argument is equal to the value of Integer.MIN_VALUE, the
most negative representable int value, the result is that same value, which is
negative.
abs
public static long abs(long a)

Returns the absolute value of a long value. If the argument is not negative, the
argument is returned. If the argument is negative, the negation of the argument is
returned. Note that if the argument is equal to the value of Long.MIN_VALUE, the
most negative representable long value, the result is that same value, which is
negative.
ceil
public static double ceil(double a)

Returns the smallest (closest to negative infinity) double value that is not less than
the argument and is equal to a mathematical integer. Special cases: If the argument
value is already equal to a mathematical integer, then the result is the same as the
argument. If the argument is NaN or an infinity or positive zero or negative zero, then
the result is the same as the argument. If the argument value is less than zero but
greater than -1.0, then the result is negative zero. Note that the value of Math.ceil(x)
is exactly the value of -Math.floor(-x).
cos
public static double cos(double a)

Returns the trigonometric cosine of an angle. Special case: If the argument is NaN or
an infinity, then the result is NaN.
floor
public static double floor(double a)

Returns the largest (closest to positive infinity) double value that is not greater than
the argument and is equal to a mathematical integer. Special cases: If the argument
value is already equal to a mathematical integer, then the result is the same as the
argument. If the argument is NaN or an infinity or positive zero or negative zero, then

Method Detail

499

Overview (Codename One API)


the result is the same as the argument.
max
public static double max(double a,
double b)

Returns the greater of two double values. That is, the result is the argument closer to
positive infinity. If the arguments have the same value, the result is that same value.
If either value is NaN, then the result is NaN. Unlike the the numerical comparison
operators, this method considers negative zero to be strictly smaller than positive
zero. If one argument is positive zero and the other negative zero, the result is
positive zero.
max
public static float max(float a,
float b)

Returns the greater of two float values. That is, the result is the argument closer to
positive infinity. If the arguments have the same value, the result is that same value.
If either value is NaN, then the result is NaN. Unlike the the numerical comparison
operators, this method considers negative zero to be strictly smaller than positive
zero. If one argument is positive zero and the other negative zero, the result is
positive zero.
max
public static int max(int a,
int b)

Returns the greater of two int values. That is, the result is the argument closer to the
value of Integer.MAX_VALUE. If the arguments have the same value, the result is
that same value.
max
public static long max(long a,
long b)

Returns the greater of two long values. That is, the result is the argument closer to
the value of Long.MAX_VALUE. If the arguments have the same value, the result is
that same value.
min
public static double min(double a,
double b)

Returns the smaller of two double values. That is, the result is the value closer to
negative infinity. If the arguments have the same value, the result is that same value.
If either value is NaN, then the result is NaN. Unlike the the numerical comparison
operators, this method considers negative zero to be strictly smaller than positive
zero. If one argument is positive zero and the other is negative zero, the result is
negative zero.
min
public static float min(float a,
float b)

Returns the smaller of two float values. That is, the result is the value closer to
negative infinity. If the arguments have the same value, the result is that same value.
If either value is NaN, then the result is NaN. Unlike the the numerical comparison
operators, this method considers negative zero to be strictly smaller than positive
zero. If one argument is positive zero and the other is negative zero, the result is
negative zero.
min
public static int min(int a,
int b)

Returns the smaller of two int values. That is, the result the argument closer to the
value of Integer.MIN_VALUE. If the arguments have the same value, the result is that

Method Detail

500

Overview (Codename One API)


same value.
min
public static long min(long a,
long b)

Returns the smaller of two long values. That is, the result is the argument closer to
the value of Long.MIN_VALUE. If the arguments have the same value, the result is
that same value.
sin
public static double sin(double a)

Returns the trigonometric sine of an angle. Special cases: If the argument is NaN or
an infinity, then the result is NaN. If the argument is positive zero, then the result is
positive zero; if the argument is negative zero, then the result is negative zero.
sqrt
public static double sqrt(double a)

Returns the correctly rounded positive square root of a double value. Special cases:
If the argument is NaN or less than zero, then the result is NaN. If the argument is
positive infinity, then the result is positive infinity. If the argument is positive zero or
negative zero, then the result is the same as the argument.
tan
public static double tan(double a)

Returns the trigonometric tangent of an angle. Special cases: If the argument is NaN
or an infinity, then the result is NaN. If the argument is positive zero, then the result is
positive zero; if the argument is negative zero, then the result is negative zero
toDegrees
public static double toDegrees(double angrad)

Converts an angle measured in radians to the equivalent angle measured in degrees.


toRadians
public static double toRadians(double angdeg)

Converts an angle measured in degrees to the equivalent angle measured in radians.


round
public static long round(double d)

Returns the result of rounding the argument to an integer. The result is equivalent to
(long) Math.floor(d+0.5).
Special cases:
round(+0.0) = +0.0
round(-0.0) = +0.0
round((anything > Long.MAX_VALUE) = Long.MAX_VALUE
round((anything < Long.MIN_VALUE) = Long.MIN_VALUE
round(+infintiy) = Long.MAX_VALUE
round(-infintiy) = Long.MIN_VALUE
round(NaN) = +0.0
Parameters:
d - the value to be rounded.
Returns:
the closest integer to the argument.
round
public static int round(float f)

Returns the result of rounding the argument to an integer. The result is equivalent to
(int) Math.floor(f+0.5).

Method Detail

501

Overview (Codename One API)

Special cases:
round(+0.0) = +0.0
round(-0.0) = +0.0
round((anything > Integer.MAX_VALUE) = Integer.MAX_VALUE
round((anything < Integer.MIN_VALUE) = Integer.MIN_VALUE
round(+infintiy) = Integer.MAX_VALUE
round(-infintiy) = Integer.MIN_VALUE
round(NaN) = +0.0
Parameters:
f - the value to be rounded.
Returns:
the closest integer to the argument.

Method Detail

502

Overview (Codename One API)


java.lang

Class Long
java.lang.Object

java.lang.Long

public final class


extends Object

The Long class wraps a value of the primitive type long in an object. An object of type Long contains a
single field whose type is long. In addition, this class provides several methods for converting a long
to a String and a String to a long, as well as other constants and methods useful when dealing with a
long. Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and Type

Field and Description


MAX_VALUE

static long

The largest value of type long.


MIN_VALUE

static long

The smallest value of type long.

Constructor Summary
Constructor and Description
Long(long value)

Constructs a newly allocated Long object that represents the primitive long argument.

Method Summary
Modifier and
Type
int
double
boolean
float
int
int
long
static long

Method and Description


byteValue()

Returns the value of this Long as a byte value.


doubleValue()

Returns the value of this Long as a double.


equals(Object obj)

Compares this object against the specified object.


floatValue()

Returns the value of this Long as a float.


hashCode()

Computes a hashcode for this Long.


intValue()

Returns the value of this Long as an int value.


longValue()

Returns the value of this Long as a long value.


parseLong(String s)

Parses the string argument as a signed decimal long.


parseLong(String s, int radix)

static long

String

Class Long

Parses the string argument as a signed long in the radix specified by the
second argument.
toString()

Returns a String object representing this Long's value.

503

Overview (Codename One API)


static String

toString(long i)

Returns a new String object representing the specified integer.


toString(long i, int radix)

static String

static Long

Creates a string representation of the first argument in the radix specified


by the second argument.
valueOf(long i)

Returns the object instance of i

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
MAX_VALUE
public static final long MAX_VALUE

The largest value of type long. See Also:Constant Field Values


See Also:
Constant Field Values
MIN_VALUE
public static final long MIN_VALUE

The smallest value of type long. See Also:Constant Field Values


See Also:
Constant Field Values

Constructor Detail
Long
public Long(long value)

Constructs a newly allocated Long object that represents the primitive long argument.
value - the value to be represented by the Long object.

Method Detail
doubleValue
public double doubleValue()

Returns the value of this Long as a double.


equals
public boolean equals(Object obj)

Compares this object against the specified object. The result is true if and only if the
argument is not null and is a Long object that contains the same long value as this
object.
Overrides:
equals in class Object
floatValue
public float floatValue()

Returns the value of this Long as a float.

Method Summary

504

Overview (Codename One API)


hashCode
public int hashCode()

Computes a hashcode for this Long. The result is the exclusive OR of the two halves
of the primitive long value represented by this Long object. That is, the hashcode is
the value of the expression: (int)(this.longValue()^(this.longValue()>>>32))
Overrides:
hashCode in class Object
longValue
public long longValue()

Returns the value of this Long as a long value.


intValue
public int intValue()

Returns the value of this Long as an int value.


byteValue
public int byteValue()

Returns the value of this Long as a byte value.


parseLong
public static long parseLong(String s)
throws NumberFormatException

Parses the string argument as a signed decimal long. The characters in the string
must all be decimal digits, except that the first character may be an ASCII minus sign
'-' ( u002d') to indicate a negative value. The resulting long value is returned, exactly
as if the argument and the radix 10 were given as arguments to the method that
takes two arguments. Note that neither L nor l is permitted to appear at the end of the
string as a type indicator, as would be permitted in Java programming language
source code.
Throws:
NumberFormatException

parseLong
public static long parseLong(String s,
int radix)
throws NumberFormatException

Parses the string argument as a signed long in the radix specified by the second
argument. The characters in the string must all be digits of the specified radix (as
determined by whether Character.digit returns a nonnegative value), except that the
first character may be an ASCII minus sign '-' (' u002d' to indicate a negative value.
The resulting long value is returned. Note that neither L nor l is permitted to appear at
the end of the string as a type indicator, as would be permitted in Java programming
language source code - except that either L or l may appear as a digit for a radix
greater than 22. An exception of type NumberFormatException is thrown if any of the
following situations occurs: The first argument is null or is a string of length zero. The
radix is either smaller than Character.MIN_RADIX or larger than
Character.MAX_RADIX. The first character of the string is not a digit of the specified
radix and is not a minus sign '-' ('u002d'). The first character of the string is a minus
sign and the string is of length 1. Any character of the string after the first is not a digit
of the specified radix. The integer value represented by the string cannot be
represented as a value of type long. Examples: parseLong("0", 10) returns 0L
parseLong("473", 10) returns 473L parseLong("-0", 10) returns 0L parseLong("-FF",
16) returns -255L parseLong("1100110", 2) returns 102L parseLong("99", 8) throws a
NumberFormatException parseLong("Hazelnut", 10) throws a
NumberFormatException parseLong("Hazelnut", 36) returns 1356099454469L
Throws:
NumberFormatException

Method Detail

505

Overview (Codename One API)


toString
public String toString()

Returns a String object representing this Long's value. The long integer value
represented by this Long object is converted to signed decimal representation and
returned as a string, exactly as if the long value were given as an argument to the
method that takes one argument.
Overrides:
toString in class Object
toString
public static String toString(long i)

Returns a new String object representing the specified integer. The argument is
converted to signed decimal representation and returned as a string, exactly as if the
argument and the radix 10 were given as arguments to the method that takes two
arguments.
toString
public static String toString(long i,
int radix)

Creates a string representation of the first argument in the radix specified by the
second argument. If the radix is smaller than Character.MIN_RADIX or larger than
Character.MAX_RADIX, then the radix 10 is used instead. If the first argument is
negative, the first element of the result is the ASCII minus sign '-' ('u002d'. If the first
argument is not negative, no sign character appears in the result. The remaining
characters of the result represent the magnitude of the first argument. If the
magnitude is zero, it is represented by a single zero character '0' ('u0030'); otherwise,
the first character of the representation of the magnitude will not be the zero
character. The following ASCII characters are used as digits:
0123456789abcdefghijklmnopqrstuvwxyz These are ' u0030' through ' u0039' and '
u0061' through ' u007a'. If the radix is N, then the first N of these characters are used
as radix-N digits in the order shown. Thus, the digits for hexadecimal (radix 16) are
0123456789abcdef.
valueOf
public static Long valueOf(long i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance

Method Detail

506

Overview (Codename One API)


java.lang

Class LinkageError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.LinkageError
Direct Known Subclasses:
IncompatibleClassChangeError

public class
extends Error
LinkageError

is the superclass of all error classes that occur when loading and linking class files.

See Also:
Error

Constructor Summary
Constructor and Description
LinkageError()

Constructs a new LinkageError that includes the current stack trace.


LinkageError(String detailMessage)
Constructs a new LinkageError with the

current stack trace and the specified detail

message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
LinkageError
public LinkageError()

Constructs a new LinkageError that includes the current stack trace.


LinkageError
public LinkageError(String detailMessage)

Constructs a new LinkageError with the current stack trace and the specified detail
message.
Parameters:
detailMessage - the detail message for this error.

Class LinkageError

507

Overview (Codename One API)


java.lang

Interface Iterable<T>
All Known Subinterfaces:
Collection<E>, Deque<E>, List<E>, NavigableSet<E>, Queue<E>, Set<E>, SortedSet<E>
All Known Implementing Classes:
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet, Ads,
ArrayDeque, ArrayList, BaseSpinner, BrowserComponent, Calendar, ComponentGroup,
Container, ContainerList, DateSpinner, DateTimeSpinner, Dialog, Element,
EmbeddedContainer, FileTree, FloatingHint, Form, GenericSpinner, HashSet,
HTMLComponent, HTMLElement, InfiniteContainer, InteractionDialog, LinkedHashSet,
LinkedList, MapComponent, MediaPlayer, MenuBar, MultiButton, NumericSpinner,
OnOffSwitch, PriorityQueue, Progress, SideMenuBar, SpanButton, SpanLabel, Stack,
SwipeableContainer, Table, Tabs, TimeSpinner, Toolbar, Tree, TreeSet, Vector,
VirtualKeyboard, WebBrowser

public interface

Objects of classes that implement this interface can be used within a foreach statement.
Since:
1.5

Method Summary
Modifier and Type
Iterator<T>

Method and Description


iterator()

Returns an Iterator for the elements in this object.

Method Detail
iterator
Iterator<T> iterator()

Returns an Iterator for the elements in this object.


Returns:
An Iterator instance.

Constructor Detail

508

Overview (Codename One API)


java.lang

Class InterruptedException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.InterruptedException

public class
extends Exception

Thrown when a thread is waiting, sleeping, or otherwise paused for a long time and another thread
interrupts it. Since: JDK1.0, CLDC 1.0 See Also:Object.wait(), Object.wait(long), Object.wait(long, int),
Thread.sleep(long)

Constructor Summary
Constructor and Description
InterruptedException()

Constructs an InterruptedException with no detail message.


InterruptedException(String s)

Constructs an InterruptedException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
InterruptedException
public InterruptedException()

Constructs an InterruptedException with no detail message.


InterruptedException
public InterruptedException(String s)

Constructs an InterruptedException with the specified detail message. s - the detail


message.

Method Detail

509

Overview (Codename One API)


java.lang

Class Integer
java.lang.Object

java.lang.Integer

public final class


extends Object

The Integer class wraps a value of the primitive type int in an object. An object of type Integer
contains a single field whose type is int. In addition, this class provides several methods for converting
an int to a String and a String to an int, as well as other constants and methods useful when dealing
with an int. Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and Type

Field and Description


MAX_VALUE

static int

The largest value of type int.


MIN_VALUE

static int

The smallest value of type int.

Constructor Summary
Constructor and Description
Integer(int value)

Constructs a newly allocated Integer object that represents the primitive int argument.

Method Summary
Modifier and
Type
byte
double
boolean
float
int
int
long
static int

Method and Description


byteValue()

Returns the value of this Integer as a byte.


doubleValue()

Returns the value of this Integer as a double.


equals(Object obj)

Compares this object to the specified object.


floatValue()

Returns the value of this Integer as a float.


hashCode()

Returns a hashcode for this Integer.


intValue()

Returns the value of this Integer as an int.


longValue()

Returns the value of this Integer as a long.


parseInt(String s)

Parses the string argument as a signed decimal integer.


parseInt(String s, int radix)

static int

short

Constructor Detail

Parses the string argument as a signed integer in the radix specified by the
second argument.
shortValue()

Returns the value of this Integer as a short.

510

Overview (Codename One API)


static int

signum(int i)

Returns the value of the signum function for the specified integer.
toBinaryString(int i)

static String

Creates a string representation of the integer argument as an unsigned


integer in base 2.
toHexString(int i)

static String

Creates a string representation of the integer argument as an unsigned


integer in base 16.
toOctalString(int i)

static String

Creates a string representation of the integer argument as an unsigned


integer in base 8.
toString()

String

Returns a String object representing this Integer's value.

static String

toString(int i)

Returns a new String object representing the specified integer.


toString(int i, int radix)

static String

static Integer
static Integer
static Integer

Creates a string representation of the first argument in the radix specified


by the second argument.
valueOf(int i)

Returns the object instance of i


valueOf(String s)

Returns a new Integer object initialized to the value of the specified String.
valueOf(String s, int radix)

Returns a new Integer object initialized to the value of the specified String.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
MAX_VALUE
public static final int MAX_VALUE

The largest value of type int. The constant value of this field is 2147483647. See
Also:Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final int MIN_VALUE

The smallest value of type int. The constant value of this field is -2147483648. See
Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Integer
public Integer(int value)

Constructs a newly allocated Integer object that represents the primitive int argument.
value - the value to be represented by the Integer.

Method Summary

511

Overview (Codename One API)

Method Detail
byteValue
public byte byteValue()

Returns the value of this Integer as a byte.


doubleValue
public double doubleValue()

Returns the value of this Integer as a double.


equals
public boolean equals(Object obj)

Compares this object to the specified object. The result is true if and only if the
argument is not null and is an Integer object that contains the same int value as this
object.
Overrides:
equals in class Object
floatValue
public float floatValue()

Returns the value of this Integer as a float.


hashCode
public int hashCode()

Returns a hashcode for this Integer.


Overrides:
hashCode in class Object
intValue
public int intValue()

Returns the value of this Integer as an int.


longValue
public long longValue()

Returns the value of this Integer as a long.


parseInt
public static int parseInt(String s)
throws NumberFormatException

Parses the string argument as a signed decimal integer. The characters in the string
must all be decimal digits, except that the first character may be an ASCII minus sign
'-' (' u002d') to indicate a negative value. The resulting integer value is returned,
exactly as if the argument and the radix 10 were given as arguments to the method.
Throws:
NumberFormatException

parseInt
public static int parseInt(String s,
int radix)
throws NumberFormatException

Parses the string argument as a signed integer in the radix specified by the second
argument. The characters in the string must all be digits of the specified radix (as
determined by whether returns a nonnegative value), except that the first character
may be an ASCII minus sign '-' (' u002d') to indicate a negative value. The resulting
integer value is returned. An exception of type NumberFormatException is thrown if
any of the following situations occurs: The first argument is null or is a string of length

Method Detail

512

Overview (Codename One API)


zero. The radix is either smaller than Character.MIN_RADIX or larger than
Character.MAX_RADIX. Any character of the string is not a digit of the specified
radix, except that the first character may be a minus sign '-' ('u002d') provided that the
string is longer than length 1. The integer value represented by the string is not a
value of type int. Examples: parseInt("0", 10) returns 0 parseInt("473", 10) returns 473
parseInt("-0", 10) returns 0 parseInt("-FF", 16) returns -255 parseInt("1100110", 2)
returns 102 parseInt("2147483647", 10) returns 2147483647 parseInt("-2147483648",
10) returns -2147483648 parseInt("2147483648", 10) throws a
NumberFormatException parseInt("99", 8) throws a NumberFormatException
parseInt("Kona", 10) throws a NumberFormatException parseInt("Kona", 27) returns
411787
Throws:
NumberFormatException

shortValue
public short shortValue()

Returns the value of this Integer as a short.


toBinaryString
public static String toBinaryString(int i)

Creates a string representation of the integer argument as an unsigned integer in


base 2. The unsigned integer value is the argument plus 232if the argument is
negative; otherwise it is equal to the argument. This value is converted to a string of
ASCII digits in binary (base2) with no extra leading 0s. If the unsigned magnitude is
zero, it is represented by a single zero character '0' ('u0030'); otherwise, the first
character of the representation of the unsigned magnitude will not be the zero
character. The characters '0' ('u0030') and '1' ('u0031') are used as binary digits.
toHexString
public static String toHexString(int i)

Creates a string representation of the integer argument as an unsigned integer in


base 16. The unsigned integer value is the argument plus 232 if the argument is
negative; otherwise, it is equal to the argument. This value is converted to a string of
ASCII digits in hexadecimal (base16) with no extra leading 0s. If the unsigned
magnitude is zero, it is represented by a single zero character '0' ('u0030'); otherwise,
the first character of the representation of the unsigned magnitude will not be the zero
character. The following characters are used as hexadecimal digits:
0123456789abcdef These are the characters ' u0030' through ' u0039' and 'u\0039'
through ' u0066'.
toOctalString
public static String toOctalString(int i)

Creates a string representation of the integer argument as an unsigned integer in


base 8. The unsigned integer value is the argument plus 232 if the argument is
negative; otherwise, it is equal to the argument. This value is converted to a string of
ASCII digits in octal (base8) with no extra leading 0s. If the unsigned magnitude is
zero, it is represented by a single zero character '0' ('u0030'); otherwise, the first
character of the representation of the unsigned magnitude will not be the zero
character. The octal digits are: 01234567 These are the characters ' u0030' through '
u0037'.
toString
public String toString()

Returns a String object representing this Integer's value. The value is converted to
signed decimal representation and returned as a string, exactly as if the integer value
were given as an argument to the method.
Overrides:
toString in class Object

Method Detail

513

Overview (Codename One API)


toString
public static String toString(int i)

Returns a new String object representing the specified integer. The argument is
converted to signed decimal representation and returned as a string, exactly as if the
argument and radix 10 were given as arguments to the method.
toString
public static String toString(int i,
int radix)

Creates a string representation of the first argument in the radix specified by the
second argument. If the radix is smaller than Character.MIN_RADIX or larger than
Character.MAX_RADIX, then the radix 10 is used instead. If the first argument is
negative, the first element of the result is the ASCII minus character '-' ('u002d'). If the
first argument is not negative, no sign character appears in the result. The remaining
characters of the result represent the magnitude of the first argument. If the
magnitude is zero, it is represented by a single zero character '0' ('u0030'); otherwise,
the first character of the representation of the magnitude will not be the zero
character. The following ASCII characters are used as digits:
0123456789abcdefghijklmnopqrstuvwxyz These are ' u0030' through ' u0039' and '
u0061' through ' u007a'. If the radix is N, then the first N of these characters are used
as radix-N digits in the order shown. Thus, the digits for hexadecimal (radix 16) are
0123456789abcdef.
valueOf
public static Integer valueOf(String s)
throws NumberFormatException

Returns a new Integer object initialized to the value of the specified String. The
argument is interpreted as representing a signed decimal integer, exactly as if the
argument were given to the method. The result is an Integer object that represents
the integer value specified by the string. In other words, this method returns an
Integer object equal to the value of: new Integer(Integer.parseInt(s))
Throws:
NumberFormatException

valueOf
public static Integer valueOf(String s,
int radix)
throws NumberFormatException

Returns a new Integer object initialized to the value of the specified String. The first
argument is interpreted as representing a signed integer in the radix specified by the
second argument, exactly as if the arguments were given to the method. The result is
an Integer object that represents the integer value specified by the string. In other
words, this method returns an Integer object equal to the value of: new
Integer(Integer.parseInt(s, radix))
Throws:
NumberFormatException

valueOf
public static Integer valueOf(int i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance
signum
public static int signum(int i)

Returns the value of the signum function for the specified integer.
Parameters:
i - the integer value to check.
Returns:

Method Detail

514

Overview (Codename One API)


-1 if i is negative, 1 if i is positive, 0 if i is zero.

Since:

1.5

Method Detail

515

Overview (Codename One API)


java.lang

Class InstantiationException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.InstantiationException

public class
extends Exception

Thrown when an application tries to create an instance of a class using the newInstance method in
class Class, but the specified class object cannot be instantiated because it is an interface or is an
abstract class. Since: JDK1.0, CLDC 1.0 See Also:Class.newInstance()

Constructor Summary
Constructor and Description
InstantiationException()

Constructs an InstantiationException with no detail message.


InstantiationException(String s)

Constructs an InstantiationException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
InstantiationException
public InstantiationException()

Constructs an InstantiationException with no detail message.


InstantiationException
public InstantiationException(String s)

Constructs an InstantiationException with the specified detail message. s - the detail


message.

Class InstantiationException

516

Overview (Codename One API)


java.lang

Class IndexOutOfBoundsException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IndexOutOfBoundsException
Direct Known Subclasses:
ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException

public class
extends RuntimeException

Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of
range. Applications can subclass this class to indicate similar exceptions. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
IndexOutOfBoundsException()

Constructs an IndexOutOfBoundsException with no detail message.


IndexOutOfBoundsException(String s)

Constructs an IndexOutOfBoundsException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IndexOutOfBoundsException
public IndexOutOfBoundsException()

Constructs an IndexOutOfBoundsException with no detail message.


IndexOutOfBoundsException
public IndexOutOfBoundsException(String s)

Constructs an IndexOutOfBoundsException with the specified detail message. s - the


detail message.

Constructor Detail

517

Overview (Codename One API)


java.lang

Class IncompatibleClassChangeError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.LinkageError

java.lang.IncompatibleClassChangeError
Direct Known Subclasses:
NoSuchFieldError

public class
extends LinkageError

is the superclass of all classes which represent errors that occur


when inconsistent class files are loaded into the same running image.
See Also:
IncompatibleClassChangeError

Error

Constructor Summary
Constructor and Description
IncompatibleClassChangeError()
Constructs a new IncompatibleClassChangeError

that includes the current stack trace.

IncompatibleClassChangeError(String detailMessage)
Constructs a new IncompatibleClassChangeError with the

current stack trace and the

specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IncompatibleClassChangeError
public IncompatibleClassChangeError()

Constructs a new IncompatibleClassChangeError that includes the current stack


trace.
IncompatibleClassChangeError
public IncompatibleClassChangeError(String detailMessage)

Constructs a new IncompatibleClassChangeError with the current stack trace and the
specified detail message.
Parameters:
detailMessage - the detail message for this error.

Constructor Detail

518

Overview (Codename One API)


java.lang

Class IllegalThreadStateException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IllegalArgumentException

java.lang.IllegalThreadStateException

public class
extends IllegalArgumentException

Thrown to indicate that a thread is not in an appropriate state for the requested operation. See, for
example, the suspend and resume methods in class Thread. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
IllegalThreadStateException()

Constructs an IllegalThreadStateException with no detail message.


IllegalThreadStateException(String s)

Constructs an IllegalThreadStateException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IllegalThreadStateException
public IllegalThreadStateException()

Constructs an IllegalThreadStateException with no detail message.


IllegalThreadStateException
public IllegalThreadStateException(String s)

Constructs an IllegalThreadStateException with the specified detail message. s - the


detail message.

Constructor Detail

519

Overview (Codename One API)


java.lang

Class IllegalStateException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IllegalStateException

public class
extends RuntimeException

Constructor Summary
Constructor and Description
IllegalStateException()
IllegalStateException(String s)

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IllegalStateException
public IllegalStateException()

IllegalStateException
public IllegalStateException(String s)

Constructor Detail

520

Overview (Codename One API)


java.lang

Class IllegalMonitorStateException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IllegalMonitorStateException

public class
extends RuntimeException

Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads
waiting on an object's monitor without owning the specified monitor. Since: JDK1.0, CLDC 1.0 See
Also:Object.notify(), Object.notifyAll(), Object.wait(), Object.wait(long), Object.wait(long, int)

Constructor Summary
Constructor and Description
IllegalMonitorStateException()

Constructs an IllegalMonitorStateException with no detail message.


IllegalMonitorStateException(String s)

Constructs an IllegalMonitorStateException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IllegalMonitorStateException
public IllegalMonitorStateException()

Constructs an IllegalMonitorStateException with no detail message.


IllegalMonitorStateException
public IllegalMonitorStateException(String s)

Constructs an IllegalMonitorStateException with the specified detail message. s - the


detail message.

Constructor Detail

521

Overview (Codename One API)


java.lang

Class IllegalArgumentException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IllegalArgumentException
Direct Known Subclasses:
IllegalThreadStateException, NumberFormatException

public class
extends RuntimeException

Thrown to indicate that a method has been passed an illegal or inappropriate argument. Since:
JDK1.0, CLDC 1.0 See Also:Thread.setPriority(int)

Constructor Summary
Constructor and Description
IllegalArgumentException()

Constructs an IllegalArgumentException with no detail message.


IllegalArgumentException(String s)

Constructs an IllegalArgumentException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IllegalArgumentException
public IllegalArgumentException()

Constructs an IllegalArgumentException with no detail message.


IllegalArgumentException
public IllegalArgumentException(String s)

Constructs an IllegalArgumentException with the specified detail message. s - the


detail message.

Constructor Detail

522

Overview (Codename One API)


java.lang

Class IllegalAccessException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.IllegalAccessException

public class
extends Exception

Thrown when an application tries to load in a class, but the currently executing method does not have
access to the definition of the specified class, because the class is not public and in another package.
An instance of this class can also be thrown when an application tries to create an instance of a class
using the newInstance method in class Class, but the current method does not have access to the
appropriate zero-argument constructor. Since: JDK1.0, CLDC 1.0 See
Also:Class.forName(java.lang.String), Class.newInstance()

Constructor Summary
Constructor and Description
IllegalAccessException()

Constructs an IllegalAccessException without a detail message.


IllegalAccessException(String s)

Constructs an IllegalAccessException with a detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IllegalAccessException
public IllegalAccessException()

Constructs an IllegalAccessException without a detail message.


IllegalAccessException
public IllegalAccessException(String s)

Constructs an IllegalAccessException with a detail message. s - the detail message.

Constructor Detail

523

Overview (Codename One API)


java.lang

Class Float
java.lang.Object

java.lang.Float

public final class


extends Object

The Float class wraps a value of primitive type float in an object. An object of type Float contains a
single field whose type is float. In addition, this class provides several methods for converting a float
to a String and a String to a float, as well as other constants and methods useful when dealing with a
float. Since: JDK1.0, CLDC 1.1

Field Summary
Modifier and Type

Field and Description


MAX_VALUE

static float

The largest positive value of type float.


MIN_VALUE

static float

The smallest positive value of type float.


NaN

static float

The Not-a-Number (NaN) value of type float.


NEGATIVE_INFINITY

static float

The negative infinity of type float.


POSITIVE_INFINITY

static float

The positive infinity of type float.

Constructor Summary
Constructor and Description
Float(double value)

Constructs a newly allocated Floatobject that represents the argument converted to type
float.
Float(float value)

Constructs a newly allocated Float object that represents the primitive float argument.

Method Summary
Modifier and
Type
byte
double
boolean
static int
float
int

Constructor Detail

Method and Description


byteValue()

Returns the value of this Float as a byte (by casting to a byte).


doubleValue()

Returns the double value of this Float object.


equals(Object obj)

Compares this object against some other object.


floatToIntBits(float value)

Returns the bit representation of a single-float value.


floatValue()

Returns the float value of this Float object.


hashCode()

Returns a hashcode for this Float object.

524

Overview (Codename One API)


static float

intBitsToFloat(int bits)

Returns the single-float corresponding to a given bit representation.


intValue()

int

Returns the integer value of this Float (by casting to an int).

boolean
static boolean
boolean

isInfinite()

Returns true if this Float value is infinitely large in magnitude.


isInfinite(float v)

Returns true if the specified number is infinitely large in magnitude.


isNaN()

Returns true if this Float value is Not-a-Number (NaN).


isNaN(float v)

static boolean

Returns true if the specified number is the special Not-a-Number (NaN)


value.
longValue()

long

Returns the long value of this Float (by casting to a long).


parseFloat(String s)

static float

Returns a new float initialized to the value represented by the specified


String.
shortValue()

short

Returns the value of this Float as a short (by casting to a short).


toString()

String

Returns a String representation of this Float object.

static String
static Float
static Float

toString(float f)

Returns a String representation for the specified float value.


valueOf(float i)

Returns the object instance of i


valueOf(String s)

Returns the floating point value represented by the specified String.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
MAX_VALUE
public static final float MAX_VALUE

The largest positive value of type float. It is equal to the value returned by
Float.intBitsToFloat(0x7f7fffff). See Also:Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final float MIN_VALUE

The smallest positive value of type float. It is equal to the value returned by
Float.intBitsToFloat(0x1). See Also:Constant Field Values
See Also:
Constant Field Values
NaN
public static final float NaN

The Not-a-Number (NaN) value of type float. It is equal to the value returned by
Float.intBitsToFloat(0x7fc00000). See Also:Constant Field Values
See Also:
Constant Field Values

Method Summary

525

Overview (Codename One API)


NEGATIVE_INFINITY
public static final float NEGATIVE_INFINITY

The negative infinity of type float. It is equal to the value returned by


Float.intBitsToFloat(0xff800000). See Also:Constant Field Values
See Also:
Constant Field Values
POSITIVE_INFINITY
public static final float POSITIVE_INFINITY

The positive infinity of type float. It is equal to the value returned by


Float.intBitsToFloat(0x7f800000). See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Float
public Float(double value)

Constructs a newly allocated Floatobject that represents the argument converted to


type float. value - the value to be represented by the Float.
Float
public Float(float value)

Constructs a newly allocated Float object that represents the primitive float argument.
value - the value to be represented by the Float.

Method Detail
byteValue
public byte byteValue()

Returns the value of this Float as a byte (by casting to a byte).


doubleValue
public double doubleValue()

Returns the double value of this Float object.


equals
public boolean equals(Object obj)

Compares this object against some other object. The result is true if and only if the
argument is not null and is a Float object that represents a float that has the identical
bit pattern to the bit pattern of the float represented by this object. For this purpose,
two float values are considered to be the same if and only if the method returns the
same int value when applied to each. Note that in most cases, for two instances of
class Float, f1 and f2, the value of f1.equals(f2) is true if and only if f1.floatValue() ==
f2.floatValue() also has the value true. However, there are two exceptions: If f1 and f2
both represent Float.NaN, then the equals method returns true, even though
Float.NaN==Float.NaN has the value false. If f1 represents +0.0f while f2 represents
-0.0f, or vice versa, the equal test has the value false, even though 0.0f==-0.0f has
the value true. This definition allows hashtables to operate properly.
Overrides:
equals in class Object

Field Detail

526

Overview (Codename One API)


floatToIntBits
public static int floatToIntBits(float value)

Returns the bit representation of a single-float value. The result is a representation of


the floating-point argument according to the IEEE 754 floating-point "single precision"
bit layout. Bit 31 (the bit that is selected by the mask 0x80000000) represents the
sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask
0x7f800000) represent the exponent. Bits 22-0 (the bits that are selected by the mask
0x007fffff) represent the significand (sometimes called the mantissa) of the
floating-point number. If the argument is positive infinity, the result is 0x7f800000. If
the argument is negative infinity, the result is 0xff800000. If the argument is NaN, the
result is 0x7fc00000. In all cases, the result is an integer that, when given to the
method, will produce a floating-point value equal to the argument to floatToIntBits.
floatValue
public float floatValue()

Returns the float value of this Float object.


hashCode
public int hashCode()

Returns a hashcode for this Float object. The result is the integer bit representation,
exactly as produced by the method , of the primitive float value represented by this
Float object.
Overrides:
hashCode in class Object
intBitsToFloat
public static float intBitsToFloat(int bits)

Returns the single-float corresponding to a given bit representation. The argument is


considered to be a representation of a floating-point value according to the IEEE 754
floating-point "single precision" bit layout. If the argument is 0x7f800000, the result is
positive infinity. If the argument is 0xff800000, the result is negative infinity. If the
argument is any value in the range 0x7f800001 through 0x7fffffff or in the range
0xff800001 through 0xffffffff, the result is NaN. All IEEE 754 NaN values of type float
are, in effect, lumped together by the Java programming language into a single float
value called NaN. In all other cases, let s, e, and m be three values that can be
computed from the argument: int s = ((bits >> 31) == 0) ? 1 : -1; int e = ((bits >> 23) &
0xff); int m = (e == 0) ? (bits & 0x7fffff) << 1 : (bits & 0x7fffff) | 0x800000; Then the
floating-point result equals the value of the mathematical expression .
intValue
public int intValue()

Returns the integer value of this Float (by casting to an int).


isInfinite
public boolean isInfinite()

Returns true if this Float value is infinitely large in magnitude.


isInfinite
public static boolean isInfinite(float v)

Returns true if the specified number is infinitely large in magnitude.


isNaN
public boolean isNaN()

Returns true if this Float value is Not-a-Number (NaN).

Method Detail

527

Overview (Codename One API)


isNaN
public static boolean isNaN(float v)

Returns true if the specified number is the special Not-a-Number (NaN) value.
longValue
public long longValue()

Returns the long value of this Float (by casting to a long).


parseFloat
public static float parseFloat(String s)
throws NumberFormatException

Returns a new float initialized to the value represented by the specified String.
Throws:
NumberFormatException

shortValue
public short shortValue()

Returns the value of this Float as a short (by casting to a short).


toString
public String toString()

Returns a String representation of this Float object. The primitive float value
represented by this object is converted to a String exactly as if by the method toString
of one argument.
Overrides:
toString in class Object
toString
public static String toString(float f)

Returns a String representation for the specified float value. The argument is
converted to a readable string format as follows. All characters and characters in
strings mentioned below are ASCII characters. If the argument is NaN, the result is
the string "NaN". Otherwise, the result is a string that represents the sign and
magnitude (absolute value) of the argument. If the sign is negative, the first character
of the result is '-' ('-'); if the sign is positive, no sign character appears in the result. As
for the magnitude m: If m is infinity, it is represented by the characters "Infinity"; thus,
positive infinity produces the result "Infinity" and negative infinity produces the result
"-Infinity". If m is zero, it is represented by the characters "0.0"; thus, negative zero
produces the result "-0.0" and positive zero produces the result "0.0". If m is greater
than or equal to 10-3 but less than 107, then it is represented as the integer part of m,
in decimal form with no leading zeroes, followed by '.' (.), followed by one or more
decimal digits representing the fractional part of m. If m is less than 10-3 or not less
than 107, then it is represented in so-called "computerized scientific notation." Let n
be the unique integer such that 10n =m 1; then let a be the mathematically exact
quotient of m and 10n so that 1 a&lt10. The magnitude is then represented as the
integer part of a, as a single decimal digit, followed by '.' (.), followed by decimal digits
representing the fractional part of a, followed by the letter 'E' (E), followed by a
representation of n as a decimal integer, as produced by the method of one
argument. How many digits must be printed for the fractional part of m or a? There
must be at least one digit to represent the fractional part, and beyond that as many,
but only as many, more digits as are needed to uniquely distinguish the argument
value from adjacent values of type float. That is, suppose that x is the exact
mathematical value represented by the decimal representation produced by this
method for a finite nonzero argument f. Then f must be the float value nearest to x;
or, if two float values are equally close to xthen f must be one of them and the least
significant bit of the significand of f must be 0.

Method Detail

528

Overview (Codename One API)


valueOf
public static Float valueOf(String s)
throws NumberFormatException

Returns the floating point value represented by the specified String. The string s is
interpreted as the representation of a floating-point value and a Float object
representing that value is created and returned. If s is null, then a
NullPointerException is thrown. Leading and trailing whitespace characters in s are
ignored. The rest of s should constitute a FloatValue as described by the lexical
syntax rules: where , are as defined in Section 3.10.2 of the . If it does not have the
form of a , then a NumberFormatException is thrown. Otherwise, it is regarded as
representing an exact decimal value in the usual "computerized scientific notation";
this exact decimal value is then conceptually converted to an "infinitely precise"
binary value that is then rounded to type float by the usual round-to-nearest rule of
IEEE 754 floating-point arithmetic.
Throws:
NumberFormatException

valueOf
public static Float valueOf(float i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance

Method Detail

529

Overview (Codename One API)


java.lang

Class Exception
java.lang.Object

java.lang.Throwable

java.lang.Exception
Direct Known Subclasses:
ClassNotFoundException, CloneNotSupportedException, CloudException,
IllegalAccessException, InstantiationException, InterruptedException, IOException,
ParseException, ParseException, RuntimeException, URISyntaxException

public class
extends Throwable

The class Exception and its subclasses are a form of Throwable that indicates conditions that a
reasonable application might want to catch. Since: JDK1.0, CLDC 1.0 See Also:Error

Constructor Summary
Constructor and Description
Exception()

Constructs an Exception with no specified detail message.


Exception(String s)

Constructs an Exception with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Exception
public Exception()

Constructs an Exception with no specified detail message.


Exception
public Exception(String s)

Constructs an Exception with the specified detail message. s - the detail message.

Class Exception

530

Overview (Codename One API)


java.lang

Class Error
java.lang.Object

java.lang.Throwable

java.lang.Error
Direct Known Subclasses:
AnnotationFormatError, AssertionError, LinkageError, NoClassDefFoundError,
VirtualMachineError

public class
extends Throwable

An Error is a subclass of Throwable that indicates serious problems that a reasonable application
should not try to catch. Most such errors are abnormal conditions. A method is not required to declare
in its throws clause any subclasses of Error that might be thrown during the execution of the method
but not caught, since these errors are abnormal conditions that should never occur. Since: JDK1.0,
CLDC 1.0

Constructor Summary
Constructor and Description
Error()

Constructs an Error with no specified detail message.


Error(String s)

Constructs an Error with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Error
public Error()

Constructs an Error with no specified detail message.


Error
public Error(String s)

Constructs an Error with the specified detail message. s - the detail message.

Constructor Detail

531

Overview (Codename One API)


java.lang

Class Enum<E extends Enum<E>>


java.lang.Object

java.lang.Enum<E>
All Implemented Interfaces:
Comparable<E>

public class
extends Object
implements Comparable<E>

Implementation class required to compile enums

Constructor Summary
Modifier

Constructor and Description

protected Enum(String name, int ordinal)

Method Summary
Modifier and Type
protected Object

Method and Description


clone()
compareTo(E e)

Compares this object to the specified object to determine their


relative order.

int

boolean

equals(Object other)

Indicates whether some other object is "equal to" this one.

Class<E>

getDeclaringClass()

protected static
<T> T[]

getEnumValues(Class<T> class_)
hashCode()

int

Returns a hash code value for the object.

String

name()

int

ordinal()

protected static void

setEnumValues(Object[] values, Class c)


toString()

String

Returns a string representation of the object.

static <T extends


Enum<T>>
T

valueOf(Class<T> enumType, String name)

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Constructor Detail

532

Overview (Codename One API)


Enum
protected Enum(String name,
int ordinal)

Method Detail
clone
protected Object clone()

setEnumValues
protected static final void setEnumValues(Object[] values,
Class c)

getEnumValues
protected static final <T> T[] getEnumValues(Class<T> class_)

valueOf
public static <T extends Enum<T>> T valueOf(Class<T> enumType,
String name)

equals
public final boolean equals(Object other)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public final int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object

Constructor Detail

533

Overview (Codename One API)


toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
compareTo
public final int compareTo(E e)

Description copied from interface: Comparable


Compares this object to the specified object to determine their relative order.
Specified by:
compareTo in interface Comparable<E extends Enum<E>>
Parameters:
e - the object to compare to this instance.
Returns:
a negative integer if this instance is less than another; a positive integer if
this instance is greater than another; 0 if this instance has the same order as
another.
name
public final String name()

ordinal
public final int ordinal()

getDeclaringClass
public final Class<E> getDeclaringClass()

Method Detail

534

Overview (Codename One API)


java.lang

Class Double
java.lang.Object

java.lang.Double

public final class


extends Object

The Double class wraps a value of the primitive type double in an object. An object of type Double
contains a single field whose type is double. In addition, this class provides several methods for
converting a double to a String and a String to a double, as well as other constants and methods
useful when dealing with a double. Since: JDK1.0, CLDC 1.1

Field Summary
Modifier and Type
static double
static double
static double
static double
static double

Field and Description


MAX_VALUE

The largest positive finite value of type double.


MIN_VALUE

The smallest positive value of type double.


NaN

A Not-a-Number (NaN) value of type double.


NEGATIVE_INFINITY

The negative infinity of type double.


POSITIVE_INFINITY

The positive infinity of type double.

Constructor Summary
Constructor and Description
Double(double value)

Constructs a newly allocated Double object that represents the primitive double argument.

Method Summary
Modifier and
Type
byte

Method and Description


byteValue()

Returns the value of this Double as a byte (by casting to a byte).


doubleToLongBits(double value)

static long

double
boolean
float
int
int

Class Double

Returns a representation of the specified floating-point value according to the


IEEE 754 floating-point "double format" bit layout.
doubleValue()

Returns the double value of this Double.


equals(Object obj)

Compares this object against the specified object.


floatValue()

Returns the float value of this Double.


hashCode()

Returns a hashcode for this Double object.


intValue()

Returns the integer value of this Double (by casting to an int).

535

Overview (Codename One API)


boolean
static
boolean
boolean

isInfinite()

Returns true if this Double value is infinitely large in magnitude.


isInfinite(double v)

Returns true if the specified number is infinitely large in magnitude.


isNaN()

Returns true if this Double value is the special Not-a-Number (NaN) value.

static
boolean

isNaN(double v)

static
double

longBitsToDouble(long bits)

Returns true if the specified number is the special Not-a-Number (NaN) value.
Returns the double-float corresponding to a given bit representation.
longValue()

long

Returns the long value of this Double (by casting to a long).


parseDouble(String s)

static
double

Returns a new double initialized to the value represented by the specified


String, as performed by the valueOf method of class Double.
shortValue()

short

Returns the value of this Double as a short (by casting to a short).


toString()

String

Returns a String representation of this Double object.

static
String

toString(double d)

static
Double

valueOf(double i)

Creates a string representation of the double argument.


Returns the object instance of i
valueOf(String s)

static
Double

Returns a new Double object initialized to the value represented by the


specified string.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
MAX_VALUE
public static final double MAX_VALUE

The largest positive finite value of type double. It is equal to the value returned by
Double.longBitsToDouble(0x7fefffffffffffffL) See Also:Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final double MIN_VALUE

The smallest positive value of type double. It is equal to the value returned by
Double.longBitsToDouble(0x1L).
See Also:
Constant Field Values
NaN
public static final double NaN

A Not-a-Number (NaN) value of type double. It is equal to the value returned by


Double.longBitsToDouble(0x7ff8000000000000L). See Also:Constant Field Values
See Also:
Constant Field Values

Method Summary

536

Overview (Codename One API)


NEGATIVE_INFINITY
public static final double NEGATIVE_INFINITY

The negative infinity of type double. It is equal to the value returned by


Double.longBitsToDouble(0xfff0000000000000L). See Also:Constant Field Values
See Also:
Constant Field Values
POSITIVE_INFINITY
public static final double POSITIVE_INFINITY

The positive infinity of type double. It is equal to the value returned by


Double.longBitsToDouble(0x7ff0000000000000L). See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Double
public Double(double value)

Constructs a newly allocated Double object that represents the primitive double
argument. value - the value to be represented by the Double.

Method Detail
byteValue
public byte byteValue()

Returns the value of this Double as a byte (by casting to a byte).


doubleToLongBits
public static long doubleToLongBits(double value)

Returns a representation of the specified floating-point value according to the IEEE


754 floating-point "double format" bit layout. Bit 63 (the bit that is selected by the
mask 0x8000000000000000L) represents the sign of the floating-point number. Bits
62-52 (the bits that are selected by the mask 0x7ff0000000000000L) represent the
exponent. Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL) represent
the significand (sometimes called the mantissa) of the floating-point number. If the
argument is positive infinity, the result is 0x7ff0000000000000L. If the argument is
negative infinity, the result is 0xfff0000000000000L. If the argument is NaN, the result
is 0x7ff8000000000000L. In all cases, the result is a long integer that, when given to
the longBitsToDouble(long) method, will produce a floating-point value equal to the
argument to doubleToLongBits.
doubleValue
public double doubleValue()

Returns the double value of this Double.


equals
public boolean equals(Object obj)

Compares this object against the specified object. The result is true if and only if the
argument is not null and is a Double object that represents a double that has the
identical bit pattern to the bit pattern of the double represented by this object. For this
purpose, two double values are considered to be the same if and only if the method
returns the same long value when applied to each. Note that in most cases, for two
instances of class Double, d1 and d2, the value of d1.equals(d2) is true if and only if
d1.doubleValue() == d2.doubleValue() also has the value true. However, there are

Field Detail

537

Overview (Codename One API)


two exceptions: If d1 and d2 both represent Double.NaN, then the equals method
returns true, even though Double.NaN==Double.NaN has the value false. If d1
represents +0.0 while d2 represents -0.0, or vice versa, the equals test has the value
false, even though +0.0==-0.0 has the value true. This allows hashtables to operate
properly.
Overrides:
equals in class Object
floatValue
public float floatValue()

Returns the float value of this Double.


hashCode
public int hashCode()

Returns a hashcode for this Double object. The result is the exclusive OR of the two
halves of the long integer bit representation, exactly as produced by the method , of
the primitive double value represented by this Double object. That is, the hashcode is
the value of the expression: (int)(v^(v>>>32)) where v is defined by: long v =
Double.doubleToLongBits(this.doubleValue());
Overrides:
hashCode in class Object
intValue
public int intValue()

Returns the integer value of this Double (by casting to an int).


isInfinite
public boolean isInfinite()

Returns true if this Double value is infinitely large in magnitude.


isInfinite
public static boolean isInfinite(double v)

Returns true if the specified number is infinitely large in magnitude.


isNaN
public boolean isNaN()

Returns true if this Double value is the special Not-a-Number (NaN) value.
isNaN
public static boolean isNaN(double v)

Returns true if the specified number is the special Not-a-Number (NaN) value.
longBitsToDouble
public static double longBitsToDouble(long bits)

Returns the double-float corresponding to a given bit representation. The argument is


considered to be a representation of a floating-point value according to the IEEE 754
floating-point "double precision" bit layout. That floating-point value is returned as the
result. If the argument is 0x7ff0000000000000L, the result is positive infinity. If the
argument is 0xfff0000000000000L, the result is negative infinity. If the argument is
any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range
0xfff0000000000001L through 0xffffffffffffffffL, the result is NaN. All IEEE 754 NaN
values of type double are, in effect, lumped together by the Java programming
language into a single value called NaN. In all other cases, let s, e, and m be three
values that can be computed from the argument: int s = ((bits >> 63) == 0) ? 1 : -1; int
e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) ? (bits & 0xfffffffffffffL) << 1 : (bits &
0xfffffffffffffL) | 0x10000000000000L; Then the floating-point result equals the value of
the mathematical expression 2e-1075.

Method Detail

538

Overview (Codename One API)


longValue
public long longValue()

Returns the long value of this Double (by casting to a long).


parseDouble
public static double parseDouble(String s)
throws NumberFormatException

Returns a new double initialized to the value represented by the specified String, as
performed by the valueOf method of class Double.
Throws:
NumberFormatException

shortValue
public short shortValue()

Returns the value of this Double as a short (by casting to a short).


toString
public String toString()

Returns a String representation of this Double object. The primitive double value
represented by this object is converted to a string exactly as if by the method toString
of one argument.
Overrides:
toString in class Object
toString
public static String toString(double d)

Creates a string representation of the double argument. All characters mentioned


below are ASCII characters. If the argument is NaN, the result is the string "NaN".
Otherwise, the result is a string that represents the sign and magnitude (absolute
value) of the argument. If the sign is negative, the first character of the result is '-' ('-');
if the sign is positive, no sign character appears in the result. As for the magnitude : If
is infinity, it is represented by the characters "Infinity"; thus, positive infinity produces
the result "Infinity" and negative infinity produces the result "-Infinity". If is zero, it is
represented by the characters "0.0"; thus, negative zero produces the result "-0.0"
and positive zero produces the result "0.0". If is greater than or equal to 10-3 but less
than 107, then it is represented as the integer part of , in decimal form with no leading
zeroes, followed by '.' (.), followed by one or more decimal digits representing the
fractional part of . If is less than 10-3 or not less than 107, then it is represented in
so-called "computerized scientific notation." Let be the unique integer such that 10n =
10n+1; then let be the mathematically exact quotient of and 10n so that 1 = 10. The
magnitude is then represented as the integer part of , as a single decimal digit,
followed by '.' (.), followed by decimal digits representing the fractional part of ,
followed by the letter 'E' (E), followed by a representation of as a decimal integer, as
produced by the method . How many digits must be printed for the fractional part of m
or a? There must be at least one digit to represent the fractional part, and beyond
that as many, but only as many, more digits as are needed to uniquely distinguish the
argument value from adjacent values of type double. That is, suppose that x is the
exact mathematical value represented by the decimal representation produced by
this method for a finite nonzero argument d. Then d must be the double value nearest
to x; or if two double values are equally close to x, then d must be one of them and
the least significant bit of the significand of d must be 0.
valueOf
public static Double valueOf(String s)
throws NumberFormatException

Returns a new Double object initialized to the value represented by the specified
string. The string s is interpreted as the representation of a floating-point value and a
Double object representing that value is created and returned. If s is null, then a
NullPointerException is thrown. Leading and trailing whitespace characters in s are
ignored. The rest of s should constitute a FloatValue as described by the lexical rule:

Method Detail

539

Overview (Codename One API)


where and are as defined in Section 3.10.2 of the . If it does not have the form of a ,
then a NumberFormatException is thrown. Otherwise, it is regarded as representing
an exact decimal value in the usual "computerized scientific notation"; this exact
decimal value is then conceptually converted to an "infinitely precise" binary value
that is then rounded to type double by the usual round-to-nearest rule of IEEE 754
floating-point arithmetic. Finally, a new object of class Double is created to represent
the double value.
Throws:
NumberFormatException

valueOf
public static Double valueOf(double i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance

Method Detail

540

Overview (Codename One API)


java.lang

Annotation Type Deprecated

@Documented
@Retention(value=RUNTIME)
public @interface

An annotation for marking an element as deprecated.


Since:
1.5

Annotation Type Deprecated

541

Overview (Codename One API)


java.lang

Interface Comparable<T>
All Known Implementing Classes:
ActionEvent.Type, BarChart.Type, DialRenderer.Type, ElementType, Enum, PointStyle,
RetentionPolicy, Validator.HighlightMode, XYMultipleSeriesRenderer.Orientation,
XYSeriesRenderer.FillOutsideLine.Type

public interface

This interface should be implemented by all classes that wish to define a natural order of their
instances. Collections.sort(java.util.List<T>) and java.util.Arrays#sort can then be used to
automatically sort lists of classes that implement this interface.
The order rule must be both transitive (if x.compareTo(y) < 0 and y.compareTo(z) < 0, then
x.compareTo(z) < 0 must hold) and invertible (the sign of the result of x.compareTo(y) must be equal
to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).
In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is
zero, then the result of x.equals(y) should be true.

Method Summary
Modifier and
Type

Method and Description


compareTo(T another)

Compares this object to the specified object to determine their relative


order.

int

Method Detail

compareTo
int compareTo(T another)

Compares this object to the specified object to determine their relative order.
Parameters:
another - the object to compare to this instance.
Returns:
a negative integer if this instance is less than another; a positive integer if
this instance is greater than another; 0 if this instance has the same order as
another.
Throws:
ClassCastException - if another cannot be converted into something
comparable to this instance.

Interface Comparable<T>

542

Overview (Codename One API)


java.lang

Interface Cloneable

public interface

This (empty) interface must be implemented by all classes that wish to support cloning. The
implementation of clone() in Object checks if the object being cloned implements this interface and
throws CloneNotSupportedException if it does not.
See Also:
Object#clone, CloneNotSupportedException

Method Detail

543

Overview (Codename One API)


java.lang

Class CloneNotSupportedException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.CloneNotSupportedException

public class
extends Exception

Thrown when a program attempts to clone an object which does not support the Cloneable interface.
See Also:
Cloneable

Constructor Summary
Constructor and Description
CloneNotSupportedException()
Constructs a new CloneNotSupportedException

that includes the current stack trace.

CloneNotSupportedException(String detailMessage)
Constructs a new CloneNotSupportedException with the

current stack trace and the

specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
CloneNotSupportedException
public CloneNotSupportedException()

Constructs a new CloneNotSupportedException that includes the current stack trace.


CloneNotSupportedException
public CloneNotSupportedException(String detailMessage)

Constructs a new CloneNotSupportedException with the current stack trace and the
specified detail message.
Parameters:
detailMessage - the detail message for this exception.

Interface Cloneable

544

Overview (Codename One API)


java.lang

Class ClassNotFoundException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.ClassNotFoundException

public class
extends Exception

Thrown when an application tries to load in a class through its string name using the forName method
in class Class but no definition for the class with the specified name could be found. Since: JDK1.0,
CLDC 1.0 See Also:Class.forName(java.lang.String)

Constructor Summary
Constructor and Description
ClassNotFoundException()

Constructs a ClassNotFoundException with no detail message.


ClassNotFoundException(String s)

Constructs a ClassNotFoundException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ClassNotFoundException
public ClassNotFoundException()

Constructs a ClassNotFoundException with no detail message.


ClassNotFoundException
public ClassNotFoundException(String s)

Constructs a ClassNotFoundException with the specified detail message. s - the


detail message.

Constructor Detail

545

Overview (Codename One API)


java.lang

Class ClassCastException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.ClassCastException

public class
extends RuntimeException

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an
instance. For example, the following code generates a ClassCastException: Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
ClassCastException()

Constructs a ClassCastException with no detail message.


ClassCastException(String s)

Constructs a ClassCastException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ClassCastException
public ClassCastException()

Constructs a ClassCastException with no detail message.


ClassCastException
public ClassCastException(String s)

Constructs a ClassCastException with the specified detail message. s - the detail


message.

Constructor Detail

546

Overview (Codename One API)


java.lang

Class Class<T>
java.lang.Object

java.lang.Class<T>

public final class


extends Object

Instances of the class Class represent classes and interfaces in a running Java application. Every
array also belongs to a class that is reflected as a Class object that is shared by all arrays with the
same element type and number of dimensions. Class has no public constructor. Instead Class objects
are constructed automatically by the Java Virtual Machine as classes are loaded. The following
example uses a Class object to print the class name of an object: Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
Class()

Method Summary
Modifier and
Type
Class
Object
boolean

Method and Description


asSubclass(Class superclass)

Replacement for Class.asSubclass(Class).


cast(Object object)

Replacement for Class.cast(Object).


desiredAssertionStatus()
forName(String className)

static Class

<T extends
Annotation>
T
Annotation[]

Deprecated.
don't use this method for anything important since class names are
obfuscated on the device!
getAnnotation(Class annotationType)

Returns this element's annotation for the specified type if such an


annotation is present, else null.
getAnnotations()

Returns all annotations present on this element.


getCanonicalName()

String

Annotation[]

Deprecated.
don't use this method for anything important since class names are
obfuscated on the device!
getDeclaredAnnotations()

Returns all annotations that are directly present on this element.


getName()

String

Deprecated.
don't use this method for anything important since class names are
obfuscated on the device!
getSimpleName()

String

Deprecated.
don't use this method for anything important since class names are
obfuscated on the device!

boolean

isAnnotation()

boolean

isAnnotationPresent(Class annotationType)

Constructor Detail

547

Overview (Codename One API)


Returns true if an annotation for the specified type is present on this
element, else false.
isAnonymousClass()

boolean

replacement for Class.isAnonymousClass()


isArray()

boolean

Determines if this Class object represents an array class.


isAssignableFrom(Class cls)

Determines if the class or interface represented by this Class object is


either the same as, or is a superclass or superinterface of, the class or
interface represented by the specified Class parameter.

boolean

isEnum()

boolean

Replacement for Class.isEnum().


isInstance(Object obj)

Determines if the specified Object is assignment-compatible with the object


represented by this Class.

boolean

isInterface()

boolean

Determines if the specified Class object represents an interface type.


isSynthetic()

boolean

replacement for Class.isSynthetic()


newInstance()

Object

Creates a new instance of a class.


toString()

String

Converts the object to a string.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Class
public Class()

Method Detail
forName
public static Class forName(String className)
throws ClassNotFoundException

Deprecated. don't use this method for anything important since class names are
obfuscated on the device!
Returns the Class object associated with the class with the given string name. Given
the fully-qualified name for a class or interface, this method attempts to locate, load
and link the class. For example, the following code fragment returns the runtime
Class descriptor for the class named java.lang.Thread: Classt=
Class.forName("java.lang.Thread")
Throws:
ClassNotFoundException

getName
public String getName()

Deprecated. don't use this method for anything important since class names are
obfuscated on the device!
Returns the fully-qualified name of the entity (class, interface, array class, primitive
type, or void) represented by this Class object, as a String. If this Class object
represents a class of arrays, then the internal form of the name consists of the name
of the element type in Java signature format, preceded by one or more "[" characters

Method Summary

548

Overview (Codename One API)


representing the depth of array nesting. Thus: (new Object[3]).getClass().getName()
returns "[Ljava.lang.Object;" and: (new int[3][4][5][6][7][8][9]).getClass().getName()
returns "[[[[[[[I". The encoding of element type names is as follows: B byte C char D
double F float I int J long L class or interface S short Z boolean The class or interface
name is given in fully qualified form as shown in the example above.
isArray
public boolean isArray()

Determines if this Class object represents an array class.


isAssignableFrom
public boolean isAssignableFrom(Class cls)

Determines if the class or interface represented by this Class object is either the
same as, or is a superclass or superinterface of, the class or interface represented by
the specified Class parameter. It returns true if so; otherwise it returns false. If this
Class object represents a primitive type, this method returns true if the specified
Class parameter is exactly this Class object; otherwise it returns false. Specifically,
this method tests whether the type represented by the specified Class parameter can
be converted to the type represented by this Class object via an identity conversion
or via a widening reference conversion. See The Java Language Specification,
sections 5.1.1 and 5.1.4 , for details.
isInstance
public boolean isInstance(Object obj)

Determines if the specified Object is assignment-compatible with the object


represented by this Class. This method is the dynamic equivalent of the Java
language instanceof operator. The method returns true if the specified Object
argument is non-null and can be cast to the reference type represented by this Class
object without raising a ClassCastException. It returns false otherwise. Specifically, if
this Class object represents a declared class, this method returns true if the specified
Object argument is an instance of the represented class (or of any of its subclasses);
it returns false otherwise. If this Class object represents an array class, this method
returns true if the specified Object argument can be converted to an object of the
array class by an identity conversion or by a widening reference conversion; it returns
false otherwise. If this Class object represents an interface, this method returns true if
the class or any superclass of the specified Object argument implements this
interface; it returns false otherwise. If this Class object represents a primitive type,
this method returns false.
isInterface
public boolean isInterface()

Determines if the specified Class object represents an interface type.


newInstance
public Object newInstance()
throws InstantiationException,
IllegalAccessException

Creates a new instance of a class.


Throws:
InstantiationException
IllegalAccessException

toString
public String toString()

Converts the object to a string. The string representation is the string "class" or
"interface", followed by a space, and then by the fully qualified name of the class in
the format returned by getName. If this Class object represents a primitive type, this
method returns the name of the primitive type. If this Class object represents void this
method returns "void".
Overrides:
toString in class Object

Method Detail

549

Overview (Codename One API)


isAnnotation
public boolean isAnnotation()

getAnnotation
public <T extends Annotation> T getAnnotation(Class annotationType)

Returns this element's annotation for the specified type if such an annotation is
present, else null.
getAnnotations
public Annotation[] getAnnotations()

Returns all annotations present on this element.


getDeclaredAnnotations
public Annotation[] getDeclaredAnnotations()

Returns all annotations that are directly present on this element.


isAnnotationPresent
public boolean isAnnotationPresent(Class annotationType)

Returns true if an annotation for the specified type is present on this element, else
false.
asSubclass
public Class asSubclass(Class superclass)

Replacement for Class.asSubclass(Class).


Parameters:
c - a Class
superclass - another Class which must be a superclass of c
Returns:
c
Throws:
ClassCastException - if c is
cast
public Object cast(Object object)

Replacement for Class.cast(Object). Throws a ClassCastException if obj is not an


instance of class c, or a subtype of c.
Parameters:
c - Class we want to cast obj to
object - object we want to cast
Returns:
The object, or null if the object is null.
Throws:
ClassCastException - if obj is not null or an instance of c
isEnum
public boolean isEnum()

Replacement for Class.isEnum().


Parameters:
class_ - class we want to test.
Returns:
true if the class was declared as an Enum.
isAnonymousClass
public boolean isAnonymousClass()

replacement for Class.isAnonymousClass()

Method Detail

550

Overview (Codename One API)


getSimpleName
public String getSimpleName()

Deprecated. don't use this method for anything important since class names are
obfuscated on the device!
isSynthetic
public boolean isSynthetic()

replacement for Class.isSynthetic()


getCanonicalName
public String getCanonicalName()

Deprecated. don't use this method for anything important since class names are
obfuscated on the device!
desiredAssertionStatus
public boolean desiredAssertionStatus()

Method Detail

551

Overview (Codename One API)


java.lang

Class Character
java.lang.Object

java.lang.Character

public final class


extends Object

The Character class wraps a value of the primitive type char in an object. An object of type Character
contains a single field whose type is char. In addition, this class provides several methods for
determining the type of a character and converting characters from uppercase to lowercase and vice
versa. Character information is based on the Unicode Standard, version 3.0. However, in order to
reduce footprint, by default the character property and case conversion operations in CLDC are
available only for the ISO Latin-1 range of characters. Other Unicode character blocks can be
supported as necessary. Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and
Type
static int

Field and Description


MAX_CODE_POINT

Maximum code point value - U+10FFFF.


MAX_HIGH_SURROGATE

static char

Maximum value of a high surrogate or leading surrogate unit in UTF-16


encoding - '?'.
MAX_LOW_SURROGATE

static char

static int
static char
static char
static int

Maximum value of a low surrogate or trailing surrogate unit in UTF-16


encoding - '?'.
MAX_RADIX

The maximum radix available for conversion to and from Strings.


MAX_SURROGATE

Maximum value of a surrogate unit in UTF-16 encoding - '?'.


MAX_VALUE

The constant value of this field is the largest value of type char.
MIN_CODE_POINT

Minimum code point value - U+0000.


MIN_HIGH_SURROGATE

static char

Minimum value of a high surrogate or leading surrogate unit in UTF-16


encoding - '?'.
MIN_LOW_SURROGATE

static char

static int
static int
static char
static char

Minimum value of a low surrogate or trailing surrogate unit in UTF-16


encoding - '?'.
MIN_RADIX

The minimum radix available for conversion to and from Strings.


MIN_SUPPLEMENTARY_CODE_POINT

Minimum value of a supplementary code point - U+010000.


MIN_SURROGATE

Minimum value of a surrogate unit in UTF-16 encoding - '?'.


MIN_VALUE

The constant value of this field is the smallest value of type char.
SIZE

static int

Class Character

Constant for the number of bits to represent a char in two's compliment


form.

552

Overview (Codename One API)


Constructor

Summary
Constructor and Description

Character(char value)

Constructs a Character object and initializes it so that it represents the primitive value
argument.

Method Summary
Modifier
and Type
static int

Method and Description


charCount(int codePoint)
Calculates the number of char

values required to represent the Unicode code

point.
char
static int

charValue()

Returns the value of this Character object.


codePointAt(char[] seq, int index)

Returns the code point at the index in the char[].

static int

codePointAt(char[] seq, int index, int limit)


Returns the code point at the index in the char[] that's

static int

codePointAt(CharSequence seq, int index)


Returns the code point at the index in the CharSequence.

static int

static int

static int

within the limit.

codePointBefore(char[] seq, int index)

Returns the Unicode code point that proceeds the index in the char[].
codePointBefore(char[] seq, int index, int start)
Returns the Unicode code point that proceeds the index
isn't less than start.

in the char[] and

codePointBefore(CharSequence seq, int index)

Returns the Unicode code point that proceeds the index in the CharSequence.
codePointCount(char[] seq, int offset, int count)

static int

Counts the number of Unicode code points in the subsequence of the char[],
as delineated by the offset and count.
codePointCount(CharSequence seq, int beginIndex, int endIndex)

static int

static int
boolean
int
static
boolean
static
boolean
static
boolean
static
boolean

Counts the number of Unicode code points in the subsequence of the


CharSequence, as delineated by the beginIndex and endIndex.
digit(char ch, int radix)

Returns the numeric value of the character ch in the specified radix.


equals(Object obj)

Compares this object against the specified object.


hashCode()

Returns a hash code for this Character.


isDigit(char ch)

Determines if the specified character is a digit.


isHighSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit


that's used for representing supplementary characters in UTF-16 encoding.
isLowerCase(char ch)

Determines if the specified character is a lowercase character.


isLowSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit


that's used for representing supplementary characters in UTF-16 encoding.

static
boolean

isSupplementaryCodePoint(int codePoint)
A test for determining if the codePoint is within

static
boolean

isSurrogatePair(char high, char low)


A test for determining if the char pair is a

Constructor Summary

the supplementary code point

range.
valid surrogate pair.

553

Overview (Codename One API)


static
boolean

isUpperCase(char ch)

static
boolean

isValidCodePoint(int codePoint)
A test for determining if the codePoint

static
boolean

isWhitespace(char c)
See isWhitespace(int).

static
boolean

isWhitespace(int codePoint)

Determines if the specified character is an uppercase character.


is a valid Unicode code point.

Returns true if the given code point is a Unicode whitespace character.

static int

offsetByCodePoints(char[] seq, int start, int count, int index,


int codePointOffset)
Determines the index into the char[] that is offset (measured in code points
and specified by codePointOffset), from the index argument and is within the
subsequence as delineated by start and count.

static int

offsetByCodePoints(CharSequence seq, int index, int codePointOffset)


Determines the index into the CharSequence that is offset (measured in code
points and specified by codePointOffset), from the index argument.

static char

reverseBytes(char c)

Reverse the order of the first and second bytes in character


toChars(int codePoint)

static
char[]

Converts the Unicode code point, codePoint, into a UTF-16 encoded


sequence that is returned as a char[].

static int

static int

toChars(int codePoint, char[] dst, int dstIndex)


Converts the Unicode code point, codePoint, into a UTF-16 encoded
sequence and copies the value(s) into the char[] dst, starting at the index
dstIndex.
toCodePoint(char high, char low)

Converts a surrogate pair into a Unicode code point.


toLowerCase(char ch)

static char

The given character is mapped to its lowercase equivalent; if the character


has no lowercase equivalent, the character itself is returned.
toString()

String

Returns a String object representing this character's value.


toUpperCase(char ch)

static char

Converts the character argument to uppercase; if the character has no


uppercase equivalent, the character itself is returned.

static
Character

valueOf(char i)

Returns the object instance of i

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
MAX_RADIX
public static final int MAX_RADIX

The maximum radix available for conversion to and from Strings. See
Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values
See Also:
Constant Field Values
MAX_VALUE
public static final char MAX_VALUE

The constant value of this field is the largest value of type char. Since: JDK1.0.2 See
Also:Constant Field Values
See Also:
Constant Field Values

Method Summary

554

Overview (Codename One API)


MIN_RADIX
public static final int MIN_RADIX

The minimum radix available for conversion to and from Strings. See
Also:Integer.toString(int, int), Integer.valueOf(java.lang.String), Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final char MIN_VALUE

The constant value of this field is the smallest value of type char. Since: JDK1.0.2
See Also:Constant Field Values
See Also:
Constant Field Values
MIN_HIGH_SURROGATE
public static final char MIN_HIGH_SURROGATE

Minimum value of a high surrogate or leading surrogate unit in UTF-16 encoding '?'.
Since:
1.5
See Also:
Constant Field Values
MAX_HIGH_SURROGATE
public static final char MAX_HIGH_SURROGATE

Maximum value of a high surrogate or leading surrogate unit in UTF-16 encoding '?'.
Since:
1.5
See Also:
Constant Field Values
MIN_LOW_SURROGATE
public static final char MIN_LOW_SURROGATE

Minimum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?'.
Since:
1.5
See Also:
Constant Field Values
MAX_LOW_SURROGATE
public static final char MAX_LOW_SURROGATE

Maximum value of a low surrogate or trailing surrogate unit in UTF-16 encoding - '?'.
Since:
1.5
See Also:
Constant Field Values
MIN_SURROGATE
public static final char MIN_SURROGATE

Minimum value of a surrogate unit in UTF-16 encoding - '?'.


Since:
1.5
See Also:
Constant Field Values

Field Detail

555

Overview (Codename One API)


MAX_SURROGATE
public static final char MAX_SURROGATE

Maximum value of a surrogate unit in UTF-16 encoding - '?'.


Since:
1.5
See Also:
Constant Field Values
MIN_SUPPLEMENTARY_CODE_POINT
public static final int MIN_SUPPLEMENTARY_CODE_POINT

Minimum value of a supplementary code point - U+010000.


Since:
1.5
See Also:
Constant Field Values
MIN_CODE_POINT
public static final int MIN_CODE_POINT

Minimum code point value - U+0000.


Since:
1.5
See Also:
Constant Field Values
MAX_CODE_POINT
public static final int MAX_CODE_POINT

Maximum code point value - U+10FFFF.


Since:
1.5
See Also:
Constant Field Values
SIZE
public static final int SIZE

Constant for the number of bits to represent a char in two's compliment form.
Since:
1.5
See Also:
Constant Field Values

Constructor Detail
Character
public Character(char value)

Constructs a Character object and initializes it so that it represents the primitive value
argument. value - value for the new Character object.

Method Detail

Field Detail

556

Overview (Codename One API)


charValue
public char charValue()

Returns the value of this Character object.


digit
public static int digit(char ch,
int radix)

Returns the numeric value of the character ch in the specified radix.


equals
public boolean equals(Object obj)

Compares this object against the specified object. The result is true if and only if the
argument is not null and is a Character object that represents the same char value as
this object.
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code for this Character.


Overrides:
hashCode in class Object
isDigit
public static boolean isDigit(char ch)

Determines if the specified character is a digit.


isLowerCase
public static boolean isLowerCase(char ch)

Determines if the specified character is a lowercase character. Note that by default


CLDC only supports the ISO Latin-1 range of characters. Of the ISO Latin-1
characters (character codes 0x0000 through 0x00FF), the following are lowercase: a
b c d e f g h i j k l m n o p q r s t u v w x y z u00DF u00E0 u00E1 u00E2 u00E3
u00E4 u00E5 u00E6 u00E7 u00E8 u00E9 u00EA u00EB u00EC u00ED u00EE
u00EF u00F0 u00F1 u00F2 u00F3 u00F4 u00F5 u00F6 u00F8 u00F9 u00FA u00FB
u00FC u00FD u00FE u00FF
isUpperCase
public static boolean isUpperCase(char ch)

Determines if the specified character is an uppercase character. Note that by default


CLDC only supports the ISO Latin-1 range of characters. Of the ISO Latin-1
characters (character codes 0x0000 through 0x00FF), the following are uppercase: A
B C D E F G H I J K L M N O P Q R S T U V W X Y Z u00C0 u00C1 u00C2 u00C3
u00C4 u00C5 u00C6 u00C7 u00C8 u00C9 u00CA u00CB u00CC u00CD u00CE
u00CF u00D0 u00D1 u00D2 u00D3 u00D4 u00D5 u00D6 u00D8 u00D9 u00DA
u00DB u00DC u00DD u00DE
toLowerCase
public static char toLowerCase(char ch)

The given character is mapped to its lowercase equivalent; if the character has no
lowercase equivalent, the character itself is returned. Note that by default CLDC only
supports the ISO Latin-1 range of characters.
toString
public String toString()

Returns a String object representing this character's value. Converts this Character
object to a string. The result is a string whose length is 1. The string's sole

Method Detail

557

Overview (Codename One API)


component is the primitive char value represented by this object.
Overrides:
toString in class Object
toUpperCase
public static char toUpperCase(char ch)

Converts the character argument to uppercase; if the character has no uppercase


equivalent, the character itself is returned. Note that by default CLDC only supports
the ISO Latin-1 range of characters.
isValidCodePoint
public static boolean isValidCodePoint(int codePoint)

A test for determining if the codePoint is a valid Unicode code point.


Parameters:
codePoint - The code point to test.
Returns:
A boolean value.
Since:
1.5
isSupplementaryCodePoint
public static boolean isSupplementaryCodePoint(int codePoint)

A test for determining if the codePoint is within the supplementary code point range.
Parameters:
codePoint - The code point to test.
Returns:
A boolean value.
Since:
1.5
isHighSurrogate
public static boolean isHighSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used
for representing supplementary characters in UTF-16 encoding.
Parameters:
ch - The char unit to test.
Returns:
A boolean value.
Since:
1.5
See Also:
isLowSurrogate(char)

isLowSurrogate
public static boolean isLowSurrogate(char ch)

A test for determining if the char is a high surrogate/leading surrogate unit that's used
for representing supplementary characters in UTF-16 encoding.
Parameters:
ch - The char unit to test.
Returns:
A boolean value.
Since:
1.5
See Also:
isHighSurrogate(char)

Method Detail

558

Overview (Codename One API)


isSurrogatePair
public static boolean isSurrogatePair(char high,
char low)

A test for determining if the char pair is a valid surrogate pair.


Parameters:
high - The high surrogate unit to test.
low - The low surrogate unit to test.

Returns:
A boolean value.
Since:
1.5
See Also:
isHighSurrogate(char), isLowSurrogate(char)

charCount
public static int charCount(int codePoint)

Calculates the number of char values required to represent the Unicode code point.
This method only tests if the codePoint is greater than or equal to 0x10000, in which
case 2 is returned, otherwise 1. To test if the code point is valid, use the
isValidCodePoint(int) method.
Parameters:
codePoint - The code point to test.
Returns:
An int value of 2 or 1.
Since:
1.5
See Also:
isValidCodePoint(int), isSupplementaryCodePoint(int)
toCodePoint
public static int toCodePoint(char high,
char low)

Converts a surrogate pair into a Unicode code point. This method assume that the
pair are valid surrogates. If the pair are NOT valid surrogates, then the result is
indeterminate. The isSurrogatePair(char, char) method should be used prior to
this method to validate the pair.
Parameters:
high - The high surrogate unit.
low - The low surrogate unit.

Returns:
The decoded code point.
Since:
1.5
See Also:
isSurrogatePair(char, char)

codePointAt
public static int codePointAt(CharSequence seq,
int index)

Returns the code point at the index in the CharSequence. If char unit at the index is a
high-surrogate unit, the next index is less than the length of the sequence and the
char unit at the next index is a low surrogate unit, then the code point represented by
the pair is returned; otherwise the char unit at the index is returned.
Parameters:
seq - The sequence of char units.
index - The index into the seq to retrieve and convert.
Returns:
The Unicode code point.

Method Detail

559

Overview (Codename One API)


Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the index
to seq.length().

is negative or greater than or equal

Since:
1.5
codePointAt
public static int codePointAt(char[] seq,
int index)

Returns the code point at the index in the char[]. If char unit at the index is a
high-surrogate unit, the next index is less than the length of the sequence and the
char unit at the next index is a low surrogate unit, then the code point represented by
the pair is returned; otherwise the char unit at the index is returned.
Parameters:
seq - The sequence of char units.
index - The index into the seq to retrieve and convert.
Returns:
The Unicode code point.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the index is negative or greater than or equal
to seq.length().
Since:
1.5
codePointAt
public static int codePointAt(char[] seq,
int index,
int limit)

Returns the code point at the index in the char[] that's within the limit. If char unit at
the index is a high-surrogate unit, the next index is less than the limit and the char
unit at the next index is a low surrogate unit, then the code point represented by the
pair is returned; otherwise the char unit at the index is returned.
Parameters:
seq - The sequence of char units.
index - The index into the seq to retrieve and convert.
limit - The exclusive index into the seq that marks the end of the units that
can be used.
Returns:
The Unicode code point.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if the index is negative, greater than or equal
to limit, limit is negative or limit is greater than the length of seq.
Since:
1.5
codePointBefore
public static int codePointBefore(CharSequence seq,
int index)

Returns the Unicode code point that proceeds the index in the CharSequence. If the
char unit at index - 1 is within the low surrogate range, the value index - 2 isn't
negative and the char unit at index - 2 is within the high surrogate range, then the
supplementary code point made up of the surrogate pair is returned; otherwise, the
char value at index - 1 is returned.
Parameters:
seq - The CharSequence to search.
index - The index into the seq.
Returns:
A Unicode code point.

Method Detail

560

Overview (Codename One API)


Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if index is
seq.length().

less than 1 or greater than

Since:
1.5
codePointBefore
public static int codePointBefore(char[] seq,
int index)

Returns the Unicode code point that proceeds the index in the char[]. If the char unit
at index - 1 is within the low surrogate range, the value index - 2 isn't negative and
the char unit at index - 2 is within the high surrogate range, then the supplementary
code point made up of the surrogate pair is returned; otherwise, the char value at
index - 1 is returned.
Parameters:
seq - The char[] to search.
index - The index into the seq.
Returns:
A Unicode code point.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if index is less than 1 or greater than
seq.length.
Since:
1.5
codePointBefore
public static int codePointBefore(char[] seq,
int index,
int start)

Returns the Unicode code point that proceeds the index in the char[] and isn't less
than start. If the char unit at index - 1 is within the low surrogate range, the value
index - 2 isn't less than start and the char unit at index - 2 is within the high
surrogate range, then the supplementary code point made up of the surrogate pair is
returned; otherwise, the char value at index - 1 is returned.
Parameters:
seq - The char[] to search.
index - The index into the seq.
Returns:
A Unicode code point.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if index is less than or equal to start, index is
greater than seq.length, start is not negative and start is greater than
seq.length.
Since:
1.5
toChars
public static int toChars(int codePoint,
char[] dst,
int dstIndex)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence and
copies the value(s) into the char[] dst, starting at the index dstIndex.
Parameters:
codePoint - The Unicode code point to encode.
dst - The char[] to copy the encoded value into.
dstIndex - The index to start copying into dst.

Returns:
The number of char value units copied into dst.

Method Detail

561

Overview (Codename One API)


Throws:
IllegalArgumentException - if codePoint is not a valid Unicode code point.
NullPointerException - if dst is null.
IndexOutOfBoundsException - if dstIndex is negative, greater than or equal to
dst.length or equals dst.length - 1 when codePoint is a supplementary
code point.

Since:
1.5
toChars
public static char[] toChars(int codePoint)

Converts the Unicode code point, codePoint, into a UTF-16 encoded sequence that
is returned as a char[].
Parameters:
codePoint - The Unicode code point to encode.
Returns:
The UTF-16 encoded char sequence; if code point is a supplementary code
point, then a 2 char array is returned, otherwise a 1 char array is returned.
Throws:
IllegalArgumentException - if codePoint is not a valid Unicode code point.
Since:
1.5
codePointCount
public static int codePointCount(CharSequence seq,
int beginIndex,
int endIndex)

Counts the number of Unicode code points in the subsequence of the CharSequence,
as delineated by the beginIndex and endIndex. Any surrogate values with missing
pair values will be counted as 1 code point.
Parameters:
seq - The CharSequence to look through.
beginIndex - The inclusive index to begin counting at.
endIndex - The exclusive index to stop counting at.
Returns:
The number of Unicode code points.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if beginIndex is negative, greater than
seq.length() or greater than endIndex.
Since:
1.5
codePointCount
public static int codePointCount(char[] seq,
int offset,
int count)

Counts the number of Unicode code points in the subsequence of the char[], as
delineated by the offset and count. Any surrogate values with missing pair values
will be counted as 1 code point.
Parameters:
seq - The char[] to look through.
offset - The inclusive index to begin counting at.
count - The number of char values to look through in seq.
Returns:
The number of Unicode code points.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if offset or count is negative or if endIndex is
greater than seq.length.
Since:

Method Detail

562

Overview (Codename One API)


1.5
offsetByCodePoints
public static int offsetByCodePoints(CharSequence seq,
int index,
int codePointOffset)

Determines the index into the CharSequence that is offset (measured in code points
and specified by codePointOffset), from the index argument.
Parameters:
seq - The CharSequence to find the index within.
index - The index to begin from, within the CharSequence.
codePointOffset - The number of code points to look back or forwards; may
be a negative or positive value.
Returns:
The calculated index that is codePointOffset code points from index.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if index is negative, greater than seq.length(),
there aren't enough values in seq after index or before index if
codePointOffset is negative.
Since:
1.5
offsetByCodePoints
public static int offsetByCodePoints(char[] seq,
int start,
int count,
int index,
int codePointOffset)

Determines the index into the char[] that is offset (measured in code points and
specified by codePointOffset), from the index argument and is within the
subsequence as delineated by start and count.
Parameters:
seq - The char[] to find the index within.
index - The index to begin from, within the char[].
codePointOffset - The number of code points to look back or forwards; may
be a negative or positive value.
start - The inclusive index that marks the beginning of the subsequence.
count - The number of char values to include within the subsequence.
Returns:
The calculated index that is codePointOffset code points from index.
Throws:
NullPointerException - if seq is null.
IndexOutOfBoundsException - if start or count is negative, start + count
greater than seq.length, index is less than start, index is greater than start
+ count or there aren't enough values in seq after index or before index if
codePointOffset is negative.
Since:
1.5
reverseBytes
public static char reverseBytes(char c)

Reverse the order of the first and second bytes in character


Parameters:
c - the character
Returns:
the character with reordered bytes.
valueOf
public static Character valueOf(char i)

Returns the object instance of i

Method Detail

563

Overview (Codename One API)


Parameters:
i - the primitive
Returns:
object instance
isWhitespace
public static boolean isWhitespace(char c)

See isWhitespace(int).
isWhitespace
public static boolean isWhitespace(int codePoint)

Returns true if the given code point is a Unicode whitespace character. The exact set
of characters considered as whitespace varies with Unicode version. Note that
non-breaking spaces are not considered whitespace. Note also that line separators
are considered whitespace; see #isSpaceChar for an alternative.

Method Detail

564

Overview (Codename One API)


java.lang

Interface CharSequence

public interface

This interface represents an ordered set of characters and defines the methods to probe them.

Method Summary
Modifier and
Type

Method and Description


charAt(int index)

Returns the character at the specified index, with the first character
having index zero.

char

length()

int

Returns the number of characters in this sequence.

CharSequence

subSequence(int start, int end)


Returns a CharSequence from the start

index (inclusive) to the end index

(exclusive) of this sequence.


toString()

Returns a string with the same characters in the same order as in this
sequence.

String

Method Detail
length
int length()

Returns the number of characters in this sequence.


Returns:
the number of characters.
charAt
char charAt(int index)

Returns the character at the specified index, with the first character having index
zero.
Parameters:
index - the index of the character to return.
Returns:
the requested character.
Throws:
IndexOutOfBoundsException - if index < 0 or index is greater than the length
of this sequence.
subSequence
CharSequence subSequence(int start,
int end)

Returns a CharSequence from the start index (inclusive) to the end index (exclusive)
of this sequence.
Parameters:
start - the start offset of the sub-sequence. It is inclusive, that is, the index of
the first character that is included in the sub-sequence.
end - the end offset of the sub-sequence. It is exclusive, that is, the index of
the first character after those that are included in the sub-sequence

Interface CharSequence

565

Overview (Codename One API)


Returns:
the requested sub-sequence.
Throws:
IndexOutOfBoundsException - if start < 0, end < 0, start > end, or if start
or end are greater than the length of this sequence.
toString
String toString()

Returns a string with the same characters in the same order as in this sequence.
Overrides:
toString in class Object
Returns:
a string based on this sequence.

Method Detail

566

Overview (Codename One API)


java.lang

Class Byte
java.lang.Object

java.lang.Byte

public final class


extends Object

The Byte class is the standard wrapper for byte values. Since: JDK1.1, CLDC 1.0

Field Summary
Modifier and Type

Field and Description


MAX_VALUE

static byte

The maximum value a Byte can have.


MIN_VALUE

static byte

The minimum value a Byte can have.

Constructor Summary
Constructor and Description
Byte(byte value)

Constructs a Byte object initialized to the specified byte value.

Method Summary
Modifier and
Type

Method and Description


byteValue()

byte

Returns the value of this Byte as a byte.

boolean

equals(Object obj)

Compares this object to the specified object.


hashCode()

int

Returns a hashcode for this Byte.


parseByte(String s)

static byte

Assuming the specified String represents a byte, returns that byte's


value.
parseByte(String s, int radix)

static byte

Assuming the specified String represents a byte, returns that byte's


value.
toString()

String

Returns a String object representing this Byte's value.

static Byte

valueOf(byte i)

Returns the object instance of i

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class Byte

567

Overview (Codename One API)


Field

Detail
MAX_VALUE
public static final byte MAX_VALUE

The maximum value a Byte can have. See Also:Constant Field Values
See Also:
Constant Field Values
MIN_VALUE
public static final byte MIN_VALUE

The minimum value a Byte can have. See Also:Constant Field Values
See Also:
Constant Field Values

Constructor Detail
Byte
public Byte(byte value)

Constructs a Byte object initialized to the specified byte value. value - the initial value
of the Byte

Method Detail
byteValue
public byte byteValue()

Returns the value of this Byte as a byte.


equals
public boolean equals(Object obj)

Compares this object to the specified object.


Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hashcode for this Byte.


Overrides:
hashCode in class Object
parseByte
public static byte parseByte(String s)
throws NumberFormatException

Assuming the specified String represents a byte, returns that byte's value. Throws an
exception if the String cannot be parsed as a byte. The radix is assumed to be 10.
Throws:
NumberFormatException

parseByte
public static byte parseByte(String s,
int radix)
throws NumberFormatException

Assuming the specified String represents a byte, returns that byte's value. Throws an
exception if the String cannot be parsed as a byte.

Field Detail

568

Overview (Codename One API)

Throws:
NumberFormatException

toString
public String toString()

Returns a String object representing this Byte's value.


Overrides:
toString in class Object
valueOf
public static Byte valueOf(byte i)

Returns the object instance of i


Parameters:
i - the primitive
Returns:
object instance

Method Detail

569

Overview (Codename One API)


java.lang

Class Boolean
java.lang.Object

java.lang.Boolean

public final class


extends Object

The Boolean class wraps a value of the primitive type boolean in an object. An object of type Boolean
contains a single field whose type is boolean. Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and Type
static Boolean
static Boolean

Field and Description


FALSE

The Boolean object corresponding to the primitive value false.


TRUE

The Boolean object corresponding to the primitive value true.

Constructor Summary
Constructor and Description
Boolean(boolean value)

Allocates a Boolean object representing the value argument.

Method Summary
Modifier and
Type
boolean
int

Method and Description


booleanValue()

Returns the value of this Boolean object as a boolean primitive.


compareTo(Boolean b2)
equals(Object obj)

boolean

Returns true if and only if the argument is not null and is a Boolean object
that represents the same boolean value as this object.
hashCode()

int

Returns a hash code for this Boolean object.

static
boolean

parseBoolean(String s)
toString()

String

Returns a String object representing this Boolean's value.

static
Boolean
static
Boolean

valueOf(boolean b)

Returns the object instance of i


valueOf(String b)

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class Boolean

570

Overview (Codename One API)


Field

Detail
FALSE
public static final Boolean FALSE

The Boolean object corresponding to the primitive value false.


TRUE
public static final Boolean TRUE

The Boolean object corresponding to the primitive value true.

Constructor Detail
Boolean
public Boolean(boolean value)

Allocates a Boolean object representing the value argument. value - the value of the
Boolean.

Method Detail
booleanValue
public boolean booleanValue()

Returns the value of this Boolean object as a boolean primitive.


equals
public boolean equals(Object obj)

Returns true if and only if the argument is not null and is a Boolean object that
represents the same boolean value as this object.
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code for this Boolean object.


Overrides:
hashCode in class Object
toString
public String toString()

Returns a String object representing this Boolean's value. If this object represents the
value true, a string equal to "true" is returned. Otherwise, a string equal to "false" is
returned.
Overrides:
toString in class Object
valueOf
public static Boolean valueOf(boolean b)

Returns the object instance of i


Parameters:
b - the primitive
Returns:
object instance

Field Detail

571

Overview (Codename One API)

valueOf
public static Boolean valueOf(String b)

parseBoolean
public static boolean parseBoolean(String s)

compareTo
public int compareTo(Boolean b2)

Method Detail

572

Overview (Codename One API)


java.lang

Interface AutoCloseable
All Known Subinterfaces:
DataInput, DataOutput
All Known Implementing Classes:
BufferedInputStream, BufferedOutputStream, ByteArrayInputStream,
ByteArrayOutputStream, CharArrayReader, DataInputStream, DataOutputStream,
DeflaterOutputStream, FilterInputStream, FilterOutputStream, GZIPInputStream,
GZIPOutputStream, InflaterInputStream, InputStream, InputStreamReader, OutputStream,
OutputStreamWriter, PrintStream, Reader, StringReader, TarInputStream, TarOutputStream,
Writer

public interface

Method Summary
Modifier and Type Method and Description
void

close()

Method Detail
close
void close()
throws Exception

Throws:
Exception

Interface AutoCloseable

573

Overview (Codename One API)


java.lang

Class AssertionError
java.lang.Object

java.lang.Throwable

java.lang.Error

java.lang.AssertionError

public class
extends Error

Constructor Summary
Constructor and Description
AssertionError()
AssertionError(boolean detailMessage)
AssertionError(char detailMessage)
AssertionError(double detailMessage)
AssertionError(float detailMessage)
AssertionError(int detailMessage)
AssertionError(long detailMessage)
AssertionError(Object detailMessage)
AssertionError(String detailMessage)
AssertionError(String message, Throwable cause)

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
AssertionError
public AssertionError()

AssertionError
public AssertionError(String detailMessage)

AssertionError
public AssertionError(Object detailMessage)

AssertionError
public AssertionError(boolean detailMessage)

Method Detail

574

Overview (Codename One API)


AssertionError
public AssertionError(char detailMessage)

AssertionError
public AssertionError(int detailMessage)

AssertionError
public AssertionError(long detailMessage)

AssertionError
public AssertionError(float detailMessage)

AssertionError
public AssertionError(double detailMessage)

AssertionError
public AssertionError(String message,
Throwable cause)

Constructor Detail

575

Overview (Codename One API)


java.lang

Class ArrayStoreException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.ArrayStoreException

public class
extends RuntimeException

Thrown to indicate that an attempt has been made to store the wrong type of object into an array of
objects. For example, the following code generates an ArrayStoreException: Since: JDK1.0, CLDC
1.0

Constructor Summary
Constructor and Description
ArrayStoreException()

Constructs an ArrayStoreException with no detail message.


ArrayStoreException(String s)

Constructs an ArrayStoreException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ArrayStoreException
public ArrayStoreException()

Constructs an ArrayStoreException with no detail message.


ArrayStoreException
public ArrayStoreException(String s)

Constructs an ArrayStoreException with the specified detail message. s - the detail


message.

Class ArrayStoreException

576

Overview (Codename One API)


java.lang

Class ArrayIndexOutOfBoundsException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.IndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException

public class
extends IndexOutOfBoundsException

Thrown to indicate that an array has been accessed with an illegal index. The index is either negative
or greater than or equal to the size of the array. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
ArrayIndexOutOfBoundsException()

Constructs an ArrayIndexOutOfBoundsException with no detail message.


ArrayIndexOutOfBoundsException(int index)

Constructs a new ArrayIndexOutOfBoundsException class with an argument indicating the


illegal index.
ArrayIndexOutOfBoundsException(String s)

Constructs an ArrayIndexOutOfBoundsException class with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ArrayIndexOutOfBoundsException
public ArrayIndexOutOfBoundsException()

Constructs an ArrayIndexOutOfBoundsException with no detail message.


ArrayIndexOutOfBoundsException
public ArrayIndexOutOfBoundsException(int index)

Constructs a new ArrayIndexOutOfBoundsException class with an argument


indicating the illegal index. index - the illegal index.
ArrayIndexOutOfBoundsException
public ArrayIndexOutOfBoundsException(String s)

Constructs an ArrayIndexOutOfBoundsException class with the specified detail


message. s - the detail message.

Constructor Detail

577

Overview (Codename One API)


java.lang

Class ArithmeticException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

java.lang.ArithmeticException

public class
extends RuntimeException

Thrown when an exceptional arithmetic condition has occurred. For example, an integer "divide by
zero" throws an instance of this class. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
ArithmeticException()

Constructs an ArithmeticException with no detail message.


ArithmeticException(String s)

Constructs an ArithmeticException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ArithmeticException
public ArithmeticException()

Constructs an ArithmeticException with no detail message.


ArithmeticException
public ArithmeticException(String s)

Constructs an ArithmeticException with the specified detail message. s - the detail


message.

Constructor Detail

578

Overview (Codename One API)


java.lang

Interface Appendable

public interface

Declares methods to append characters or character sequences. Any class that implements this
interface can receive data formatted by a java.util.Formatter. The appended character or character
sequence should be valid according to the rules described in Unicode Character Representation.
Appendable

itself does not guarantee thread safety. This responsibility is up to the implementing class.

Implementing classes can choose different exception handling mechanism. They can choose to throw
exceptions other than IOException or they do not throw any exceptions at all and use error codes
instead.

Method Summary
Modifier and Type
Appendable
Appendable
Appendable

Method and Description


append(char c)

Appends the specified character.


append(CharSequence csq)

Appends the character sequence csq.


append(CharSequence csq, int start, int end)
Appends a subsequence of csq.

Method Detail
append
Appendable append(char c)
throws IOException

Appends the specified character.


Parameters:
c - the character to append.
Returns:
this Appendable.
Throws:
IOException - if an I/O error occurs.
append
Appendable append(CharSequence csq)
throws IOException

Appends the character sequence csq. Implementation classes may not append the
whole sequence, for example if the target is a buffer with limited size.
If csq is null, the characters "null" are appended.
Parameters:
csq - the character sequence to append.
Returns:
this Appendable.
Throws:
IOException - if an I/O error occurs.

Constructor Detail

579

Overview (Codename One API)


append
Appendable append(CharSequence csq,
int start,
int end)
throws IOException

Appends a subsequence of csq.


If csq is not null then calling this method is equivalent to calling
append(csq.subSequence(start, end)).
If csq is null, the characters "null" are appended.
Parameters:
csq - the character sequence to append.
start - the first index of the subsequence of csq that is appended.
end - the last index of the subsequence of csq that is appended.
Returns:
this Appendable.
Throws:
IndexOutOfBoundsException - if start < 0, end < 0, start > end or end is
greater than the length of csq.
IOException - if an I/O error occurs.

Method Detail

580

Overview (Codename One API)


java.io

Class Writer
java.lang.Object

java.io.Writer
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
OutputStreamWriter

public abstract class


extends Object
implements AutoCloseable

Abstract class for writing to character streams. The only methods that a subclass must implement are
write(char[], int, int), flush(), and close(). Most subclasses, however, will override some of the methods
defined here in order to provide higher efficiency, additional functionality, or both. Since: JDK1.1,
CLDC 1.0 See Also:OutputStreamWriter, Reader

Field Summary
Modifier and Type
protected Object

Field and Description


lock

The object used to synchronize operations on this stream.

Constructor Summary
Modifier

Constructor and Description


Writer()

protected

Create a new character-stream writer whose critical sections will synchronize on


the writer itself.
Writer(Object lock)

protected

Create a new character-stream writer whose critical sections will synchronize on


the given object.

Method Summary
Modifier and Type
abstract void
abstract void
void
abstract void
void
void
void

Class Writer

Method and Description


close()

Close the stream, flushing it first.


flush()

Flush the stream.


write(char[] cbuf)

Write an array of characters.


write(char[] cbuf, int off, int len)

Write a portion of an array of characters.


write(int c)

Write a single character.


write(String str)

Write a string.
write(String str, int off, int len)

Write a portion of a string.

581

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
lock
protected Object lock

The object used to synchronize operations on this stream. For efficiency, a


character-stream object may use an object other than itself to protect critical sections.
A subclass should therefore use the object in this field rather than this or a
synchronized method.

Constructor Detail
Writer
protected Writer()

Create a new character-stream writer whose critical sections will synchronize on the
writer itself.
Writer
protected Writer(Object lock)

Create a new character-stream writer whose critical sections will synchronize on the
given object. lock - Object to synchronize on.

Method Detail
close
public abstract void close()
throws IOException

Close the stream, flushing it first. Once a stream has been closed, further write() or
flush() invocations will cause an IOException to be thrown. Closing a
previously-closed stream, however, has no effect.
Specified by:
close in interface AutoCloseable
Throws:
IOException

flush
public abstract void flush()
throws IOException

Flush the stream. If the stream has saved any characters from the various write()
methods in a buffer, write them immediately to their intended destination. Then, if that
destination is another character or byte stream, flush it. Thus one flush() invocation
will flush all the buffers in a chain of Writers and OutputStreams.
Throws:
IOException

write
public void write(char[] cbuf)
throws IOException

Write an array of characters.


Throws:
IOException

Methods inherited from class java.lang.Object

582

Overview (Codename One API)


write
public abstract void write(char[] cbuf,
int off,
int len)
throws IOException

Write a portion of an array of characters.


Throws:
IOException

write
public void write(int c)
throws IOException

Write a single character. The character to be written is contained in the 16 low-order


bits of the given integer value; the 16 high-order bits are ignored. Subclasses that
intend to support efficient single-character output should override this method.
Throws:
IOException

write
public void write(String str)
throws IOException

Write a string.
Throws:
IOException

write
public void write(String str,
int off,
int len)
throws IOException

Write a portion of a string.


Throws:
IOException

Method Detail

583

Overview (Codename One API)


java.io

Class UnsupportedEncodingException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException

java.io.UnsupportedEncodingException

public class
extends IOException

The Character Encoding is not supported. Since: JDK1.1, CLDC 1.0

Constructor Summary
Constructor and Description
UnsupportedEncodingException()

Constructs an UnsupportedEncodingException without a detail message.


UnsupportedEncodingException(String s)

Constructs an UnsupportedEncodingException with a detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
UnsupportedEncodingException
public UnsupportedEncodingException()

Constructs an UnsupportedEncodingException without a detail message.


UnsupportedEncodingException
public UnsupportedEncodingException(String s)

Constructs an UnsupportedEncodingException with a detail message. s - Describes


the reason for the exception.

Class UnsupportedEncodingException

584

Overview (Codename One API)


java.io

Class UTFDataFormatException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException

java.io.UTFDataFormatException

public class
extends IOException

Signals that a malformed UTF-8 string has been read in a data input stream or by any class that
implements the data input interface. See the writeUTF method for the format in which UTF-8 strings
are read and written. Since: JDK1.0, CLDC 1.0 See Also:DataInput,
DataInputStream.readUTF(java.io.DataInput), IOException

Constructor Summary
Constructor and Description
UTFDataFormatException()

Constructs a UTFDataFormatException with null as its error detail message.


UTFDataFormatException(String s)

Constructs a UTFDataFormatException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
UTFDataFormatException
public UTFDataFormatException()

Constructs a UTFDataFormatException with null as its error detail message.


UTFDataFormatException
public UTFDataFormatException(String s)

Constructs a UTFDataFormatException with the specified detail message. The string


s can be retrieved later by the method of class java.lang.Throwable. s - the detail
message.

Constructor Detail

585

Overview (Codename One API)


java.io

Interface Serializable

public interface

Here to simplify porting, won't actually work...

Constructor Detail

586

Overview (Codename One API)


java.io

Class Reader
java.lang.Object

java.io.Reader
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
CharArrayReader, InputStreamReader, StringReader

public abstract class


extends Object
implements AutoCloseable

Abstract class for reading character streams. The only methods that a subclass must implement are
read(char[], int, int) and close(). Most subclasses, however, will override some of the methods defined
here in order to provide higher efficiency, additional functionality, or both. Since: JDK1.1, CLDC 1.0
See Also:InputStreamReader, Writer

Field Summary
Modifier and Type
protected Object

Field and Description


lock

The object used to synchronize operations on this stream.

Constructor Summary
Modifier

Constructor and Description


Reader()

protected

Create a new character-stream reader whose critical sections will synchronize on


the reader itself.
Reader(Object lock)

protected

Create a new character-stream reader whose critical sections will synchronize on


the given object.

Method Summary
Modifier and Type
abstract void
void
boolean
int
int
abstract int
boolean
void

Interface Serializable

Method and Description


close()

Close the stream.


mark(int readAheadLimit)

Mark the present position in the stream.


markSupported()

Tell whether this stream supports the mark() operation.


read()

Read a single character.


read(char[] cbuf)

Read characters into an array.


read(char[] cbuf, int off, int len)

Read characters into a portion of an array.


ready()

Tell whether this stream is ready to be read.


reset()

Reset the stream.

587

Overview (Codename One API)


skip(long n)

long

Skip characters.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
lock
protected Object lock

The object used to synchronize operations on this stream. For efficiency, a


character-stream object may use an object other than itself to protect critical sections.
A subclass should therefore use the object in this field rather than this or a
synchronized method.

Constructor Detail
Reader
protected Reader()

Create a new character-stream reader whose critical sections will synchronize on the
reader itself.
Reader
protected Reader(Object lock)

Create a new character-stream reader whose critical sections will synchronize on the
given object. lock - The Object to synchronize on.

Method Detail
close
public abstract void close()
throws IOException

Close the stream. Once a stream has been closed, further read(), ready(), mark(), or
reset() invocations will throw an IOException. Closing a previously-closed stream,
however, has no effect.
Specified by:
close in interface AutoCloseable
Throws:
IOException

mark
public void mark(int readAheadLimit)
throws IOException

Mark the present position in the stream. Subsequent calls to reset() will attempt to
reposition the stream to this point. Not all character-input streams support the mark()
operation.
Throws:
IOException

markSupported
public boolean markSupported()

Method Summary

588

Overview (Codename One API)


Tell whether this stream supports the mark() operation. The default implementation
always returns false. Subclasses should override this method.
read
public int read()
throws IOException

Read a single character. This method will block until a character is available, an I/O
error occurs, or the end of the stream is reached. Subclasses that intend to support
efficient single-character input should override this method.
Throws:
IOException

read
public int read(char[] cbuf)
throws IOException

Read characters into an array. This method will block until some input is available, an
I/O error occurs, or the end of the stream is reached.
Throws:
IOException

read
public abstract int read(char[] cbuf,
int off,
int len)
throws IOException

Read characters into a portion of an array. This method will block until some input is
available, an I/O error occurs, or the end of the stream is reached.
Throws:
IOException

ready
public boolean ready()
throws IOException

Tell whether this stream is ready to be read.


Throws:
IOException

reset
public void reset()
throws IOException

Reset the stream. If the stream has been marked, then attempt to reposition it at the
mark. If the stream has not been marked, then attempt to reset it in some way
appropriate to the particular stream, for example by repositioning it to its starting
point. Not all character-input streams support the reset() operation, and some support
reset() without supporting mark().
Throws:
IOException

skip
public long skip(long n)
throws IOException

Skip characters. This method will block until some characters are available, an I/O
error occurs, or the end of the stream is reached.
Throws:
IOException

Method Detail

589

Overview (Codename One API)


java.io

Class PrintStream
java.lang.Object

java.io.OutputStream

java.io.PrintStream
All Implemented Interfaces:
AutoCloseable

public class
extends OutputStream

A PrintStream adds functionality to another output stream, namely the ability to print representations
of various data values conveniently. Two other features are provided as well. Unlike other output
streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an
internal flag that can be tested via the checkError method. All characters printed by a PrintStream are
converted into bytes using the platform's default character encoding. Since: JDK1.0, CLDC 1.0

Constructor Summary
Constructor and Description
PrintStream(OutputStream out)

Create a new print stream.

Method Summary
Modifier and
Type
boolean
void
void
void
void
void
void
void
void
void
void
void
void

Class PrintStream

Method and Description


checkError()

Flush the stream and check its error state.


close()

Close the stream.


flush()

Flush the stream.


print(boolean b)

Print a boolean value.


print(char c)

Print an array of characters.


print(double d)

Print a double-precision floating point number.


print(float f)

Print a floating point number.


print(int i)

Print an integer.
print(long l)

Print a long integer.


print(Object obj)

Print an object.
print(String s)

Print a string.
println()

Terminate the current line by writing the line separator string.


println(boolean x)

Print a boolean and then terminate the line.

590

Overview (Codename One API)


println(char x)

void

Print an array of characters and then terminate the line.


println(double x)

void

Print a double and then terminate the line.


println(float x)

void

Print a float and then terminate the line.


println(int x)

void

Print an integer and then terminate the line.


println(long x)

void

Print a long and then terminate the line.


println(Object x)

void

Print an Object and then terminate the line.


println(String x)

void

Print a String and then terminate the line.

protected void

setError()

Set the error state of the stream to true.


write(byte[] buf, int off, int len)

Write len bytes from the specified byte array starting at offset off to this
stream.

void

write(int b)

void

Write the specified byte to this stream.

Methods inherited from class java.io.OutputStream


write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
PrintStream
public PrintStream(OutputStream out)

Create a new print stream. This stream will not flush automatically. out - The output
stream to which values and objects will be printed

Method Detail
checkError
public boolean checkError()

Flush the stream and check its error state. The internal error state is set to true when
the underlying output stream throws an IOException, and when the setError method
is invoked.
close
public void close()

Close the stream. This is done by flushing the stream and then closing the underlying
output stream.
Specified by:
close in interface AutoCloseable
Overrides:
close in class OutputStream

Method Summary

591

Overview (Codename One API)


flush
public void flush()

Flush the stream. This is done by writing any buffered output bytes to the underlying
output stream and then flushing that stream.
Overrides:
flush in class OutputStream
print
public void print(boolean b)

Print a boolean value. The string produced by is translated into bytes according to the
platform's default character encoding, and these bytes are written in exactly the
manner of the method.
print
public void print(char c)

Print an array of characters. The characters are converted into bytes according to the
platform's default character encoding, and these bytes are written in exactly the
manner of the method.
print
public void print(double d)

Print a double-precision floating point number. The string produced by is translated


into bytes according to the platform's default character encoding, and these bytes are
written in exactly the manner of the method.
print
public void print(float f)

Print a floating point number. The string produced by is translated into bytes
according to the platform's default character encoding, and these bytes are written in
exactly the manner of the method.
print
public void print(int i)

Print an integer. The string produced by is translated into bytes according to the
platform's default character encoding, and these bytes are written in exactly the
manner of the method.
print
public void print(long l)

Print a long integer. The string produced by is translated into bytes according to the
platform's default character encoding, and these bytes are written in exactly the
manner of the method.
print
public void print(Object obj)

Print an object. The string produced by the method is translated into bytes according
to the platform's default character encoding, and these bytes are written in exactly the
manner of the method.
print
public void print(String s)

Print a string. If the argument is null then the string "null" is printed. Otherwise, the
string's characters are converted into bytes according to the platform's default
character encoding, and these bytes are written in exactly the manner of the method.

Method Detail

592

Overview (Codename One API)


println
public void println()

Terminate the current line by writing the line separator string. The line separator
string is defined by the system property line.separator, and is not necessarily a single
newline character ('\n').
println
public void println(boolean x)

Print a boolean and then terminate the line. This method behaves as though it
invokes and then .
println
public void println(char x)

Print an array of characters and then terminate the line. This method behaves as
though it invokes and then .
println
public void println(double x)

Print a double and then terminate the line. This method behaves as though it invokes
and then .
println
public void println(float x)

Print a float and then terminate the line. This method behaves as though it invokes
and then .
println
public void println(int x)

Print an integer and then terminate the line. This method behaves as though it
invokes and then .
println
public void println(long x)

Print a long and then terminate the line. This method behaves as though it invokes
and then .
println
public void println(Object x)

Print an Object and then terminate the line. This method behaves as though it
invokes and then .
println
public void println(String x)

Print a String and then terminate the line. This method behaves as though it invokes
and then .
setError
protected void setError()

Set the error state of the stream to true.


write
public void write(byte[] buf,
int off,
int len)

Write len bytes from the specified byte array starting at offset off to this stream. Note
that the bytes will be written as given; to write characters that will be translated

Method Detail

593

Overview (Codename One API)


according to the platform's default character encoding, use the print(char) or
println(char) methods.
Overrides:
write in class OutputStream
write
public void write(int b)

Write the specified byte to this stream. Note that the byte is written as given; to write
a character that will be translated according to the platform's default character
encoding, use the print(char) or println(char) methods.
Specified by:
write in class OutputStream

Method Detail

594

Overview (Codename One API)


java.io

Class OutputStreamWriter
java.lang.Object

java.io.Writer

java.io.OutputStreamWriter
All Implemented Interfaces:
AutoCloseable

public class
extends Writer

An OutputStreamWriter is a bridge from character streams to byte streams: Characters written to it


are translated into bytes. The encoding that it uses may be specified by name, or the platform's
default encoding may be accepted. Each invocation of a write() method causes the encoding
converter to be invoked on the given character(s). The resulting bytes are accumulated in a buffer
before being written to the underlying output stream. The size of this buffer may be specified, but by
default it is large enough for most purposes. Note that the characters passed to the write() methods
are not buffered. Since: CLDC 1.0 See Also:Writer, UnsupportedEncodingException

Field Summary

Fields inherited from class java.io.Writer


lock

Constructor Summary
Constructor and Description
OutputStreamWriter(OutputStream os)

Create an OutputStreamWriter that uses the default character encoding.


OutputStreamWriter(OutputStream os, String enc)

Create an OutputStreamWriter that uses the named character encoding.

Method Summary
Modifier and Type

Method and Description


close()

void

Close the stream.


flush()

void

Flush the stream.


write(char[] cbuf, int off, int len)

void

Write a portion of an array of characters.


write(int c)

void

Write a single character.


write(String str, int off, int len)

void

Write a portion of a string.

Methods inherited from class java.io.Writer


write, write

Class OutputStreamWriter

595

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
OutputStreamWriter
public OutputStreamWriter(OutputStream os)

Create an OutputStreamWriter that uses the default character encoding. os - An


OutputStream
OutputStreamWriter
public OutputStreamWriter(OutputStream os,
String enc)
throws UnsupportedEncodingException

Create an OutputStreamWriter that uses the named character encoding. os - An


OutputStreamenc - The name of a supported - If the named encoding is not
supported
Throws:
UnsupportedEncodingException

Method Detail
close
public void close()
throws IOException

Close the stream.


Specified by:
close in interface AutoCloseable
Specified by:
close in class Writer
Throws:
IOException

flush
public void flush()
throws IOException

Flush the stream.


Specified by:
flush in class Writer
Throws:
IOException

write
public void write(char[] cbuf,
int off,
int len)
throws IOException

Write a portion of an array of characters.


Specified by:
write in class Writer
Throws:
IOException

write
public void write(int c)
throws IOException

Methods inherited from class java.lang.Object

596

Overview (Codename One API)


Write a single character.
Overrides:
write in class Writer
Throws:
IOException

write
public void write(String str,
int off,
int len)
throws IOException

Write a portion of a string.


Overrides:
write in class Writer
Throws:
IOException

Method Detail

597

Overview (Codename One API)


java.io

Class OutputStream
java.lang.Object

java.io.OutputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
BufferedOutputStream, ByteArrayOutputStream, DataOutputStream, FilterOutputStream,
PrintStream

public abstract class


extends Object
implements AutoCloseable

This abstract class is the superclass of all classes representing an output stream of bytes. An output
stream accepts output bytes and sends them to some sink. Applications that need to define a
subclass of OutputStream must always provide at least a method that writes one byte of output.
Since: JDK1.0, CLDC 1.0 See Also:ByteArrayOutputStream, DataOutputStream, InputStream,
write(int)

Constructor Summary
Constructor and Description
OutputStream()

Method Summary
Modifier and
Type

Method and Description


close()

Closes this output stream and releases any system resources associated
with this stream.

void

flush()

Flushes this output stream and forces any buffered output bytes to be
written out.

void

write(byte[] b)

void

Writes b.length bytes from the specified byte array to this output stream.
write(byte[] b, int off, int len)

Writes len bytes from the specified byte array starting at offset off to this
output stream.

void

abstract void

write(int b)

Writes the specified byte to this output stream.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class OutputStream

598

Overview (Codename One API)


OutputStream
public OutputStream()

Method Detail
close
public void close()
throws IOException

Closes this output stream and releases any system resources associated with this
stream. The general contract of close is that it closes the output stream. A closed
stream cannot perform output operations and cannot be reopened. The close method
of OutputStream does nothing.
Specified by:
close in interface AutoCloseable
Throws:
IOException

flush
public void flush()
throws IOException

Flushes this output stream and forces any buffered output bytes to be written out.
The general contract of flush is that calling it is an indication that, if any bytes
previously written have been buffered by the implementation of the output stream,
such bytes should immediately be written to their intended destination. The flush
method of OutputStream does nothing.
Throws:
IOException

write
public void write(byte[] b)
throws IOException

Writes b.length bytes from the specified byte array to this output stream. The general
contract for write(b) is that it should have exactly the same effect as the call write(b,
0, b.length).
Throws:
IOException

write
public void write(byte[] b,
int off,
int len)
throws IOException

Writes len bytes from the specified byte array starting at offset off to this output
stream. The general contract for write(b, off, len) is that some of the bytes in the array
b are written to the output stream in order; element b[off] is the first byte written and
b[off+len-1] is the last byte written by this operation. The write method of
OutputStream calls the write method of one argument on each of the bytes to be
written out. Subclasses are encouraged to override this method and provide a more
efficient implementation. If b is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array b, then
an IndexOutOfBoundsException is thrown.
Throws:
IOException

write
public abstract void write(int b)
throws IOException

Writes the specified byte to this output stream. The general contract for write is that
one byte is written to the output stream. The byte to be written is the eight low-order
bits of the argument b. The 24 high-order bits of b are ignored. Subclasses of

Constructor Detail

599

Overview (Codename One API)


OutputStream must provide an implementation for this method.
Throws:
IOException

Method Detail

600

Overview (Codename One API)


java.io

Class InterruptedIOException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException

java.io.InterruptedIOException

public class
extends IOException

Signals that an I/O operation has been interrupted. An InterruptedIOException is thrown to indicate
that an input or output transfer has been terminated because the thread performing it was terminated.
The field bytesTransferred indicates how many bytes were successfully transferred before the
interruption occurred. Since: JDK1.0, CLDC 1.0 See Also:InputStream, OutputStream

Field Summary
Modifier and
Type

Field and Description


bytesTransferred

Reports how many bytes had been transferred as part of the I/O operation
before it was interrupted.

int

Constructor Summary
Constructor and Description
InterruptedIOException()

Constructs an InterruptedIOException with null as its error detail message.


InterruptedIOException(String s)

Constructs an InterruptedIOException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
bytesTransferred
public int bytesTransferred

Reports how many bytes had been transferred as part of the I/O operation before it
was interrupted.

Class InterruptedIOException

601

Overview (Codename One API)


Constructor

Detail

InterruptedIOException
public InterruptedIOException()

Constructs an InterruptedIOException with null as its error detail message.


InterruptedIOException
public InterruptedIOException(String s)

Constructs an InterruptedIOException with the specified detail message. The string s


can be retrieved later by the method of class java.lang.Throwable. s - the detail
message.

Constructor Detail

602

Overview (Codename One API)


java.io

Class InputStreamReader
java.lang.Object

java.io.Reader

java.io.InputStreamReader
All Implemented Interfaces:
AutoCloseable

public class
extends Reader

An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and
translates them into characters. The encoding that it uses may be specified by name, or the platform's
default encoding may be accepted. Each invocation of one of an InputStreamReader's read()
methods may cause one or more bytes to be read from the underlying byte input stream. To enable
the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying
stream than are necessary to satisfy the current read operation. Since: CLDC 1.0 See Also:Reader,
UnsupportedEncodingException

Field Summary

Fields inherited from class java.io.Reader


lock

Constructor Summary
Constructor and Description
InputStreamReader(InputStream is)

Create an InputStreamReader that uses the default character encoding.


InputStreamReader(InputStream is, String enc)

Create an InputStreamReader that uses the named character encoding.

Method Summary
Modifier and Type
void
void
boolean
int
int
boolean
void
long

Class InputStreamReader

Method and Description


close()

Close the stream.


mark(int readAheadLimit)

Mark the present position in the stream.


markSupported()

Tell whether this stream supports the mark() operation.


read()

Read a single character.


read(char[] cbuf, int off, int len)

Read characters into a portion of an array.


ready()

Tell whether this stream is ready to be read.


reset()

Reset the stream.


skip(long n)

Skip characters.

603

Overview (Codename One API)


Methods

inherited from class java.io.Reader

read

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
InputStreamReader
public InputStreamReader(InputStream is)

Create an InputStreamReader that uses the default character encoding. is - An


InputStream
InputStreamReader
public InputStreamReader(InputStream is,
String enc)
throws UnsupportedEncodingException

Create an InputStreamReader that uses the named character encoding. is - An


InputStreamenc - The name of a supported character encoding - If the named
encoding is not supported
Throws:
UnsupportedEncodingException

Method Detail
close
public void close()
throws IOException

Close the stream. Closing a previously closed stream has no effect.


Specified by:
close in interface AutoCloseable
Specified by:
close in class Reader
Throws:
IOException

mark
public void mark(int readAheadLimit)
throws IOException

Mark the present position in the stream.


Overrides:
mark in class Reader
Throws:
IOException

markSupported
public boolean markSupported()

Tell whether this stream supports the mark() operation.


Overrides:
markSupported in class Reader
read
public int read()
throws IOException

Methods inherited from class java.io.Reader

604

Overview (Codename One API)


Read a single character.
Overrides:
read in class Reader
Throws:
IOException

read
public int read(char[] cbuf,
int off,
int len)
throws IOException

Read characters into a portion of an array.


Specified by:
read in class Reader
Throws:
IOException

ready
public boolean ready()
throws IOException

Tell whether this stream is ready to be read.


Overrides:
ready in class Reader
Throws:
IOException

reset
public void reset()
throws IOException

Reset the stream.


Overrides:
reset in class Reader
Throws:
IOException

skip
public long skip(long n)
throws IOException

Skip characters.
Overrides:
skip in class Reader
Throws:
IOException

Method Detail

605

Overview (Codename One API)


java.io

Class InputStream
java.lang.Object

java.io.InputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
BufferedInputStream, ByteArrayInputStream, DataInputStream, FilterInputStream

public abstract class


extends Object
implements AutoCloseable

This abstract class is the superclass of all classes representing an input stream of bytes. Applications
that need to define a subclass of InputStream must always provide a method that returns the next
byte of input. Since: JDK1.0, CLDC 1.0 See Also:ByteArrayInputStream, DataInputStream, read(),
OutputStream

Constructor Summary
Constructor and Description
InputStream()

Method Summary
Modifier and
Type

Method and Description


available()

Returns the number of bytes that can be read (or skipped over) from this input
stream without blocking by the next caller of a method for this input stream.

int

close()

Closes this input stream and releases any system resources associated with
the stream.

void

mark(int readlimit)

void

Marks the current position in this input stream.

boolean
abstract
int

markSupported()

Tests if this input stream supports the mark and reset methods.
read()

Reads the next byte of data from the input stream.


read(byte[] b)

Reads some number of bytes from the input stream and stores them into the
buffer array b.

int

read(byte[] b, int off, int len)

int

Reads up to len bytes of data from the input stream into an array of bytes.
reset()

Repositions this stream to the position at the time the mark method was last
called on this input stream.

void

skip(long n)

long

Skips over and discards n bytes of data from this input stream.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class InputStream

606

Overview (Codename One API)


Constructor

Detail

InputStream
public InputStream()

Method Detail
available
public int available()
throws IOException

Returns the number of bytes that can be read (or skipped over) from this input stream
without blocking by the next caller of a method for this input stream. The next caller
might be the same thread or another thread. The available method for class
InputStream always returns 0. This method should be overridden by subclasses.
Throws:
IOException

close
public void close()
throws IOException

Closes this input stream and releases any system resources associated with the
stream. The close method of InputStream does nothing.
Specified by:
close in interface AutoCloseable
Throws:
IOException

mark
public void mark(int readlimit)

Marks the current position in this input stream. A subsequent call to the reset method
repositions this stream at the last marked position so that subsequent reads re-read
the same bytes. The readlimit arguments tells this input stream to allow that many
bytes to be read before the mark position gets invalidated. The general contract of
mark is that, if the method markSupported returns true, the stream somehow
remembers all the bytes read after the call to mark and stands ready to supply those
same bytes again if and whenever the method reset is called. However, the stream is
not required to remember any data at all if more than readlimit bytes are read from
the stream before reset is called. The mark method of InputStream does nothing.
markSupported
public boolean markSupported()

Tests if this input stream supports the mark and reset methods. The markSupported
method of InputStream returns false.
read
public abstract int read()
throws IOException

Reads the next byte of data from the input stream. The value byte is returned as an
int in the range 0 to 255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown. A subclass
must provide an implementation of this method.
Throws:
IOException

Constructor Detail

607

Overview (Codename One API)


read
public int read(byte[] b)
throws IOException

Reads some number of bytes from the input stream and stores them into the buffer
array b. The number of bytes actually read is returned as an integer. This method
blocks until input data is available, end of file is detected, or an exception is thrown. If
b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are
read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no
byte is available because the stream is at end of file, the value -1 is returned;
otherwise, at least one byte is read and stored into b. The first byte read is stored into
element b[0], the next one into b[1], and so on. The number of bytes read is, at most,
equal to the length of b. Let k be the number of bytes actually read; these bytes will
be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1]
unaffected. If the first byte cannot be read for any reason other than end of file, then
an IOException is thrown. In particular, an IOException is thrown if the input stream
has been closed. The read(b) method for class InputStream has the same effect as:
read(b, 0, b.length)
Throws:
IOException

read
public int read(byte[] b,
int off,
int len)
throws IOException

Reads up to len bytes of data from the input stream into an array of bytes. An attempt
is made to read as many as len bytes, but a smaller number may be read, possibly
zero. The number of bytes actually read is returned as an integer. This method blocks
until input data is available, end of file is detected, or an exception is thrown. If b is
null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len
is greater than the length of the array b, then an IndexOutOfBoundsException is
thrown. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an
attempt to read at least one byte. If no byte is available because the stream is at end
of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
The first byte read is stored into element b[off], the next one into b[off+1], and so on.
The number of bytes read is, at most, equal to len. Let k be the number of bytes
actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving
elements b[off+k] through b[off+len-1] unaffected. In every case, elements b[0]
through b[off] and elements b[off+len] through b[b.length-1] are unaffected. If the first
byte cannot be read for any reason other than end of file, then an IOException is
thrown. In particular, an IOException is thrown if the input stream has been closed.
The read(b, off, len) method for class InputStream simply calls the method read()
repeatedly. If the first such call results in an IOException, that exception is returned
from the call to the read(b, off, len) method. If any subsequent call to read() results in
a IOException, the exception is caught and treated as if it were end of file; the bytes
read up to that point are stored into b and the number of bytes read before the
exception occurred is returned. Subclasses are encouraged to provide a more
efficient implementation of this method.
Throws:
IOException

reset
public void reset()
throws IOException

Repositions this stream to the position at the time the mark method was last called on
this input stream. The general contract of reset is: If the method markSupported
returns true, then: If the method mark has not been called since the stream was
created, or the number of bytes read from the stream since mark was last called is
larger than the argument to mark at that last call, then an IOException might be
thrown. If such an IOException is not thrown, then the stream is reset to a state such
that all the bytes read since the most recent call to mark (or since the start of the file,
if mark has not been called) will be resupplied to subsequent callers of the read
method, followed by any bytes that otherwise would have been the next input data as

Method Detail

608

Overview (Codename One API)

of the time of the call to reset. If the method markSupported returns false, then: The
call to reset may throw an IOException. If an IOException is not thrown, then the
stream is reset to a fixed state that depends on the particular type of the input stream
and how it was created. The bytes that will be supplied to subsequent callers of the
read method depend on the particular type of the input stream. The method reset for
class InputStream does nothing and always throws an IOException.
Throws:
IOException

skip
public long skip(long n)
throws IOException

Skips over and discards n bytes of data from this input stream. The skip method may,
for a variety of reasons, end up skipping over some smaller number of bytes, possibly
0. This may result from any of a number of conditions; reaching end of file before n
bytes have been skipped is only one possibility. The actual number of bytes skipped
is returned. If n is negative, no bytes are skipped. The skip method of InputStream
creates a byte array and then repeatedly reads into it until n bytes have been read or
the end of the stream has been reached. Subclasses are encouraged to provide a
more efficient implementation of this method.
Throws:
IOException

Method Detail

609

Overview (Codename One API)


java.io

Class IOException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException
Direct Known Subclasses:
EOFException, GZIPException, InterruptedIOException, UnsupportedEncodingException,
UTFDataFormatException

public class
extends Exception

Signals that an I/O exception of some sort has occurred. This class is the general class of exceptions
produced by failed or interrupted I/O operations. Since: JDK1.0, CLDC 1.0 See Also:InputStream,
OutputStream

Constructor Summary
Constructor and Description
IOException()

Constructs an IOException with null as its error detail message.


IOException(String s)

Constructs an IOException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
IOException
public IOException()

Constructs an IOException with null as its error detail message.


IOException
public IOException(String s)

Constructs an IOException with the specified detail message. The error message
string s can later be retrieved by the method of class java.lang.Throwable. s - the
detail message.

Class IOException

610

Overview (Codename One API)


java.io

Interface Flushable

public interface

Indicates that an output object can be flushed.


Since:
1.5

Method Summary
Modifier and
Type

Method and Description


flush()

Flushes the object by writing out any buffered data to the underlying
output.

void

Method Detail
flush
void flush()
throws IOException

Flushes the object by writing out any buffered data to the underlying output.
Throws:
IOException

Constructor Detail

- if there are any issues writing the data.

611

Overview (Codename One API)


java.io

Class EOFException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException

java.io.EOFException

public class
extends IOException

Signals that an end of file or end of stream has been reached unexpectedly during input. This
exception is mainly used by data input streams, which generally expect a binary file in a specific
format, and for which an end of stream is an unusual condition. Most other input streams return a
special value on end of stream. Note that some input operations react to end-of-file by returning a
distinguished value (such as -1) rather than by throwing an exception. Since: JDK1.0, CLDC 1.0 See
Also:DataInputStream, IOException

Constructor Summary
Constructor and Description
EOFException()

Constructs an EOFException with null as its error detail message.


EOFException(String s)

Constructs an EOFException with the specified detail message.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
EOFException
public EOFException()

Constructs an EOFException with null as its error detail message.


EOFException
public EOFException(String s)

Constructs an EOFException with the specified detail message. The string s may
later be retrieved by the method of class java.lang.Throwable. s - the detail message.

Method Detail

612

Overview (Codename One API)


java.io

Class DataOutputStream
java.lang.Object

java.io.OutputStream

java.io.DataOutputStream
All Implemented Interfaces:
DataOutput, AutoCloseable

public class
extends OutputStream
implements DataOutput

A data output stream lets an application write primitive Java data types to an output stream in a
portable way. An application can then use a data input stream to read the data back in. Since:
JDK1.0, CLDC 1.0 See Also:DataInputStream

Field Summary
Modifier and Type
protected OutputStream

Field and Description


out

The output stream.

Constructor Summary
Constructor and Description
DataOutputStream(OutputStream out)

Creates a new data output stream to write data to the specified underlying output stream.

Method Summary
Modifier
and Type

Method and Description


close()

void

void

Closes this output stream and releases any system resources associated with
the stream.
flush()

Flushes this data output stream.


write(byte[] b, int off, int len)

void

Writes len bytes from the specified byte array starting at offset off to the
underlying output stream.
write(int b)

void

void
void
void
void
void

Constructor Detail

Writes the specified byte (the low eight bits of the argument b) to the underlying
output stream.
writeBoolean(boolean v)

Writes a boolean to the underlying output stream as a 1-byte value.


writeByte(int v)

Writes out a byte to the underlying output stream as a 1-byte value.


writeChar(int v)

Writes a char to the underlying output stream as a 2-byte value, high byte first.
writeChars(String s)

Writes a string to the underlying output stream as a sequence of characters.


writeDouble(double v)

613

Overview (Codename One API)


Converts the double argument to a long using the doubleToLongBits method in
class Double, and then writes that long value to the underlying output stream
as an 8-byte quantity, high byte first.
writeFloat(float v)

Converts the float argument to an int using the floatToIntBits method in class
Float, and then writes that int value to the underlying output stream as a 4-byte
quantity, high byte first.

void

writeInt(int v)

void

Writes an int to the underlying output stream as four bytes, high byte first.
writeLong(long v)

void

Writes a long to the underlying output stream as eight bytes, high byte first.
writeShort(int v)

void

Writes a short to the underlying output stream as two bytes, high byte first.
writeUTF(String str)

Writes a string to the underlying output stream using UTF-8 encoding in a


machine-independent manner.

void

Methods inherited from class java.io.OutputStream


write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.io.DataOutput


write

Field Detail
out
protected OutputStream out

The output stream.

Constructor Detail
DataOutputStream
public DataOutputStream(OutputStream out)

Creates a new data output stream to write data to the specified underlying output
stream. out - the underlying output stream, to be saved for later use.

Method Detail
close
public void close()
throws IOException

Closes this output stream and releases any system resources associated with the
stream. The close method calls its flush method, and then calls the close method of
its underlying output stream.
Specified by:
close in interface AutoCloseable
Overrides:
close in class OutputStream

Method Summary

614

Overview (Codename One API)


Throws:
IOException

flush
public void flush()
throws IOException

Flushes this data output stream. This forces any buffered output bytes to be written
out to the stream. The flush method of DataOutputStream calls the flush method of its
underlying output stream.
Overrides:
flush in class OutputStream
Throws:
IOException

write
public void write(byte[] b,
int off,
int len)
throws IOException

Writes len bytes from the specified byte array starting at offset off to the underlying
output stream.
Specified by:
write in interface DataOutput
Overrides:
write in class OutputStream
Throws:
IOException

write
public void write(int b)
throws IOException

Writes the specified byte (the low eight bits of the argument b) to the underlying
output stream. Implements the write method of OutputStream.
Specified by:
write in interface DataOutput
Specified by:
write in class OutputStream
Throws:
IOException

writeBoolean
public final void writeBoolean(boolean v)
throws IOException

Writes a boolean to the underlying output stream as a 1-byte value. The value true is
written out as the value (byte)1; the value false is written out as the value (byte)0.
Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte
public final void writeByte(int v)
throws IOException

Writes out a byte to the underlying output stream as a 1-byte value.


Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeChar
public final void writeChar(int v)
throws IOException

Writes a char to the underlying output stream as a 2-byte value, high byte first.

Method Detail

615

Overview (Codename One API)


Specified by:
writeChar

in interface DataOutput

Throws:
IOException

writeChars
public final void writeChars(String s)
throws IOException

Writes a string to the underlying output stream as a sequence of characters. Each


character is written to the data output stream as if by the writeChar method.
Specified by:
writeChars in interface DataOutput
Throws:
IOException

writeDouble
public final void writeDouble(double v)
throws IOException

Converts the double argument to a long using the doubleToLongBits method in class
Double, and then writes that long value to the underlying output stream as an 8-byte
quantity, high byte first.
Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeFloat
public final void writeFloat(float v)
throws IOException

Converts the float argument to an int using the floatToIntBits method in class Float,
and then writes that int value to the underlying output stream as a 4-byte quantity,
high byte first.
Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeInt
public final void writeInt(int v)
throws IOException

Writes an int to the underlying output stream as four bytes, high byte first.
Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong
public final void writeLong(long v)
throws IOException

Writes a long to the underlying output stream as eight bytes, high byte first.
Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeShort
public final void writeShort(int v)
throws IOException

Writes a short to the underlying output stream as two bytes, high byte first.
Specified by:
writeShort in interface DataOutput
Throws:
IOException

Method Detail

616

Overview (Codename One API)


writeUTF
public final void writeUTF(String str)
throws IOException

Writes a string to the underlying output stream using UTF-8 encoding in a


machine-independent manner. First, two bytes are written to the output stream as if
by the writeShort method giving the number of bytes to follow. This value is the
number of bytes actually written out, not the length of the string. Following the length,
each character of the string is output, in sequence, using the UTF-8 encoding for the
character.
Specified by:
writeUTF in interface DataOutput
Throws:
IOException

Method Detail

617

Overview (Codename One API)


java.io

Interface DataOutput
All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DataOutputStream

public interface
extends AutoCloseable

The DataOutput interface provides for converting data from any of the Java primitive types to a series
of bytes and writing these bytes to a binary stream. There is also a facility for converting a String into
Java modified UTF-8 format and writing the resulting series of bytes. For all the methods in this
interface that write bytes, it is generally true that if a byte cannot be written for any reason, an
IOException is thrown. Since: JDK1.0, CLDC 1.0 See Also:DataInput, DataOutputStream

Method Summary
Modifier and
Type

Method and Description


write(byte[] b)

void

Writes to the output stream all the bytes in array b.


write(byte[] b, int off, int len)

void

Writes len bytes from array b, in order, to the output stream.


write(int b)

void

Writes to the output stream the eight low-order bits of the argument b.
writeBoolean(boolean v)

void

Writes a boolean value to this output stream.


writeByte(int v)

void

Writes to the output stream the eight low- order bits of the argument v.
writeChar(int v)

void

Writes a char value, which is comprised of two bytes, to the output stream.
writeChars(String s)

Writes every character in the string s, to the output stream, in order, two bytes
per character.

void

writeDouble(double v)

Writes a double value, which is comprised of eight bytes, to the output


stream.

void

writeFloat(float v)

void

Writes a float value, which is comprised of four bytes, to the output stream.
writeInt(int v)

void

Writes an int value, which is comprised of four bytes, to the output stream.
writeLong(long v)

void

Writes an long value, which is comprised of four bytes, to the output stream.
writeShort(int v)

void

Writes two bytes to the output stream to represent the value of the argument.
writeUTF(String s)

Writes two bytes of length information to the output stream, followed by the
Java modified UTF representation of every character in the string s.

void

Methods inherited from interface java.lang.AutoCloseable


close

Interface DataOutput

618

Overview (Codename One API)

Method Detail
write
void write(byte[] b)
throws IOException

Writes to the output stream all the bytes in array b. If b is null, a NullPointerException
is thrown. If b.length is zero, then no bytes are written. Otherwise, the byte b[0] is
written first, then b[1], and so on; the last byte written is b[b.length-1].
Throws:
IOException

write
void write(byte[] b,
int off,
int len)
throws IOException

Writes len bytes from array b, in order, to the output stream. If b is null, a
NullPointerException is thrown. If off is negative, or len is negative, or off+len is
greater than the length of the array b, then an IndexOutOfBoundsException is thrown.
If len is zero, then no bytes are written. Otherwise, the byte b[off] is written first, then
b[off+1], and so on; the last byte written is b[off+len-1].
Throws:
IOException

write
void write(int b)
throws IOException

Writes to the output stream the eight low-order bits of the argument b. The 24
high-order bits of b are ignored.
Throws:
IOException

writeBoolean
void writeBoolean(boolean v)
throws IOException

Writes a boolean value to this output stream. If the argument v is true, the value
(byte)1 is written; if v is false, the value (byte)0 is written. The byte written by this
method may be read by the readBoolean method of interface DataInput, which will
then return a boolean equal to v.
Throws:
IOException

writeByte
void writeByte(int v)
throws IOException

Writes to the output stream the eight low- order bits of the argument v. The 24
high-order bits of v are ignored. (This means that writeByte does exactly the same
thing as write for an integer argument.) The byte written by this method may be read
by the readByte method of interface DataInput, which will then return a byte equal to
(byte)v.
Throws:
IOException

writeChar
void writeChar(int v)
throws IOException

Writes a char value, which is comprised of two bytes, to the output stream. The byte
values to be written, in the order shown, are: (byte)(0xff (v 8)) (byte)(0xff v) The bytes
written by this method may be read by the readChar method of interface DataInput,
which will then return a char equal to (char)v.

Method Detail

619

Overview (Codename One API)


Throws:
IOException

writeChars
void writeChars(String s)
throws IOException

Writes every character in the string s, to the output stream, in order, two bytes per
character. If s is null, a NullPointerException is thrown. If s.length is zero, then no
characters are written. Otherwise, the character s[0] is written first, then s[1], and so
on; the last character written is s[s.length-1]. For each character, two bytes are
actually written, high-order byte first, in exactly the manner of the writeChar method.
Throws:
IOException

writeDouble
void writeDouble(double v)
throws IOException

Writes a double value, which is comprised of eight bytes, to the output stream. It does
this as if it first converts this double value to a long in exactly the manner of the
Double.doubleToLongBits method and then writes the long value in exactly the
manner of the writeLong method. The bytes written by this method may be read by
the readDouble method of interface DataInput, which will then return a double equal
to v.
Throws:
IOException

writeFloat
void writeFloat(float v)
throws IOException

Writes a float value, which is comprised of four bytes, to the output stream. It does
this as if it first converts this float value to an int in exactly the manner of the
Float.floatToIntBits method and then writes the int value in exactly the manner of the
writeInt method. The bytes written by this method may be read by the readFloat
method of interface DataInput, which will then return a float equal to v.
Throws:
IOException

writeInt
void writeInt(int v)
throws IOException

Writes an int value, which is comprised of four bytes, to the output stream. The byte
values to be written, in the order shown, are: (byte)(0xff (v 24)) (byte)(0xff (v 16))
(byte)(0xff (v 8)) (byte)(0xff v) The bytes written by this method may be read by the
readInt method of interface DataInput, which will then return an int equal to v.
Throws:
IOException

writeLong
void writeLong(long v)
throws IOException

Writes an long value, which is comprised of four bytes, to the output stream. The byte
values to be written, in the order shown, are: (byte)(0xff (v 56)) (byte)(0xff (v 48))
(byte)(0xff (v 40)) (byte)(0xff (v 32)) (byte)(0xff (v 24)) (byte)(0xff (v 16)) (byte)(0xff (v
8)) (byte)(0xff v) The bytes written by this method may be read by the readLong
method of interface DataInput, which will then return a long equal to v.
Throws:
IOException

writeShort
void writeShort(int v)
throws IOException

Writes two bytes to the output stream to represent the value of the argument. The
byte values to be written, in the order shown, are: (byte)(0xff (v 8)) (byte)(0xff v) The

Method Detail

620

Overview (Codename One API)

bytes written by this method may be read by the readShort method of interface
DataInput, which will then return a short equal to (short)v.
Throws:
IOException

writeUTF
void writeUTF(String s)
throws IOException

Writes two bytes of length information to the output stream, followed by the Java
modified UTF representation of every character in the string s. If s is null, a
NullPointerException is thrown. Each character in the string s is converted to a group
of one, two, or three bytes, depending on the value of the character. If a character c
is in the range u0001 through u007f, it is represented by one byte: (byte)c If a
character c is u0000 or is in the range u0080 through u07ff, then it is represented by
two bytes, to be written in the order shown: (byte)(0xc0 | (0x1f (c 6))) (byte)(0x80 |
(0x3f c)) If a character c is in the range u0800 through uffff, then it is represented by
three bytes, to be written in the order shown: (byte)(0xe0 | (0x0f (c 12))) (byte)(0x80 |
(0x3f (c 6))) (byte)(0x80 | (0x3f c)) First, the total number of bytes needed to
represent all the characters of s is calculated. If this number is larger than 65535,
then a UTFDataFormatError is thrown. Otherwise, this length is written to the output
stream in exactly the manner of the writeShort method; after this, the one-, two-, or
three-byte representation of each character in the string s is written. The bytes written
by this method may be read by the readUTF method of interface DataInput, which will
then return a String equal to s.
Throws:
IOException

Method Detail

621

Overview (Codename One API)


java.io

Class DataInputStream
java.lang.Object

java.io.InputStream

java.io.DataInputStream
All Implemented Interfaces:
DataInput, AutoCloseable

public class
extends InputStream
implements DataInput

A data input stream lets an application read primitive Java data types from an underlying input stream
in a machine-independent way. An application uses a data output stream to write data that can later
be read by a data input stream. Since: JDK1.0, CLDC 1.0 See Also:DataOutputStream

Field Summary
Modifier and Type
protected InputStream

Field and Description


in

The input stream.

Constructor Summary
Constructor and Description
DataInputStream(InputStream in)

Creates a DataInputStream and saves its argument, the input stream in, for later use.

Method Summary
Modifier
and Type

Method and Description


available()

int

Returns the number of bytes that can be read from this input stream without
blocking.
close()

void

void
boolean
int
int
int
boolean
byte

Class DataInputStream

Closes this input stream and releases any system resources associated with
the stream.
mark(int readlimit)

Marks the current position in this input stream.


markSupported()

Tests if this input stream supports the mark and reset methods.
read()

Reads the next byte of data from this input stream.


read(byte[] b)

See the general contract of the read method of DataInput.


read(byte[] b, int off, int len)

Reads up to len bytes of data from this input stream into an array of bytes.
readBoolean()

See the general contract of the readBoolean method of DataInput.


readByte()

See the general contract of the readByte method of DataInput.

622

Overview (Codename One API)


readChar()

char

See the general contract of the readChar method of DataInput.


readDouble()

double

See the general contract of the readDouble method of DataInput.


readFloat()

float

See the general contract of the readFloat method of DataInput.


readFully(byte[] b)

void

See the general contract of the readFully method of DataInput.


readFully(byte[] b, int off, int len)

void

See the general contract of the readFully method of DataInput.


readInt()

int

See the general contract of the readInt method of DataInput.


readLong()

long

See the general contract of the readLong method of DataInput.


readShort()

short

See the general contract of the readShort method of DataInput.


readUnsignedByte()

int

See the general contract of the readUnsignedByte method of DataInput.


readUnsignedShort()

int

See the general contract of the readUnsignedShort method of DataInput.


readUTF()

String

See the general contract of the readUTF method of DataInput.


readUTF(DataInput in)

Reads from the stream in a representation of a Unicode character string


encoded in Java modified UTF-8 format; this string of characters is then
returned as a String.

static
String

reset()

Repositions this stream to the position at the time the mark method was last
called on this input stream.

void

skip(long n)

long

Skips over and discards n bytes of data from the input stream.
skipBytes(int n)

int

See the general contract of the skipBytes method of DataInput.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
in
protected InputStream in

The input stream.

Constructor Detail
DataInputStream
public DataInputStream(InputStream in)

Creates a DataInputStream and saves its argument, the input stream in, for later use.
in - the input stream.

Method Summary

623

Overview (Codename One API)

Method Detail
available
public int available()
throws IOException

Returns the number of bytes that can be read from this input stream without blocking.
This method simply performs in.available() and returns the result.
Overrides:
available in class InputStream
Throws:
IOException

close
public void close()
throws IOException

Closes this input stream and releases any system resources associated with the
stream. This method simply performs in.close().
Specified by:
close in interface AutoCloseable
Overrides:
close in class InputStream
Throws:
IOException

mark
public void mark(int readlimit)

Marks the current position in this input stream. A subsequent call to the reset method
repositions this stream at the last marked position so that subsequent reads re-read
the same bytes. The readlimit argument tells this input stream to allow that many
bytes to be read before the mark position gets invalidated. This method simply
performs in.mark(readlimit).
Overrides:
mark in class InputStream
markSupported
public boolean markSupported()

Tests if this input stream supports the mark and reset methods. This method simply
performs in.markSupported().
Overrides:
markSupported in class InputStream
read
public int read()
throws IOException

Reads the next byte of data from this input stream. The value byte is returned as an
int in the range 0 to 255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown. This method
simply performs in.read() and returns the result.
Specified by:
read in class InputStream
Throws:
IOException

read
public final int read(byte[] b)
throws IOException

See the general contract of the read method of DataInput. Bytes for this operation are
read from the contained input stream.

Method Detail

624

Overview (Codename One API)


Overrides:
read

in class InputStream

Throws:
IOException

read
public final int read(byte[] b,
int off,
int len)
throws IOException

Reads up to len bytes of data from this input stream into an array of bytes. This
method blocks until some input is available. This method simply performs in.read(b,
off, len) and returns the result.
Overrides:
read in class InputStream
Throws:
IOException

readBoolean
public final boolean readBoolean()
throws IOException

See the general contract of the readBoolean method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readBoolean in interface DataInput
Throws:
IOException

readByte
public final byte readByte()
throws IOException

See the general contract of the readByte method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readByte in interface DataInput
Throws:
IOException

readChar
public final char readChar()
throws IOException

See the general contract of the readChar method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readChar in interface DataInput
Throws:
IOException

readDouble
public final double readDouble()
throws IOException

See the general contract of the readDouble method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readDouble in interface DataInput
Throws:
IOException

readFloat
public final float readFloat()
throws IOException

See the general contract of the readFloat method of DataInput. Bytes for this
operation are read from the contained input stream.

Method Detail

625

Overview (Codename One API)


Specified by:
readFloat

in interface DataInput

Throws:
IOException

readFully
public final void readFully(byte[] b)
throws IOException

See the general contract of the readFully method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readFully in interface DataInput
Throws:
IOException

readFully
public final void readFully(byte[] b,
int off,
int len)
throws IOException

See the general contract of the readFully method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readFully in interface DataInput
Throws:
IOException

readInt
public final int readInt()
throws IOException

See the general contract of the readInt method of DataInput. Bytes for this operation
are read from the contained input stream.
Specified by:
readInt in interface DataInput
Throws:
IOException

readLong
public final long readLong()
throws IOException

See the general contract of the readLong method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readLong in interface DataInput
Throws:
IOException

readShort
public final short readShort()
throws IOException

See the general contract of the readShort method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readShort in interface DataInput
Throws:
IOException

readUnsignedByte
public final int readUnsignedByte()
throws IOException

See the general contract of the readUnsignedByte method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:

Method Detail

626

Overview (Codename One API)


readUnsignedByte

in interface DataInput

Throws:
IOException

readUnsignedShort
public final int readUnsignedShort()
throws IOException

See the general contract of the readUnsignedShort method of DataInput. Bytes for
this operation are read from the contained input stream.
Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readUTF
public final String readUTF()
throws IOException

See the general contract of the readUTF method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
readUTF in interface DataInput
Throws:
IOException

readUTF
public static final String readUTF(DataInput in)
throws IOException

Reads from the stream in a representation of a Unicode character string encoded in


Java modified UTF-8 format; this string of characters is then returned as a String. The
details of the modified UTF-8 representation are exactly the same as for the readUTF
method of DataInput.
Throws:
IOException

reset
public void reset()
throws IOException

Repositions this stream to the position at the time the mark method was last called on
this input stream. This method simply performs in.reset(). Stream marks are intended
to be used in situations where you need to read ahead a little to see what's in the
stream. Often this is most easily done by invoking some general parser. If the stream
is of the type handled by the parse, it just chugs along happily. If the stream is not of
that type, the parser should toss an exception when it fails. If this happens within
readlimit bytes, it allows the outer code to reset the stream and try another parser.
Overrides:
reset in class InputStream
Throws:
IOException

skip
public long skip(long n)
throws IOException

Skips over and discards n bytes of data from the input stream. The skip method may,
for a variety of reasons, end up skipping over some smaller number of bytes, possibly
0. The actual number of bytes skipped is returned. This method simply performs
in.skip(n).
Overrides:
skip in class InputStream
Throws:
IOException

Method Detail

627

Overview (Codename One API)

skipBytes
public final int skipBytes(int n)
throws IOException

See the general contract of the skipBytes method of DataInput. Bytes for this
operation are read from the contained input stream.
Specified by:
skipBytes in interface DataInput
Throws:
IOException

Method Detail

628

Overview (Codename One API)


java.io

Interface DataInput
All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DataInputStream

public interface
extends AutoCloseable

The DataInput interface provides for reading bytes from a binary stream and reconstructing from them
data in any of the Java primitive types. There is also a facility for reconstructing a String from data in
Java modified UTF-8 format. It is generally true of all the reading routines in this interface that if end
of file is reached before the desired number of bytes has been read, an EOFException (which is a
kind of IOException) is thrown. If any byte cannot be read for any reason other than end of file, an
IOException other than EOFException is thrown. In particular, an IOException may be thrown if the
input stream has been closed. Since: JDK1.0, CLDC 1.0 See Also:DataInputStream, DataOutput

Method Summary
Modifier and
Type

Method and Description


readBoolean()

boolean

byte
char
double
float

Reads one input byte and returns true if that byte is nonzero, false if that
byte is zero.
readByte()

Reads and returns one input byte.


readChar()

Reads an input char and returns the char value.


readDouble()

Reads eight input bytes and returns a double value.


readFloat()

Reads four input bytes and returns a float value.


readFully(byte[] b)

void

void
int
long
short

Reads some bytes from an input stream and stores them into the buffer
array b.
readFully(byte[] b, int off, int len)

Reads len bytes from an input stream.


readInt()

Reads four input bytes and returns an int value.


readLong()

Reads eight input bytes and returns a long value.


readShort()

Reads two input bytes and returns a short value.


readUnsignedByte()

int

Reads one input byte, zero-extends it to type int, and returns the result,
which is therefore in the range 0 through 255.
readUnsignedShort()

int

String

Reads two input bytes, zero-extends it to type int, and returns an int value in
the range 0 through 65535.
readUTF()

Reads in a string that has been encoded using a modified UTF-8 format.
skipBytes(int n)

int

Interface DataInput

Makes an attempt to skip over n bytes of data from the input stream,
discarding the skipped bytes.

629

Overview (Codename One API)


Methods

inherited from interface java.lang.AutoCloseable

close

Method Detail
readBoolean
boolean readBoolean()
throws IOException

Reads one input byte and returns true if that byte is nonzero, false if that byte is zero.
This method is suitable for reading the byte written by the writeBoolean method of
interface DataOutput.
Throws:
IOException

readByte
byte readByte()
throws IOException

Reads and returns one input byte. The byte is treated as a signed value in the range
-128 through 127, inclusive. This method is suitable for reading the byte written by
the writeByte method of interface DataOutput.
Throws:
IOException

readChar
char readChar()
throws IOException

Reads an input char and returns the char value. A Unicode char is made up of two
bytes. Let a be the first byte read and b be the second byte. The value returned is:
(char)((a 8) | (b 0xff)) This method is suitable for reading bytes written by the
writeChar method of interface DataOutput.
Throws:
IOException

readDouble
double readDouble()
throws IOException

Reads eight input bytes and returns a double value. It does this by first constructing a
long value in exactly the manner of the readlong method, then converting this long
value to a double in exactly the manner of the method Double.longBitsToDouble. This
method is suitable for reading bytes written by the writeDouble method of interface
DataOutput.
Throws:
IOException

readFloat
float readFloat()
throws IOException

Reads four input bytes and returns a float value. It does this by first constructing an
int value in exactly the manner of the readInt method, then converting this int value to
a float in exactly the manner of the method Float.intBitsToFloat. This method is
suitable for reading bytes written by the writeFloat method of interface DataOutput.
Throws:
IOException

readFully
void readFully(byte[] b)
throws IOException

Methods inherited from interface java.lang.AutoCloseable

630

Overview (Codename One API)


Reads some bytes from an input stream and stores them into the buffer array b. The
number of bytes read is equal to the length of b. This method blocks until one of the
following conditions occurs: b.length bytes of input data are available, in which case a
normal return is made. End of file is detected, in which case an EOFException is
thrown. An I/O error occurs, in which case an IOException other than EOFException
is thrown. If b is null, a NullPointerException is thrown. If b.length is zero, then no
bytes are read. Otherwise, the first byte read is stored into element b[0], the next one
into b[1], and so on. If an exception is thrown from this method, then it may be that
some but not all bytes of b have been updated with data from the input stream.
Throws:
IOException

readFully
void readFully(byte[] b,
int off,
int len)
throws IOException

Reads len bytes from an input stream. This method blocks until one of the following
conditions occurs: len bytes of input data are available, in which case a normal return
is made. End of file is detected, in which case an EOFException is thrown. An I/O
error occurs, in which case an IOException other than EOFException is thrown. If b is
null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len
is greater than the length of the array b, then an IndexOutOfBoundsException is
thrown. If len is zero, then no bytes are read. Otherwise, the first byte read is stored
into element b[off], the next one into b[off+1], and so on. The number of bytes read is,
at most, equal to len.
Throws:
IOException

readInt
int readInt()
throws IOException

Reads four input bytes and returns an int value. Let a be the first byte read, b be the
second byte, c be the third byte, and d be the fourth byte. The value returned is: (((a
0xff) 24) | ((b 0xff) 16) | ((c 0xff) 8) | (d 0xff)) This method is suitable for reading bytes
written by the writeInt method of interface DataOutput.
Throws:
IOException

readLong
long readLong()
throws IOException

Reads eight input bytes and returns a long value. Let a be the first byte read, b be the
second byte, c be the third byte, d be the fourth byte, e be the fifth byte, f be the sixth
byte, g be the seventh byte, and h be the eighth byte. The value returned is:
(((long)(a 0xff) 56) | ((long)(b 0xff) 48) | ((long)(c 0xff) 40) | ((long)(d 0xff) 32) |
((long)(e 0xff) 24) | ((long)(f 0xff) 16) | ((long)(g 0xff) 8) | ((long)(h 0xff))) This method
is suitable for reading bytes written by the writeLong method of interface DataOutput.
Throws:
IOException

readShort
short readShort()
throws IOException

Reads two input bytes and returns a short value. Let a be the first byte read and b be
the second byte. The value returned is: (short)((a 8) | (b 0xff)) This method is suitable
for reading the bytes written by the writeShort method of interface DataOutput.
Throws:
IOException

readUnsignedByte
int readUnsignedByte()
throws IOException

Method Detail

631

Overview (Codename One API)


Reads one input byte, zero-extends it to type int, and returns the result, which is
therefore in the range 0 through 255. This method is suitable for reading the byte
written by the writeByte method of interface DataOutput if the argument to writeByte
was intended to be a value in the range 0 through 255.
Throws:
IOException

readUnsignedShort
int readUnsignedShort()
throws IOException

Reads two input bytes, zero-extends it to type int, and returns an int value in the
range 0 through 65535. Let a be the first byte read and b be the second byte. The
value returned is: (((a 0xff) 8) | (b 0xff)) This method is suitable for reading the bytes
written by the writeShort method of interface DataOutput if the argument to writeShort
was intended to be a value in the range 0 through 65535.
Throws:
IOException

readUTF
String readUTF()
throws IOException

Reads in a string that has been encoded using a modified UTF-8 format. The general
contract of readUTF is that it reads a representation of a Unicode character string
encoded in Java modified UTF-8 format; this string of characters is then returned as a
String. First, two bytes are read and used to construct an unsigned 16-bit integer in
exactly the manner of the readUnsignedShort method . This integer value is called
the UTF length and specifies the number of additional bytes to be read. These bytes
are then converted to characters by considering them in groups. The length of each
group is computed from the value of the first byte of the group. The byte following a
group, if any, is the first byte of the next group. If the first byte of a group matches the
bit pattern 0xxxxxxx (where x means "may be 0 or 1"), then the group consists of just
that byte. The byte is zero-extended to form a character. If the first byte of a group
matches the bit pattern 110xxxxx, then the group consists of that byte a and a second
byte b. If there is no byte b (because byte a was the last of the bytes to be read), or if
byte b does not match the bit pattern 10xxxxxx, then a UTFDataFormatException is
thrown. Otherwise, the group is converted to the character: (char)(((a 0x1F) 6) | (b
0x3F)) If the first byte of a group matches the bit pattern 1110xxxx, then the group
consists of that byte a and two more bytes b and c. If there is no byte c (because byte
a was one of the last two of the bytes to be read), or either byte b or byte c does not
match the bit pattern 10xxxxxx, then a UTFDataFormatException is thrown.
Otherwise, the group is converted to the character: (char)(((a 0x0F) 12) | ((b 0x3F) 6)
| (c 0x3F)) If the first byte of a group matches the pattern 1111xxxx or the pattern
10xxxxxx, then a UTFDataFormatException is thrown. If end of file is encountered at
any time during this entire process, then an EOFException is thrown. After every
group has been converted to a character by this process, the characters are
gathered, in the same order in which their corresponding groups were read from the
input stream, to form a String, which is returned. The writeUTF method of interface
DataOutput may be used to write data that is suitable for reading by this method.
Throws:
IOException

skipBytes
int skipBytes(int n)
throws IOException

Makes an attempt to skip over n bytes of data from the input stream, discarding the
skipped bytes. However, it may skip over some smaller number of bytes, possibly
zero. This may result from any of a number of conditions; reaching end of file before
n bytes have been skipped is only one possibility. This method never throws an
EOFException. The actual number of bytes skipped is returned.
Throws:
IOException

Method Detail

632

Overview (Codename One API)


java.io

Class ByteArrayOutputStream
java.lang.Object

java.io.OutputStream

java.io.ByteArrayOutputStream
All Implemented Interfaces:
AutoCloseable

public class
extends OutputStream

This class implements an output stream in which the data is written into a byte array. The buffer
automatically grows as data is written to it. The data can be retrieved using toByteArray() and
toString(). Since: JDK1.0, CLDC 1.0

Field Summary
Modifier and Type
protected byte[]

Field and Description


buf

The buffer where data is stored.


count

protected int

The number of valid bytes in the buffer.

Constructor Summary
Constructor and Description
ByteArrayOutputStream()

Creates a new byte array output stream.


ByteArrayOutputStream(int size)

Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Method Summary
Modifier and
Type

Method and Description


close()

void

Closes this output stream and releases any system resources associated
with this stream.
reset()

void

int
byte[]

Resets the count field of this byte array output stream to zero, so that all
currently accumulated output in the output stream is discarded.
size()

Returns the current size of the buffer.


toByteArray()

Creates a newly allocated byte array.


toString()

String

Converts the buffer's contents into a string, translating bytes into characters
according to the platform's default character encoding.
write(byte[] b, int off, int len)

void

Writes len bytes from the specified byte array starting at offset off to this byte
array output stream.

void

write(int b)

Class ByteArrayOutputStream

633

Overview (Codename One API)


Writes the specified byte to this byte array output stream.

Methods inherited from class java.io.OutputStream


flush, write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
buf
protected byte[] buf

The buffer where data is stored.


count
protected int count

The number of valid bytes in the buffer.

Constructor Detail
ByteArrayOutputStream
public ByteArrayOutputStream()

Creates a new byte array output stream. The buffer capacity is initially 32 bytes,
though its size increases if necessary.
ByteArrayOutputStream
public ByteArrayOutputStream(int size)

Creates a new byte array output stream, with a buffer capacity of the specified size,
in bytes. size - the initial size. - if size is negative.

Method Detail
close
public void close()
throws IOException

Closes this output stream and releases any system resources associated with this
stream. A closed stream cannot perform output operations and cannot be reopened.
Specified by:
close in interface AutoCloseable
Overrides:
close in class OutputStream
Throws:
IOException

reset
public void reset()

Resets the count field of this byte array output stream to zero, so that all currently
accumulated output in the output stream is discarded. The output stream can be used
again, reusing the already allocated buffer space.

Method Summary

634

Overview (Codename One API)


size
public int size()

Returns the current size of the buffer.


toByteArray
public byte[] toByteArray()

Creates a newly allocated byte array. Its size is the current size of this output stream
and the valid contents of the buffer have been copied into it.
toString
public String toString()

Converts the buffer's contents into a string, translating bytes into characters
according to the platform's default character encoding.
Overrides:
toString in class Object
write
public void write(byte[] b,
int off,
int len)

Writes len bytes from the specified byte array starting at offset off to this byte array
output stream.
Overrides:
write in class OutputStream
write
public void write(int b)

Writes the specified byte to this byte array output stream.


Specified by:
write in class OutputStream

Method Detail

635

Overview (Codename One API)


java.io

Class ByteArrayInputStream
java.lang.Object

java.io.InputStream

java.io.ByteArrayInputStream
All Implemented Interfaces:
AutoCloseable

public class
extends InputStream

A ByteArrayInputStream contains an internal buffer that contains bytes that may be read from the
stream. An internal counter keeps track of the next byte to be supplied by the read method. Since:
JDK1.0, CLDC 1.0

Field Summary
Modifier and
Type
protected byte[]

Field and Description


buf

An array of bytes that was provided by the creator of the stream.


count

protected int

protected int
protected int

The index one greater than the last valid character in the input stream
buffer.
mark

The currently marked position in the stream.


pos

The index of the next character to read from the input stream buffer.

Constructor Summary
Constructor and Description
ByteArrayInputStream(byte[] buf)

Creates a ByteArrayInputStream so that it uses buf as its buffer array.


ByteArrayInputStream(byte[] buf, int offset, int length)

Creates ByteArrayInputStream that uses buf as its buffer array.

Method Summary
Modifier and
Type

Method and Description


available()

int

Returns the number of bytes that can be read from this input stream
without blocking.
close()

void

void
boolean
int

Class ByteArrayInputStream

Closes this input stream and releases any system resources associated
with the stream.
mark(int readAheadLimit)

Set the current marked position in the stream.


markSupported()

Tests if ByteArrayInputStream supports mark/reset.


read()

636

Overview (Codename One API)


Reads the next byte of data from this input stream.
read(byte[] b, int off, int len)

int

Reads up to len bytes of data into an array of bytes from this input stream.
reset()

void

Resets the buffer to the marked position.


skip(long n)

long

Skips n bytes of input from this input stream.

Methods inherited from class java.io.InputStream


read

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
buf
protected byte[] buf

An array of bytes that was provided by the creator of the stream. Elements buf[0]
through buf[count-1] are the only bytes that can ever be read from the stream;
element buf[pos] is the next byte to be read.
count
protected int count

The index one greater than the last valid character in the input stream buffer. This
value should always be nonnegative and not larger than the length of buf. It is one
greater than the position of the last byte within buf that can ever be read from the
input stream buffer.
mark
protected int mark

The currently marked position in the stream. ByteArrayInputStream objects are


marked at position zero by default when constructed. They may be marked at another
position within the buffer by the mark() method. The current buffer position is set to
this point by the reset() method. Since: JDK1.1
pos
protected int pos

The index of the next character to read from the input stream buffer. This value
should always be nonnegative and not larger than the value of count. The next byte
to be read from the input stream buffer will be buf[pos].

Constructor Detail
ByteArrayInputStream
public ByteArrayInputStream(byte[] buf)

Creates a ByteArrayInputStream so that it uses buf as its buffer array. The buffer
array is not copied. The initial value of pos is 0 and the initial value of count is the
length of buf. buf - the input buffer.

Method Summary

637

Overview (Codename One API)


ByteArrayInputStream
public ByteArrayInputStream(byte[] buf,
int offset,
int length)

Creates ByteArrayInputStream that uses buf as its buffer array. The initial value of
pos is offset and the initial value of count is offset+length. The buffer array is not
copied. Note that if bytes are simply read from the resulting input stream, elements
buf[pos] through buf[pos+len-1] will be read; however, if a reset operation is
performed, then bytes buf[0] through buf[pos-1] will then become available for input.
buf - the input buffer.offset - the offset in the buffer of the first byte to read.length - the
maximum number of bytes to read from the buffer.

Method Detail
available
public int available()

Returns the number of bytes that can be read from this input stream without blocking.
The value returned is count - pos, which is the number of bytes remaining to be read
from the input buffer.
Overrides:
available in class InputStream
close
public void close()
throws IOException

Closes this input stream and releases any system resources associated with the
stream.
Specified by:
close in interface AutoCloseable
Overrides:
close in class InputStream
Throws:
IOException

mark
public void mark(int readAheadLimit)

Set the current marked position in the stream. ByteArrayInputStream objects are
marked at position zero by default when constructed. They may be marked at another
position within the buffer by this method.
Overrides:
mark in class InputStream
markSupported
public boolean markSupported()

Tests if ByteArrayInputStream supports mark/reset.


Overrides:
markSupported in class InputStream
read
public int read()

Reads the next byte of data from this input stream. The value byte is returned as an
int in the range 0 to 255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This read method cannot block.
Specified by:
read in class InputStream

Constructor Detail

638

Overview (Codename One API)


read
public int read(byte[] b,
int off,
int len)

Reads up to len bytes of data into an array of bytes from this input stream. If pos
equals count, then -1 is returned to indicate end of file. Otherwise, the number k of
bytes read is equal to the smaller of len and count-pos. If k is positive, then bytes
buf[pos] through buf[pos+k-1] are copied into b[off] through b[off+k-1] in the manner
performed by System.arraycopy. The value k is added into pos and k is returned.
This read method cannot block.
Overrides:
read in class InputStream
reset
public void reset()

Resets the buffer to the marked position. The marked position is the beginning unless
another position was marked. The value of pos is set to 0.
Overrides:
reset in class InputStream
skip
public long skip(long n)

Skips n bytes of input from this input stream. Fewer bytes might be skipped if the end
of the input stream is reached. The actual number k of bytes to be skipped is equal to
the smaller of n and count-pos. The value k is added into pos and k is returned.
Overrides:
skip in class InputStream

Method Detail

639

Overview (Codename One API)


com.codename1.xml

Class XMLWriter
java.lang.Object

com.codename1.xml.XMLWriter

public class
extends Object

Constructor Summary
Constructor and Description
XMLWriter(boolean encodeText)

Creates a new XMLWriter.

Method Summary
Modifier and Type

Method and Description


writeXML(Writer writer, Element element)

void

Writes the XML of an Element to a Writer.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XMLWriter
public XMLWriter(boolean encodeText)

Creates a new XMLWriter.


Parameters:
encodeText - Determines whether or not text components (text content, tag
names, attribute names, and attribute values) should be encoded with
escapes when written. Use false if these values are already encoded.

Method Detail
writeXML
public void writeXML(Writer writer,
Element element)
throws IOException

Writes the XML of an Element to a Writer. Note: may output invalid XML if you
created text Elements using un-escaped Strings.
Parameters:
writer - The Writer to which the XML will be written.
element - The element whose XML will be written.
Throws:
IOException - if a write operation fails.

Class XMLWriter

640

Overview (Codename One API)


com.codename1.xml

Class XMLParser
java.lang.Object

com.codename1.xml.XMLParser
Direct Known Subclasses:
HTMLParser

public class
extends Object

Parser class used to parse an XML document into a DOM object (Element). This code was originally
developed to parse HTML and as a result isn't as strict as most XML parsers and can parse many
HTML documents out of the box. The parser is mostly stateful (although it does have an event
callback API as well), its modeled closely to the Java DOM API's.
In this sample an XML hierarchy is displayed using a Tree:

Constructor Summary
Constructor and Description
XMLParser()

Constructs the XMLParser

Method Summary
Modifier
and Type

Method and Description


addCharEntitiesRange(String[] symbols, int startcode)

void

Method Detail

Adds the given symbols array to the user defined char entities table with the
startcode provided as the code of the first string, startcode+1 for the second etc.

641

Overview (Codename One API)


addCharEntity(String symbol, int code)
void

protected
void

Adds the given symbol and code to the user defined char entities table
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
attribute(String tag, String attributeName, String value)

Invoked for every attribute value of the givne tag This callback method is invoked
only on the eventParser.

protected convertCharEntity(String charEntity)


String
Converts a char entity to the matching character.
protected createNewElement(String name)
Element
Creates a new element.
protected createNewTextElement(String text)
Element
Creates a new text element.
protected
void

endTag(String tag)

Invoked when a tag ends This callback method is invoked only on the
eventParser.
eventParser(Reader r)

void

The event parser requires deriving this class and overriding callback methods to
work effectively.

protected getSupportedStandardName()
String
Returns a string identifying the

document type this parser supports.

isCaseSensitive()
boolean

Sets the parser to be case sensitive and retain case, otherwise it will convert all
data to lower case

protected isEmptyTag(String tagName)


boolean
Checks whether the specified

tag is an empty tag

isSupported(Element element)
protected
boolean

Returns true if this element is supported, false otherwise In XMLParser this


always returns true, but subclasses can determine if an element is supported in
their context according to its name etc.

protected isWhiteSpace(char ch)


boolean
Checks if the specified character

is a white space or not.

notifyError(int errorId, String tag, String attribute, String value,


protected String description)
A utility method used to notify an error to the ParserCallback and throw an
void

IllegalArgumentException if parsingError returned false


parse(Reader is)
Element

This is the entry point for parsing a document and the only non-private member
method in this class

protected parseCommentOrXMLDeclaration(Reader is, String endTag)


Element
This utility method is used to parse comments and XML declarations
protected parseTag(Reader is)
Element
This method collects the

in the XML.

tag name and all of its attributes.

protected parseTagContent(Element element, Reader is)


void
Parses tags content, accumulating text and child

elements .

setCaseSensitive(boolean caseSensitive)
void

Sets the parser to be case sensitive and retain case, otherwise it will convert all
data to lower case

void

setIncludeWhitespacesBetweenTags(boolean include)

void
protected
boolean
protected
boolean

setParserCallback(ParserCallback parserCallback)

Sets the specified callback to serve as the callback for parsing errors
shouldEvaluate(Element element)

Checks if this element should be evaluated by the parser This can be overriden
by subclasses to skip certain elements
startTag(String tag)

Invoked when a tag is opened, this method should return true to process the tag
or return false to skip the tag.

protected textElement(String text)


void
Invoked when the event parser

Method Summary

encounters a text element.

642

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XMLParser
public XMLParser()

Constructs the XMLParser

Method Detail
getSupportedStandardName
protected String getSupportedStandardName()

Returns a string identifying the document type this parser supports. This should be
overriden by subclassing parsers.
Returns:
a string identifying the document type this parser supports.
addCharEntity
public void addCharEntity(String symbol,
int code)

Adds the given symbol and code to the user defined char entities table
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
Parameters:
symbol - The symbol to add
code - The symbol's code
addCharEntitiesRange
public void addCharEntitiesRange(String[] symbols,
int startcode)

Adds the given symbols array to the user defined char entities table with the
startcode provided as the code of the first string, startcode+1 for the second etc.
Some strings in the symbols array may be null thus skipping code numbers.
Parameters:
symbols - The symbols to add
startcode - The symbol's code
convertCharEntity
protected String convertCharEntity(String charEntity)

Converts a char entity to the matching character. This handles both numbered and
symbol char entities (The latter is done via getCharEntityCode)
Parameters:
charEntity - The char entity to convert
Returns:
A string containing a single char, or the original char entity string (with & and
;) if the char entity couldn't be resolved
parse
public Element parse(Reader is)

This is the entry point for parsing a document and the only non-private member
method in this class
Parameters:
is - The InputStream containing the XML
Returns:

Methods inherited from class java.lang.Object

643

Overview (Codename One API)


an Element object describing the parsed document (Basically its DOM)
createNewElement
protected Element createNewElement(String name)

Creates a new element. This should be overriden by parsers that use a subclass of
Element.
Parameters:
name - The new element's name
Returns:
a new instance of the element
createNewTextElement
protected Element createNewTextElement(String text)

Creates a new text element. This should be overriden by parsers that use a subclass
of Element.
Parameters:
text - The new element's text
Returns:
a new instance of the element
setIncludeWhitespacesBetweenTags
public void setIncludeWhitespacesBetweenTags(boolean include)

eventParser
public void eventParser(Reader r)
throws IOException

The event parser requires deriving this class and overriding callback methods to work
effectively. To stop the event parser in mid way a callback can simply throw an
IOException on purpose.
Parameters:
r - the reader from which the data should be parsed
Throws:
IOException - if an exception is thrown by the reader
textElement
protected void textElement(String text)

Invoked when the event parser encounters a text element. This callback method is
invoked only on the eventParser.
Parameters:
text - the text encountered
startTag
protected boolean startTag(String tag)

Invoked when a tag is opened, this method should return true to process the tag or
return false to skip the tag. This callback method is invoked only on the eventParser.
Parameters:
tag - the tag name
Returns:
true to process the tag, false to skip the tag
endTag
protected void endTag(String tag)

Invoked when a tag ends This callback method is invoked only on the eventParser.
Parameters:
tag - the tag name
attribute
protected void attribute(String tag,
String attributeName,
String value)

Method Detail

644

Overview (Codename One API)


Invoked for every attribute value of the givne tag This callback method is invoked only
on the eventParser.
Parameters:
tag - the tag name
parseTagContent
protected void parseTagContent(Element element,
Reader is)
throws IOException

Parses tags content, accumulating text and child elements . Upon bumping a start tag
character it calls the parseTag method. This method is called at first from the parse
method, and later on from parseTag (which creates the recursion).
Parameters:
element - The current parent element
is - The InputStream containing the XML
Throws:
IOException - if an I/O error in the stream is encountered
isWhiteSpace
protected boolean isWhiteSpace(char ch)

Checks if the specified character is a white space or not. Exposed to packaage since
used by HTMLComponent as well
Parameters:
ch - The character to check
Returns:
true if the character is a white space, false otherwise
parseTag
protected Element parseTag(Reader is)
throws IOException

This method collects the tag name and all of its attributes. For comments and XML
declarations this will call the parseCommentOrXMLDeclaration method. Note that this
method returns an Element with a name and attrbutes, but not its content/children
which will be done by parseTagContent
Parameters:
is - The InputStream containing the XML
Returns:
The parsed element
Throws:
IOException - if an I/O error in the stream is encountered
parseCommentOrXMLDeclaration
protected Element parseCommentOrXMLDeclaration(Reader is,
String endTag)
throws IOException

This utility method is used to parse comments and XML declarations in the XML. The
comment/declaration is returned as an Element, but is flagged as a comment since
both comments and XML declarations are not part of the XML DOM. This method can
be overridden to process specific XML declarations
Parameters:
is - The inputstream
endTag - The endtag to look for
Returns:
An Element representing the comment or XML declartaion
Throws:
IOException

isEmptyTag
protected boolean isEmptyTag(String tagName)

Checks whether the specified tag is an empty tag


Parameters:
tagName - The tag name to check

Method Detail

645

Overview (Codename One API)


Returns:
true if that tag is defined as an empty tag, false otherwise
notifyError
protected void notifyError(int errorId,
String tag,
String attribute,
String value,
String description)

A utility method used to notify an error to the ParserCallback and throw an


IllegalArgumentException if parsingError returned false
Parameters:
errorId - The error ID, one of the ERROR_* constants in ParserCallback
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)
value - The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Throws:
IllegalArgumentException - If the parser callback returned false on this error
isSupported
protected boolean isSupported(Element element)

Returns true if this element is supported, false otherwise In XMLParser this always
returns true, but subclasses can determine if an element is supported in their context
according to its name etc. Unsupported elements will be skipped by the parser and
excluded from the resulting DOM object
Parameters:
element - The element to check
Returns:
true if the element is supported, false otherwise
shouldEvaluate
protected boolean shouldEvaluate(Element element)

Checks if this element should be evaluated by the parser This can be overriden by
subclasses to skip certain elements
Parameters:
element - The element to check
Returns:
true if this element should be evaluated by the parser, false to skip it
completely
setParserCallback
public void setParserCallback(ParserCallback parserCallback)

Sets the specified callback to serve as the callback for parsing errors
Parameters:
parserCallback - The callback to use for parsing errors
isCaseSensitive
public boolean isCaseSensitive()

Sets the parser to be case sensitive and retain case, otherwise it will convert all data
to lower case
Returns:
the caseSensitive
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)

Sets the parser to be case sensitive and retain case, otherwise it will convert all data
to lower case

Method Detail

646

Overview (Codename One API)


Parameters:
caseSensitive

Method Detail

- the caseSensitive to set

647

Overview (Codename One API)


com.codename1.xml

Interface ParserCallback
All Known Subinterfaces:
HTMLCallback
All Known Implementing Classes:
Ads, DefaultHTMLCallback, RSSService

public interface

A callback used to dispatch errors encountered while parsing XML resources

Field Summary
Modifier
and Type
static int
static int

Field and Description


ERROR_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the XML
ERROR_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported attribute was found in the XML
ERROR_ENCODING

static int

static int
static int

Error code denoting that the encoding the page needed according to its charset
(usually specified in the content-type response header) is unsupported in the
device
ERROR_MULTIPLE_ROOTS

Error code denoting that the document had more than one root element
ERROR_NO_CLOSE_TAG

Error code denoting that a tag was not closed properly in the XML
ERROR_NO_ROOTS

static int

static int
static int
static int

Error code denoting that the document had no root element at all (empty
document or seriously malformed XML)
ERROR_TAG_NOT_SUPPORTED

Error code denoting that an unsupported tag was found in the XML
ERROR_UNEXPECTED_CHARACTER

Error code denoting that the parser bumped into an unexpected character
ERROR_UNEXPECTED_TAG_CLOSING

Error code denoting that a tag was not closed prematurely


ERROR_UNRECOGNIZED_CHAR_ENTITY

static int

Error code denoting that an invalid character entity was found A character
entity is XML codes that start with an ampersand and end with semicolon and
denote special/reserved chars

Method Summary
Modifier and
Type
boolean

Method and Description


parsingError(int errorId, String tag, String attribute,
String value, String description)

Called when encountering an error while parsing the XML document.

Field Detail

Interface ParserCallback

648

Overview (Codename One API)


ERROR_TAG_NOT_SUPPORTED
static final int ERROR_TAG_NOT_SUPPORTED

Error code denoting that an unsupported tag was found in the XML
See Also:
Constant Field Values
ERROR_ATTRIBUTE_NOT_SUPPORTED
static final int ERROR_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported attribute was found in the XML
See Also:
Constant Field Values
ERROR_ATTIBUTE_VALUE_INVALID
static final int ERROR_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the XML
See Also:
Constant Field Values
ERROR_NO_CLOSE_TAG
static final int ERROR_NO_CLOSE_TAG

Error code denoting that a tag was not closed properly in the XML
See Also:
Constant Field Values
ERROR_UNRECOGNIZED_CHAR_ENTITY
static final int ERROR_UNRECOGNIZED_CHAR_ENTITY

Error code denoting that an invalid character entity was found A character entity is
XML codes that start with an ampersand and end with semicolon and denote
special/reserved chars
See Also:
Constant Field Values
ERROR_UNEXPECTED_TAG_CLOSING
static final int ERROR_UNEXPECTED_TAG_CLOSING

Error code denoting that a tag was not closed prematurely


See Also:
Constant Field Values
ERROR_UNEXPECTED_CHARACTER
static final int ERROR_UNEXPECTED_CHARACTER

Error code denoting that the parser bumped into an unexpected character
See Also:
Constant Field Values
ERROR_MULTIPLE_ROOTS
static final int ERROR_MULTIPLE_ROOTS

Error code denoting that the document had more than one root element
See Also:
Constant Field Values
ERROR_NO_ROOTS
static final int ERROR_NO_ROOTS

Error code denoting that the document had no root element at all (empty document or
seriously malformed XML)
See Also:
Constant Field Values

Field Detail

649

Overview (Codename One API)


ERROR_ENCODING
static final int ERROR_ENCODING

Error code denoting that the encoding the page needed according to its charset
(usually specified in the content-type response header) is unsupported in the device
See Also:
Constant Field Values

Method Detail
parsingError
boolean parsingError(int errorId,
String tag,
String attribute,
String value,
String description)

Called when encountering an error while parsing the XML document. When
implementing this, the developer should return true if the error should be ignored and
the document needs to be further parsed, or false to stop parsing and issue an error
to the user Note that this method is always called NOT on the EDT thread.
Parameters:
errorId - The error ID, one of the ERROR_* constants
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)
value - The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Returns:
true to continue parsing, false to stop

Field Detail

650

Overview (Codename One API)


com.codename1.xml

Class Element
java.lang.Object

com.codename1.xml.Element
All Implemented Interfaces:
Iterable<Element>
Direct Known Subclasses:
HTMLElement

public class
extends Object
implements Iterable<Element>

The Element class defines a single XML element with its attributes and children. Due to its hierarchial
nature, this class can be used for a single "leaf" Element, for more complex elements (with child
elements), and up to describing the entire document.

Field Summary
Modifier and
Type

Field and Description


DEPTH_INFINITE

static int

A constant that can be used for the get descendants methods to denote
infinite recursion

Constructor Summary
Modifier

Constructor and Description


Element()

protected

Constructs and Element without specifying a name This can be used by


subclasses that do not require name assigments.
Element(String tagName)

Constructs an Element with the specified name


Element(String tagName, boolean isTextElement)

Constructs an Element (or a text element) with the specified name or text.

Method Summary
Modifier and Type
void

Method and Description


addChild(Element childElement)

Adds the specified Element as a child to this element.


contains(Element element)

boolean

Returns true if the specified element is contained in this element's


hierarchy (meaning it is one of its descendants)
getAttribute(String name)

String

int
Hashtable
Element

Method Detail

Returns the attribute value by its name (or null if it wasn't defined for
this element)
getAttributeAsInt(String name, int def)

Helper method to return the attribute as an integer


getAttributes()

Returns the attributes Hashtable


getChildAt(int index)

Returns the Element's child positioned at the specified index

651

Overview (Codename One API)


int

getChildIndex(Element child)

Returns the child index


getChildren()

protected Vector

Vector
Vector
Vector

Vector

Element
Element
int
Element
String
String
Vector
Vector

Vector

Deprecated.
this uses the old vector API instead of the more modern Collection/List
getChildrenByTagName(String name)

Returns all children with the specified tag name


getDescendantsByTagName(String name)

Returns all descendants with the specified tag name


getDescendantsByTagName(String name, int depth)

Returns all descendants with the specified tag name


getDescendantsByTagNameAndAttribute(String name,
String attributeName, int depth)

Returns all descendants with the specified tag name and the none
empty attribute
getElementById(String id)

Returns the element with the specified ID


getFirstChildByTagName(String name)

Returns an Element's child by a tag name


getNumChildren()

Returns the number of this Element's children


getParent()

Returns this Element's parent


getTagName()

Returns this Element's tag name


getText()

Returns the text of this element (for text elements only)


getTextChildren(String text, boolean caseSensitive)

Returns all children with the specified text


getTextDescendants(String text, boolean caseSensitive)

Returns all text descendants containing the specified text


getTextDescendants(String text, boolean caseSensitive,
int depth)

Returns all text descendants containing the specified text


boolean
void
boolean
boolean

hasTextChild()

Determines whether or not this Element has any text children.


insertChildAt(Element child, int index)

Inserts the given child at the specified index


isEmpty()

Determines whether or not this Element has no children.


isTextElement()

Returns true if this is a text element, false otherwise


iterator()

Iterator<Element>

Iterable for children of this entry making tree walking easier, this makes
for(Element child : base) {} possible
removeAttribute(Object id)

protected void

void
void
void

Removes the specified attribute if it exist in this Element This method


allows creating a key that is non-string to be used by subclasses that
optimize attributes retrieval
removeAttribute(String attribute)

Removes the specified attribute


removeChildAt(int index)

Removes the child at the given index


replaceChild(Element oldChild, Element newChild)

Replaces one child with another


setAttribute(Object id, String value)

protected void

Adds the specified attribute and value to this Element if it is supported


for the Element and has a valid value.

int

setAttribute(String attribute, String value)

Method Summary

652

Overview (Codename One API)


Adds the specified attribute and value to this Element if it is supported
for the Element and has a valid value.
setChildren(Vector children)
protected void

protected void
protected void

Deprecated.
this uses the old vector API instead of the more modern Collection/List
setParent(Element parent)

Sets this element parent, done interanlly in addChild


setTagName(String name)

Sets the name or text (for text elements) of this tag


setText(String str)

Sets the text of this element to the specified string (For text elements
only)

void

protected void

setTextElement(boolean textElement)

Sets this element as a text element


toString()

String

Returns a printable string representing this element

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
DEPTH_INFINITE
public static final int DEPTH_INFINITE

A constant that can be used for the get descendants methods to denote infinite
recursion
See Also:
Constant Field Values

Constructor Detail
Element
protected Element()

Constructs and Element without specifying a name This can be used by subclasses
that do not require name assigments.
Element
public Element(String tagName)

Constructs an Element with the specified name


Parameters:
tagName - The tag name
Element
public Element(String tagName,
boolean isTextElement)

Constructs an Element (or a text element) with the specified name or text.
Parameters:
tagName - The tag name, or in the case of a text element the element's text
isTextElement - true for a text element, false otherwise

Method Detail

Methods inherited from class java.lang.Object

653

Overview (Codename One API)


isTextElement
public boolean isTextElement()

Returns true if this is a text element, false otherwise


Returns:
true if this is a text element, false otherwise
getTagName
public String getTagName()

Returns this Element's tag name


Returns:
the Element's tag name
Throws:
IllegalStateException - if this is a text element
getAttributes
public Hashtable getAttributes()

Returns the attributes Hashtable


Returns:
the attributes Hashtable
setAttribute
protected void setAttribute(Object id,
String value)

Adds the specified attribute and value to this Element if it is supported for the
Element and has a valid value. This method allows creating a key that is non-string to
be used by subclasses that optimize attributes retrieval
Parameters:
id - The attribute ID
value - The attribute value
addChild
public void addChild(Element childElement)

Adds the specified Element as a child to this element. If the specified element was
found to be unsupported (i.e. it's ID is TAG_UNSUPPORTED, it is not added.
Parameters:
childElement - The child element
setParent
protected void setParent(Element parent)

Sets this element parent, done interanlly in addChild


Parameters:
parent - The element's parent
getParent
public Element getParent()

Returns this Element's parent


Returns:
this Element's parent
getNumChildren
public int getNumChildren()

Returns the number of this Element's children


Returns:
the number of this Element's children

Method Detail

654

Overview (Codename One API)


getChildren
protected Vector getChildren()

Deprecated. this uses the old vector API instead of the more modern Collection/List
Returns the internal children vector
Returns:
the children vector
setChildren
protected void setChildren(Vector children)

Deprecated. this uses the old vector API instead of the more modern Collection/List
Sets the children vector of this Element
Parameters:
children - The vector to set as this Element's children
setTagName
protected void setTagName(String name)

Sets the name or text (for text elements) of this tag


Parameters:
name - The name or text of this tag
setTextElement
protected void setTextElement(boolean textElement)

Sets this element as a text element


Parameters:
textElement - true to set this as a text element, false otherwise
getChildAt
public Element getChildAt(int index)

Returns the Element's child positioned at the specified index


Parameters:
index - The requested index
Returns:
child number index of this ELement
Throws:
ArrayIndexOutOfBoundsException - if the index is bigger than the children's
count or smaller than 0
getFirstChildByTagName
public Element getFirstChildByTagName(String name)

Returns an Element's child by a tag name


Parameters:
name - The child's tag name
Returns:
the first child with the specified name, or null if not found
getElementById
public Element getElementById(String id)

Returns the element with the specified ID


Parameters:
id - The id to find
Returns:
An element with the id, or null if none found
getDescendantsByTagNameAndAttribute
public Vector getDescendantsByTagNameAndAttribute(String name,
String attributeName,
int depth)

Returns all descendants with the specified tag name and the none empty attribute

Method Detail

655

Overview (Codename One API)


Parameters:
name - The tag name to look for
attributeName - the attribute that must exist on the tag
depth - The search depth (1 - children, 2 - grandchildren

....
DEPTH_INFINITE - for all descendants)
Returns:
A vector containing descendants with the specified tag name
getDescendantsByTagName
public Vector getDescendantsByTagName(String name,
int depth)

Returns all descendants with the specified tag name


Parameters:
name - The tag name to look for
depth - The search depth (1 - children, 2 - grandchildren ....
DEPTH_INFINITE - for all descendants)
Returns:
A vector containing descendants with the specified tag name
getDescendantsByTagName
public Vector getDescendantsByTagName(String name)

Returns all descendants with the specified tag name


Parameters:
name - The tag name to look for
Returns:
A vector containing descendants with the specified tag name
getChildrenByTagName
public Vector getChildrenByTagName(String name)

Returns all children with the specified tag name


Parameters:
name - The tag name to look for
Returns:
A vector containing children with the specified tag name
getTextDescendants
public Vector getTextDescendants(String text,
boolean caseSensitive,
int depth)

Returns all text descendants containing the specified text


Parameters:
text - The text to look for (null to return all text children)
caseSensitive - true to perform a case sensitive match, false to ignore case
depth - The search depth (1 - children, 2 - grandchildren ....
DEPTH_INFINITE - for all descendants)
Returns:
A vector containing descendants containing the specified text
getTextDescendants
public Vector getTextDescendants(String text,
boolean caseSensitive)

Returns all text descendants containing the specified text


Parameters:
text - The text to look for (null to return all text children)
caseSensitive - true to perform a case sensitive match, false to ignore case
Returns:
A vector containing decensants containing the specified text
getTextChildren
public Vector getTextChildren(String text,
boolean caseSensitive)

Method Detail

656

Overview (Codename One API)


Returns all children with the specified text
Parameters:
text - The text to look for (null to return all text children)
caseSensitive - true to perform a case sensitive match, false to ignore case
Returns:
A vector containing children containing the specified text
contains
public boolean contains(Element element)

Returns true if the specified element is contained in this element's hierarchy (meaning
it is one of its descendants)
Parameters:
element - The element to look for
Returns:
true if this element contains the specified element, false otherwise
setAttribute
public int setAttribute(String attribute,
String value)

Adds the specified attribute and value to this Element if it is supported for the
Element and has a valid value.
Parameters:
attribute - The attribute's name
value - The attribute's value
Returns:
a positive error code or -1 if attribute is supported and valid
removeAttribute
public void removeAttribute(String attribute)

Removes the specified attribute


Parameters:
attribute - The attribute to remove
removeAttribute
protected void removeAttribute(Object id)

Removes the specified attribute if it exist in this Element This method allows creating
a key that is non-string to be used by subclasses that optimize attributes retrieval
Parameters:
id - The attribute ID
getAttributeAsInt
public int getAttributeAsInt(String name,
int def)

Helper method to return the attribute as an integer


Parameters:
name - the name of the attribute
def - default value
Returns:
return value
getAttribute
public String getAttribute(String name)

Returns the attribute value by its name (or null if it wasn't defined for this element)
Parameters:
name - The attribute id
Returns:
the attribute value by its name (or null if it wasn't defined for this element)

Method Detail

657

Overview (Codename One API)


removeChildAt
public void removeChildAt(int index)

Removes the child at the given index


Parameters:
index - The child's index
getChildIndex
public int getChildIndex(Element child)

Returns the child index


Parameters:
child - The child element to look for
Returns:
The child position, or -1 if the child does not belong to this element.
insertChildAt
public void insertChildAt(Element child,
int index)

Inserts the given child at the specified index


Parameters:
child - The child to insert
index - The index to insert it at
replaceChild
public void replaceChild(Element oldChild,
Element newChild)

Replaces one child with another


Parameters:
oldChild - The child to replace (Must belong to this element, otherwise a call
to this method will have no effect)
newChild - The child to replace it with
getText
public String getText()

Returns the text of this element (for text elements only)


Returns:
the text of this element (for text elements only)
Throws:
IllegalStateException - if this is not a text element
setText
public void setText(String str)

Sets the text of this element to the specified string (For text elements only)
Parameters:
str - The text to set
Throws:
IllegalStateException - if this is not a text element
toString
public String toString()

Returns a printable string representing this element


Overrides:
toString in class Object
Returns:
a printable string representing this element
hasTextChild
public boolean hasTextChild()

Determines whether or not this Element has any text children.

Method Detail

658

Overview (Codename One API)


Returns:
true if any of this Elements children are text Elements.
isEmpty
public boolean isEmpty()

Determines whether or not this Element has no children.


Returns:
true if this Element has no children.
iterator
public Iterator<Element> iterator()

Iterable for children of this entry making tree walking easier, this makes for(Element
child : base) {} possible
Specified by:
iterator in interface Iterable<Element>
Returns:
the children iterator

Method Detail

659

Overview (Codename One API)


com.codename1.util.regex

Class StringReader
java.lang.Object

java.io.Reader

com.codename1.util.regex.StringReader
All Implemented Interfaces:
AutoCloseable

public class
extends Reader

Field Summary

Fields inherited from class java.io.Reader


lock

Constructor Summary
Constructor and Description
StringReader(String str)

Method Summary
Modifier and Type

Method and Description


close()

void

Close the stream.


read()

int

Read a single character.


read(char[] cbuf, int off, int len)

int

Read characters into a portion of an array.

String

readLine()

boolean

ready()

Tell whether this stream is ready to be read.

Methods inherited from class java.io.Reader


mark, markSupported, read, reset, skip

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
StringReader
public StringReader(String str)

Class StringReader

660

Overview (Codename One API)


Method

Detail

read
public int read()

Description copied from class: Reader


Read a single character. This method will block until a character is available, an I/O
error occurs, or the end of the stream is reached. Subclasses that intend to support
efficient single-character input should override this method.
Overrides:
read in class Reader
read
public int read(char[] cbuf,
int off,
int len)

Description copied from class: Reader


Read characters into a portion of an array. This method will block until some input is
available, an I/O error occurs, or the end of the stream is reached.
Specified by:
read in class Reader
close
public void close()

Description copied from class: Reader


Close the stream. Once a stream has been closed, further read(), ready(), mark(), or
reset() invocations will throw an IOException. Closing a previously-closed stream,
however, has no effect.
Specified by:
close in interface AutoCloseable
Specified by:
close in class Reader
readLine
public String readLine()

ready
public boolean ready()

Description copied from class: Reader


Tell whether this stream is ready to be read.
Overrides:
ready in class Reader

Method Detail

661

Overview (Codename One API)


com.codename1.util.regex

Class StringCharacterIterator
java.lang.Object

com.codename1.util.regex.StringCharacterIterator
All Implemented Interfaces:
CharacterIterator

public final class


extends Object
implements CharacterIterator

Encapsulates String as CharacterIterator.


Version:
CVS $Id: StringCharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
StringCharacterIterator(String src)

Method Summary
Modifier and Type

Method and Description

char

charAt(int pos)

boolean

isEnd(int pos)

String

substring(int beginIndex)

String

substring(int beginIndex, int endIndex)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
StringCharacterIterator
public StringCharacterIterator(String src)

Parameters:
src - - encapsulated String

Method Detail
substring
public String substring(int beginIndex,
int endIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring

Class StringCharacterIterator

662

Overview (Codename One API)


substring
public String substring(int beginIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring
charAt
public char charAt(int pos)

Specified by:
charAt in interface CharacterIterator
Returns:
a character at the specified position.
isEnd
public boolean isEnd(int pos)

Specified by:
isEnd

in interface CharacterIterator

Returns:
true

Method Detail

iff if the specified index is after the end of the character stream

663

Overview (Codename One API)


com.codename1.util.regex

Class StreamCharacterIterator
java.lang.Object

com.codename1.util.regex.StreamCharacterIterator
All Implemented Interfaces:
CharacterIterator

public final class


extends Object
implements CharacterIterator

Encapsulates java.io.InputStream as CharacterIterator.


Version:
CVS $Id: StreamCharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
StreamCharacterIterator(InputStream is)

Method Summary
Modifier and Type

Method and Description

char

charAt(int pos)

boolean

isEnd(int pos)

String

substring(int beginIndex)

String

substring(int beginIndex, int endIndex)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
StreamCharacterIterator
public StreamCharacterIterator(InputStream is)

Parameters:
is - an InputStream, which is parsed

Method Detail
substring
public String substring(int beginIndex,
int endIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring

Class StreamCharacterIterator

664

Overview (Codename One API)


substring
public String substring(int beginIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring
charAt
public char charAt(int pos)

Specified by:
charAt in interface CharacterIterator
Returns:
a character at the specified position.
isEnd
public boolean isEnd(int pos)

Specified by:
isEnd

in interface CharacterIterator

Returns:
true

Method Detail

iff if the specified index is after the end of the character stream

665

Overview (Codename One API)


com.codename1.util.regex

Class ReaderCharacterIterator
java.lang.Object

com.codename1.util.regex.ReaderCharacterIterator
All Implemented Interfaces:
CharacterIterator

public final class


extends Object
implements CharacterIterator

Encapsulates java.io.Reader as CharacterIterator


Version:
CVS $Id: ReaderCharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
ReaderCharacterIterator(Reader reader)

Method Summary
Modifier and Type

Method and Description

char

charAt(int pos)

boolean

isEnd(int pos)

String

substring(int beginIndex)

String

substring(int beginIndex, int endIndex)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ReaderCharacterIterator
public ReaderCharacterIterator(Reader reader)

Parameters:
reader

- a Reader, which is parsed

Method Detail
substring
public String substring(int beginIndex,
int endIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring

Class ReaderCharacterIterator

666

Overview (Codename One API)


substring
public String substring(int beginIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring
charAt
public char charAt(int pos)

Specified by:
charAt in interface CharacterIterator
Returns:
a character at the specified position.
isEnd
public boolean isEnd(int pos)

Specified by:
isEnd

in interface CharacterIterator

Returns:
true

Method Detail

iff if the specified index is after the end of the character stream

667

Overview (Codename One API)


com.codename1.util.regex

Class REUtil
java.lang.Object

com.codename1.util.regex.REUtil

public class
extends Object

This is a class that contains utility helper methods for this package.
Version:
$Id: REUtil.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
REUtil()

Method Summary
Modifier and Type
static RE
static RE

Method and Description


createRE(String expression)

Creates a regular expression, permitting simple or complex syntax


createRE(String expression, int matchFlags)

Creates a regular expression, permitting simple or complex syntax

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
REUtil
public REUtil()

Method Detail
createRE
public static RE createRE(String expression,
int matchFlags)
throws RESyntaxException

Creates a regular expression, permitting simple or complex syntax


Parameters:
expression - The expression, beginning with a prefix if it's complex or having
no prefix if it's simple
matchFlags - Matching style flags
Returns:
The regular expression object
Throws:
RESyntaxException - thrown in case of error

Class REUtil

668

Overview (Codename One API)


createRE
public static RE createRE(String expression)
throws RESyntaxException

Creates a regular expression, permitting simple or complex syntax


Parameters:
expression - The expression, beginning with a prefix if it's complex or having
no prefix if it's simple
Returns:
The regular expression object
Throws:
RESyntaxException - thrown in case of error

Method Detail

669

Overview (Codename One API)


com.codename1.util.regex

Class RESyntaxException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.lang.RuntimeException

com.codename1.util.regex.RESyntaxException

public class
extends RuntimeException

Exception thrown to indicate a syntax error in a regular expression. This is a non-checked exception
because you should only have problems compiling a regular expression during development. If you
are making regular expresion programs dynamically then you can catch it if you wish. But should not
be forced to.
Version:
$Id: RESyntaxException.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
RESyntaxException(String s)

Constructor.

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
RESyntaxException
public RESyntaxException(String s)

Constructor.
Parameters:
s - Further description of the syntax error

Class RESyntaxException

670

Overview (Codename One API)


com.codename1.util.regex

Class REProgram
java.lang.Object

com.codename1.util.regex.REProgram

public class
extends Object

A class that holds compiled regular expressions. You should not need to work directly with this class.
Version:
$Id: REProgram.java 518156 2007-03-14 14:31:26Z vgritsenko $
See Also:
RE, RECompiler

Constructor Summary
Constructor and Description
REProgram(char[] instruction)

Constructs a program object from a character array


REProgram(char[] instruction, int lenInstruction)

Constructs a program object from a character array


REProgram(int parens, char[] instruction)

Constructs a program object from a character array

Method Summary
Modifier and
Type

Method and Description


getInstructions()

char[]

Returns a copy of the current regular expression program in a character


array that is exactly the right length to hold the program.
getPrefix()

char[]

Returns a copy of the prefix of current regular expression program in a


character array.
setInstructions(char[] instruction, int lenInstruction)

void

Sets a new regular expression program to run.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
REProgram
public REProgram(char[] instruction)

Constructs a program object from a character array


Parameters:
instruction - Character array with RE opcode instructions in it

Constructor Detail

671

Overview (Codename One API)


REProgram
public REProgram(int parens,
char[] instruction)

Constructs a program object from a character array


Parameters:
parens - Count of parens in the program
instruction - Character array with RE opcode instructions in it
REProgram
public REProgram(char[] instruction,
int lenInstruction)

Constructs a program object from a character array


Parameters:
instruction - Character array with RE opcode instructions in it
lenInstruction - Amount of instruction array in use

Method Detail
getInstructions
public char[] getInstructions()

Returns a copy of the current regular expression program in a character array that is
exactly the right length to hold the program. If there is no program compiled yet,
getInstructions() will return null.
Returns:
A copy of the current compiled RE program
setInstructions
public void setInstructions(char[] instruction,
int lenInstruction)

Sets a new regular expression program to run. It is this method which performs any
special compile-time search optimizations. Currently only two optimizations are in
place - one which checks for backreferences (so that they can be lazily allocated) and
another which attempts to find an prefix anchor string so that substantial amounts of
input can potentially be skipped without running the actual program.
Parameters:
instruction - Program instruction buffer
lenInstruction - Length of instruction buffer in use
getPrefix
public char[] getPrefix()

Returns a copy of the prefix of current regular expression program in a character


array. If there is no prefix, or there is no program compiled yet, getPrefix will return
null.
Returns:
A copy of the prefix of current compiled RE program

Constructor Detail

672

Overview (Codename One API)


com.codename1.util.regex

Class REDebugCompiler
java.lang.Object

com.codename1.util.regex.RECompiler

com.codename1.util.regex.REDebugCompiler

public class
extends RECompiler

A subclass of RECompiler which can dump a regular expression program for debugging purposes.

Constructor Summary
Constructor and Description
REDebugCompiler()

Method Summary
Modifier and Type

Method and Description


dumpProgram()

void

Dumps the current program to a System.out.


dumpProgram(PrintStream p)

void

Dumps the current program to a PrintStream.

Methods inherited from


class com.codename1.util.regex.RECompiler
compile

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
REDebugCompiler
public REDebugCompiler()

Method Detail
dumpProgram
public void dumpProgram(PrintStream p)

Dumps the current program to a PrintStream.


Parameters:
p - PrintStream for program dump output
dumpProgram
public void dumpProgram()

Dumps the current program to a System.out.

Method Detail

673

Overview (Codename One API)


com.codename1.util.regex

Class RECompiler
java.lang.Object

com.codename1.util.regex.RECompiler
Direct Known Subclasses:
REDebugCompiler

public class
extends Object

A regular expression compiler class. This class compiles a pattern string into a regular expression
program interpretable by the RE evaluator class. The 'recompile' command line tool uses this
compiler to pre-compile regular expressions for use with RE. For a description of the syntax accepted
by RECompiler and what you can do with regular expressions, see the documentation for the RE
matcher class.
Version:
$Id: RECompiler.java 518156 2007-03-14 14:31:26Z vgritsenko $
See Also:
RE

Constructor Summary
Constructor and Description
RECompiler()

Constructor.

Method Summary
Modifier and
Type

Method and Description


compile(String pattern)

REProgram

Compiles a regular expression pattern into a program runnable by the


pattern matcher class 'RE'.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
RECompiler
public RECompiler()

Constructor. Creates (initially empty) storage for a regular expression program.

Method Detail
compile
public REProgram compile(String pattern)
throws RESyntaxException

Method Detail

674

Overview (Codename One API)


Compiles a regular expression pattern into a program runnable by the pattern
matcher class 'RE'.
Parameters:
pattern - Regular expression pattern to compile (see RECompiler class for
details).
Returns:
A compiled regular expression program.
Throws:
RESyntaxException - Thrown if the regular expression has invalid syntax.
See Also:
RECompiler, RE

Method Detail

675

Overview (Codename One API)


com.codename1.util.regex

Class RECharacter
java.lang.Object

com.codename1.util.regex.RECharacter

public class
extends Object

Field Summary
Modifier and Type

Field and Description

static byte

COMBINING_SPACING_MARK

static byte

CONNECTOR_PUNCTUATION

static byte

CONTROL

static byte

CURRENCY_SYMBOL

static byte

DASH_PUNCTUATION

static byte

DECIMAL_DIGIT_NUMBER

static byte

ENCLOSING_MARK

static byte

END_PUNCTUATION

static byte

FORMAT

static byte

LETTER_NUMBER

static byte

LINE_SEPARATOR

static byte

LOWERCASE_LETTER

static byte

MATH_SYMBOL

static byte

MODIFIER_LETTER

static byte

MODIFIER_SYMBOL

static byte

NON_SPACING_MARK

static byte

OTHER_LETTER

static byte

OTHER_NUMBER

static byte

OTHER_PUNCTUATION

static byte

OTHER_SYMBOL

static byte

PARAGRAPH_SEPARATOR

static byte

PRIVATE_USE

static byte

SPACE_SEPARATOR

static byte

START_PUNCTUATION

static byte

SURROGATE

static byte

TITLECASE_LETTER

static byte

UNASSIGNED

static byte

UPPERCASE_LETTER

Constructor Summary
Constructor and Description
RECharacter()

Class RECharacter

676

Overview (Codename One API)


Method

Summary

Modifier and Type

Method and Description

static byte

getType(char c)

static boolean

isDigit(char c)

static boolean

isJavaIdentifierPart(char c)

static boolean

isJavaIdentifierStart(char c)

static boolean

isLetter(char c)

static boolean

isLetterOrDigit(char c)

static boolean

isSpaceChar(char c)

static boolean

isWhitespace(char c)

static char

toLowerCase(char c)

static char

toUpperCase(char c)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
UNASSIGNED
public static final byte UNASSIGNED

See Also:
Constant Field Values
UPPERCASE_LETTER
public static final byte UPPERCASE_LETTER

See Also:
Constant Field Values
LOWERCASE_LETTER
public static final byte LOWERCASE_LETTER

See Also:
Constant Field Values
TITLECASE_LETTER
public static final byte TITLECASE_LETTER

See Also:
Constant Field Values
MODIFIER_LETTER
public static final byte MODIFIER_LETTER

See Also:
Constant Field Values
OTHER_LETTER
public static final byte OTHER_LETTER

See Also:
Constant Field Values

Method Summary

677

Overview (Codename One API)


NON_SPACING_MARK
public static final byte NON_SPACING_MARK

See Also:
Constant Field Values
ENCLOSING_MARK
public static final byte ENCLOSING_MARK

See Also:
Constant Field Values
COMBINING_SPACING_MARK
public static final byte COMBINING_SPACING_MARK

See Also:
Constant Field Values
DECIMAL_DIGIT_NUMBER
public static final byte DECIMAL_DIGIT_NUMBER

See Also:
Constant Field Values
LETTER_NUMBER
public static final byte LETTER_NUMBER

See Also:
Constant Field Values
OTHER_NUMBER
public static final byte OTHER_NUMBER

See Also:
Constant Field Values
SPACE_SEPARATOR
public static final byte SPACE_SEPARATOR

See Also:
Constant Field Values
LINE_SEPARATOR
public static final byte LINE_SEPARATOR

See Also:
Constant Field Values
PARAGRAPH_SEPARATOR
public static final byte PARAGRAPH_SEPARATOR

See Also:
Constant Field Values
CONTROL
public static final byte CONTROL

See Also:
Constant Field Values
FORMAT
public static final byte FORMAT

See Also:
Constant Field Values

Field Detail

678

Overview (Codename One API)


PRIVATE_USE
public static final byte PRIVATE_USE

See Also:
Constant Field Values
SURROGATE
public static final byte SURROGATE

See Also:
Constant Field Values
DASH_PUNCTUATION
public static final byte DASH_PUNCTUATION

See Also:
Constant Field Values
START_PUNCTUATION
public static final byte START_PUNCTUATION

See Also:
Constant Field Values
END_PUNCTUATION
public static final byte END_PUNCTUATION

See Also:
Constant Field Values
CONNECTOR_PUNCTUATION
public static final byte CONNECTOR_PUNCTUATION

See Also:
Constant Field Values
OTHER_PUNCTUATION
public static final byte OTHER_PUNCTUATION

See Also:
Constant Field Values
MATH_SYMBOL
public static final byte MATH_SYMBOL

See Also:
Constant Field Values
CURRENCY_SYMBOL
public static final byte CURRENCY_SYMBOL

See Also:
Constant Field Values
MODIFIER_SYMBOL
public static final byte MODIFIER_SYMBOL

See Also:
Constant Field Values
OTHER_SYMBOL
public static final byte OTHER_SYMBOL

See Also:
Constant Field Values

Field Detail

679

Overview (Codename One API)


Constructor

Detail

RECharacter
public RECharacter()

Method Detail
toLowerCase
public static char toLowerCase(char c)

toUpperCase
public static char toUpperCase(char c)

isWhitespace
public static boolean isWhitespace(char c)

isDigit
public static boolean isDigit(char c)

isLetter
public static boolean isLetter(char c)

isLetterOrDigit
public static boolean isLetterOrDigit(char c)

isSpaceChar
public static boolean isSpaceChar(char c)

isJavaIdentifierStart
public static boolean isJavaIdentifierStart(char c)

isJavaIdentifierPart
public static boolean isJavaIdentifierPart(char c)

getType
public static byte getType(char c)

Constructor Detail

680

Overview (Codename One API)


com.codename1.util.regex

Class RE
java.lang.Object

com.codename1.util.regex.RE

public class
extends Object

RE is an efficient, lightweight regular expression evaluator/matcher class. Regular expressions are


pattern descriptions which enable sophisticated matching of strings. In addition to being able to match
a string against a pattern, you can also extract parts of the match. This is especially useful in text
parsing! Details on the syntax of regular expression patterns are given below.
To compile a regular expression (RE), you can simply construct an RE matcher object from the string
specification of the pattern, like this:
RE r = new RE("a*b");

Once you have done this, you can call either of the RE.match methods to perform matching on a
String. For example:
boolean matched = r.match("aaaab");

will cause the boolean matched to be set to true because the pattern "a*b" matches the string
"aaaab".
If you were interested in the number of a's which matched the first part of our example expression,
you could change the expression to "(a*)b". Then when you compiled the expression and matched it
against something like "xaaaab", you would get results like this:
RE r = new RE("(a*)b");
boolean matched = r.match("xaaaab");

// Compile expression
// Match against "xaaaab"

String wholeExpr = r.getParen(0);


String insideParens = r.getParen(1);

// wholeExpr will be 'aaaab'


// insideParens will be 'aaaa'

int startWholeExpr = r.getParenStart(0); // startWholeExpr will be index 1


int endWholeExpr = r.getParenEnd(0);
// endWholeExpr will be index 6
int lenWholeExpr = r.getParenLength(0); // lenWholeExpr will be 5
int startInside = r.getParenStart(1);
int endInside = r.getParenEnd(1);
int lenInside = r.getParenLength(1);

// startInside will be index 1


// endInside will be index 5
// lenInside will be 4

You can also refer to the contents of a parenthesized expression within a regular expression itself.
This is called a 'backreference'. The first backreference in a regular expression is denoted by \1, the
second by \2 and so on. So the expression:
([0-9]+)=\1

will match any string of the form n=n (like 0=0 or 2=2).
The full regular expression syntax accepted by RE is described here:
Characters
unicodeChar
\
\\
\0nnn
\xhh

Method Detail

Matches any identical unicode character


Used to quote a meta-character (like '*')
Matches a single '\' character
Matches a given octal character
Matches a given 8-bit hexadecimal character

681

Overview (Codename One API)


\\uhhhh
\t
\n
\r
\f

Matches
Matches
Matches
Matches
Matches

a given 16-bit hexadecimal character


an ASCII tab character
an ASCII newline character
an ASCII return character
an ASCII form feed character

Character Classes
[abc]
[a-zA-Z]
[^abc]

Simple character class


Character class with ranges
Negated character class

NOTE: Incomplete ranges will be interpreted as "starts from zero" or "ends with last character".
I.e. [-a] is the same as [\\u0000-a], and [a-] is the same as [a-\\uFFFF], [-] means "all characters".
Standard POSIX Character Classes
[:alnum:]
[:alpha:]
[:blank:]
[:cntrl:]
[:digit:]
[:graph:]

Alphanumeric characters.
Alphabetic characters.
Space and tab characters.
Control characters.
Numeric characters.
Characters that are printable and are also visible.
(A space is printable, but not visible, while an
`a' is both.)
Lower-case alphabetic characters.
Printable characters (characters that are not
control characters.)
Punctuation characters (characters that are not letter,
digits, control characters, or space characters).
Space characters (such as space, tab, and formfeed,
to name a few).
Upper-case alphabetic characters.
Characters that are hexadecimal digits.

[:lower:]
[:print:]
[:punct:]
[:space:]
[:upper:]
[:xdigit:]

Non-standard POSIX-style Character Classes


[:javastart:]
[:javapart:]

Start of a Java identifier


Part of a Java identifier

Predefined Classes
.
\w
\W
\s
\S
\d
\D

Matches
Matches
Matches
Matches
Matches
Matches
Matches

any character other than newline


a "word" character (alphanumeric plus "_")
a non-word character
a whitespace character
a non-whitespace character
a digit character
a non-digit character

Boundary Matchers
^
$
\b
\B

Matches
Matches
Matches
Matches

only
only
only
only

Matches
Matches
Matches
Matches
Matches
Matches

A
A
A
A
A
A

at
at
at
at

the beginning of a line


the end of a line
a word boundary
a non-word boundary

Greedy Closures
A*
A+
A?
A{n}
A{n,}
A{n,m}

0 or more times (greedy)


1 or more times (greedy)
1 or 0 times (greedy)
exactly n times (greedy)
at least n times (greedy)
at least n but not more than m times (greedy)

Reluctant Closures
A*?
A+?

Class RE

Matches A 0 or more times (reluctant)


Matches A 1 or more times (reluctant)

682

Overview (Codename One API)


A??

Matches A 0 or 1 times (reluctant)

Logical Operators
AB
A|B
(A)
(?:A)

Matches A followed by B
Matches either A or B
Used for subexpression grouping
Used for subexpression clustering (just like grouping but
no backrefs)

Backreferences
\1
\2
\3
\4
\5
\6
\7
\8
\9

Backreference
Backreference
Backreference
Backreference
Backreference
Backreference
Backreference
Backreference
Backreference

to
to
to
to
to
to
to
to
to

1st
2nd
3rd
4th
5th
6th
7th
8th
9th

parenthesized
parenthesized
parenthesized
parenthesized
parenthesized
parenthesized
parenthesized
parenthesized
parenthesized

subexpression
subexpression
subexpression
subexpression
subexpression
subexpression
subexpression
subexpression
subexpression

All closure operators (+, *, ?, {m,n}) are greedy by default, meaning that they match as many
elements of the string as possible without causing the overall match to fail. If you want a closure to be
reluctant (non-greedy), you can simply follow it with a '?'. A reluctant closure will match as few
elements of the string as possible when finding matches. {m,n} closures don't currently support
reluctancy.
Line terminators
A line terminator is a one- or two-character sequence that marks the end of a line of the input
character sequence. The following are recognized as line terminators:
A newline (line feed) character ('\n'),
A carriage-return character followed immediately by a newline character ("\r\n"),
A standalone carriage-return character ('\r'),
A next-line character (' '),
A line-separator character (' '), or
A paragraph-separator character (' ).
RE runs programs compiled by the RECompiler class. But the RE matcher class does not include the
actual regular expression compiler for reasons of efficiency. You can construct a single RECompiler
object and re-use it to compile each expression. Similarly, you can change the program run by a given
matcher object at any time. However, RE and RECompiler are not threadsafe (for efficiency reasons,
and because requiring thread safety in this class is deemed to be a rare requirement), so you will
need to construct a separate compiler or matcher object for each thread (unless you do thread
synchronization yourself). Once expression compiled into the REProgram object, REProgram can be
safely shared across multiple threads and RE objects.
ISSUES:
com.weusours.util.re is not currently compatible with all standard POSIX regcomp flags
com.weusours.util.re does not support POSIX equivalence classes ([=foo=] syntax)
(I18N/locale issue)
com.weusours.util.re does not support nested POSIX character classes (definitely should, but
not completely trivial)
com.weusours.util.re Does not support POSIX character collation concepts ([.foo.] syntax)
(I18N/locale issue)
Should there be different matching styles (simple, POSIX, Perl etc?)
Should RE support character iterators (for backwards RE matching!)?
Should RE support reluctant {m,n} closures (does anyone care)?
Not *all* possibilities are considered for greediness when backreferences are involved (as
POSIX suggests should be the case). The POSIX RE "(ac*)c*d[ac]*\1", when matched
against "acdacaa" should yield a match of acdacaa where \1 is "a". This is not the case in this
RE package, and actually Perl doesn't go to this extent either! Until someone actually
complains about this, I'm not sure it's worth "fixing". If it ever is fixed, test #137 in RETest.txt
should be updated.
See Also:

Class RE

683

Overview (Codename One API)


RECompiler

Field Summary
Modifier and
Type
static int
static int
static int
static int

Field and Description


MATCH_CASEINDEPENDENT

Flag to indicate that matching should be case-independent (folded)


MATCH_MULTILINE

Newlines should match as BOL/EOL (^ and $)


MATCH_NORMAL

Specifies normal, case-sensitive matching behaviour.


MATCH_SINGLELINE

Consider all input a single body of text - newlines are matched by .


REPLACE_ALL

static int

static int

Flag bit that indicates that subst should replace all occurrences of this
regular expression.
REPLACE_BACKREFERENCES

Flag bit that indicates that subst should replace backreferences


REPLACE_FIRSTONLY

static int

Flag bit that indicates that subst should only replace the first occurrence of
this regular expression.

Constructor Summary
Constructor and Description
RE()

Constructs a regular expression matcher with no initial program.


RE(REProgram program)

Construct a matcher for a pre-compiled regular expression from program (bytecode) data.
RE(REProgram program, int matchFlags)

Construct a matcher for a pre-compiled regular expression from program (bytecode) data.
RE(String pattern)

Constructs a regular expression matcher from a String by compiling it using a new instance
of RECompiler.
RE(String pattern, int matchFlags)

Constructs a regular expression matcher from a String by compiling it using a new instance
of RECompiler.

Method Summary
Modifier
and Type
int
String

Method and Description


getMatchFlags()

Returns the current match behaviour flags.


getParen(int which)

Gets the contents of a parenthesized subexpression after a successful match.


getParenCount()

int

int
int
int

Field Summary

Returns the number of parenthesized subexpressions available after a


successful match.
getParenEnd(int which)

Returns the end index of a given paren level.


getParenLength(int which)

Returns the length of a given paren level.


getParenStart(int which)

684

Overview (Codename One API)


Returns the start index of a given paren level.
REProgram

getProgram()

Returns the current regular expression program in use by this matcher object.
grep(Object[] search)

String[]

protected
void

Returns an array of Strings, whose toString representation matches a regular


expression.
internalError(String s)

Throws an Error representing an internal error condition probably resulting from


a bug in the regular expression compiler (or possibly data corruption).
match(CharacterIterator search, int i)

boolean

boolean

Matches the current regular expression program against a character array,


starting at a given index.
match(String search)

Matches the current regular expression program against a String.


match(String search, int i)

boolean

protected
boolean
protected
int

Matches the current regular expression program against a character array,


starting at a given index.
matchAt(int i)

Match the current regular expression program against the current input string,
starting at index i of the input string.
matchNodes(int firstNode, int lastNode, int idxStart)

Try to match a string against a subset of nodes in the program


setMatchFlags(int matchFlags)

void

Sets match behaviour flags which alter the way RE does matching.

protected
void

setParenEnd(int which, int i)

protected
void

setParenStart(int which, int i)

Sets the end of a paren level


Sets the start of a paren level
setProgram(REProgram program)

void

Sets the current regular expression program used by this matcher object.
simplePatternToFullRegularExpression(String pattern)

static
String

Converts a 'simplified' regular expression to a full regular expression

String[]
String
String

split(String s)

Splits a string into an array of strings on regular expression boundaries.


subst(String substituteIn, String substitution)

Substitutes a string for this regular expression in another string.


subst(String substituteIn, String substitution, int flags)

Substitutes a string for this regular expression in another string.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
MATCH_NORMAL
public static final int MATCH_NORMAL

Specifies normal, case-sensitive matching behaviour.


See Also:
Constant Field Values
MATCH_CASEINDEPENDENT
public static final int MATCH_CASEINDEPENDENT

Flag to indicate that matching should be case-independent (folded)


See Also:
Constant Field Values

Method Summary

685

Overview (Codename One API)


MATCH_MULTILINE
public static final int MATCH_MULTILINE

Newlines should match as BOL/EOL (^ and $)


See Also:
Constant Field Values
MATCH_SINGLELINE
public static final int MATCH_SINGLELINE

Consider all input a single body of text - newlines are matched by .


See Also:
Constant Field Values
REPLACE_ALL
public static final int REPLACE_ALL

Flag bit that indicates that subst should replace all occurrences of this regular
expression.
See Also:
Constant Field Values
REPLACE_FIRSTONLY
public static final int REPLACE_FIRSTONLY

Flag bit that indicates that subst should only replace the first occurrence of this
regular expression.
See Also:
Constant Field Values
REPLACE_BACKREFERENCES
public static final int REPLACE_BACKREFERENCES

Flag bit that indicates that subst should replace backreferences


See Also:
Constant Field Values

Constructor Detail
RE
public RE(String pattern)
throws RESyntaxException

Constructs a regular expression matcher from a String by compiling it using a new


instance of RECompiler. If you will be compiling many expressions, you may prefer to
use a single RECompiler object instead.
Parameters:
pattern - The regular expression pattern to compile.
Throws:
RESyntaxException - Thrown if the regular expression has invalid syntax.
See Also:
RECompiler

RE
public RE(String pattern,
int matchFlags)
throws RESyntaxException

Constructs a regular expression matcher from a String by compiling it using a new


instance of RECompiler. If you will be compiling many expressions, you may prefer to
use a single RECompiler object instead.
Parameters:
pattern - The regular expression pattern to compile.
matchFlags - The matching style

Field Detail

686

Overview (Codename One API)


Throws:
RESyntaxException

- Thrown if the regular expression has invalid syntax.

See Also:
RECompiler

RE
public RE(REProgram program,
int matchFlags)

Construct a matcher for a pre-compiled regular expression from program (bytecode)


data. Permits special flags to be passed in to modify matching behaviour.
Parameters:
program - Compiled regular expression program (see RECompiler)
matchFlags - One or more of the RE match behaviour flags (RE.MATCH_*):
MATCH_NORMAL
MATCH_CASEINDEPENDENT
MATCH_MULTILINE

// Normal (case-sensitive) matching


// Case folded comparisons
// Newline matches as BOL/EOL

See Also:
RECompiler, REProgram

RE
public RE(REProgram program)

Construct a matcher for a pre-compiled regular expression from program (bytecode)


data.
Parameters:
program - Compiled regular expression program
See Also:
RECompiler

RE
public RE()

Constructs a regular expression matcher with no initial program. This is likely to be an


uncommon practice, but is still supported.

Method Detail
simplePatternToFullRegularExpression
public static String simplePatternToFullRegularExpression(String pattern)

Converts a 'simplified' regular expression to a full regular expression


Parameters:
pattern - The pattern to convert
Returns:
The full regular expression
setMatchFlags
public void setMatchFlags(int matchFlags)

Sets match behaviour flags which alter the way RE does matching.
Parameters:
matchFlags - One or more of the RE match behaviour flags (RE.MATCH_*):
MATCH_NORMAL
MATCH_CASEINDEPENDENT
MATCH_MULTILINE

// Normal (case-sensitive) matching


// Case folded comparisons
// Newline matches as BOL/EOL

getMatchFlags
public int getMatchFlags()

Returns the current match behaviour flags.


Returns:

Constructor Detail

687

Overview (Codename One API)


Current match behaviour flags (RE.MATCH_*).
MATCH_NORMAL
MATCH_CASEINDEPENDENT
MATCH_MULTILINE

// Normal (case-sensitive) matching


// Case folded comparisons
// Newline matches as BOL/EOL

See Also:
setMatchFlags(int)

setProgram
public void setProgram(REProgram program)

Sets the current regular expression program used by this matcher object.
Parameters:
program - Regular expression program compiled by RECompiler.
See Also:
RECompiler, REProgram
getProgram
public REProgram getProgram()

Returns the current regular expression program in use by this matcher object.
Returns:
Regular expression program
See Also:
setProgram(com.codename1.util.regex.REProgram)

getParenCount
public int getParenCount()

Returns the number of parenthesized subexpressions available after a successful


match.
Returns:
Number of available parenthesized subexpressions
getParen
public String getParen(int which)

Gets the contents of a parenthesized subexpression after a successful match.


Parameters:
which - Nesting level of subexpression
Returns:
String
getParenStart
public final int getParenStart(int which)

Returns the start index of a given paren level.


Parameters:
which - Nesting level of subexpression
Returns:
String index
getParenEnd
public final int getParenEnd(int which)

Returns the end index of a given paren level.


Parameters:
which - Nesting level of subexpression
Returns:
String index
getParenLength
public final int getParenLength(int which)

Returns the length of a given paren level.


Parameters:
which - Nesting level of subexpression

Method Detail

688

Overview (Codename One API)


Returns:
Number of characters in the parenthesized subexpression
setParenStart
protected final void setParenStart(int which,
int i)

Sets the start of a paren level


Parameters:
which - Which paren level
i - Index in input array
setParenEnd
protected final void setParenEnd(int which,
int i)

Sets the end of a paren level


Parameters:
which - Which paren level
i - Index in input array
internalError
protected void internalError(String s)
throws Error

Throws an Error representing an internal error condition probably resulting from a bug
in the regular expression compiler (or possibly data corruption). In practice, this
should be very rare.
Parameters:
s - Error description
Throws:
Error

matchNodes
protected int matchNodes(int firstNode,
int lastNode,
int idxStart)

Try to match a string against a subset of nodes in the program


Parameters:
firstNode - Node to start at in program
lastNode - Last valid node (used for matching a subexpression without
matching the rest of the program as well).
idxStart - Starting position in character array
Returns:
Final input array index if match succeeded. -1 if not.
matchAt
protected boolean matchAt(int i)

Match the current regular expression program against the current input string, starting
at index i of the input string. This method is only meant for internal use.
Parameters:
i - The input string index to start matching at
Returns:
True if the input matched the expression
match
public boolean match(String search,
int i)

Matches the current regular expression program against a character array, starting at
a given index.
Parameters:
search - String to match against
i - Index to start searching at
Returns:
True if string matched

Method Detail

689

Overview (Codename One API)


match
public boolean match(CharacterIterator search,
int i)

Matches the current regular expression program against a character array, starting at
a given index.
Parameters:
search - String to match against
i - Index to start searching at
Returns:
True if string matched
match
public boolean match(String search)

Matches the current regular expression program against a String.


Parameters:
search - String to match against
Returns:
True if string matched
split
public String[] split(String s)

Splits a string into an array of strings on regular expression boundaries. This function
works the same way as the Perl function of the same name. Given a regular
expression of "[ab]+" and a string to split of "xyzzyababbayyzabbbab123", the result
would be the array of Strings "[xyzzy, yyz, 123]".
Please note that the first string in the resulting array may be an empty string. This
happens when the very first character of input string is matched by the pattern.
Parameters:
s - String to split on this regular exression
Returns:
Array of strings
subst
public String subst(String substituteIn,
String substitution)

Substitutes a string for this regular expression in another string. This method works
like the Perl function of the same name. Given a regular expression of "a*b", a String
to substituteIn of "aaaabfooaaabgarplyaaabwackyb" and the substitution String "-",
the resulting String returned by subst would be "-foo-garply-wacky-".
Parameters:
substituteIn - String to substitute within
substitution - String to substitute for all matches of this regular expression.
Returns:
The string substituteIn with zero or more occurrences of the current regular
expression replaced with the substitution String (if this regular expression
object doesn't match at any position, the original String is returned
unchanged).
subst
public String subst(String substituteIn,
String substitution,
int flags)

Substitutes a string for this regular expression in another string. This method works
like the Perl function of the same name. Given a regular expression of "a*b", a String
to substituteIn of "aaaabfooaaabgarplyaaabwackyb" and the substitution String "-",
the resulting String returned by subst would be "-foo-garply-wacky-".
It is also possible to reference the contents of a parenthesized expression with $0,
$1, ... $9. A regular expression of "http://[\\.\\w\\-\\?/~_@&=%]+", a String to

Method Detail

690

Overview (Codename One API)


substituteIn of "visit us: http://www.apache.org!" and the substitution String "<a
href=\"$0\">$0</a>", the resulting String returned by subst would be "visit us: <a
href=\"http://www.apache.org\">http://www.apache.org</a>!".
Note: $0 represents the whole match.
Parameters:
substituteIn - String to substitute within
substitution - String to substitute for matches of this regular
flags - One or more bitwise flags from REPLACE_*. If the

expression

REPLACE_FIRSTONLY flag bit is set, only the first occurrence of this regular
expression is replaced. If the bit is not set (REPLACE_ALL), all occurrences
of this pattern will be replaced. If the flag REPLACE_BACKREFERENCES is
set, all backreferences will be processed.
Returns:
The string substituteIn with zero or more occurrences of the current regular
expression replaced with the substitution String (if this regular expression
object doesn't match at any position, the original String is returned
unchanged).
grep
public String[] grep(Object[] search)

Returns an array of Strings, whose toString representation matches a regular


expression. This method works like the Perl function of the same name. Given a
regular expression of "a*b" and an array of String objects of [foo, aab, zzz, aaaab],
the array of Strings returned by grep would be [aab, aaaab].
Parameters:
search - Array of Objects to search
Returns:
Array of Strings whose toString() value matches this regular expression.

Method Detail

691

Overview (Codename One API)


com.codename1.util.regex

Interface CharacterIterator
All Known Implementing Classes:
CharacterArrayCharacterIterator, ReaderCharacterIterator, StreamCharacterIterator,
StringCharacterIterator

public interface

Encapsulates different types of character sources - String, InputStream, ... Defines a set of common
methods
Version:
CVS $Id: CharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $

Method Summary
Modifier and Type

Method and Description

char

charAt(int pos)

boolean

isEnd(int pos)

String

substring(int beginIndex)

String

substring(int beginIndex, int endIndex)

Method Detail
substring
String substring(int beginIndex,
int endIndex)

Returns:
a substring
substring
String substring(int beginIndex)

Returns:
a substring
charAt
char charAt(int pos)

Returns:
a character at the specified position.
isEnd
boolean isEnd(int pos)

Returns:
true

Interface CharacterIterator

iff if the specified index is after the end of the character stream

692

Overview (Codename One API)


com.codename1.util.regex

Class CharacterArrayCharacterIterator
java.lang.Object

com.codename1.util.regex.CharacterArrayCharacterIterator
All Implemented Interfaces:
CharacterIterator

public final class


extends Object
implements CharacterIterator

Encapsulates char[] as CharacterIterator


Version:
CVS $Id: CharacterArrayCharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $

Constructor Summary
Constructor and Description
CharacterArrayCharacterIterator(char[] src, int off, int len)

Method Summary
Modifier and Type

Method and Description

char

charAt(int pos)

boolean

isEnd(int pos)

String

substring(int beginIndex)

String

substring(int beginIndex, int endIndex)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CharacterArrayCharacterIterator
public CharacterArrayCharacterIterator(char[] src,
int off,
int len)

Parameters:
src - - encapsulated String

Method Detail
substring
public String substring(int beginIndex,
int endIndex)

Specified by:
substring

Method Detail

in interface CharacterIterator

693

Overview (Codename One API)


Returns:
a substring
substring
public String substring(int beginIndex)

Specified by:
substring in interface CharacterIterator
Returns:
a substring
charAt
public char charAt(int pos)

Specified by:
charAt in interface CharacterIterator
Returns:
a character at the specified position.
isEnd
public boolean isEnd(int pos)

Specified by:
isEnd

in interface CharacterIterator

Returns:
true

Method Detail

iff if the specified index is after the end of the character stream

694

Overview (Codename One API)


com.codename1.util

Class StringUtil
java.lang.Object

com.codename1.util.StringUtil

public class
extends Object

Various utility methods for manipulating strings

Constructor Summary
Constructor and Description
StringUtil()

Method Summary
Modifier and
Type

Method and Description


replaceAll(String source, String pattern, String replace)

static String

This method replaces all occurrences of the pattern with the replacement
String
setImplementation(com.codename1.impl.CodenameOneImplementation i)

static void

Deprecated.
exposed as part of an internal optimization, this method isn't meant for
general access

static
List<String>

tokenize(String source, char separator)

static
List<String>

tokenize(String source, String separator)

Breaks a String to multiple strings.


Breaks a String to multiple strings (similar to string tokenizer)
tokenizeString(String source, char separator)

static Vector

Deprecated.
use the tokenize() method instead
tokenizeString(String source, String separator)

static Vector

Deprecated.
use the tokenize() method instead

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
StringUtil
public StringUtil()

Method Detail

Class StringUtil

695

Overview (Codename One API)


setImplementation

public static void setImplementation(com.codename1.impl.CodenameOneImplementation i)

Deprecated. exposed as part of an internal optimization, this method isn't meant for
general access
replaceAll
public static String replaceAll(String source,
String pattern,
String replace)

This method replaces all occurrences of the pattern with the replacement String
Parameters:
source - the String source
pattern - String to replace in the source
replace - replacement String
Returns:
string with replaced elements
tokenizeString
public static Vector tokenizeString(String source,
char separator)

Deprecated. use the tokenize() method instead


Breaks a String to multiple strings.
Parameters:
source - the String to break
separator - the pattern to search and break.
Returns:
a Vector of Strings
tokenizeString
public static Vector tokenizeString(String source,
String separator)

Deprecated. use the tokenize() method instead


Breaks a String to multiple strings (similar to string tokenizer)
Parameters:
source - the String to break
separator - the characters that can be used to search and break.
Returns:
a Vector of Strings
tokenize
public static List<String> tokenize(String source,
char separator)

Breaks a String to multiple strings.


Parameters:
source - the String to break
separator - the pattern to search and break.
Returns:
a Vector of Strings
tokenize
public static List<String> tokenize(String source,
String separator)

Breaks a String to multiple strings (similar to string tokenizer)


Parameters:
source - the String to break
separator - the characters that can be used to search and break.
Returns:
a Vector of Strings

Method Detail

696

Overview (Codename One API)


com.codename1.util

Class MathUtil
java.lang.Object

com.codename1.util.MathUtil

public abstract class


extends Object

MathUtil for Java ME. This fills the gap in Java ME Math with a port of Sun's public FDLIBM C-library
for IEEE-754.
See Also:
For the Freely Distributable C-library conforming to IEEE-754 floating point math.,
For the GNU C variant of the same IEEE-754 routines., Another take on the IEEE-754
routines., Yet another take on the IEEE-754 routines., For other approximations., For
fast but rough approximations., For more fast but rough approximations.

Constructor Summary
Constructor and Description
MathUtil()

Method Summary
Modifier
and Type

Method and Description

static
double

acos(double a)

static
double

asin(double a)

static
double

atan(double a)

Return the arccosine of a.


Return the arcsine of a.
Return the arctangent of a, call it b, where a = tan(b).
atan2(double b, double a)

static
double

static
double
static
double
static
double
static long
static int

copysign(double x, double y)

Deprecated.
Please update your code to use copySign
copySign(double x, double y)
exp(double a)

Return Math.E to the exponent a.


floor(double a)

Rounds the number down


floor(float a)

Rounds the number down

static
double

log(double a)

static
double

log10(double a)

static
double

Class MathUtil

For any real arguments x and y not both equal to zero, atan2(y, x) is the angle
in radians between the positive x-axis of a plane and the point given by the
coordinates (x, y) on it.

Return the natural logarithm, ln(a), as it relates to Math.E.


Return the common base-10 logarithm, log10(a).
nextAfter(double start, double direction)

Returns the next representable floating point number after the first argument in
the direction of the second argument.

697

Overview (Codename One API)


pow(double a, double b)

static
double

Return a to the power of b, sometimes written as a ** b but not to be confused


with the bitwise ^ operator.

static long
static int

round(double a)

Rounds the number to the closest integer


round(float a)

Rounds the number to the closest integer


scalb(double x, int n)

scalbn (double x, int n) scalbn(x,n) returns x* 2**n computed by exponent


manipulation rather than by actually performing an exponentiation or a
multiplication.

static
double

scalbn(double x, int n)

static
double

Deprecated.
Please update your code to use scalb
ulp(double d)

static
double

Returns the size of an ulp (units in the last place) of the argument.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MathUtil
public MathUtil()

Method Detail
exp
public static final double exp(double a)

Return Math.E to the exponent a. This in turn uses ieee7854_exp(double).


log
public static final double log(double a)

Return the natural logarithm, ln(a), as it relates to Math.E. This in turn uses
ieee7854_log(double).
log10
public static final double log10(double a)

Return the common base-10 logarithm, log10(a). This in turn uses


ieee7854_log(double)/ieee7854_log(10.0).
pow
public static final double pow(double a,
double b)

Return a to the power of b, sometimes written as a ** b but not to be confused with


the bitwise ^ operator. This in turn uses ieee7854_log(double).
asin
public static final double asin(double a)

Return the arcsine of a.

Method Summary

698

Overview (Codename One API)


acos
public static final double acos(double a)

Return the arccosine of a.


atan
public static final double atan(double a)

Return the arctangent of a, call it b, where a = tan(b).


atan2
public static final double atan2(double b,
double a)

For any real arguments x and y not both equal to zero, atan2(y, x) is the angle in
radians between the positive x-axis of a plane and the point given by the coordinates
(x, y) on it. The angle is positive for counter-clockwise angles (upper half-plane, y >
0), and negative for clockwise angles (lower half-plane, y < 0). This in turn uses
ieee7854_arctan2(double).
scalb
public static final double scalb(double x,
int n)

scalbn (double x, int n) scalbn(x,n) returns x* 2**n computed by exponent


manipulation rather than by actually performing an exponentiation or a multiplication.
scalbn
public static final double scalbn(double x,
int n)

Deprecated. Please update your code to use scalb


Please update your code to use scalb
Parameters:
xnReturns:
scalb(x,n)
copySign
public static final double copySign(double x,
double y)

copysign
public static final double copysign(double x,
double y)

Deprecated. Please update your code to use copySign


Please update your code to use copySign
Parameters:
xyReturns:
copySign(x,y)
ulp
public static double ulp(double d)

Returns the size of an ulp (units in the last place) of the argument.
Parameters:
d - value whose ulp is to be returned
Returns:
size of an ulp for the argument

Method Detail

699

Overview (Codename One API)


nextAfter
public static double nextAfter(double start,
double direction)

Returns the next representable floating point number after the first argument in the
direction of the second argument.
Parameters:
start - starting value
direction - value indicating which of the neighboring representable floating
point number to return
Returns:
The floating-point number next to start in the direction of .
round
public static int round(float a)

Rounds the number to the closest integer


Parameters:
a - the number
Returns:
the closest integer
round
public static long round(double a)

Rounds the number to the closest integer


Parameters:
a - the number
Returns:
the closest integer
floor
public static int floor(float a)

Rounds the number down


Parameters:
a - the number
Returns:
a rounded down number
floor
public static long floor(double a)

Rounds the number down


Parameters:
a - the number
Returns:
a rounded down number

Method Detail

700

Overview (Codename One API)


com.codename1.util

Interface LazyValue<T>

public interface

Useful when passing a value that might not exist to a function, e.g. when we pass a form that we
might need to construct dynamically later on.

Method Summary
Modifier and Type Method and Description
get(Object... args)

Returns the actual value

Method Detail
get
T get(Object... args)

Returns the actual value


Parameters:
args - optional arguments for the creation of the lazy value
Returns:
the value

Interface LazyValue<T>

701

Overview (Codename One API)


com.codename1.util

Class CaseInsensitiveOrder
java.lang.Object

com.codename1.util.CaseInsensitiveOrder
All Implemented Interfaces:
Comparator<String>

public class
extends Object
implements Comparator<String>

A string comparator equivalent to String.CASE_INSENSITIVE_ORDER which isn't available in


Codename One

Constructor Summary
Constructor and Description
CaseInsensitiveOrder()

Method Summary
Modifier and Type

Method and Description


compare(String s1, String s2)

int

Compares the two specified objects to determine their relative ordering.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.util.Comparator


equals

Constructor Detail
CaseInsensitiveOrder
public CaseInsensitiveOrder()

Method Detail
compare
public int compare(String s1,
String s2)

Compares the two specified objects to determine their relative ordering. The ordering
implied by the return value of this method for all possible pairs of (object1, object2)
should form an equivalence relation. This means that
compare(a,a) returns zero for all a
the sign of compare(a,b) must be the opposite of the sign of compare(b,a) for
all pairs of (a,b)

Method Detail

702

Overview (Codename One API)


From compare(a,b) > 0 and compare(b,c) > 0 it must follow compare(a,c) >
0 for all possible combinations of (a,b,c)
Specified by:
compare in interface Comparator<String>
Parameters:
s1 - an Object.
s2 - a second Object to compare with object1.
Returns:
an integer < 0 if object1 is less than object2, 0 if they are equal, and > 0 if
object1 is greater than object2.

Method Detail

703

Overview (Codename One API)


com.codename1.util

Interface Callback<T>

public interface

Simple interface that allows asynchronous code to perform a parameterized callback or failure in a
similar way to GWT's callback interface

Method Summary
Modifier and
Type

Method and Description


onError(Object sender, Throwable err, int errorCode,
String errorMessage)

void

Invoked when the async method throws an exception


onSucess(T value)

void

Invoked when the async method returns with a successful value

Method Detail

onSucess
void onSucess(T value)

Invoked when the async method returns with a successful value


Parameters:
value - the value
onError
void onError(Object sender,
Throwable err,
int errorCode,
String errorMessage)

Invoked when the async method throws an exception


Parameters:
sender - the source of the error e.g. connection request that triggered the
error, could be null
err - in case of an error triggered by an exception
errorCode - if applicable e.g. with http error codes, -1 for unknown
errorMessage - if applicable a user displayable message (can be null)

Interface Callback<T>

704

Overview (Codename One API)


com.codename1.util

Class CStringBuilder
java.lang.Object

com.codename1.util.CStringBuilder

Deprecated.
we will be moving to the proper string builder very soon
public final class
extends Object

This is generally the Apache String builder class refactored here so we can use it regardless of vm
limitations/differences for increased performance. A modifiable sequence of characters for use in
creating and modifying Strings. This class is intended as a direct replacement of StringBuffer for
non-concurrent use; unlike StringBuffer this class is not synchronized for thread safety.
The majority of the modification methods on this class return StringBuilder, so that, like
StringBuffers, they can be used in chaining method calls together. For example, new
StringBuilder("One should ").append("always strive ").append("to achieve Harmony").

Since:
1.5
See Also:
CharSequence, Appendable, StringBuffer, String

Constructor Summary
Constructor and Description
CStringBuilder()

Deprecated.
Constructs an instance with an initial capacity of 16.
CStringBuilder(int capacity)

Deprecated.
Constructs an instance with the specified capacity.
CStringBuilder(String str)

Deprecated.
Constructs an instance that's initialized with the contents of the specified String.

Method Summary
Modifier and
Type

Method and Description


append(boolean b)

CStringBuilder

Deprecated.
Appends the string representation of the specified boolean value.
append(char c)

CStringBuilder

Deprecated.
Appends the string representation of the specified char value.
append(char[] ch)

CStringBuilder

Deprecated.
Appends the string representation of the specified char[].
append(char[] str, int offset, int len)

CStringBuilder

Deprecated.
Appends the string representation of the specified subset of the char[].

CStringBuilder

append(double d)

Deprecated.

Method Detail

705

Overview (Codename One API)


Appends the string representation of the specified double value.
append(float f)
CStringBuilder

Deprecated.
Appends the string representation of the specified float value.
append(int i)

CStringBuilder

Deprecated.
Appends the string representation of the specified int value.
append(long lng)

CStringBuilder

Deprecated.
Appends the string representation of the specified long value.
append(Object obj)

CStringBuilder

Deprecated.
Appends the string representation of the specified Object.
append(String str)

CStringBuilder

Deprecated.
Appends the contents of the specified string.
appendCodePoint(int codePoint)

CStringBuilder

int
char
int
int

Deprecated.
Appends the encoded Unicode code point.
capacity()

Returns the number of characters that can be held without growing.


charAt(int index)

Retrieves the character at the index.


codePointAt(int index)

Retrieves the Unicode code point value at the index.


codePointBefore(int index)

Retrieves the Unicode code point value that precedes the index.
codePointCount(int beginIndex, int endIndex)

int

Calculates the number of Unicode code points between beginIndex and


endIndex.
delete(int start, int end)

CStringBuilder

Deprecated.
Deletes a sequence of characters specified by start and end.
deleteCharAt(int index)

CStringBuilder

Deprecated.
Deletes the character at the specified index.
ensureCapacity(int min)

void

void

int
int

Ensures that this object has a minimum capacity available before


requiring the internal buffer to be enlarged.
getChars(int start, int end, char[] dest, int destStart)
Copies the requested sequence of characters to the char[] passed
starting at destStart.
indexOf(String string)

Searches for the first index of the specified character.


indexOf(String subString, int start)

Searches for the index of the specified character.


insert(int offset, boolean b)

CStringBuilder

Deprecated.
Inserts the string representation of the specified boolean value at the
specified offset.
insert(int offset, char c)

CStringBuilder

Deprecated.
Inserts the string representation of the specified char value at the
specified offset.
insert(int offset, char[] ch)

CStringBuilder

CStringBuilder

Method Summary

Deprecated.
Inserts the string representation of the specified char[] at the specified
offset.
insert(int offset, char[] str, int strOffset, int strLen)

706

Overview (Codename One API)


Deprecated.
Inserts the string representation of the specified subsequence of the
char[] at the specified offset.
insert(int offset, double d)
CStringBuilder

Deprecated.
Inserts the string representation of the specified double value at the
specified offset.
insert(int offset, float f)

CStringBuilder

Deprecated.
Inserts the string representation of the specified float value at the
specified offset.
insert(int offset, int i)

CStringBuilder

Deprecated.
Inserts the string representation of the specified int value at the specified
offset.
insert(int offset, long l)

CStringBuilder

Deprecated.
Inserts the string representation of the specified long value at the
specified offset.
insert(int offset, Object obj)

CStringBuilder

Deprecated.
Inserts the string representation of the specified Object at the specified
offset.
insert(int offset, String str)

CStringBuilder

int
int
int
int

Deprecated.
Inserts the specified string at the specified offset.
lastIndexOf(String string)

Searches for the last index of the specified character.


lastIndexOf(String subString, int start)

Searches for the index of the specified character.


length()

The current length.


offsetByCodePoints(int index, int codePointOffset)
Returns the index that is offset codePointOffset code points

from index.

replace(int start, int end, String str)


CStringBuilder

Deprecated.
Replaces the specified subsequence in this builder with the specified
string.
reverse()

CStringBuilder

void
void

Deprecated.
Reverses the order of characters in this builder.
setCharAt(int index, char ch)
Sets the character at the index.
setLength(int length)

Sets the current length to a new value.


substring(int start)

String

Returns the String value of the subsequence from the start index to the
current end.
substring(int start, int end)

String

Returns the String value of the subsequence from the start index to the
end index.
toString()

String

void

Method Summary

Deprecated.
Returns the contents of this builder.
trimToSize()

Trims off any extra capacity beyond the current length.

707

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
CStringBuilder
public CStringBuilder()

Deprecated.
Constructs an instance with an initial capacity of 16.
See Also:
capacity()

CStringBuilder
public CStringBuilder(int capacity)

Deprecated.
Constructs an instance with the specified capacity.
Parameters:
capacity - the initial capacity to use.
Throws:
NegativeArraySizeException - if the specified capacity is negative.
See Also:
capacity()

CStringBuilder
public CStringBuilder(String str)

Deprecated.
Constructs an instance that's initialized with the contents of the specified String. The
capacity of the new builder will be the length of the String plus 16.
Parameters:
str - the String to copy into the builder.
Throws:
NullPointerException - if str is null.

Method Detail
append
public CStringBuilder append(boolean b)

Deprecated.
Appends the string representation of the specified boolean value. The boolean value
is converted to a String according to the rule defined by String.valueOf(boolean).
Parameters:
b - the boolean value to append.
Returns:
this builder.
See Also:
String.valueOf(boolean)

append
public CStringBuilder append(char c)

Deprecated.
Appends the string representation of the specified char value. The char value is
converted to a string according to the rule defined by String.valueOf(char).
Parameters:
c - the char value to append.
Returns:

Methods inherited from class java.lang.Object

708

Overview (Codename One API)


this builder.
See Also:
String.valueOf(char)

append
public CStringBuilder append(int i)

Deprecated.
Appends the string representation of the specified int value. The int value is
converted to a string according to the rule defined by String.valueOf(int).
Parameters:
i - the int value to append.
Returns:
this builder.
See Also:
String.valueOf(int)

append
public CStringBuilder append(long lng)

Deprecated.
Appends the string representation of the specified long value. The long value is
converted to a string according to the rule defined by String.valueOf(long).
Parameters:
lng - the long value.
Returns:
this builder.
See Also:
String.valueOf(long)

append
public CStringBuilder append(float f)

Deprecated.
Appends the string representation of the specified float value. The float value is
converted to a string according to the rule defined by String.valueOf(float).
Parameters:
f - the float value to append.
Returns:
this builder.
See Also:
String.valueOf(float)

append
public CStringBuilder append(double d)

Deprecated.
Appends the string representation of the specified double value. The double value is
converted to a string according to the rule defined by String.valueOf(double).
Parameters:
d - the double value to append.
Returns:
this builder.
See Also:
String.valueOf(double)

append
public CStringBuilder append(Object obj)

Deprecated.
Appends the string representation of the specified Object. The Object value is
converted to a string according to the rule defined by String.valueOf(Object).
Parameters:
obj - the Object to append.
Returns:
this builder.
See Also:

Method Detail

709

Overview (Codename One API)


String.valueOf(Object)

append
public CStringBuilder append(String str)

Deprecated.
Appends the contents of the specified string. If the string is null, then the string
"null" is appended.
Parameters:
str - the string to append.
Returns:
this builder.
append
public CStringBuilder append(char[] ch)

Deprecated.
Appends the string representation of the specified char[]. The char[] is converted to
a string according to the rule defined by String.valueOf(char[]).
Parameters:
ch - the char[] to append..
Returns:
this builder.
See Also:
String.valueOf(char[])

append
public CStringBuilder append(char[] str,
int offset,
int len)

Deprecated.
Appends the string representation of the specified subset of the char[]. The char[]
value is converted to a String according to the rule defined by
String.valueOf(char[],int,int).
Parameters:
str - the char[] to append.
offset - the inclusive offset index.
len - the number of characters.
Returns:
this builder.
Throws:
ArrayIndexOutOfBoundsException - if offset and len do not specify a valid
subsequence.
See Also:
String.valueOf(char[],int,int)

appendCodePoint
public CStringBuilder appendCodePoint(int codePoint)

Deprecated.
Appends the encoded Unicode code point. The code point is converted to a char[]
as defined by Character.toChars(int).
Parameters:
codePoint - the Unicode code point to encode and append.
Returns:
this builder.
See Also:
Character.toChars(int)

delete
public CStringBuilder delete(int start,
int end)

Deprecated.
Deletes a sequence of characters specified by start and end. Shifts any remaining
characters to the left.
Parameters:

Method Detail

710

Overview (Codename One API)


start - the inclusive start index.
end - the exclusive end index.

Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if start
the current length or greater than end.

is less than zero, greater than

deleteCharAt
public CStringBuilder deleteCharAt(int index)

Deprecated.
Deletes the character at the specified index. shifts any remaining characters to the
left.
Parameters:
index - the index of the character to delete.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if index is less than zero or is greater
than or equal to the current length.
insert
public CStringBuilder insert(int offset,
boolean b)

Deprecated.
Inserts the string representation of the specified boolean value at the specified
offset. The boolean value is converted to a string according to the rule defined by
String.valueOf(boolean).
Parameters:
offset - the index to insert at.
b - the boolean value to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length.
See Also:
String.valueOf(boolean)

insert
public CStringBuilder insert(int offset,
char c)

Deprecated.
Inserts the string representation of the specified char value at the specified offset.
The char value is converted to a string according to the rule defined by
String.valueOf(char).
Parameters:
offset - the index to insert at.
c - the char value to insert.
Returns:
this builder.
Throws:
IndexOutOfBoundsException - if offset is negative or greater than the current
length().
See Also:
String.valueOf(char)

insert
public CStringBuilder insert(int offset,
int i)

Deprecated.
Inserts the string representation of the specified int value at the specified offset.
The int value is converted to a String according to the rule defined by

Method Detail

711

Overview (Codename One API)


String.valueOf(int).

Parameters:
offset - the index to insert
i - the int value to insert.

at.

Returns:
this builder.
Throws:
StringIndexOutOfBoundsException
current length().

- if offset is negative or greater than the

See Also:
String.valueOf(int)

insert
public CStringBuilder insert(int offset,
long l)

Deprecated.
Inserts the string representation of the specified long value at the specified offset.
The long value is converted to a String according to the rule defined by
String.valueOf(long).
Parameters:
offset - the index to insert at.
l - the long value to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current {code length()}.
See Also:
String.valueOf(long)

insert
public CStringBuilder insert(int offset,
float f)

Deprecated.
Inserts the string representation of the specified float value at the specified offset.
The float value is converted to a string according to the rule defined by
String.valueOf(float).
Parameters:
offset - the index to insert at.
f - the float value to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length().
See Also:
String.valueOf(float)

insert
public CStringBuilder insert(int offset,
double d)

Deprecated.
Inserts the string representation of the specified double value at the specified offset.
The double value is converted to a String according to the rule defined by
String.valueOf(double).
Parameters:
offset - the index to insert at.
d - the double value to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length().
See Also:

Method Detail

712

Overview (Codename One API)


String.valueOf(double)

insert
public CStringBuilder insert(int offset,
Object obj)

Deprecated.
Inserts the string representation of the specified Object at the specified offset. The
Object value is converted to a String according to the rule defined by
String.valueOf(Object).
Parameters:
offset - the index to insert at.
obj - the Object to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length().
See Also:
String.valueOf(Object)

insert
public CStringBuilder insert(int offset,
String str)

Deprecated.
Inserts the specified string at the specified offset. If the specified string is null, then
the String "null" is inserted.
Parameters:
offset - the index to insert at.
str - the String to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length().
insert
public CStringBuilder insert(int offset,
char[] ch)

Deprecated.
Inserts the string representation of the specified char[] at the specified offset. The
char[] value is converted to a String according to the rule defined by
String.valueOf(char[]).
Parameters:
offset - the index to insert at.
ch - the char[] to insert.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater than the
current length().
See Also:
String.valueOf(char[])

insert
public CStringBuilder insert(int offset,
char[] str,
int strOffset,
int strLen)

Deprecated.
Inserts the string representation of the specified subsequence of the char[] at the
specified offset. The char[] value is converted to a String according to the rule
defined by String.valueOf(char[],int,int).
Parameters:
offset - the index to insert at.

Method Detail

713

Overview (Codename One API)


str - the char[] to insert.
strOffset - the inclusive index.
strLen - the number of characters.

Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if offset is negative or greater
current length(), or strOffset and strLen do not specify a valid

than the

subsequence.
See Also:
String.valueOf(char[],int,int)

replace
public CStringBuilder replace(int start,
int end,
String str)

Deprecated.
Replaces the specified subsequence in this builder with the specified string.
Parameters:
start - the inclusive begin index.
end - the exclusive end index.
str - the replacement string.
Returns:
this builder.
Throws:
StringIndexOutOfBoundsException - if start is negative, greater than the
current length() or greater than end.
NullPointerException - if str is null.
reverse
public CStringBuilder reverse()

Deprecated.
Reverses the order of characters in this builder.
Returns:
this buffer.
toString
public String toString()

Deprecated.
Returns the contents of this builder.
Returns:
the string representation of the data in this builder.
capacity
public int capacity()

Returns the number of characters that can be held without growing.


Returns:
the capacity
See Also:
ensureCapacity(int), length()
charAt
public char charAt(int index)

Retrieves the character at the index.


Parameters:
index - the index of the character to retrieve.
Returns:
the char value.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to
the current length().

Method Detail

714

Overview (Codename One API)


ensureCapacity
public void ensureCapacity(int min)

Ensures that this object has a minimum capacity available before requiring the
internal buffer to be enlarged. The general policy of this method is that if the
minimumCapacity is larger than the current capacity(), then the capacity will be
increased to the largest value of either the minimumCapacity or the current capacity
multiplied by two plus two. Although this is the general policy, there is no guarantee
that the capacity will change.
Parameters:
min - the new minimum capacity to set.
getChars
public void getChars(int start,
int end,
char[] dest,
int destStart)

Copies the requested sequence of characters to the char[] passed starting at


destStart.
Parameters:
start - the inclusive start index of the characters to copy.
end - the exclusive end index of the characters to copy.
dest - the char[] to copy the characters to.
destStart - the inclusive start index of dest to begin copying to.
Throws:
IndexOutOfBoundsException - if the start is negative, the destStart is
negative, the start is greater than end, the end is greater than the current
length() or destStart + end - begin is greater than dest.length.
length
public int length()

The current length.


Returns:
the number of characters contained in this instance.
setCharAt
public void setCharAt(int index,
char ch)

Sets the character at the index.


Parameters:
index - the zero-based index of the character to replace.
ch - the character to set.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to
the current length().
setLength
public void setLength(int length)

Sets the current length to a new value. If the new length is larger than the current
length, then the new characters at the end of this object will contain the char value of
.
Parameters:
length - the new length of this StringBuffer.
Throws:
IndexOutOfBoundsException - if length < 0.
See Also:
length()

substring
public String substring(int start)

Returns the String value of the subsequence from the start index to the current end.

Method Detail

715

Overview (Codename One API)


Parameters:
start - the inclusive start index to begin the subsequence.
Returns:
a String containing the subsequence.
Throws:
StringIndexOutOfBoundsException - if start is negative or greater than the
current length().
substring
public String substring(int start,
int end)

Returns the String value of the subsequence from the start index to the end index.
Parameters:
start - the inclusive start index to begin the subsequence.
end - the exclusive end index to end the subsequence.
Returns:
a String containing the subsequence.
Throws:
StringIndexOutOfBoundsException - if start is negative, greater than end or
if end is greater than the current length().
indexOf
public int indexOf(String string)

Searches for the first index of the specified character. The search for the character
starts at the beginning and moves towards the end.
Parameters:
string - the string to find.
Returns:
the index of the specified character, -1 if the character isn't found.
Since:
1.4
See Also:
lastIndexOf(String)

indexOf
public int indexOf(String subString,
int start)

Searches for the index of the specified character. The search for the character starts
at the specified offset and moves towards the end.
Parameters:
subString - the string to find.
start - the starting offset.
Returns:
the index of the specified character, -1 if the character isn't found
Since:
1.4
See Also:
lastIndexOf(String,int)

lastIndexOf
public int lastIndexOf(String string)

Searches for the last index of the specified character. The search for the character
starts at the end and moves towards the beginning.
Parameters:
string - the string to find.
Returns:
the index of the specified character, -1 if the character isn't found.
Throws:
NullPointerException - if string is null.
Since:
1.4
See Also:
String.lastIndexOf(java.lang.String)

Method Detail

716

Overview (Codename One API)


lastIndexOf
public int lastIndexOf(String subString,
int start)

Searches for the index of the specified character. The search for the character starts
at the specified offset and moves towards the beginning.
Parameters:
subString - the string to find.
start - the starting offset.
Returns:
the index of the specified character, -1 if the character isn't found.
Throws:
NullPointerException - if subString is null.
Since:
1.4
See Also:
String.lastIndexOf(String,int)

trimToSize
public void trimToSize()

Trims off any extra capacity beyond the current length. Note, this method is NOT
guaranteed to change the capacity of this object.
Since:
1.5
codePointAt
public int codePointAt(int index)

Retrieves the Unicode code point value at the index.


Parameters:
index - the index to the char code unit.
Returns:
the Unicode code point value.
Throws:
IndexOutOfBoundsException - if index is negative or greater than or equal to
length().
Since:
1.5
See Also:
Character, Character.codePointAt(char[], int, int)
codePointBefore
public int codePointBefore(int index)

Retrieves the Unicode code point value that precedes the index.
Parameters:
index - the index to the char code unit within this object.
Returns:
the Unicode code point value.
Throws:
IndexOutOfBoundsException - if index is less than 1 or greater than length().
Since:
1.5
See Also:
Character, Character.codePointBefore(char[], int, int)
codePointCount
public int codePointCount(int beginIndex,
int endIndex)

Calculates the number of Unicode code points between beginIndex and endIndex.
Parameters:
beginIndex - the inclusive beginning index of the subsequence.
endIndex - the exclusive end index of the subsequence.
Returns:

Method Detail

717

Overview (Codename One API)


the number of Unicode code points in the subsequence.
Throws:
IndexOutOfBoundsException - if beginIndex is negative
endIndex or endIndex is greater than length().

or greater than

Since:
1.5
See Also:
Character, Character.codePointCount(char[], int, int)
offsetByCodePoints
public int offsetByCodePoints(int index,
int codePointOffset)

Returns the index that is offset codePointOffset code points from index.
Parameters:
index - the index to calculate the offset from.
codePointOffset - the number of code points to count.
Returns:
the index that is codePointOffset code points away from index.
Throws:
IndexOutOfBoundsException - if index is negative or greater than length() or
if there aren't enough code points before or after index to match
codePointOffset.
Since:
1.5
See Also:
Character, Character.offsetByCodePoints(char[], int, int, int, int)

Method Detail

718

Overview (Codename One API)


com.codename1.util

Class BigInteger
java.lang.Object

com.codename1.util.BigInteger

public class
extends Object

A simplified version of big integer from the bouncy castle implementation

Field Summary
Modifier and Type Field and Description
static BigInteger

ONE

static BigInteger

ZERO

Constructor Summary
Constructor and Description
BigInteger(byte[] bval)
BigInteger(int sign, byte[] mag)
BigInteger(int bitLength, int certainty, Random rnd)
BigInteger(int numBits, Random rnd)
BigInteger(String sval)
BigInteger(String sval, int rdx)

Method Summary
Modifier and
Type

Method and Description

BigInteger

abs()

BigInteger

add(BigInteger val)

BigInteger

and(BigInteger value)

BigInteger

andNot(BigInteger value)

int

bitCount()

int

bitLength()

byte

byteValue()

BigInteger

clearBit(int n)

int

compareTo(BigInteger val)

int

compareTo(Object o)

BigInteger

divide(BigInteger val)

BigInteger[]

divideAndRemainder(BigInteger val)

boolean

equals(Object val)

Indicates whether some other object is "equal to" this one.

BigInteger

flipBit(int n)

BigInteger

gcd(BigInteger val)

Class BigInteger

719

Overview (Codename One API)


int

getLowestSetBit()
hashCode()

int

Returns a hash code value for the object.

int

intValue()
isProbablePrime(int certainty)

boolean

return whether or not a BigInteger is probably prime with a probability of 1


- (1/2)**certainty.

long

longValue()

BigInteger

max(BigInteger val)

BigInteger

min(BigInteger val)

BigInteger

mod(BigInteger m)

BigInteger

modInverse(BigInteger m)

BigInteger

modPow(BigInteger exponent, BigInteger m)

BigInteger

multiply(BigInteger val)

BigInteger

negate()

BigInteger

not()

BigInteger

or(BigInteger value)

BigInteger

pow(int exp)

static
BigInteger

probablePrime(int bitLength, Random random)

BigInteger

remainder(BigInteger n)

BigInteger

setBit(int n)

BigInteger

shiftLeft(int n)

BigInteger

shiftRight(int n)

int

signum()

BigInteger

subtract(BigInteger val)

boolean

testBit(int n)

byte[]

toByteArray()
toString()

String

Returns a string representation of the object.

String

toString(int rdx)

static
BigInteger

valueOf(long val)

BigInteger

xor(BigInteger val)

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
ZERO
public static final BigInteger ZERO

ONE
public static final BigInteger ONE

Constructor Detail

Method Summary

720

Overview (Codename One API)


BigInteger
public BigInteger(String sval)
throws NumberFormatException

Throws:
NumberFormatException

BigInteger
public BigInteger(String sval,
int rdx)
throws NumberFormatException

Throws:
NumberFormatException

BigInteger
public BigInteger(byte[] bval)
throws NumberFormatException

Throws:
NumberFormatException

BigInteger
public BigInteger(int sign,
byte[] mag)
throws NumberFormatException

Throws:
NumberFormatException

BigInteger
public BigInteger(int numBits,
Random rnd)
throws IllegalArgumentException

Throws:
IllegalArgumentException

BigInteger
public BigInteger(int bitLength,
int certainty,
Random rnd)
throws ArithmeticException

Throws:
ArithmeticException

Method Detail
abs
public BigInteger abs()

add
public BigInteger add(BigInteger val)
throws ArithmeticException

Throws:
ArithmeticException

and
public BigInteger and(BigInteger value)

andNot
public BigInteger andNot(BigInteger value)

Constructor Detail

721

Overview (Codename One API)


bitCount
public int bitCount()

bitLength
public int bitLength()

compareTo
public int compareTo(Object o)

compareTo
public int compareTo(BigInteger val)

divide
public BigInteger divide(BigInteger val)
throws ArithmeticException

Throws:
ArithmeticException

divideAndRemainder
public BigInteger[] divideAndRemainder(BigInteger val)
throws ArithmeticException

Throws:
ArithmeticException

equals
public boolean equals(Object val)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
gcd
public BigInteger gcd(BigInteger val)

hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the

Method Detail

722

Overview (Codename One API)


internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
intValue
public int intValue()

byteValue
public byte byteValue()

isProbablePrime
public boolean isProbablePrime(int certainty)

return whether or not a BigInteger is probably prime with a probability of 1 (1/2)**certainty.


From Knuth Vol 2, pg 395.
longValue
public long longValue()

max
public BigInteger max(BigInteger val)

min
public BigInteger min(BigInteger val)

mod
public BigInteger mod(BigInteger m)
throws ArithmeticException

Throws:
ArithmeticException

modInverse
public BigInteger modInverse(BigInteger m)
throws ArithmeticException

Throws:
ArithmeticException

modPow
public BigInteger modPow(BigInteger exponent,
BigInteger m)
throws ArithmeticException

Throws:
ArithmeticException

multiply
public BigInteger multiply(BigInteger val)

negate
public BigInteger negate()

not
public BigInteger not()

pow
public BigInteger pow(int exp)
throws ArithmeticException

Throws:
ArithmeticException

Method Detail

723

Overview (Codename One API)


probablePrime
public static BigInteger probablePrime(int bitLength,
Random random)

remainder
public BigInteger remainder(BigInteger n)
throws ArithmeticException

Throws:
ArithmeticException

shiftLeft
public BigInteger shiftLeft(int n)

shiftRight
public BigInteger shiftRight(int n)

signum
public int signum()

subtract
public BigInteger subtract(BigInteger val)

toByteArray
public byte[] toByteArray()

xor
public BigInteger xor(BigInteger val)

or
public BigInteger or(BigInteger value)

setBit
public BigInteger setBit(int n)
throws ArithmeticException

Throws:
ArithmeticException

clearBit
public BigInteger clearBit(int n)
throws ArithmeticException

Throws:
ArithmeticException

flipBit
public BigInteger flipBit(int n)
throws ArithmeticException

Throws:
ArithmeticException

toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

724

Overview (Codename One API)


toString
public String toString(int rdx)

valueOf
public static BigInteger valueOf(long val)

getLowestSetBit
public int getLowestSetBit()

testBit
public boolean testBit(int n)
throws ArithmeticException

Throws:
ArithmeticException

Method Detail

725

Overview (Codename One API)


com.codename1.util

Class BigDecimal
java.lang.Object

com.codename1.util.BigDecimal

public class
extends Object

Class representing a simple version of a big decimal. A BigDecimal is basically a BigInteger with a
few digits on the right of the decimal point. The number of (binary) digits on the right of the decimal
point is called the scale of the BigDecimal. Unlike in BigDecimal, the scale is not adjusted
automatically, but must be set manually. All BigDecimals taking part in the same arithmetic operation
must have equal scale. The result of a multiplication of two BigDecimals returns a BigDecimal with
double scale.

Constructor Summary
Constructor and Description
BigDecimal(BigInteger bigInt, int scale)
Constructor for BigDecimal.

Method Summary
Modifier and Type

Method and Description

BigDecimal

add(BigDecimal b)

BigDecimal

add(BigInteger b)

BigDecimal

adjustScale(int newScale)

int

compareTo(BigDecimal val)

int

compareTo(BigInteger val)

BigDecimal

divide(BigDecimal b)

BigDecimal

divide(BigInteger b)

boolean

equals(Object o)

Indicates whether some other object is "equal to" this one.

BigInteger

floor()

static BigDecimal

getInstance(BigInteger value, int scale)


Returns a BigDecimal representing the same numerical

int

getScale()

int

hashCode()

Returns a hash code value for the object.

int

intValue()

long

longValue()

BigDecimal

multiply(BigDecimal b)

BigDecimal

multiply(BigInteger b)

BigDecimal

negate()

BigInteger

round()

BigDecimal

shiftLeft(int n)

BigDecimal

subtract(BigDecimal b)

BigDecimal

subtract(BigInteger b)

Class BigDecimal

value as value.

726

Overview (Codename One API)


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
BigDecimal
public BigDecimal(BigInteger bigInt,
int scale)

Constructor for BigDecimal. The value of the constructed BigDecimal equals bigInt /
scale
2
.
Parameters:
bigInt - The bigInt value parameter.
scale - The scale of the constructed BigDecimal.

Method Detail
getInstance
public static BigDecimal getInstance(BigInteger value,
int scale)

Returns a BigDecimal representing the same numerical value as value.


Parameters:
value - The value of the BigDecimal to be created.
scale - The scale of the BigDecimal to be created.
Returns:
The such created BigDecimal.
adjustScale
public BigDecimal adjustScale(int newScale)

add
public BigDecimal add(BigDecimal b)

add
public BigDecimal add(BigInteger b)

negate
public BigDecimal negate()

subtract
public BigDecimal subtract(BigDecimal b)

subtract
public BigDecimal subtract(BigInteger b)

multiply
public BigDecimal multiply(BigDecimal b)

multiply
public BigDecimal multiply(BigInteger b)

divide
public BigDecimal divide(BigDecimal b)

Method Summary

727

Overview (Codename One API)


divide
public BigDecimal divide(BigInteger b)

shiftLeft
public BigDecimal shiftLeft(int n)

compareTo
public int compareTo(BigDecimal val)

compareTo
public int compareTo(BigInteger val)

floor
public BigInteger floor()

round
public BigInteger round()

intValue
public int intValue()

longValue
public long longValue()

getScale
public int getScale()

toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
equals
public boolean equals(Object o)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of

Method Detail

728

Overview (Codename One API)


hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object

Method Detail

729

Overview (Codename One API)


com.codename1.util

Class Base64
java.lang.Object

com.codename1.util.Base64

public class
extends Object

This class implements Base64 encoding/decoding functionality as specified in RFC 2045


(http://www.ietf.org/rfc/rfc2045.txt).

Constructor Summary
Constructor and Description
Base64()

Method Summary
Modifier and
Type
static byte[]

Method and Description


decode(byte[] in)
decode(byte[] in, int len)

static byte[]

static String
static String

Decodes an array of bytes containing a Base64 ascii string into binary


data
encode(byte[] in)

Encodes the given array as a base64 string


encodeNoNewline(byte[] in)

Encodes the given array as a base64 string without breaking lines

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Base64
public Base64()

Method Detail
decode
public static byte[] decode(byte[] in)

decode
public static byte[] decode(byte[] in,
int len)

Decodes an array of bytes containing a Base64 ascii string into binary data
Parameters:
in - the array
len - the length of the array

Class Base64

730

Overview (Codename One API)


Returns:
the decoded array
encode
public static String encode(byte[] in)

Encodes the given array as a base64 string


Parameters:
in - the array to encode
Returns:
the String containing the array
encodeNoNewline
public static String encodeNoNewline(byte[] in)

Encodes the given array as a base64 string without breaking lines


Parameters:
in - the array to encode
Returns:
the String containing the array

Method Detail

731

Overview (Codename One API)


com.codename1.ui.validation

Class Validator
java.lang.Object

com.codename1.ui.validation.Validator

public class
extends Object

Binds validation constraints to form elements, when validation fails it can be highlighted directly on the
component via an emblem or change of the UIID (to original UIID name + "Invalid" e.g.
"TextFieldInvalid"). Validators just run thru a set of Constraint objects to decide if validation
succeeded or failed.

Nested Class Summary


Modifier and Type
static class

Class and Description


Validator.HighlightMode

Indicates the validation failure modes

Constructor Summary
Constructor and Description
Validator()

Method Summary
Modifier and Type
Validator
Validator

Method and Description


addConstraint(Component cmp, Constraint... c)

Places a constraint on the validator, returns this object so constraint addit


addSubmitButtons(Component... cmp)

Submit buttons (or any other component type) can be disabled until all co
bindDataListener(Component cmp)

void

protected Object

Deprecated.
this method was exposed by accident, constraint implicitly calls it and you
protected in a future update to Codename One!
getComponentValue(Component cmp)

Returns the value of the given component, this can be overriden to add su
getDefaultValidationEmblemPositionX()

static float

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.
getDefaultValidationEmblemPositionY()

static float

static Image
static
Validator.HighlightMode
String
String
float

Class Validator

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.
getDefaultValidationFailedEmblem()

The emblem that will be drawn on top of the component to indicate the va
getDefaultValidationFailureHighlightMode()

Indicates the default mode in which validation failures are expressed


getErrorMessage(Component cmp)

Returns the validation error message for the given component or null if no
getErrorMessageUIID()

Error message UIID defaults to DialogBody.


getValidationEmblemPositionX()

732

Overview (Codename One API)

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.
getValidationEmblemPositionY()

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.

float

getValidationFailedEmblem()

Image

The emblem that will be drawn on top of the component to indicate the va

Validator.HighlightMode
boolean
boolean

getValidationFailureHighlightMode()

Indicates the default mode in which validation failures are expressed


isShowErrorMessageForFocusedComponent()

Indicates whether an error message should be shown for the focused com
isValid()

Returns true if all the constraints are currently valid


isValidateOnEveryKey()

static boolean

Indicates whether validation should occur on every key press (data chang
completion)

setDefaultValidationEmblemPositionX(float aDefaultValidationEmble
static void

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.

setDefaultValidationEmblemPositionY(float aDefaultValidationEmble
static void

static void
static void

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.

setDefaultValidationFailedEmblem(Image aDefaultValidationFailedEm

The emblem that will be drawn on top of the component to indicate the va
setDefaultValidationFailureHighlightMode(Validator.HighlightMode

Indicates the default mode in which validation failures are expressed


setErrorMessageUIID(String errorMessageUIID)

void

Error message UIID defaults to DialogBody.

setShowErrorMessageForFocusedComponent(boolean showErrorMessageFo

void

Indicates whether an error message should be shown for the focused com
setValidateOnEveryKey(boolean aValidateOnEveryKey)

static void

Indicates whether validation should occur on every key press (data chang
completion)
setValidationEmblemPositionX(float validationEmblemPositionX)

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.

void

setValidationEmblemPositionY(float validationEmblemPositionY)

The position of the validation emblem on the component as X/Y values be


the component and 1 indicates its end on the given axis.

void

setValidationFailedEmblem(Image validationFailedEmblem)

void

The emblem that will be drawn on top of the component to indicate the va

setValidationFailureHighlightMode(Validator.HighlightMode validat

void

Indicates the default mode in which validation failures are expressed

protected void

validate(Component cmp)

Validates and highlights an individual component

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Validator
public Validator()

Method Summary

733

Overview (Codename One API)

Method Detail
getDefaultValidationFailureHighlightMode
public static Validator.HighlightMode getDefaultValidationFailureHighlightMode()

Indicates the default mode in which validation failures are expressed


Returns:
the defaultValidationFailureHighlightMode
setDefaultValidationFailureHighlightMode
public static void setDefaultValidationFailureHighlightMode(Validator.HighlightMode

Indicates the default mode in which validation failures are expressed


Parameters:
aDefaultValidationFailureHighlightMode - the
defaultValidationFailureHighlightMode to set
getDefaultValidationFailedEmblem
public static Image getDefaultValidationFailedEmblem()

The emblem that will be drawn on top of the component to indicate the validation
failure
Returns:
the defaultValidationFailedEmblem
setDefaultValidationFailedEmblem

public static void setDefaultValidationFailedEmblem(Image aDefaultValidationFailedEm

The emblem that will be drawn on top of the component to indicate the validation
failure
Parameters:
aDefaultValidationFailedEmblem - the defaultValidationFailedEmblem to set
getDefaultValidationEmblemPositionX
public static float getDefaultValidationEmblemPositionX()

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Returns:
the defaultValidationEmblemPositionX
setDefaultValidationEmblemPositionX

public static void setDefaultValidationEmblemPositionX(float aDefaultValidationEmble

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Parameters:
aDefaultValidationEmblemPositionX - the
defaultValidationEmblemPositionX to set
getDefaultValidationEmblemPositionY
public static float getDefaultValidationEmblemPositionY()

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Returns:
the defaultValidationEmblemPositionY

Method Detail

734

Overview (Codename One API)


setDefaultValidationEmblemPositionY

public static void setDefaultValidationEmblemPositionY(float aDefaultValidationEmble

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Parameters:
aDefaultValidationEmblemPositionY - the
defaultValidationEmblemPositionY to set
isValidateOnEveryKey
public static boolean isValidateOnEveryKey()

Indicates whether validation should occur on every key press (data change listener)
or action performed (editing completion)
Returns:
the validateOnEveryKey
setValidateOnEveryKey
public static void setValidateOnEveryKey(boolean aValidateOnEveryKey)

Indicates whether validation should occur on every key press (data change listener)
or action performed (editing completion)
Parameters:
aValidateOnEveryKey - the validateOnEveryKey to set
getValidationFailureHighlightMode
public Validator.HighlightMode getValidationFailureHighlightMode()

Indicates the default mode in which validation failures are expressed


Returns:
the validationFailureHighlightMode
setValidationFailureHighlightMode

public void setValidationFailureHighlightMode(Validator.HighlightMode validationFail

Indicates the default mode in which validation failures are expressed


Parameters:
validationFailureHighlightMode - the validationFailureHighlightMode to set
getValidationFailedEmblem
public Image getValidationFailedEmblem()

The emblem that will be drawn on top of the component to indicate the validation
failure
Returns:
the validationFailedEmblem
setValidationFailedEmblem
public void setValidationFailedEmblem(Image validationFailedEmblem)

The emblem that will be drawn on top of the component to indicate the validation
failure
Parameters:
validationFailedEmblem - the validationFailedEmblem to set
getValidationEmblemPositionX
public float getValidationEmblemPositionX()

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Returns:
the validationEmblemPositionX

Method Detail

735

Overview (Codename One API)


setValidationEmblemPositionX
public void setValidationEmblemPositionX(float validationEmblemPositionX)

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Parameters:
validationEmblemPositionX - the validationEmblemPositionX to set
getValidationEmblemPositionY
public float getValidationEmblemPositionY()

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Returns:
the validationEmblemPositionY
setValidationEmblemPositionY
public void setValidationEmblemPositionY(float validationEmblemPositionY)

The position of the validation emblem on the component as X/Y values between 0
and 1 where 0 indicates the start of the component and 1 indicates its end on the
given axis.
Parameters:
validationEmblemPositionY - the validationEmblemPositionY to set
isShowErrorMessageForFocusedComponent
public boolean isShowErrorMessageForFocusedComponent()

Indicates whether an error message should be shown for the focused component
Returns:
true if the error message should be displayed
setShowErrorMessageForFocusedComponent

public void setShowErrorMessageForFocusedComponent(boolean showErrorMessageForFocuse

Indicates whether an error message should be shown for the focused component
Parameters:
showErrorMessageForFocusedComponent - true to show the error message
getErrorMessageUIID
public String getErrorMessageUIID()

Error message UIID defaults to DialogBody. Allows customizing the look of the
message
Returns:
the errorMessageUIID
setErrorMessageUIID
public void setErrorMessageUIID(String errorMessageUIID)

Error message UIID defaults to DialogBody. Allows customizing the look of the
message
Parameters:
errorMessageUIID - the errorMessageUIID to set
addConstraint
public Validator addConstraint(Component cmp,
Constraint... c)

Places a constraint on the validator, returns this object so constraint additions can be
chained. Notice that only one constraint
Parameters:
cmp - the component to validate
c - the constraint or constraints

Method Detail

736

Overview (Codename One API)

Returns:
this object so we can write code like v.addConstraint(cmp1,
cons).addConstraint(cmp2, otherConstraint);
addSubmitButtons
public Validator addSubmitButtons(Component... cmp)

Submit buttons (or any other component type) can be disabled until all components
contain a valid value. Notice that this method should be invoked after all the
constraints are added so the initial state of the buttons will be correct.
Parameters:
cmp - set of buttons or components to disable until everything is valid
Returns:
the validator instance so this method can be chained
getComponentValue
protected Object getComponentValue(Component cmp)

Returns the value of the given component, this can be overriden to add support for
custom built components
Parameters:
cmp - the component
Returns:
the object value
bindDataListener
public void bindDataListener(Component cmp)

Deprecated. this method was exposed by accident, constraint implicitly calls it and
you don't need to call it directly. It will be made protected in a future update to
Codename One!
Binds an event listener to the given component
Parameters:
cmp - the component to bind the data listener to
isValid
public boolean isValid()

Returns true if all the constraints are currently valid


Returns:
true if the entire validator is valid
validate
protected void validate(Component cmp)

Validates and highlights an individual component


Parameters:
cmp - the component to validate
getErrorMessage
public String getErrorMessage(Component cmp)

Returns the validation error message for the given component or null if no such
message exists
Parameters:
cmp - the invalid component
Returns:
a string representing the error message

Method Detail

737

Overview (Codename One API)


com.codename1.ui.validation

Enum Validator.HighlightMode
java.lang.Object

java.lang.Enum<Validator.HighlightMode>

com.codename1.ui.validation.Validator.HighlightMode
All Implemented Interfaces:
Comparable<Validator.HighlightMode>
Enclosing class:
Validator

public static enum


extends Enum<Validator.HighlightMode>

Indicates the validation failure modes

Enum Constant Summary


Enum Constant and Description
EMBLEM
NONE
UIID
UIID_AND_EMBLEM

Method Summary
Modifier and Type
static
Validator.HighlightMode
static
Validator.HighlightMode[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified


name.
values()

Returns an array containing the constants of this enum


type, in the order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


UIID
public static final Validator.HighlightMode UIID

EMBLEM
public static final Validator.HighlightMode EMBLEM

Enum Validator.HighlightMode

738

Overview (Codename One API)


UIID_AND_EMBLEM
public static final Validator.HighlightMode UIID_AND_EMBLEM

NONE
public static final Validator.HighlightMode NONE

Method Detail
values
public static Validator.HighlightMode[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (Validator.HighlightMode c : Validator.HighlightMode.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static Validator.HighlightMode valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Enum Constant Detail

739

Overview (Codename One API)


com.codename1.ui.validation

Class RegexConstraint
java.lang.Object

com.codename1.ui.validation.RegexConstraint
All Implemented Interfaces:
Constraint

public class
extends Object
implements Constraint

Creates a validation constraint based on a regular expression

Constructor Summary
Constructor and Description
RegexConstraint(String regex, String errorMessage)

Creates a new regex constraint

Method Summary
Modifier and Type

Method and Description


getDefaultFailMessage()

String

Includes the error message for the constraint

boolean
static Constraint
static Constraint
static Constraint
static Constraint

isValid(Object value)

Indicates if the given value is valid or not


validEmail()

Generates a valid email constraint by using a regular expression


validEmail(String errorMessage)

Generates a valid email constraint by using a regular expression


validURL()

Generates a valid URL constraint by using a regular expression


validURL(String errorMessage)

Generates a valid URL constraint by using a regular expression

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
RegexConstraint
public RegexConstraint(String regex,
String errorMessage)

Creates a new regex constraint


Parameters:
regex - the regular expression
errorMessage - the default error message if the constraint fails

Method Detail

740

Overview (Codename One API)


Method

Detail

validEmail
public static Constraint validEmail(String errorMessage)

Generates a valid email constraint by using a regular expression


Parameters:
errorMessage - error message for the constraint
Returns:
a constraint that will fail if the input isn't a valid email
validEmail
public static Constraint validEmail()

Generates a valid email constraint by using a regular expression


Returns:
a constraint that will fail if the input isn't a valid email
validURL
public static Constraint validURL(String errorMessage)

Generates a valid URL constraint by using a regular expression


Parameters:
errorMessage - error message for the constraint
Returns:
a constraint that will fail if the input isn't a valid email
validURL
public static Constraint validURL()

Generates a valid URL constraint by using a regular expression


Returns:
a constraint that will fail if the input isn't a valid email
isValid
public boolean isValid(Object value)

Indicates if the given value is valid or not


Specified by:
isValid in interface Constraint
Parameters:
value - the value for the object
Returns:
true if the value is valid and false otherwise
getDefaultFailMessage
public String getDefaultFailMessage()

Includes the error message for the constraint


Specified by:
getDefaultFailMessage in interface Constraint
Returns:
the text of the error message for a constraint

Method Detail

741

Overview (Codename One API)


com.codename1.ui.validation

Class LengthConstraint
java.lang.Object

com.codename1.ui.validation.LengthConstraint
All Implemented Interfaces:
Constraint

public class
extends Object
implements Constraint

Creates a validation constraint based on minimum input length

Constructor Summary
Constructor and Description
LengthConstraint(int length)

Creates a new length constraint


LengthConstraint(int length, String errorMessage)

Creates a new length constraint

Method Summary
Modifier and Type

Method and Description


getDefaultFailMessage()

String

Includes the error message for the constraint

boolean

isValid(Object value)

Indicates if the given value is valid or not

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
LengthConstraint
public LengthConstraint(int length,
String errorMessage)

Creates a new length constraint


Parameters:
length - the length of the constraint
errorMessage - the default error message if the constraint fails
LengthConstraint
public LengthConstraint(int length)

Creates a new length constraint


Parameters:
length - the length of the constraint

Class LengthConstraint

742

Overview (Codename One API)


Method

Detail

isValid
public boolean isValid(Object value)

Indicates if the given value is valid or not


Specified by:
isValid in interface Constraint
Parameters:
value - the value for the object
Returns:
true if the value is valid and false otherwise
getDefaultFailMessage
public String getDefaultFailMessage()

Includes the error message for the constraint


Specified by:
getDefaultFailMessage in interface Constraint
Returns:
the text of the error message for a constraint

Method Detail

743

Overview (Codename One API)


com.codename1.ui.validation

Class GroupConstraint
java.lang.Object

com.codename1.ui.validation.GroupConstraint
All Implemented Interfaces:
Constraint

public class
extends Object
implements Constraint

Groups several constraints as if they are one constraint

Constructor Summary
Constructor and Description
GroupConstraint(Constraint... group)

Create a new constraint group

Method Summary
Modifier and Type

Method and Description


getDefaultFailMessage()

String

Includes the error message for the constraint

boolean

isValid(Object value)

Indicates if the given value is valid or not

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GroupConstraint
public GroupConstraint(Constraint... group)

Create a new constraint group


Parameters:
group - the group

Method Detail
isValid
public boolean isValid(Object value)

Indicates if the given value is valid or not


Specified by:
isValid in interface Constraint
Parameters:
value - the value for the object
Returns:

Class GroupConstraint

744

Overview (Codename One API)


true if the value is valid and false otherwise
getDefaultFailMessage
public String getDefaultFailMessage()

Includes the error message for the constraint


Specified by:
getDefaultFailMessage in interface Constraint
Returns:
the text of the error message for a constraint

Method Detail

745

Overview (Codename One API)


com.codename1.ui.validation

Interface Constraint
All Known Implementing Classes:
GroupConstraint, LengthConstraint, RegexConstraint

public interface

To perform validation we add a constraint to a validator, a constraint defines whether a value if valid
for a given object

Method Summary
Modifier and Type
String

Includes the error message for the constraint

boolean

Method and Description


getDefaultFailMessage()
isValid(Object value)

Indicates if the given value is valid or not

Method Detail
isValid
boolean isValid(Object value)

Indicates if the given value is valid or not


Parameters:
value - the value for the object
Returns:
true if the value is valid and false otherwise
getDefaultFailMessage
String getDefaultFailMessage()

Includes the error message for the constraint


Returns:
the text of the error message for a constraint

Interface Constraint

746

Overview (Codename One API)


com.codename1.ui.util

Class WeakHashMap<K,V>
java.lang.Object

com.codename1.ui.util.WeakHashMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class
extends Object
implements Map<K,V>

Helper weak hash map substitute

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map


Map.Entry<K,V>

Constructor Summary
Constructor and Description
WeakHashMap()

Method Summary
Modifier and Type
void
boolean
boolean
Set<Map.Entry<K,V>>
V
boolean
Set<K>
V
void
V
int
Collection<V>

Method Detail

Method and Description


clear()

Removes all elements from this Map, leaving it empty.


containsKey(Object key)
Returns whether this Map contains

the specified key.

containsValue(Object value)

This method is unsupported in the weak hash map


entrySet()

Unsupported operation
get(Object key)

Returns the value of the mapping with the specified key.


isEmpty()

Returns whether this map is empty.


keySet()

Returns a set of the keys contained in this Map.


put(K key, V value)

Maps the specified key to the specified value.


putAll(Map<? extends K,? extends V> m)
Copies every mapping in the specified Map to

this Map.

remove(Object key)

Removes a mapping with the specified key from this Map.


size()

Returns the number of mappings in this Map.


values()

Unsupported operation

747

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface java.util.Map


equals, hashCode

Constructor Detail
WeakHashMap
public WeakHashMap()

Method Detail
size
public int size()

Returns the number of mappings in this Map.


Specified by:
size in interface Map<K,V>
Returns:
the number of mappings in this Map.
isEmpty
public boolean isEmpty()

Returns whether this map is empty.


Specified by:
isEmpty in interface Map<K,V>
Returns:
true if this map has no elements, false otherwise.
See Also:
Map.size()

containsKey
public boolean containsKey(Object key)

Returns whether this Map contains the specified key.


Specified by:
containsKey in interface Map<K,V>
Parameters:
key - the key to search for.
Returns:
true if this map contains the specified key, false otherwise.
containsValue
public boolean containsValue(Object value)

This method is unsupported in the weak hash map


Specified by:
containsValue in interface Map<K,V>
Parameters:
value - the value to search for.
Returns:
true if this map contains the specified value, false otherwise.
get
public V get(Object key)

Returns the value of the mapping with the specified key.

Methods inherited from class java.lang.Object

748

Overview (Codename One API)


Specified by:
get in interface Map<K,V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key, or null if no mapping for the
specified key is found.
put
public V put(K key,
V value)

Maps the specified key to the specified value.


Specified by:
put in interface Map<K,V>
Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was
no mapping.
remove
public V remove(Object key)

Removes a mapping with the specified key from this Map.


Specified by:
remove in interface Map<K,V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key
was found.
putAll
public void putAll(Map<? extends K,? extends V> m)

Copies every mapping in the specified Map to this Map.


Specified by:
putAll in interface Map<K,V>
Parameters:
m - the Map to copy mappings from.
clear
public void clear()

Removes all elements from this Map, leaving it empty.


Specified by:
clear in interface Map<K,V>
See Also:
Map.isEmpty(), Map.size()
keySet
public Set<K> keySet()

Returns a set of the keys contained in this Map. The Set is backed by this Map so
changes to one are reflected by the other. The Set does not support adding.
Specified by:
keySet in interface Map<K,V>
Returns:
a set of the keys.
values
public Collection<V> values()

Unsupported operation

Method Detail

749

Overview (Codename One API)


Specified by:
values in interface Map<K,V>
Returns:
a collection of the values contained in this map.
entrySet
public Set<Map.Entry<K,V>> entrySet()

Unsupported operation
Specified by:
entrySet in interface Map<K,V>
Returns:
a set of the mappings

Method Detail

750

Overview (Codename One API)


com.codename1.ui.util

Class UITimer
java.lang.Object

com.codename1.ui.util.UITimer

public class
extends Object

Simple timer callback that is invoked on the CodenameOne EDT thread rather than on a separate
thread. Notice that the accuracy of this timer is very low! A timer must be linked to a specific form

Constructor Summary
Modifier
protected

Constructor and Description


UITimer()

This constructor is useful when deriving this class to implement a timer.


UITimer(Runnable r)

Constructor that accepts a runnable to invoke on timer elapse

Method Summary
Modifier and
Type

Method and Description


cancel()

void

Stops executing the timer


schedule(int timeMillis, boolean repeat, Form bound)

void

Binds the timer to start at the given schedule

static UITimer

timer(int timeMillis, boolean repeat, Form parent, Runnable r)

Convenience method to schedule a UITimer more easily


timer(int timeMillis, boolean repeat, Runnable r)

static UITimer

Convenience method to schedule a UITimer more easily on the current


form

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
UITimer
protected UITimer()

This constructor is useful when deriving this class to implement a timer.


UITimer
public UITimer(Runnable r)

Constructor that accepts a runnable to invoke on timer elapse


Parameters:
r - runnable instance

Class UITimer

751

Overview (Codename One API)


Method

Detail

schedule
public void schedule(int timeMillis,
boolean repeat,
Form bound)

Binds the timer to start at the given schedule


Parameters:
timeMillis - the time from now in milliseconds
repeat - whether the timer repeats
bound - the form to which the timer is bound
timer
public static UITimer timer(int timeMillis,
boolean repeat,
Form parent,
Runnable r)

Convenience method to schedule a UITimer more easily


Parameters:
timeMillis - the time from now in milliseconds
repeat - whether the timer repeats
parent - the form to which the timer is bound
r - callback when the timer elapses
Returns:
the timer instance
timer
public static UITimer timer(int timeMillis,
boolean repeat,
Runnable r)

Convenience method to schedule a UITimer more easily on the current form


Parameters:
timeMillis - the time from now in milliseconds
repeat - whether the timer repeats
r - callback when the timer elapses
Returns:
the timer instance
cancel
public void cancel()

Stops executing the timer

Method Detail

752

Overview (Codename One API)


com.codename1.ui.util

Class UIBuilder
java.lang.Object

com.codename1.ui.util.UIBuilder

public class
extends Object

The UI builder can create a user interface based on the UI designed in the resource editor and allows
us to bind to said UI. Notice that if a Component was used in the GUI that is not a part of the
com.codename1.ui package (even a Component from sub packages such as table or tree) it MUST
be registered before loading a GUI!

Field Summary
Modifier and Type
static int
static String
static String
static String
static String

Field and Description


BACK_COMMAND_ID
FORM_STATE_KEY_FOCUS

A key in the form state hashtable used in the back command navigation
FORM_STATE_KEY_NAME

A key in the form state hashtable used in the back command navigation
FORM_STATE_KEY_SELECTION

A key in the form state hashtable used in the back command navigation
FORM_STATE_KEY_TITLE

A key in the form state hashtable used in the back command navigation

Constructor Summary
Constructor and Description
UIBuilder()

Method Summary
Modifier and
Type

Method and Description


addCommandListener(ActionListener l)

void

void

void

protected
boolean
protected void

Adds a command listener that would be bound to all forms in the GUI
seamlessly
addCommandListener(String formName, ActionListener l)

Adds a command listener to be invoked for commands on a specific form


addComponentListener(String formName, String componentName,
Object listener)

Adds a component listener that would be bound when a UI for this form is
created.
allowBackTo(String formName)

Indicates whether a back command to this form should be generated


automatically when leaving said form.
analyticsCallback(String page, String referrer)

Invokes the analytics service if it is enabled and if


asyncCommandProcess(Command cmd, ActionEvent sourceEvent)

protected void

Class UIBuilder

Warning: This method is invoked OFF the EDT and is intended for usage
with asynchronous command processing.

753

Overview (Codename One API)


back()
void

This method effectively pops the form navigation stack and goes back to
the previous form if back navigation is enabled and there is a previous
form.
back(Component sourceComponent)

void

This method effectively pops the form navigation stack and goes back to
the previous form if back navigation is enabled and there is a previous
form.
beforeShow(Form f)

protected void

This method allows binding an action that should occur before showing
the given form
beforeShowContainer(Container c)

protected void

This method allows binding an action that should occur before showing
the given container
bindListenerToComponent(Component cmp, Object listener)

protected void

LazyValue<Form>
protected
Command

Binds the given listener object to the component, this works seamlessly
for common Codename One events but might be an issue with custom
components and custom listener types so this method can be overloaded
to add support for such cases.
createBackLazyValue(Form f)

This is useful for swipe back navigation behavior


createCommand(String commandName, Image icon, int commandId,
String action)

Creates a command instance.


createComponentInstance(String componentType, Class cls)

protected
Component

Container
Container

This method can be overriden to create custom components in a custom


way, the component type is a shorthand for the component name and not
the full name of the class.
createContainer(Resources res, String resourceName)

Creates the container defined under the given name in the res file
createContainer(String resPath, String resourceName)

Creates the container defined under the given name in the res file
exitForm(Form f)

protected void

protected
Resources
Component
Component

This method allows binding an action that should occur before leaving
the given form, e.g.
fetchResourceFile()

This method may be overriden by subclasses to provide a way to


dynamically load a resource file.
findByName(String name, Component rootComponent)

Finds the given component by its name


findByName(String name, Container rootComponent)

Finds the given component by its name


formNavigationStackDebug()

protected String

protected String
protected
Hashtable
protected
Hashtable
String

Useful method for logging form navigation, it returns a string representing


the navigation state which can be used to analyze crash reports
getBackCommandText(String previousFormTitle)

Returns the text for the back command string.


getContainerState(Container cnt)

This method is the container navigation equivalent of getFormState() see


that method for details.
getFormState(Form f)

Returns the state of the current form which we are about to leave as part
of the navigation logic.
getHomeForm()

When reaching the home form the navigation stack is cleared


getResourceFilePath()

String

Allows the navigation code to avoid storing the resource file and lets the
GC remove it from memory when its not in use

protected
Container

getRootAncestor(Component c)

Method Summary

754

Overview (Codename One API)


Returns either the parent form or the component bellow the embedded
container above c.
handleComponentAction(Component c, ActionEvent event)
protected void

boolean

This method is invoked for every component to which an action event


listener can be bound and delivers the event data for the given
component seamlessly.
isBackCommandEnabled()

Seamlessly inserts a back command to all the forms


isBlockAnalytics()

static boolean

Enables blocking analytics in the UIBuilder, this is useful for the designer
tool.
isKeepResourcesInRam()

boolean

Indicates that the UIBuilder should cache resources in memory and


never release them.
isSameBackDestination(Container source, Container destination)

protected
boolean

When navigating from one form/container to another we sometimes


might not want the back command to return to the previous
container/form but rather to the one before source.
onBackNavigation()

protected void

This callback is invoked to indicate that the upcoming form is shown as


part of a "back" navigation.
onCreateRoot(String rootName)

protected void

This method allows binding logic that should occur before creating the
root object e.g.
popNavigationStack()

protected void

Removes a navigation frame from the stack, this is useful in case you
want to go back to a form in the middle of the navigation stack.
postAsyncCommand(Command cmd, ActionEvent sourceEvent)

protected void

This method is invoked in conjunction with asyncCommandProcess after


the command was handled asynchronously on the separate thread.
postCreateComponent(Component cmp)

protected void

Callback to allow binding custom logic/listeners to a component after its


major properties were set (notice that not all properties or the full
hierarchy will be available at this stage).
postShow(Form f)

protected void

This method allows binding an action that should occur immediately after
showing the given form
postShowContainer(Container c)

protected void

This method allows binding an action that should occur immediately after
showing the given container

protected
boolean

processBackground(Form f)

Warning: this method is invoked on a separate thread.


processCommand(ActionEvent ev, Command cmd)

protected void

Invoked to process a given command before naviation or any other


internal processing occurs.
registerCustomComponent(String name, Class cmp)

static void

This method allows the UIBuilder to package a smaller portion of


Codename One into the JAR and add support for additional 3rd party
components to the GUI builder.
reloadContainer(Component cnt)

void

Useful tool to refresh the current state of a container shown using show
container without pushing another instance to the back stack
reloadForm()

void

void
void

Useful tool to refresh the current state of a form shown using show form
without pushing another instance to the back stack
removeCommandListener(ActionListener l)

Removes a command listener


removeCommandListener(String formName, ActionListener l)

Removes a command listener on a specific form

void

Method Summary

755

Overview (Codename One API)


removeComponentListener(String formName, String componentName,
Object listener)

Removes a component listener bound to a specific component


restoreComponentState(Component c, Hashtable destination)
protected void

By default Codename One stores the states of components in the


navigation graph as it moves between forms.
setBackCommand(Form f, Command backCommand)

protected void

void

Invoked internally to set the back command on the form, this method
allows subclasses to change the behavior of back command adding or
disable it
setBackCommandEnabled(boolean back)

Seamlessly inserts a back command to all the forms


setBackDestination(String formName)

protected void

Pops the navigation stack until it finds form name and the back button will
match form name if form name isn't in the stack this method will fail
setBlockAnalytics(boolean aBlockAnalytics)

static void

Enables blocking analytics in the UIBuilder, this is useful for the designer
tool.
setContainerState(Container cnt, Hashtable state)

protected void

This method is the container navigation equivalent of setFormState() see


that method for details.
setFormState(Form f, Hashtable state)

protected void

void

Sets the state of the current form to which we are returing as part of the
navigation logic.
setHomeForm(String homeForm)

When reaching the home form the navigation stack is cleared


setKeepResourcesInRam(boolean keepResourcesInRam)

void

Indicates that the UIBuilder should cache resources in memory and


never release them.

protected
boolean

setListModel(ContainerList cmp)

protected
boolean

setListModel(List cmp)

protected void

Allows a subclass to set the list model for the given component
Allows a subclass to set the list model for the given component
setResourceFile(Resources res)

Sets the resource file if keep in rum or no path is defined


setResourceFilePath(String resourceFilePath)

void

Allows the navigation code to avoid storing the resource file and lets the
GC remove it from memory when its not in use
shouldAddBackCommandToMenu()

protected
boolean

Back commands are set implicitly (see allowBackTo to disable that), this
method allows subclasses to disable the behavior where the back
command is also added to the menu (not just set to the back button).
shouldAutoStoreState()

protected
boolean

Indicates whether the UIBuilder should try storing states for forms on its
own by seeking lists, tabs and other statefull elements and keeping their
selection
showContainer(String resourceName, Command sourceCommand,
Component sourceComponent)

Container

This method is equivalent to the internal navigation behavior, it adds


functionality such as the back command into the given form resource and
shows it.
showForm(String resourceName, Command sourceCommand)

Form

This method is equivalent to the internal navigation behavior, it adds


functionality such as the back command into the given form resource and
shows it.
storeComponentState(Component c, Hashtable destination)

protected void

Method Summary

By default Codename One stores the states of components in the


navigation graph as it moves between forms.

756

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
FORM_STATE_KEY_NAME
public static final String FORM_STATE_KEY_NAME

A key in the form state hashtable used in the back command navigation
See Also:
Constant Field Values
FORM_STATE_KEY_TITLE
public static final String FORM_STATE_KEY_TITLE

A key in the form state hashtable used in the back command navigation
See Also:
Constant Field Values
FORM_STATE_KEY_FOCUS
public static final String FORM_STATE_KEY_FOCUS

A key in the form state hashtable used in the back command navigation
See Also:
Constant Field Values
FORM_STATE_KEY_SELECTION
public static final String FORM_STATE_KEY_SELECTION

A key in the form state hashtable used in the back command navigation
See Also:
Constant Field Values
BACK_COMMAND_ID
public static final int BACK_COMMAND_ID

See Also:
Constant Field Values

Constructor Detail
UIBuilder
public UIBuilder()

Method Detail
isBlockAnalytics
public static boolean isBlockAnalytics()

Enables blocking analytics in the UIBuilder, this is useful for the designer tool.
Returns:
the blockAnalytics
setBlockAnalytics
public static void setBlockAnalytics(boolean aBlockAnalytics)

Enables blocking analytics in the UIBuilder, this is useful for the designer tool.
Parameters:

Methods inherited from class java.lang.Object

757

Overview (Codename One API)


aBlockAnalytics - the blockAnalytics to set
setBackCommandEnabled
public void setBackCommandEnabled(boolean back)

Seamlessly inserts a back command to all the forms


Parameters:
back - true to automatically add a back command
popNavigationStack
protected void popNavigationStack()

Removes a navigation frame from the stack, this is useful in case you want to go
back to a form in the middle of the navigation stack.
setBackDestination
protected void setBackDestination(String formName)

Pops the navigation stack until it finds form name and the back button will match form
name if form name isn't in the stack this method will fail
Parameters:
formName - the name of the form to navigate back to.
formNavigationStackDebug
protected String formNavigationStackDebug()

Useful method for logging form navigation, it returns a string representing the
navigation state which can be used to analyze crash reports
Returns:
A string representing form states
isBackCommandEnabled
public boolean isBackCommandEnabled()

Seamlessly inserts a back command to all the forms


Returns:
true if a back command is automatically added
registerCustomComponent
public static void registerCustomComponent(String name,
Class cmp)

This method allows the UIBuilder to package a smaller portion of Codename One into
the JAR and add support for additional 3rd party components to the GUI builder.
Components must be registered using their UIID name, by default all the content of
com.codename1.ui is registered however subpackages and 3rd party components
are not. Registration is essential for obfuscation to work properly!
Parameters:
name - the name of the component (UIID)
cmp - the class for the given component
analyticsCallback
protected void analyticsCallback(String page,
String referrer)

Invokes the analytics service if it is enabled and if


Parameters:
page - the page visited
referrer - the source page
createContainer
public Container createContainer(String resPath,
String resourceName)

Creates the container defined under the given name in the res file
Parameters:
resPath - the path to the res file containing the UI widget

Method Detail

758

Overview (Codename One API)


resourceName - the name of the widget in the res file
Returns:
a Codename One container instance
createContainer
public Container createContainer(Resources res,
String resourceName)

Creates the container defined under the given name in the res file
Parameters:
res - the res file containing the UI widget
resourceName - the name of the widget in the res file
Returns:
a Codename One container instance
findByName
public Component findByName(String name,
Component rootComponent)

Finds the given component by its name


Parameters:
name - the name of the component as defined in the resource editor
rootComponent - the root container
Returns:
the component matching the given name or null if its not found
findByName
public Component findByName(String name,
Container rootComponent)

Finds the given component by its name


Parameters:
name - the name of the component as defined in the resource editor
rootComponent - the root container
Returns:
the component matching the given name or null if its not found
createComponentInstance
protected Component createComponentInstance(String componentType,
Class cls)

This method can be overriden to create custom components in a custom way, the
component type is a shorthand for the component name and not the full name of the
class. By default this method returns null which indicates Codename One should try
to reolve the component on its own.
Parameters:
componentType - the type of the component from the UI builder
cls - assumed component class based on the component registry
Returns:
a new component instance or null
postCreateComponent
protected void postCreateComponent(Component cmp)

Callback to allow binding custom logic/listeners to a component after its major


properties were set (notice that not all properties or the full hierarchy will be available
at this stage). This is the perfect place to bind models/renderers etc. to components.
Parameters:
cmp - the component
bindListenerToComponent
protected void bindListenerToComponent(Component cmp,
Object listener)

Binds the given listener object to the component, this works seamlessly for common
Codename One events but might be an issue with custom components and custom
listener types so this method can be overloaded to add support for such cases.

Method Detail

759

Overview (Codename One API)


Parameters:
cmp - the component to bind the listener to
listener - the listener object
setListModel
protected boolean setListModel(List cmp)

Allows a subclass to set the list model for the given component
Parameters:
cmp - the list whose model may be set
Returns:
true if a model was set by this method
setListModel
protected boolean setListModel(ContainerList cmp)

Allows a subclass to set the list model for the given component
Parameters:
cmp - the list whose model may be set
Returns:
true if a model was set by this method
createCommand
protected Command createCommand(String commandName,
Image icon,
int commandId,
String action)

Creates a command instance. This method is invoked by the loading code and can
be overriden to create a subclass of the Command class.
Parameters:
commandName - the label on the command
icon - the icon for the command
commandId - the id of the command
action - the action assigned to the command if such an action is defined
Returns:
a new command instance
fetchResourceFile
protected Resources fetchResourceFile()

This method may be overriden by subclasses to provide a way to dynamically load a


resource file. Normally the navigation feature of the UIBuilder requires the resource
file present in RAM. However, that might be expensive to maintain. By implementing
this method and replacing the storeResourceFile() with an empty implementation the
resource file storage can be done strictly in RAM.
Returns:
the instance of the resource file
getResourceFilePath
public String getResourceFilePath()

Allows the navigation code to avoid storing the resource file and lets the GC remove
it from memory when its not in use
Returns:
the resourceFilePath
setResourceFilePath
public void setResourceFilePath(String resourceFilePath)

Allows the navigation code to avoid storing the resource file and lets the GC remove
it from memory when its not in use
Parameters:
resourceFilePath - the resourceFilePath to set

Method Detail

760

Overview (Codename One API)


setResourceFile
protected void setResourceFile(Resources res)

Sets the resource file if keep in rum or no path is defined


Parameters:
res - the resource file
processCommand
protected void processCommand(ActionEvent ev,
Command cmd)

Invoked to process a given command before naviation or any other internal


processing occurs. The event can be consumed to prevent further processing.
Parameters:
ev - the action event source of the command
cmd - the command to process
addCommandListener
public void addCommandListener(ActionListener l)

Adds a command listener that would be bound to all forms in the GUI seamlessly
Parameters:
l - the listener to bind
removeCommandListener
public void removeCommandListener(ActionListener l)

Removes a command listener


Parameters:
l - the listener to remove
addComponentListener
public void addComponentListener(String formName,
String componentName,
Object listener)

Adds a component listener that would be bound when a UI for this form is created.
Notice that this method is only effective before the form was created and would do
nothing for an existing form
Parameters:
formName - the name of the form to which the listener should be bound
componentName - the name of the component to bind to
listener - the listener to bind, common listener types are supported
removeComponentListener
public void removeComponentListener(String formName,
String componentName,
Object listener)

Removes a component listener bound to a specific component


Parameters:
formName - the name of the form
componentName - the name of the component
listener - the listener instance
addCommandListener
public void addCommandListener(String formName,
ActionListener l)

Adds a command listener to be invoked for commands on a specific form


Parameters:
formName - the name of the form to which the listener should be bound
l - the listener to bind

Method Detail

761

Overview (Codename One API)


removeCommandListener
public void removeCommandListener(String formName,
ActionListener l)

Removes a command listener on a specific form


Parameters:
formName - the name of the form
l - the listener to remove
handleComponentAction
protected void handleComponentAction(Component c,
ActionEvent event)

This method is invoked for every component to which an action event listener can be
bound and delivers the event data for the given component seamlessly.
Parameters:
c - the component broadcasting the event
event - the event meta data
asyncCommandProcess
protected void asyncCommandProcess(Command cmd,
ActionEvent sourceEvent)

Warning: This method is invoked OFF the EDT and is intended for usage with
asynchronous command processing. This method is invoked when the UI indicates
that an operation should occur in the background. To finish the processing of the
operation within the EDT one should override the postAsyncCommand() method.
Parameters:
cmd - the command requiring background processing
sourceEvent - the triggering event
postAsyncCommand
protected void postAsyncCommand(Command cmd,
ActionEvent sourceEvent)

This method is invoked in conjunction with asyncCommandProcess after the


command was handled asynchronously on the separate thread. Here Codename
One code can be execute to update the UI with the results from the separate thread.
Parameters:
cmd - the command
sourceEvent - the source event
processBackground
protected boolean processBackground(Form f)

Warning: this method is invoked on a separate thread. This method is invoked when
a next form property is defined, this property indicates a background process for a
form of a transitional nature should take place (e.g. splash screen, IO etc.) after
which the next form should be shown. After this method completes the next form is
shown.
Parameters:
f - the form for which the background thread was constructed, notice that
most methods are not threadsafe and one should use callSerially* in this
method when mutating the form.
Returns:
if false is returned from this method navigation should not proceed to that
given form
getFormState
protected Hashtable getFormState(Form f)

Returns the state of the current form which we are about to leave as part of the
navigation logic. When a back command will return to this form the state would be
restored using setFormState. The default implementation of this method restores
focus and list selection. You can add arbitrary keys to the form state, keys starting
with a $ sign are reserved for the UIBuilder base class use.

Method Detail

762

Overview (Codename One API)


Parameters:
f - the form whose state should be preserved
Returns:
arbitrary state object
restoreComponentState
protected void restoreComponentState(Component c,
Hashtable destination)

By default Codename One stores the states of components in the navigation graph
as it moves between forms. However, some components aren't recognized by
Codename One by default to enable smaller executable size. This method can be
overriden to enable storing the state of custom components
Parameters:
c - the component whose state should be restored
destination - the hashtable containing the state
storeComponentState
protected void storeComponentState(Component c,
Hashtable destination)

By default Codename One stores the states of components in the navigation graph
as it moves between forms. However, some components aren't recognized by
Codename One by default to enable smaller executable size. This method can be
overriden to enable storing the state of custom components
Parameters:
c - the component whose state should be stored
destination - the destination hashtable
shouldAutoStoreState
protected boolean shouldAutoStoreState()

Indicates whether the UIBuilder should try storing states for forms on its own by
seeking lists, tabs and other statefull elements and keeping their selection
Returns:
true to handle state automatically, false otherwise
setFormState
protected void setFormState(Form f,
Hashtable state)

Sets the state of the current form to which we are returing as part of the navigation
logic. When a back command is pressed this form state should be restored, it was
obtained via getFormState. The default implementation of this method restores focus
and list selection.
Parameters:
f - the form whose state should be preserved
state - arbitrary state object
getContainerState
protected Hashtable getContainerState(Container cnt)

This method is the container navigation equivalent of getFormState() see that method
for details.
Parameters:
cnt - the container
Returns:
the state
setContainerState
protected void setContainerState(Container cnt,
Hashtable state)

This method is the container navigation equivalent of setFormState() see that method
for details.
Parameters:
cnt - the container

Method Detail

763

Overview (Codename One API)


state - the state
getHomeForm
public String getHomeForm()

When reaching the home form the navigation stack is cleared


Returns:
the homeForm
setHomeForm
public void setHomeForm(String homeForm)

When reaching the home form the navigation stack is cleared


Parameters:
homeForm - the homeForm to set
back
public void back()

This method effectively pops the form navigation stack and goes back to the previous
form if back navigation is enabled and there is a previous form.
back
public void back(Component sourceComponent)

This method effectively pops the form navigation stack and goes back to the previous
form if back navigation is enabled and there is a previous form.
Parameters:
sourceComponent - the component that triggered the back command which
effectively allows us to find the EmbeddedContainer for a case of container
navigation. Null can be used if not applicable.
getBackCommandText
protected String getBackCommandText(String previousFormTitle)

Returns the text for the back command string. This can be controlled in the theme by
the "backUsesTitleBool" constant
Parameters:
previousFormTitle - the title of the previous form
Returns:
the string for the back command inserted implicitly
setBackCommand
protected void setBackCommand(Form f,
Command backCommand)

Invoked internally to set the back command on the form, this method allows
subclasses to change the behavior of back command adding or disable it
Parameters:
f - the form
backCommand - the back command
showContainer
public Container showContainer(String resourceName,
Command sourceCommand,
Component sourceComponent)

This method is equivalent to the internal navigation behavior, it adds functionality


such as the back command into the given form resource and shows it. If the source
command is the back command the showBack() method will run. Notice that
container navigation (none-form) doesn't support the back() method or the form stack.
However a command marked as back command will be respected.
Parameters:
resourceName - the name of the resource for the form to show
sourceCommand - the command of the resource (may be null)
sourceComponent - the component that activated the show (may be null)
Returns:

Method Detail

764

Overview (Codename One API)


the container thats being shown, notice that you can still manipulate some
states of the container before it actually appears
reloadContainer
public void reloadContainer(Component cnt)

Useful tool to refresh the current state of a container shown using show container
without pushing another instance to the back stack
Parameters:
cnt - the container thats embedded into the application
reloadForm
public void reloadForm()

Useful tool to refresh the current state of a form shown using show form without
pushing another instance to the back stack
createBackLazyValue
public LazyValue<Form> createBackLazyValue(Form f)

This is useful for swipe back navigation behavior


Parameters:
f - the form from which we should go back
Returns:
a lazy value that will return the back form
allowBackTo
protected boolean allowBackTo(String formName)

Indicates whether a back command to this form should be generated automatically


when leaving said form.
Parameters:
formName - the name of the form
Returns:
true to autogenerate and add a back command to the destination form
isSameBackDestination
protected boolean isSameBackDestination(Container source,
Container destination)

When navigating from one form/container to another we sometimes might not want
the back command to return to the previous container/form but rather to the one
before source. A good example would be a "refresh" command or a toggle button that
changes the form state.
Parameters:
source - the form or container we are leaving
destination - the container or form we are navigating to
Returns:
false if we want a standard back button to source, true if we want to use the
same back button as the one in source
showForm
public Form showForm(String resourceName,
Command sourceCommand)

This method is equivalent to the internal navigation behavior, it adds functionality


such as the back command into the given form resource and shows it. If the source
command is the back command the showBack() method will run.
Parameters:
resourceName - the name of the resource for the form to show
sourceCommand - the command of the resource (may be null)
Returns:
the form thats being shown, notice that you can still manipulate some states
of the form before it actually appears

Method Detail

765

Overview (Codename One API)


exitForm
protected void exitForm(Form f)

This method allows binding an action that should occur before leaving the given form,
e.g. memory cleanup
Parameters:
f - the form being left
beforeShow
protected void beforeShow(Form f)

This method allows binding an action that should occur before showing the given
form
Parameters:
f - the form about to be shown
onBackNavigation
protected void onBackNavigation()

This callback is invoked to indicate that the upcoming form is shown as part of a
"back" navigation. This is useful for the case of a breadcrumb UI where the navigation
stack is shown at the top of the UI, in that case this method can be used to pop out
the breadcrumb stack.
shouldAddBackCommandToMenu
protected boolean shouldAddBackCommandToMenu()

Back commands are set implicitly (see allowBackTo to disable that), this method
allows subclasses to disable the behavior where the back command is also added to
the menu (not just set to the back button).
Returns:
postShow
protected void postShow(Form f)

This method allows binding an action that should occur immediately after showing the
given form
Parameters:
f - the form that was just shown
beforeShowContainer
protected void beforeShowContainer(Container c)

This method allows binding an action that should occur before showing the given
container
Parameters:
c - the container about to be shown
postShowContainer
protected void postShowContainer(Container c)

This method allows binding an action that should occur immediately after showing the
given container
Parameters:
c - the container that was just shown
onCreateRoot
protected void onCreateRoot(String rootName)

This method allows binding logic that should occur before creating the root object e.g.
a case where a created form needs data fetched for it.
Parameters:
rootName - the name of the root to be created from the resource file

Method Detail

766

Overview (Codename One API)


isKeepResourcesInRam
public boolean isKeepResourcesInRam()

Indicates that the UIBuilder should cache resources in memory and never release
them. This is useful with small resource files or high RAM devices since it saves the
cost of constantly fetching the res file from the jar whenever moving between forms.
This can be toggled in the properties (e.g. jad) using the flag: cacheResFile
(true/false) which defaults to false.
Returns:
the keepResourcesInRam
setKeepResourcesInRam
public void setKeepResourcesInRam(boolean keepResourcesInRam)

Indicates that the UIBuilder should cache resources in memory and never release
them. This is useful with small resource files or high RAM devices since it saves the
cost of constantly fetching the res file from the jar whenever moving between forms.
This can be toggled in the properties (e.g. jad) using the flag: cacheResFile
(true/false) which defaults to false.
Parameters:
keepResourcesInRam - the keepResourcesInRam to set
getRootAncestor
protected Container getRootAncestor(Component c)

Returns either the parent form or the component bellow the embedded container
above c.
Parameters:
c - the component whose root ancestor we should find
Returns:
the root

Method Detail

767

Overview (Codename One API)


com.codename1.ui.util

Class SwipeBackSupport
java.lang.Object

com.codename1.ui.util.SwipeBackSupport

public class
extends Object

Allows binding a swipe listener to the form that enables the user to swipe back to the previous form.

Constructor Summary
Constructor and Description
SwipeBackSupport()

Method Summary
Modifier and Type
protected void
static void
static void

Method and Description


bind(Form currentForm, LazyValue<Form> destination)

Binds support for swiping to the given forms


bindBack(Form currentForm, LazyValue<Form> destination)

Binds support for swiping to the given forms


bindBack(LazyValue<Form> destination)

Binds support for swiping to the current form

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SwipeBackSupport
public SwipeBackSupport()

Method Detail
bindBack
public static void bindBack(Form currentForm,
LazyValue<Form> destination)

Binds support for swiping to the given forms


Parameters:
currentForm - the current form
destination - the destination form which can be created lazily
bindBack
public static void bindBack(LazyValue<Form> destination)

Binds support for swiping to the current form


Parameters:
destination - the destination form which can be created lazily

Class SwipeBackSupport

768

Overview (Codename One API)


bind
protected void bind(Form currentForm,
LazyValue<Form> destination)

Binds support for swiping to the given forms


Parameters:
currentForm - the current form
destination - the destination form which can be created lazily

Method Detail

769

Overview (Codename One API)


com.codename1.ui.util

Class Resources
java.lang.Object

com.codename1.ui.util.Resources

public class
extends Object

Loads resources from the binary resource file generated by the Codename One Designer. A resource
is loaded entirely into memory since random file access is not supported in Java ME, any other
approach would be inefficient. This means that memory must be made available to accommodate the
resource file.

Method Summary
Modifier and Type
InputStream
String[]
Font
String[]

Method and Description


getData(String id)

Returns the data resource from the file


getDataResourceNames()

Returns the names of the data resources within this bundle


getFont(String id)

Returns the font resource from the file


getFontResourceNames()

Returns the names of the fonts within this bundle


getGlobalResources()

static Resources

Image
String[]

Global resources are used by new GUI builder apps to keep


track of the applications resources
getImage(String id)

Returns the image resource from the file


getImageResourceNames()

Returns the names of the images within this bundle


getL10N(String id, String locale)

Hashtable<String,String>

String[]
int
String[]

Returns a hashmap containing localized String key/value pairs


for the given locale name
getL10NResourceNames()

Returns the names of the localization bundles within this bundle


getMajorVersion()

Returns the version number for this resource file.


getMetaData()

Returns optional meta-data associated with the resource file


getMinorVersion()

int

String[]

Returns the minor version number for this resource file This
value relates to the value from the header defined by the
resource file specification.
getResourceNames()

Returns the names of the resources within this bundle


getSystemResource()

static Resources

Hashtable
String[]
String[]

Class Resources

Gets the system resource which can be located


/CN1Images.res.
getTheme(String id)

Returns the theme resource from the file


getThemeResourceNames()

Returns the names of the images within this bundle


getUIResourceNames()

770

Overview (Codename One API)


Returns the names of the ui resources within this bundle
isAnimation(String name)
boolean

boolean
static boolean
boolean
boolean
boolean
boolean
boolean
Collection<String>

Deprecated.
animations are no longer distinguished from images in the
resource file, use Image.isAnimation instead
isData(String name)

Returns true if this is a data resource


isFailOnMissingTruetype()
isFont(String name)

Returns true if this is a font resource


isImage(String name)

Returns true if this is an image resource


isL10N(String name)

Returns true if this is a generic data resource


isTheme(String name)

Returns true if this is a theme resource


isUI(String name)

Returns true if this is a UI resource


l10NLocaleSet(String id)

Returns a collection of the l10 locale names


listL10NLocales(String id)

Enumeration

static Resources
static Resources
static Resources
static Resources

Returns an enumration of the locales supported by this resource


id
open(InputStream resource)

Creates a resource object from the given input stream


open(InputStream resource, int dpi)

Creates a resource object from the given input stream


open(String resource)

Creates a resource object from the local JAR resource identifier


open(String resource, int dpi)

Creates a resource object from the local JAR resource identifier


openLayered(String resource)

static Resources

Opens a multi-layer resource file that supports overriding


features on a specific platform.
openLayered(String resource, int dpi)

static Resources

Opens a multi-layer resource file that supports overriding


features on a specific platform.
override(InputStream input)

This method allows overriding the data of a resource file with


another resource file thus replacing or enhancing existing
content with platform specific content.

void

static void

setFailOnMissingTruetype(boolean aFailOnMissingTruetype)
setGlobalResources(Resources res)

static void

static void

Global resources are used by new GUI builder apps to keep


track of the applications resources
setPassword(String password)

Sets the password to use for password protected resource files


setRuntimeMultiImageEnabled(boolean b)

static void

Deprecated.
do not use this method!

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Summary

771

Overview (Codename One API)

Method Detail
isFailOnMissingTruetype
public static boolean isFailOnMissingTruetype()

Returns:
the failOnMissingTruetype
setFailOnMissingTruetype
public static void setFailOnMissingTruetype(boolean aFailOnMissingTruetype)

Parameters:
aFailOnMissingTruetype

- the failOnMissingTruetype to set

setRuntimeMultiImageEnabled
public static void setRuntimeMultiImageEnabled(boolean b)

Deprecated. do not use this method!


This flag should be off and it is off by default, some special case implementations for
development e.g. the AWT implementation activate this flag in order to use the
EncodedImage multi-image support which is entirely for development only!
override
public void override(InputStream input)
throws IOException

This method allows overriding the data of a resource file with another resource file
thus replacing or enhancing existing content with platform specific content. E.g.
default icons for the application can be overriden on a specific platform
Parameters:
input - a new resource file
Throws:
IOException - exception thrown from the stream
setPassword
public static void setPassword(String password)

Sets the password to use for password protected resource files


Parameters:
password - the password or null to clear the password
getMajorVersion
public int getMajorVersion()

Returns the version number for this resource file. This value relates to the value from
the header defined by the resource file specification. 0 is returned for legacy versions
of the resource file format.
Returns:
major version number for the resource file
getMinorVersion
public int getMinorVersion()

Returns the minor version number for this resource file This value relates to the value
from the header defined by the resource file specification.
Returns:
minor version number for the resource file
getMetaData
public String[] getMetaData()

Returns optional meta-data associated with the resource file


Returns:
optional meta-data associated with the file

Method Detail

772

Overview (Codename One API)


getResourceNames
public String[] getResourceNames()

Returns the names of the resources within this bundle


Returns:
array of names of all the resources in this bundle
getDataResourceNames
public String[] getDataResourceNames()

Returns the names of the data resources within this bundle


Returns:
array of names of the data resources in this bundle
getUIResourceNames
public String[] getUIResourceNames()

Returns the names of the ui resources within this bundle


Returns:
array of names of the ui resources in this bundle
getL10NResourceNames
public String[] getL10NResourceNames()

Returns the names of the localization bundles within this bundle


Returns:
array of names of the localization resources in this bundle
getFontResourceNames
public String[] getFontResourceNames()

Returns the names of the fonts within this bundle


Returns:
array of names of the font resources in this bundle
getThemeResourceNames
public String[] getThemeResourceNames()

Returns the names of the images within this bundle


Returns:
array of names of the image resources in this bundle
getImageResourceNames
public String[] getImageResourceNames()

Returns the names of the images within this bundle


Returns:
array of names of the image resources in this bundle
isL10N
public boolean isL10N(String name)

Returns true if this is a generic data resource


Parameters:
name - the name of the resource
Returns:
true if the resource is a data resource
Throws:
NullPointerException - if the resource doesn't exist
isTheme
public boolean isTheme(String name)

Returns true if this is a theme resource


Parameters:
name - the name of the resource

Method Detail

773

Overview (Codename One API)


Returns:
true if the resource is a theme
Throws:
NullPointerException - if the resource doesn't exist
isFont
public boolean isFont(String name)

Returns true if this is a font resource


Parameters:
name - the name of the resource
Returns:
true if the resource is a font
Throws:
NullPointerException - if the resource doesn't exist
isAnimation
public boolean isAnimation(String name)

Deprecated. animations are no longer distinguished from images in the resource file,
use Image.isAnimation instead
Returns true if this is an animation resource
Parameters:
name - the name of the resource
Returns:
true if the resource is an animation
Throws:
NullPointerException - if the resource doesn't exist
isData
public boolean isData(String name)

Returns true if this is a data resource


Parameters:
name - the name of the resource
Returns:
true if the resource is a data resource
Throws:
NullPointerException - if the resource doesn't exist
isUI
public boolean isUI(String name)

Returns true if this is a UI resource


Parameters:
name - the name of the resource
Returns:
true if the resource is a UI resource
Throws:
NullPointerException - if the resource doesn't exist
isImage
public boolean isImage(String name)

Returns true if this is an image resource


Parameters:
name - the name of the resource
Returns:
true if the resource is an image
Throws:
NullPointerException - if the resource doesn't exist
openLayered
public static Resources openLayered(String resource)
throws IOException

Method Detail

774

Overview (Codename One API)


Opens a multi-layer resource file that supports overriding features on a specific
platform. Notice that the ".res" extension MUST not be given to this method!
Parameters:
resource - a local reference to a resource using the syntax of
Class.getResourceAsStream(String) however the extension MUST not be
included in the name! E.g. to reference /x.res use /x
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails
open
public static Resources open(String resource)
throws IOException

Creates a resource object from the local JAR resource identifier


Parameters:
resource - a local reference to a resource using the syntax of
Class.getResourceAsStream(String)
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails
open
public static Resources open(InputStream resource)
throws IOException

Creates a resource object from the given input stream


Parameters:
resource - stream from which to read the resource
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails
openLayered
public static Resources openLayered(String resource,
int dpi)
throws IOException

Opens a multi-layer resource file that supports overriding features on a specific


platform. Notice that the ".res" extension MUST not be given to this method!
Parameters:
resource - a local reference to a resource using the syntax of
Class.getResourceAsStream(String) however the extension MUST not be
included in the name! E.g. to reference /x.res use /x
dpi - the dpi used for the loaded images
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails
open
public static Resources open(String resource,
int dpi)
throws IOException

Creates a resource object from the local JAR resource identifier


Parameters:
resource - a local reference to a resource using the syntax of
Class.getResourceAsStream(String)
dpi - the dpi used for the loaded images
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails

Method Detail

775

Overview (Codename One API)


open
public static Resources open(InputStream resource,
int dpi)
throws IOException

Creates a resource object from the given input stream


Parameters:
resource - stream from which to read the resource
dpi - the dpi used for the loaded images
Returns:
a resource object
Throws:
IOException - if opening/reading the resource fails
getImage
public Image getImage(String id)

Returns the image resource from the file


Parameters:
id - name of the image resource
Returns:
cached image instance
getData
public InputStream getData(String id)

Returns the data resource from the file


Parameters:
id - name of the data resource
Returns:
newly created input stream that allows reading the data of the resource
getL10N
public Hashtable<String,String> getL10N(String id,
String locale)

Returns a hashmap containing localized String key/value pairs for the given locale
name
Parameters:
id - the name of the locale resource
locale - name of the locale resource
Returns:
Hashtable containing key value pairs for localized data
listL10NLocales
public Enumeration listL10NLocales(String id)

Returns an enumration of the locales supported by this resource id


Parameters:
id - the name of the locale resource
Returns:
enumeration of strings containing bundle names
l10NLocaleSet
public Collection<String> l10NLocaleSet(String id)

Returns a collection of the l10 locale names


Parameters:
id - the name of the locale resource
Returns:
collection of strings containing bundle names
getFont
public Font getFont(String id)

Returns the font resource from the file

Method Detail

776

Overview (Codename One API)

Parameters:
id - name of the font resource
Returns:
cached font instance
getTheme
public Hashtable getTheme(String id)

Returns the theme resource from the file


Parameters:
id - name of the theme resource
Returns:
cached theme instance
getSystemResource
public static Resources getSystemResource()

Gets the system resource which can be located /CN1Images.res.


Returns:
a Resources object which contains the system resources
setGlobalResources
public static void setGlobalResources(Resources res)

Global resources are used by new GUI builder apps to keep track of the applications
resources
Parameters:
res - the resource object used by default in the GUI builder forms
getGlobalResources
public static Resources getGlobalResources()

Global resources are used by new GUI builder apps to keep track of the applications
resources
Returns:
the resource object used by default in the GUI builder forms

Method Detail

777

Overview (Codename One API)


com.codename1.ui.util

Class ImageIO
java.lang.Object

com.codename1.ui.util.ImageIO

public abstract class


extends Object

Enable simple operations on image file & image objects such as dynamic scaling and storage to
binary formats such as JPEG. Use Display.getImageIO() to get an instance of this class.

Field Summary
Modifier and Type
static String
static String

Field and Description


FORMAT_JPEG

Indicates the JPEG output format


FORMAT_PNG

Indicates the PNG output format

Constructor Summary
Constructor and Description
ImageIO()

Method Summary
Modifier and
Type
static
ImageIO
Dimension
abstract
boolean
void
abstract
void

void

Method and Description


getImageIO()

Gets the ImageIO instance


getImageSize(String imageFilePath)

Returns the image size in pixels


isFormatSupported(String format)

Indicates if the given format for output is supported by this implementation


save(Image img, OutputStream response, String format, float quality)

Saves an image object to the given format


save(InputStream image, OutputStream response, String format,
int width, int height, float quality)

Saves an image file at the given resolution, scaling if necessary


save(String imageFilePath, OutputStream response, String format,
int width, int height, float quality)

Saves an image file at the given resolution, scaling if necessary

String

saveAndKeepAspect(String imageFilePath, String preferredOutputPath,


String format, int width, int height, float quality,
boolean onlyDownscale, boolean scaleToFill)

Scales an image on disk while maintaining an aspect ratio, the appropriate


aspect size will be picked based on the status of scaleToFill
protected
abstract
void

Class ImageIO

saveImage(Image img, OutputStream response, String format,


float quality)

Saves an image object to the given format

778

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
FORMAT_JPEG
public static final String FORMAT_JPEG

Indicates the JPEG output format


See Also:
Constant Field Values
FORMAT_PNG
public static final String FORMAT_PNG

Indicates the PNG output format


See Also:
Constant Field Values

Constructor Detail
ImageIO
public ImageIO()

Method Detail
save
public abstract void save(InputStream image,
OutputStream response,
String format,
int width,
int height,
float quality)
throws IOException

Saves an image file at the given resolution, scaling if necessary


Parameters:
image - source image stream
response - resulting image output will be written to this stream
format - the format for the image either FORMAT_PNG or FORMAT_JPEG
width - the width for the resulting image, use -1 to not scale
height - the height of the resulting image, use -1 to not scale
quality - the quality for the resulting image output (applicable mostly for
JPEG), a value between 0 and 1.
Throws:
IOException

save
public void save(Image img,
OutputStream response,
String format,
float quality)
throws IOException

Saves an image object to the given format


Parameters:
img - the image object
response - resulting image output will be written to this stream
format - the format for the image either FORMAT_PNG or FORMAT_JPEG
quality - the quality of the image, a value between 0 and 1.

Methods inherited from class java.lang.Object

779

Overview (Codename One API)


Throws:
IOException

save
public void save(String imageFilePath,
OutputStream response,
String format,
int width,
int height,
float quality)
throws IOException

Saves an image file at the given resolution, scaling if necessary


Parameters:
imageFilePath - the image file path
response - resulting image output will be written to this stream
format - the format for the image either FORMAT_PNG or FORMAT_JPEG
width - the width for the resulting image, use -1 to not scale
height - the height of the resulting image, use -1 to not scale
quality - the quality for the resulting image output (applicable mostly for
JPEG), a value between 0 and 1.
Throws:
IOException

getImageSize
public Dimension getImageSize(String imageFilePath)
throws IOException

Returns the image size in pixels


Parameters:
imageFilePath - the path to the image
Returns:
the size in pixels
Throws:
IOException

saveAndKeepAspect
public String saveAndKeepAspect(String imageFilePath,
String preferredOutputPath,
String format,
int width,
int height,
float quality,
boolean onlyDownscale,
boolean scaleToFill)
throws IOException

Scales an image on disk while maintaining an aspect ratio, the appropriate aspect
size will be picked based on the status of scaleToFill
Parameters:
imageFilePath - the path to the image
preferredOutputPath - the url where the image will be saved
format - the format for the image either FORMAT_JPEG or FORMAT_PNG
width - the desired width, either width or height will be respected based on
aspect dimensions
height - the desired height, either width or height will be respected based on
aspect dimensions
quality - the quality for JPEG scaling
onlyDownscale - will not scale if the resolution to scale will be higher in this
case will return the imageFilePath
scaleToFill - when set to true will pick the larger value so the resulting
image will be at least as big as width x height, when set to false will create an
image that is no bigger than width x height
Returns:
the url for the scaled image or the url of the unscaled image
Throws:
IOException - if the operation fails

Method Detail

780

Overview (Codename One API)


saveImage
protected abstract void saveImage(Image img,
OutputStream response,
String format,
float quality)
throws IOException

Saves an image object to the given format


Parameters:
img - the image object
response - resulting image output will be written to this stream
format - the format for the image either FORMAT_PNG or FORMAT_JPEG
quality - the quality of the image, a value between 0 and 1.
Throws:
IOException

isFormatSupported
public abstract boolean isFormatSupported(String format)

Indicates if the given format for output is supported by this implementation


Parameters:
format - the format for the image either FORMAT_PNG or FORMAT_JPEG
Returns:
true if supported
getImageIO
public static ImageIO getImageIO()

Gets the ImageIO instance


Returns:
the image IO instance or null if image IO isn't supported for the given platform

Method Detail

781

Overview (Codename One API)


com.codename1.ui.util

Class GlassTutorial
java.lang.Object

com.codename1.ui.util.GlassTutorial
All Implemented Interfaces:
Painter

public class
extends Object
implements Painter

A Glass Tutorial appears on top of the UI especially on a touch device but could be on any device and
points to/circles components within the UI coupled with explanation of what they do and a tint of the
screen. It is implemented as a GlassPane on top of a Form which is automatically removed when a
user touches the screen or presses a button.
To position elements within the glass tutorial the elements must be associated with a component
instance of the underlying UI and positioned relatively to said component.
The GlassTutorial uses the "GlassTutorial" UIID to paint itself it then paints the hint components in
their proper places.

Constructor Summary
Constructor and Description
GlassTutorial()

Method Summary
Modifier and
Type

Method and Description


addHint(Component hintComponent, Component destinationComponent,
String position)

void

Places a hint within the glass in a position relative to the


destinationComponent, the position is indicated with border layout attributes.
paint(Graphics g, Rectangle rect)

void

Draws inside the given rectangle clipping area.


showOn(Form f)

Install the glass tutorial on a form and seamlessly dismiss it when no longer
necessary

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GlassTutorial
public GlassTutorial()

Method Detail

Class GlassTutorial

782

Overview (Codename One API)


addHint
public void addHint(Component hintComponent,
Component destinationComponent,
String position)

Places a hint within the glass in a position relative to the destinationComponent, the
position is indicated with border layout attributes. Notice you can place multiple
components on a single element and they will be rendered in order e.g. a component
with a border can be used to "circle" the destination by placing it in the CENTER
position and another arrow with text can be places in the south position bellow.
Parameters:
hintComponent - The component that would be renderered in the given
position
destinationComponent - the "hinted" component over which the hint will show
position - the position relative to the destinationComponent in BorderLayout
values e.g. to place the hint above the component just place it in
BorderLayout.NORTH. The center will stretch the component but the other
sides will give the component its exact preferred size.
showOn
public void showOn(Form f)

Install the glass tutorial on a form and seamlessly dismiss it when no longer
necessary
Parameters:
f - the form
paint
public void paint(Graphics g,
Rectangle rect)

Draws inside the given rectangle clipping area.


Specified by:
paint in interface Painter
Parameters:
g - the Graphics object
rect - the given rectangle cliping area

Method Detail

783

Overview (Codename One API)


com.codename1.ui.util

Class EventDispatcher
java.lang.Object

com.codename1.ui.util.EventDispatcher

public class
extends Object

Handles event dispatching while guaranteeing that all events would be fired properly on the EDT
regardless of their source. This class handles listener registration/removal in a safe and uniform way.

Constructor Summary
Constructor and Description
EventDispatcher()

Method Summary
Modifier
and Type

Method and Description


addListener(Object listener)

void

void

void

Add a listener to the dispatcher that would receive the events when they
occurs
fireActionEvent(ActionEvent ev)

Fires the event safely on the EDT without risk of concurrency errors
fireBindTargetChange(Component source, String propertyName,
Object oldValue, Object newValue)

Fired when a property of the component changes to a new value


void
void

void

fireDataChangeEvent(int index, int type)

Fires the event safely on the EDT without risk of concurrency errors
fireFocus(Component c)

Fires the event safely on the EDT without risk of concurrency errors
fireScrollEvent(int scrollX, int scrollY, int oldscrollX,
int oldscrollY)

Fires the event safely on the EDT without risk of concurrency errors
void
void
Collection

fireSelectionEvent(int oldSelection, int newSelection)

Fires the event safely on the EDT without risk of concurrency errors
fireStyleChangeEvent(String property, Style source)

Fires the style change even to the listeners


getListenerCollection()

Returns the collection of the listeners


getListenerVector()

Vector

boolean

Deprecated.
use getListenerCollection instead, this method will now be VERY SLOW
hasListeners()

Returns true if the event dispatcher has registered listeners


isBlocking()

boolean

void
void

Class EventDispatcher

Indicates whether this dispatcher blocks when firing events or not, normally a
dispatcher uses callSeriallyAndWait() to be 100% synchronous with event
delivery however this method is very slow.
removeListener(Object listener)

Remove the listener from the dispatcher


setBlocking(boolean blocking)

784

Overview (Codename One API)


Indicates whether this dispatcher blocks when firing events or not, normally a
dispatcher uses callSeriallyAndWait() to be 100% synchronous with event
delivery however this method is very slow.
static void

setFireStyleEventsOnNonEDT(boolean fire)

When set to true, style events will be dispatched even from non-EDT threads.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
EventDispatcher
public EventDispatcher()

Method Detail
setFireStyleEventsOnNonEDT
public static void setFireStyleEventsOnNonEDT(boolean fire)

When set to true, style events will be dispatched even from non-EDT threads. When
set to false, when in non-EDT threads, style events will not be dispatched at all (And
developer has to make sure changes will be reflected by calling revalidate after all the
changes) Default is false. Setting this to true results in a performance penalty, and it
is better instead to simply aggregate events performed on non-EDT threads and
when all are over - call revalidate on the relevant container.
Parameters:
fire - true to fire on non-EDT, false otherwise
addListener
public void addListener(Object listener)

Add a listener to the dispatcher that would receive the events when they occurs
Parameters:
listener - a dispatcher listener to add
getListenerVector
public Vector getListenerVector()

Deprecated. use getListenerCollection instead, this method will now be VERY SLOW
Returns the vector of the listeners
Returns:
the vector of listeners attached to the event dispatcher
getListenerCollection
public Collection getListenerCollection()

Returns the collection of the listeners


Returns:
the collection of listeners attached to the event dispatcher
removeListener
public void removeListener(Object listener)

Remove the listener from the dispatcher


Parameters:
listener - a dispatcher listener to remove

Method Summary

785

Overview (Codename One API)


fireDataChangeEvent
public void fireDataChangeEvent(int index,
int type)

Fires the event safely on the EDT without risk of concurrency errors
Parameters:
index - the index of the event
type - the type of the event
fireBindTargetChange
public void fireBindTargetChange(Component source,
String propertyName,
Object oldValue,
Object newValue)

Fired when a property of the component changes to a new value


Parameters:
source - the source component
propertyName - the name of the property
oldValue - the old value of the property
newValue - the new value for the property
fireStyleChangeEvent
public void fireStyleChangeEvent(String property,
Style source)

Fires the style change even to the listeners


Parameters:
property - the property name for the event
source - the style firing the event
fireActionEvent
public void fireActionEvent(ActionEvent ev)

Fires the event safely on the EDT without risk of concurrency errors
Parameters:
ev - the ActionEvent to fire to the listeners
fireSelectionEvent
public void fireSelectionEvent(int oldSelection,
int newSelection)

Fires the event safely on the EDT without risk of concurrency errors
Parameters:
oldSelection - old selection
newSelection - new selection
fireScrollEvent
public void fireScrollEvent(int
int
int
int

scrollX,
scrollY,
oldscrollX,
oldscrollY)

Fires the event safely on the EDT without risk of concurrency errors
fireFocus
public void fireFocus(Component c)

Fires the event safely on the EDT without risk of concurrency errors
Parameters:
c - the Component that gets the focus event
hasListeners
public boolean hasListeners()

Returns true if the event dispatcher has registered listeners


Returns:

Method Detail

786

Overview (Codename One API)


true if the event dispatcher has registered listeners
isBlocking
public boolean isBlocking()

Indicates whether this dispatcher blocks when firing events or not, normally a
dispatcher uses callSeriallyAndWait() to be 100% synchronous with event delivery
however this method is very slow. By setting blocking to false the callSerially method
is used which allows much faster execution for IO heavy operations.
Returns:
the blocking state
setBlocking
public void setBlocking(boolean blocking)

Indicates whether this dispatcher blocks when firing events or not, normally a
dispatcher uses callSeriallyAndWait() to be 100% synchronous with event delivery
however this method is very slow. By setting blocking to false the callSerially method
is used which allows much faster execution for IO heavy operations.
Parameters:
blocking - the blocking value

Method Detail

787

Overview (Codename One API)


com.codename1.ui.util

Class EmbeddedContainer
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.util.EmbeddedContainer
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

This class is mostly used internally by the GUI builder and isn't very useful for general purpose. The
embedded container allows placing a wholy different UI hierarchy within the current hierarchy and
replace it on the fly.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
EmbeddedContainer()

Default constructor

Method Summary
Modifier and Type

Method and Description


getEmbed()

String

Indicates the name of the container to embed into this container


setEmbed(String embed)

void

Indicates the name of the container to embed into this container

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,

Class EmbeddedContainer

788

Overview (Codename One API)


replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
EmbeddedContainer
public EmbeddedContainer()

Default constructor

Methods inherited from class com.codename1.ui.Container

789

Overview (Codename One API)


Method

Detail

getEmbed
public String getEmbed()

Indicates the name of the container to embed into this container


Returns:
the embed
setEmbed
public void setEmbed(String embed)

Indicates the name of the container to embed into this container


Parameters:
embed - the embed to set

Method Detail

790

Overview (Codename One API)


com.codename1.ui.util

Class Effects
java.lang.Object

com.codename1.ui.util.Effects

public class
extends Object

Static utility class useful for simple visual effects that don't quite fit anywhere else in the core API.

Method Summary
Modifier
and Type

Method and Description


gaussianBlurImage(Image image, float radius)

static
Image

Create a blur image from the given image.


growShrink(Component c, int duration)

static void

Deprecated.
use Component.growShrink instead

static
boolean

isGaussianBlurSupported()

static
Image
static
Image

static
Image

Returns true if gaussian blur is supported on this platform


reflectionImage(Image source)

Takes the given image and appends an effect of reflection bellow it that is
similar to the way elements appear in water beneath them.
reflectionImage(Image source, float mirrorRatio, int alphaRatio)

Takes the given image and appends an effect of reflection bellow it that is
similar to the way elements appear in water beneath them.
reflectionImage(Image source, float mirrorRatio, int alphaRatio,
int spacing)

Takes the given image and appends an effect of reflection bellow it that is
similar to the way elements appear in water beneath them.
verticalPerspective(Image i, float topScaleRatio,
float bottomScaleRatio, float verticalShrink)

static
Image

Skews an image in a faux perspective transform on the vertical axis, this is


effectively a fast scale algorithm that both shrinks the image vertically and
reduces the width

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
reflectionImage
public static Image reflectionImage(Image source)

Takes the given image and appends an effect of reflection bellow it that is similar to
the way elements appear in water beneath them. This method shouldn't be used
when numAlpha is very low.
Parameters:
source - image to add the reflection effect to
Returns:
new image with a reflection effect for the source image

Class Effects

791

Overview (Codename One API)


reflectionImage
public static Image reflectionImage(Image source,
float mirrorRatio,
int alphaRatio)

Takes the given image and appends an effect of reflection bellow it that is similar to
the way elements appear in water beneath them. This method shouldn't be used
when numAlpha is very low.
Parameters:
source - image to add the reflection effect to
mirrorRatio - generally less than 1, a mirror ration of 0.5f will create a mirror
image half the height of the image, 0.75f will create a 3 quarter height mirror
etc.
alphaRatio - starting point for the alpha value in the mirror, this should be a
number between 0 - 255 (recommended larger than 0) indicating the opacity
of the closest pixel. For a mirror thats completely opaque use 255. A
recommended value would be between 128 to 90.
Returns:
new image with a reflection effect for the source image
reflectionImage
public static Image reflectionImage(Image source,
float mirrorRatio,
int alphaRatio,
int spacing)

Takes the given image and appends an effect of reflection bellow it that is similar to
the way elements appear in water beneath them. This method shouldn't be used
when numAlpha is very low.
Parameters:
source - image to add the reflection effect to
mirrorRatio - generally less than 1, a mirror ration of 0.5f will create a mirror
image half the height of the image, 0.75f will create a 3 quarter height mirror
etc.
alphaRatio - starting point for the alpha value in the mirror, this should be a
number between 0 - 255 (recommended larger than 0) indicating the opacity
of the closest pixel. For a mirror thats completely opaque use 255. A
recommended value would be between 128 to 90.
spacing - the distance in pixels between the image and its reflection
Returns:
new image with a reflection effect for the source image
growShrink
public static void growShrink(Component c,
int duration)

Deprecated. use Component.growShrink instead


Grows or shrinks the given component to its new preferred size, this method
essentially takes a component whose preferred size has changed and creates a
"growing" effect that lasts for the duration. Notice that some components (such as
text areas) don't report proper preferred size untill they are laid out once. Hence the
first time around a text area (or container containing a text area) will not produce the
expected effect. This can be solved by invoking revalidate before the call to this
method only the first time around!
Parameters:
c - the component to grow/shrink, its size must be different from its preferred
size
duration - the duration in milliseconds for the grow/shrink animation
verticalPerspective
public static Image verticalPerspective(Image
float
float
float

i,
topScaleRatio,
bottomScaleRatio,
verticalShrink)

Skews an image in a faux perspective transform on the vertical axis, this is effectively
a fast scale algorithm that both shrinks the image vertically and reduces the width

Method Detail

792

Overview (Codename One API)


Parameters:
- the amount by which the top portion should be scaled where
1.0 means none
bottomScaleRatio - the amount by which the bottom portion should be scaled
where 1.0 means none
verticalShrink - the scale ratio for the image height where 1.0 means none
Returns:
the perspective translated image
gaussianBlurImage
topScaleRatio

public static Image gaussianBlurImage(Image image,


float radius)

Create a blur image from the given image. The algorithm is gaussian blur https://en.wikipedia.org/wiki/Gaussian_blur
Parameters:
image - the image to blur
radius - the radius to be used in the algorithm
isGaussianBlurSupported
public static boolean isGaussianBlurSupported()

Returns true if gaussian blur is supported on this platform


Returns:
true if gaussian blur is supported.

Method Detail

793

Overview (Codename One API)


com.codename1.ui.tree

Interface TreeModel
All Known Implementing Classes:
FileTreeModel

public interface

Arranges tree node objects, a node can essentially be anything and it will be displayed in a hierarchy
using the Tree

And heres a more "real world" example showing an XML hierarchy in a Tree:

Interface TreeModel

794

Overview (Codename One API)

Method Summary
Modifier and
Type

Method and Description


getChildren(Object parent)

Returns the child objects representing the given parent, null should return
the root objects

Vector

boolean

isLeaf(Object node)

Is the node a leaf or a folder

Method Detail
getChildren
Vector getChildren(Object parent)

Returns the child objects representing the given parent, null should return the root
objects
Parameters:
parent - the parent object whose children should be returned, null would
return the tree roots
Returns:
the children of the given node within the tree
isLeaf
boolean isLeaf(Object node)

Is the node a leaf or a folder


Parameters:
node - a node within the tree
Returns:
true if the node is a leaf that can't be expanded

Method Summary

795

Overview (Codename One API)


com.codename1.ui.tree

Class Tree
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.tree.Tree
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
FileTree

public class
extends Container

The Tree component allows constructing simple tree component hierarchies that can be expanded
seamlessly with no limit. The tree is bound to a model that can provide data with free form depth such
as file system or similarly structured data.
To customize the look of the tree the component can be derived and component creation can be
replaced.

And heres a more "real world" example showing an XML hierarchy in a Tree:

Method Detail

796

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Tree()

Constructor for usage by GUI builder and automated tools, normally one should use the
version that accepts the model
Tree(TreeModel model)

Construct a tree with the given tree model

Method Summary
Modifier
and Type
void
protected
void

Class Tree

Method and Description


addLeafListener(ActionListener l)

A listener that fires when a leaf is clicked


bindNodeListener(ActionListener l, Component node)

Since a node may be any component type developers should override this method to add
the click listener to the given component.

protected
Dimension

calcPreferredSize()

protected
String

childToDisplayLabel(Object child)

Calculates the preferred size based on component content.

Converts a tree child to a label, this method can be overriden for simple rendering effects

797

Overview (Codename One API)


collapsePath(Object... path)

void

Collapses the last element in the path

protected
Component
protected
Button

createNode(Object node, int depth)

Creates a node within the tree, this method is protected allowing tree to be subclassed to
logic of individual tree buttons.
createNodeComponent(Object node, int depth)

Deprecated.
replaced with createNode, bindNodeListener and setNodeIcon
expandPath(boolean animate, Object... path)

void

Expands the tree path


expandPath(Object... path)

void

Expands the tree path

TreeModel

getModel()

Returns the tree model instance


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this A
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]

This method is here to workaround an XMLVM array type bug where property types aren'
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListM
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Returns the current value of the property name, this method is used by the GUI builder
getSelectedItem()

Object

Returns the currently selected item in the tree

boolean

isMultilineMode()

Toggles a mode where rows in the tree can be broken since span buttons will be used ins
removeLeafListener(ActionListener l)

void

Removes the listener that fires when a leaf is clicked

static
void

setFolderIcon(Image folderIcon)

static
void

setFolderOpenIcon(Image folderIcon)

Sets the icon for a tree folder


Sets the icon for a tree folder in its expanded state
setModel(TreeModel model)

void

Sets the tree model to a new value


setMultilineMode(boolean multilineMode)

void

Toggles a mode where rows in the tree can be broken since span buttons will be used ins

static
void

setNodeIcon(Image nodeIcon)

protected
void

setNodeIcon(Image icon, Component node)

String

Sets the icon for a tree node


Sets the icon for the given node similar in scope to bindNodeListener
setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if succe

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,

Method Summary

798

Overview (Codename One API)


paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Tree
public Tree()

Constructor for usage by GUI builder and automated tools, normally one should use
the version that accepts the model

Methods inherited from class com.codename1.ui.Container

799

Overview (Codename One API)


Tree
public Tree(TreeModel model)

Construct a tree with the given tree model


Parameters:
model - represents the contents of the tree

Method Detail
isMultilineMode
public boolean isMultilineMode()

Toggles a mode where rows in the tree can be broken since span buttons will be
used instead of plain buttons.
Returns:
the multilineMode
setMultilineMode
public void setMultilineMode(boolean multilineMode)

Toggles a mode where rows in the tree can be broken since span buttons will be
used instead of plain buttons.
Parameters:
multilineMode - the multilineMode to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component

Constructor Detail

800

Overview (Codename One API)


Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getModel
public TreeModel getModel()

Returns the tree model instance


Returns:
the tree model
setModel
public void setModel(TreeModel model)

Sets the tree model to a new value


Parameters:
model - the model of the tree
setFolderIcon
public static void setFolderIcon(Image folderIcon)

Sets the icon for a tree folder


Parameters:
folderIcon - the icon for a folder within the tree
setFolderOpenIcon
public static void setFolderOpenIcon(Image folderIcon)

Sets the icon for a tree folder in its expanded state


Parameters:
folderIcon - the icon for a folder within the tree
setNodeIcon
public static void setNodeIcon(Image nodeIcon)

Sets the icon for a tree node


Parameters:
nodeIcon - the icon for a node within the tree
expandPath
public void expandPath(Object... path)

Expands the tree path


Parameters:
path - the path to expand
expandPath
public void expandPath(boolean animate,
Object... path)

Expands the tree path

Method Detail

801

Overview (Codename One API)


Parameters:
path - the path to expand
animate - whether to animate

expansion

collapsePath
public void collapsePath(Object... path)

Collapses the last element in the path


Parameters:
path - the path to the element that should be collapsed
getSelectedItem
public Object getSelectedItem()

Returns the currently selected item in the tree


Returns:
the object selected within the tree
createNodeComponent
protected Button createNodeComponent(Object node,
int depth)

Deprecated. replaced with createNode, bindNodeListener and setNodeIcon


Creates a node within the tree, this method is protected allowing tree to be
subclassed to replace the rendering logic of individual tree buttons.
Parameters:
node - the node object from the model to display on the button
depth - the depth within the tree (normally represented by indenting the entry)
Returns:
a button representing the node within the tree
bindNodeListener
protected void bindNodeListener(ActionListener l,
Component node)

Since a node may be any component type developers should override this method to
add support for binding the click listener to the given component.
Parameters:
l - listener interface
node - node component returned by createNode
setNodeIcon
protected void setNodeIcon(Image icon,
Component node)

Sets the icon for the given node similar in scope to bindNodeListener
Parameters:
icon - the icon for the node
node - the node instance
createNode
protected Component createNode(Object node,
int depth)

Creates a node within the tree, this method is protected allowing tree to be
subclassed to replace the rendering logic of individual tree buttons.
Parameters:
node - the node object from the model to display on the button
depth - the depth within the tree (normally represented by indenting the entry)
Returns:
a button representing the node within the tree
childToDisplayLabel
protected String childToDisplayLabel(Object child)

Converts a tree child to a label, this method can be overriden for simple rendering
effects

Method Detail

802

Overview (Codename One API)


Returns:
a string representing the given tree node
addLeafListener
public void addLeafListener(ActionListener l)

A listener that fires when a leaf is clicked


Parameters:
l - listener to fire when the leaf is clicked
removeLeafListener
public void removeLeafListener(ActionListener l)

Removes the listener that fires when a leaf is clicked


Parameters:
l - listener to remove
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content

Method Detail

803

Overview (Codename One API)


com.codename1.ui.table

Interface TableModel
All Known Implementing Classes:
DefaultTableModel

public interface

The table and table model class are complimentry classes allowing the quick construction of tabular
data controls. The table model represents the data source according to which the table is constructed.

Method Summary
Modifier and Type
void

Adds a listener to the data changed event


getColumnCount()

int

Returns the number of columns in the table


getColumnName(int i)

String

Returns the name of the column at the given offset


getRowCount()

int

Returns the number of rows in the table


getValueAt(int row, int column)

Object

Returns the value of the cell at the given location

boolean

isCellEditable(int row, int column)

Returns true if the cell at the given location is an editable cell


removeDataChangeListener(DataChangedListener d)

void

Removes a listener to the data changed event


setValueAt(int row, int column, Object o)

void

Method and Description


addDataChangeListener(DataChangedListener d)

Sets the value of the cell at the given location

Method Detail
getRowCount
int getRowCount()

Returns the number of rows in the table


Returns:
the number of rows in the table
getColumnCount
int getColumnCount()

Returns the number of columns in the table


Returns:
the number of columns in the table
getColumnName
String getColumnName(int i)

Returns the name of the column at the given offset


Parameters:
i - the offset for the column name
Returns:
name to display at the top of the table

Interface TableModel

804

Overview (Codename One API)


isCellEditable
boolean isCellEditable(int row,
int column)

Returns true if the cell at the given location is an editable cell


Parameters:
row - the cell row
column - the cell column
Returns:
true if the cell at the given location is an editable cell
getValueAt
Object getValueAt(int row,
int column)

Returns the value of the cell at the given location


Parameters:
row - the cell row
column - the cell column
Returns:
the value of the cell at the given location
setValueAt
void setValueAt(int row,
int column,
Object o)

Sets the value of the cell at the given location


Parameters:
row - the cell row
column - the cell column
o - the value of the cell at the given location
addDataChangeListener
void addDataChangeListener(DataChangedListener d)

Adds a listener to the data changed event


Parameters:
d - the new listener
removeDataChangeListener
void removeDataChangeListener(DataChangedListener d)

Removes a listener to the data changed event


Parameters:
d - the listener to remove

Method Detail

805

Overview (Codename One API)


com.codename1.ui.table

Class TableLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.table.TableLayout

public class
extends Layout

TableLayout is a very elaborate constraint based layout manager that can arrange elements in
rows/columns while defining constraints to control complex behavior such as spanning,
alignment/weight etc.
Notice that the table layout is in the com.codename1.ui.table package and not in the layouts package.
This is due to the fact that TableLayout was originally designed for the Table class.
Despite being constraint based the table layout isn't strict about constraints and will implicitly add a
constraint when one is missing. However, unlike grid layout table layout won't implicitly add a row if
the row/column count is incorrect
E.g this creates a 2x2 table but adds 5 elements. The 5th element won't show:
Form hi = new Form("Table Layout 2x2", new TableLayout(2, 2));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));
hi.show();

Table layout supports the ability to grow the last column which can be enabled using the
setGrowHorizontally method. You can also use a shortened terse syntax to construct a table layout
however since the table layout is a constraint based layout you won't be able to utilize its full power
with this syntax.
The default usage of the encloseIn below uses the setGrowHorizontally flag.
Container tl = TableLayout.encloseIn(2, new Label("First"),
new Label("Second"),

Class TableLayout

806

Overview (Codename One API)


new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));

The Full Potential


To truly appreciate the TableLayout we need to use the constraint syntax which allows us to span,
align and set width/height for the rows & columns.
Table layout works with a TableLayout.Constraint instance that can communicate our intentions into
the layout manager. Such constraints can include more than one attribute e.g. span and height.
Notice that table layout constraints can't be reused for more than one component.
The constraint class supports the following attributes:
The column for the table cell. This defaults to -1 which will just place the component
in the next available cell
row
Similar to column, defaults to -1 as well
The column width in percentages, -1 will use the preferred size. -2 for width will take
width
up the rest of the available space
height
Similar to width but doesn't support the -2 value
The cells that should be occupied horizontally defaults to 1 and can't exceed the
spanHorizontal
column count - current offset.
spanVertical
Similar to spanHorizontal with the same limitations
The horizontal alignment of the content within the cell, defaults to the special case -1
horizontalAlign value to take up all the cell space can be either `-1`, `Component.LEFT`,
`Component.RIGHT` or `Component.CENTER`
Similar to horizontalAlign can be one of `-1`, `Component.TOP`,
verticalAlign
`Component.BOTTOM` or `Component.CENTER`
Notice that you only need to set `width`/`height` to one cell in a column/row.
The table layout constraint sample tries to demonstrate some of the unique things you can do with
constraints.
We go into further details on this in the developer guide so check that out.
column

TableLayout tl = new TableLayout(2, 3);


Form hi = new Form("Table Layout Cons", tl);
hi.setScrollable(false);
hi.add(tl.createConstraint().
widthPercentage(20),
new Label("AAA")).
add(tl.createConstraint().
horizontalSpan(2).
heightPercentage(80).
verticalAlign(Component.CENTER).
horizontalAlign(Component.CENTER),
new Label("Span H")).
add(new Label("BBB")).
add(tl.createConstraint().
widthPercentage(60).
heightPercentage(20),

Class TableLayout

807

Overview (Codename One API)


new Label("CCC")).
add(tl.createConstraint().
widthPercentage(20),
new Label("DDD"));

Nested Class Summary


Modifier and
Type

Class and Description


TableLayout.Constraint

static class

Represents the layout constraint for an entry within the table indicating the
desired position/behavior of the component.

Constructor Summary
Constructor and Description
TableLayout(int rows, int columns)

A table must declare the amount of rows and columns in advance

Method Summary
Modifier and Type
void

TableLayout.Constraint
TableLayout.Constraint

static Container

Method and Description


addLayoutComponent(Object value, Component comp,
Container c)

Some layouts can optionally track the addition of elements with


meta-data that allows the user to "hint" on object positioning.
createConstraint()

Creates a new Constraint instance to add to the layout


createConstraint(int row, int column)

Creates a new Constraint instance to add to the layout


encloseIn(int columns, boolean growHorizontally,
Component... cmps)

Creates a table layout container, the number of rows is


automatically calculated based on the number of columns.
encloseIn(int columns, Component... cmps)

static Container

boolean

Nested Class Summary

Creates a table layout container that grows the last column


horizontally, the number of rows is automatically calculated based
on the number of columns.
equals(Object o)

Indicates whether some other object is "equal to" this one.

808

Overview (Codename One API)


int
int
int
int
Component
Object

getCellHorizontalSpan(int row, int column)

Returns the spanning for the table cell at the given coordinate
getCellVerticalSpan(int row, int column)

Returns the spanning for the table cell at the given coordinate
getColumnPosition(int col)

Returns the position of the given table column.


getColumns()

Get the number of columns


getComponentAt(int row, int column)

Returns the component at the given row/column


getComponentConstraint(Component comp)

Returns the optional component constraint


getDefaultColumnWidth()

static int

Indicates the default (in percentage) for the column width, -1


indicates automatic sizing
getDefaultRowHeight()

static int

Indicates the default (in percentage) for the row height, -1


indicates automatic sizing
getMinimumSizePerColumn()

static int

int
int
Dimension
int
int
boolean
boolean

Indicates the minimum size for a column in the table, this is


applicable for tables that are not scrollable on the X axis.
getNextColumn()

Returns the column where the next operation of add will appear
getNextRow()

Returns the row where the next operation of add will appear
getPreferredSize(Container parent)

Returns the container preferred size


getRowPosition(int row)

Returns the position of the given table row.


getRows()

Get the number of rows


hasHorizontalSpanning()

Indicates whether there is spanning within this layout


hasVerticalSpanning()

Indicates whether there is spanning within this layout


isCellSpannedThroughHorizontally(int row, int column)

boolean

Returns true if the cell at the given position is spanned through


horizontally
isCellSpannedThroughVertically(int row, int column)

boolean

Returns true if the cell at the given position is spanned through


vertically
isConstraintTracking()

boolean

If this method returns true, the addLayoutComponent method will


be called when replacing a layout for every component within the
container
isGrowHorizontally()

boolean

void

Indicates whether the table layout should grow horizontally to take


up available space by stretching the last column
layoutContainer(Container parent)

Layout the given parent container children


removeLayoutComponent(Component comp)

void

Removes the component from the layout this operation is only


useful if the layout maintains references to components within it
setDefaultColumnWidth(int w)

static void

Indicates the default (in percentage) for the column width, -1


indicates automatic sizing
setDefaultRowHeight(int h)

static void

Method Summary

Indicates the default (in percentage) for the row height, -1


indicates automatic sizing

809

Overview (Codename One API)


setGrowHorizontally(boolean growHorizontally)

Indicates whether the table layout should grow horizontally to take


up available space by stretching the last column

void

setMinimumSizePerColumn(int minimumSize)
static void

Sets the minimum size for a column in the table, this is applicable
for tables that are not scrollable on the X axis.
toString()

String

Returns a string representation of the object.

Methods inherited from class com.codename1.ui.layouts.Layout


hashCode, isOverlapSupported, obscuresPotential

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
TableLayout
public TableLayout(int rows,
int columns)

A table must declare the amount of rows and columns in advance


Parameters:
rows - rows of the table
columns - columns of the table

Method Detail
getRows
public int getRows()

Get the number of rows


Returns:
number of rows
getColumns
public int getColumns()

Get the number of columns


Returns:
number of columns
getComponentAt
public Component getComponentAt(int row,
int column)

Returns the component at the given row/column


Parameters:
row - the row of the component
column - the column of the component
Returns:
the component instance
layoutContainer
public void layoutContainer(Container parent)

Layout the given parent container children


Specified by:

Methods inherited from class com.codename1.ui.layouts.Layout

810

Overview (Codename One API)


layoutContainer

in class Layout

Parameters:
parent - the given parent container
getRowPosition
public int getRowPosition(int row)

Returns the position of the given table row. A valid value is only returned after the
layout occurred.
Parameters:
row - the row in the table
Returns:
the Y position in pixels or -1 if layout hasn't occured/row is too large etc.
getColumnPosition
public int getColumnPosition(int col)

Returns the position of the given table column. A valid value is only returned after the
layout occurred.
Parameters:
col - the column in the table
Returns:
the X position in pixels or -1 if layout hasn't occured/column is too large etc.
getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
getNextRow
public int getNextRow()

Returns the row where the next operation of add will appear
Returns:
the row where the next operation of add will appear
getNextColumn
public int getNextColumn()

Returns the column where the next operation of add will appear
Returns:
the column where the next operation of add will appear
addLayoutComponent
public void addLayoutComponent(Object value,
Component comp,
Container c)

Some layouts can optionally track the addition of elements with meta-data that allows
the user to "hint" on object positioning.
Overrides:
addLayoutComponent in class Layout
Parameters:
value - optional meta data information, like alignment orientation
comp - the added component to the layout
c - the parent container
getCellHorizontalSpan
public int getCellHorizontalSpan(int row,
int column)

Method Detail

811

Overview (Codename One API)


Returns the spanning for the table cell at the given coordinate
Parameters:
row - row in the table
column - column within the table
Returns:
the amount of spanning 1 for no spanning
getCellVerticalSpan
public int getCellVerticalSpan(int row,
int column)

Returns the spanning for the table cell at the given coordinate
Parameters:
row - row in the table
column - column within the table
Returns:
the amount of spanning 1 for no spanning
isCellSpannedThroughVertically
public boolean isCellSpannedThroughVertically(int row,
int column)

Returns true if the cell at the given position is spanned through vertically
Parameters:
row - cell row
column - cell column
Returns:
true if the cell is a part of a span for another cell
isCellSpannedThroughHorizontally
public boolean isCellSpannedThroughHorizontally(int row,
int column)

Returns true if the cell at the given position is spanned through horizontally
Parameters:
row - cell row
column - cell column
Returns:
true if the cell is a part of a span for another cell
hasVerticalSpanning
public boolean hasVerticalSpanning()

Indicates whether there is spanning within this layout


Returns:
true if the layout makes use of spanning
hasHorizontalSpanning
public boolean hasHorizontalSpanning()

Indicates whether there is spanning within this layout


Returns:
true if the layout makes use of spanning
removeLayoutComponent
public void removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only useful if the layout
maintains references to components within it
Overrides:
removeLayoutComponent in class Layout
Parameters:
comp - the removed component from layout

Method Detail

812

Overview (Codename One API)


getComponentConstraint
public Object getComponentConstraint(Component comp)

Returns the optional component constraint


Overrides:
getComponentConstraint in class Layout
Parameters:
comp - the component whose constraint should be returned
Returns:
the optional component constraint
createConstraint
public TableLayout.Constraint createConstraint()

Creates a new Constraint instance to add to the layout


Returns:
the default constraint
createConstraint
public TableLayout.Constraint createConstraint(int row,
int column)

Creates a new Constraint instance to add to the layout


Parameters:
row - the row for the table starting with 0
column - the column for the table starting with 0
Returns:
the new constraint
setMinimumSizePerColumn
public static void setMinimumSizePerColumn(int minimumSize)

Sets the minimum size for a column in the table, this is applicable for tables that are
not scrollable on the X axis. This will force the earlier columns to leave room for the
latter columns.
Parameters:
minimumSize - the minimum width of the column
getMinimumSizePerColumn
public static int getMinimumSizePerColumn()

Indicates the minimum size for a column in the table, this is applicable for tables that
are not scrollable on the X axis. This will force the earlier columns to leave room for
the latter columns.
Returns:
the minimum width of the column
setDefaultColumnWidth
public static void setDefaultColumnWidth(int w)

Indicates the default (in percentage) for the column width, -1 indicates automatic
sizing
Parameters:
w - width in percentage
getDefaultColumnWidth
public static int getDefaultColumnWidth()

Indicates the default (in percentage) for the column width, -1 indicates automatic
sizing
Returns:
width in percentage

Method Detail

813

Overview (Codename One API)


setDefaultRowHeight
public static void setDefaultRowHeight(int h)

Indicates the default (in percentage) for the row height, -1 indicates automatic sizing
Parameters:
h - height in percentage
getDefaultRowHeight
public static int getDefaultRowHeight()

Indicates the default (in percentage) for the row height, -1 indicates automatic sizing
Returns:
height in percentage
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Layout
isConstraintTracking
public boolean isConstraintTracking()

If this method returns true, the addLayoutComponent method will be called when
replacing a layout for every component within the container
Overrides:
isConstraintTracking in class Layout
Returns:
false by default
isGrowHorizontally
public boolean isGrowHorizontally()

Indicates whether the table layout should grow horizontally to take up available space
by stretching the last column
Returns:
the growHorizontally

Method Detail

814

Overview (Codename One API)


setGrowHorizontally
public void setGrowHorizontally(boolean growHorizontally)

Indicates whether the table layout should grow horizontally to take up available space
by stretching the last column
Parameters:
growHorizontally - the growHorizontally to set
encloseIn
public static Container encloseIn(int columns,
Component... cmps)

Creates a table layout container that grows the last column horizontally, the number
of rows is automatically calculated based on the number of columns. See usage:
Container tl = TableLayout.encloseIn(2, new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));

Parameters:
columns - the number
cmps - components to

of columns
add

Returns:
a newly created table layout container with the components in it
encloseIn
public static Container encloseIn(int columns,
boolean growHorizontally,
Component... cmps)

Creates a table layout container, the number of rows is automatically calculated


based on the number of columns. See usage:
Container tl = TableLayout.encloseIn(2, new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));

Method Detail

815

Overview (Codename One API)

Parameters:
columns - the number of columns
growHorizontally - true to grow the
cmps - components to add

last column to fit available width

Returns:
a newly created table layout container with the components in it

Method Detail

816

Overview (Codename One API)


com.codename1.ui.table

Class TableLayout.Constraint
java.lang.Object

com.codename1.ui.table.TableLayout.Constraint
Enclosing class:
TableLayout

public static class


extends Object

Represents the layout constraint for an entry within the table indicating the desired position/behavior
of the component.

Constructor Summary
Constructor and Description
Constraint()

Method Summary
Modifier and Type

Method and Description

int

getColumn()

int

getHeightPercentage()

int

getHorizontalAlign()

int

getHorizontalSpan()

int

getRow()

int

getVerticalAlign()

int

getVerticalSpan()

int

getWidthPercentage()

TableLayout.Constraint
TableLayout.Constraint

heightPercentage(int height)

Sets the row height based on percentage of the parent


horizontalAlign(int align)

Sets the horizontal alignment of the table cell


horizontalSpan(int span)

TableLayout.Constraint

void
void

Sets the cells to span horizontally, this number must never be


smaller than 1
setHeightPercentage(int height)

Sets the row height based on percentage of the parent


setHorizontalAlign(int align)

Sets the horizontal alignment of the table cell


setHorizontalSpan(int span)

void

void

Sets the cells to span horizontally, this number must never be


smaller than 1
setVerticalAlign(int valign)

Sets the vertical alignment of the table cell


setVerticalSpan(int span)

void

void

Class TableLayout.Constraint

Sets the cells to span vertically, this number must never be


smaller than 1
setWidthPercentage(int width)

Sets the column width based on percentage of the parent

817

Overview (Codename One API)


toString()

String

Returns a string representation of the object.

TableLayout.Constraint

verticalAlign(int valign)

Sets the vertical alignment of the table cell


verticalSpan(int span)

TableLayout.Constraint

TableLayout.Constraint

Sets the cells to span vertically, this number must never be


smaller than 1
widthPercentage(int width)

Sets the column width based on percentage of the parent

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Constraint
public Constraint()

Method Detail
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
setVerticalSpan
public void setVerticalSpan(int span)

Sets the cells to span vertically, this number must never be smaller than 1
Parameters:
span - a number larger than 1
verticalSpan
public TableLayout.Constraint verticalSpan(int span)

Sets the cells to span vertically, this number must never be smaller than 1
Parameters:
span - a number larger than 1
Returns:
this
setHorizontalSpan
public void setHorizontalSpan(int span)

Sets the cells to span horizontally, this number must never be smaller than 1
Parameters:
span - a number larger than 1

Method Summary

818

Overview (Codename One API)


horizontalSpan
public TableLayout.Constraint horizontalSpan(int span)

Sets the cells to span horizontally, this number must never be smaller than 1
Parameters:
span - a number larger than 1
setWidthPercentage
public void setWidthPercentage(int width)

Sets the column width based on percentage of the parent


Parameters:
width - negative number indicates ignoring this member
widthPercentage
public TableLayout.Constraint widthPercentage(int width)

Sets the column width based on percentage of the parent


Parameters:
width - negative number indicates ignoring this member
setHeightPercentage
public void setHeightPercentage(int height)

Sets the row height based on percentage of the parent


Parameters:
height - negative number indicates ignoring this member
heightPercentage
public TableLayout.Constraint heightPercentage(int height)

Sets the row height based on percentage of the parent


Parameters:
height - negative number indicates ignoring this member
setHorizontalAlign
public void setHorizontalAlign(int align)

Sets the horizontal alignment of the table cell


Parameters:
align - Component.LEFT/RIGHT/CENTER
horizontalAlign
public TableLayout.Constraint horizontalAlign(int align)

Sets the horizontal alignment of the table cell


Parameters:
align - Component.LEFT/RIGHT/CENTER
setVerticalAlign
public void setVerticalAlign(int valign)

Sets the vertical alignment of the table cell


Parameters:
valign - Component.TOP/BOTTOM/CENTER
verticalAlign
public TableLayout.Constraint verticalAlign(int valign)

Sets the vertical alignment of the table cell


Parameters:
valign - Component.TOP/BOTTOM/CENTER

Method Detail

819

Overview (Codename One API)


getRow
public int getRow()

Returns:
the row
getColumn
public int getColumn()

Returns:
the column
getWidthPercentage
public int getWidthPercentage()

Returns:
the width
getHeightPercentage
public int getHeightPercentage()

Returns:
the height
getHorizontalSpan
public int getHorizontalSpan()

Returns:
the spanHorizontal
getVerticalSpan
public int getVerticalSpan()

Returns:
the spanVertical
getHorizontalAlign
public int getHorizontalAlign()

Returns:
the align
getVerticalAlign
public int getVerticalAlign()

Returns:
the valign

Method Detail

820

Overview (Codename One API)


com.codename1.ui.table

Class Table
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.table.Table
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

The Table class represents a grid of data that can be used for rendering a grid of components/labels.
The table reflects and updates the underlying model data. Table relies heavily on the TableLayout
class and TableModel interface to present its UI. Unlike a List a Table doesn't feature a separate
renderer and instead allows developers to derive the class.
Form hi = new Form("Table", new BorderLayout());
TableModel model = new DefaultTableModel(new String[] {"Col 1", "Col 2", "Col 3"}, new Object[][] {
{"Row 1", "Row A", "Row X"},
{"Row 2", "Row B can now stretch", null},
{"Row 3", "Row C", "Row Z"},
{"Row 4", "Row D", "Row K"},
}) {
public boolean isCellEditable(int row, int col) {
return col != 0;
}
};
Table table = new Table(model) {
{@literal @}Override
protected Component createCell(Object value, int row, int column, boolean editable) { (1)
Component cell;
if(row == 1 && column == 1) { (2)
Picker p = new Picker();
p.setType(Display.PICKER_TYPE_STRINGS);
p.setStrings("Row B can now stretch", "This is a good value", "So Is This", "Better than text field");
p.setSelectedString((String)value); (3)
p.setUIID("TableCell");
p.addActionListener((e) -> getModel().setValueAt(row, column, p.getSelectedString())); (4)
cell = p;
} else {
cell = super.createCell(value, row, column, editable);
}
if(row > -1 && row % 2 == 0) { (5)
// pinstripe effect
cell.getAllStyles().setBgColor(0xeeeeee);
cell.getAllStyles().setBgTransparency(255);
}
return cell;
}
{@literal @}Override
protected TableLayout.Constraint createCellConstraint(Object value, int row, int column) {
TableLayout.Constraint con = super.createCellConstraint(value, row, column);
if(row == 1 && column == 1) {
con.setHorizontalSpan(2);
}
con.setWidthPercentage(33);
return con;
}
};
hi.add(BorderLayout.CENTER, table);
hi.show();

Class Table

821

Overview (Codename One API)

Field Summary
Modifier and Type
static int

Field and Description


INNER_BORDERS_ALL

Constant denoting that inner borders should be drawn fully


INNER_BORDERS_COLS

static int

Constant denoting that only inner borders columns should


be drawn
INNER_BORDERS_NONE

static int

Constant denoting that inner borders should not be drawn


at all
INNER_BORDERS_ROWS

static int

Constant denoting that only inner borders rows should be


drawn

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Table()

Constructor for usage by GUI builder and automated tools, normally one should use the
version that accepts the model
Table(TableModel model)

Create a table with a new model


Table(TableModel model, boolean includeHeader)

Create a table with a new model

Field Summary

822

Overview (Codename One API)

Method Summary
Modifier and Type
protected Component
protected
TableLayout.Constraint

Method and Description


createCell(Object value, int row, int column, boolean editable)

Creates a cell based on the given value


createCellConstraint(Object value, int row, int column)

Creates the table cell constraint for the given cell, this method can be over
the table constraints.
deinitialize()

void

int
int
int
int
TableModel

Invoked to indicate that the component initialization is being reversed since


the container hierarchy.
getCellAlignment()

Indicates the alignment of the cells see label alignment for details
getCellColumn(Component cell)

Returns the column in which the given cell is placed


getCellRow(Component cell)

Returns the row in which the given cell is placed


getInnerBorderMode()

Returns the current inner border mode


getModel()

Returns the model instance


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to ma


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
int
int
int

This method is here to workaround an XMLVM array type bug where prope
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the
getSelectedColumn()

Returns the selected column in the table


getSelectedRow()

Returns the selected row in the table


getTitleAlignment()

Indicates the alignment of the title see label alignment for details
includeNullValues()

protected boolean

void
boolean
boolean

By default createCell/constraint won't be invoked for null values by overridi


replace this behavior
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "re
isDrawBorder()

Indicates whether the table border should be drawn


isIncludeHeader()

Indicates whether the table should render a table header as the first row
paintGlass(Graphics g)

protected void

void
void
void
void

Method Summary

This method can be overriden by a component to draw on top of itself or its


children finished drawing in a similar way to the glass pane but more refine
setBorderSpacing(int horizontal, int vertical)

Sets the spacing of cells border (relevant only for separate borders and no
setCellAlignment(int cellAlignment)

Indicates the alignment of the cells see label alignment for details
setCollapseBorder(boolean collapseBorder)

Indicates whether the borders of the cells should collapse to form a one lin
setDrawBorder(boolean drawBorder)

Indicates whether the table border should be drawn

823

Overview (Codename One API)


setDrawEmptyCellsBorder(boolean drawEmptyCellsBorder)

void

Indicates whether empty cells should have borders (relevant only for separ
setIncludeHeader(boolean includeHeader)

void

Indicates whether the table should render a table header as the first row
setInnerBorderMode(int innerBorder)

Sets how to draw the inner border (All of it, only rows/columns, none, grou
other than NONE/ALL will result in the border drawing as collapsed whethe

void

setModel(TableModel model)

void

Replaces the underlying model


setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed a
setTitleAlignment(int titleAlignment)

void

Indicates the alignment of the title see label alignment for details

protected boolean

shouldDrawInnerBorderAfterRow(int row)

Returns whether an inner border should be drawn after the specified row.

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, refreshTheme, removeAll,
removeComponent, replace, replace, replaceAndWait, replaceAndWait,
replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer,
setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX,
setScrollableY, setScrollIncrement, setShouldCalcPreferredSize,
setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,

Methods inherited from class com.codename1.ui.Container

824

Overview (Codename One API)

pointerReleased, putClientProperty, refreshTheme, refreshTheme,


removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
INNER_BORDERS_NONE
public static final int INNER_BORDERS_NONE

Constant denoting that inner borders should not be drawn at all


See Also:
Constant Field Values
INNER_BORDERS_ROWS
public static final int INNER_BORDERS_ROWS

Constant denoting that only inner borders rows should be drawn


See Also:
Constant Field Values
INNER_BORDERS_COLS
public static final int INNER_BORDERS_COLS

Constant denoting that only inner borders columns should be drawn


See Also:
Constant Field Values
INNER_BORDERS_ALL
public static final int INNER_BORDERS_ALL

Constant denoting that inner borders should be drawn fully


See Also:
Constant Field Values

Constructor Detail
Table
public Table()

Constructor for usage by GUI builder and automated tools, normally one should use
the version that accepts the model

Methods inherited from class com.codename1.ui.Component

825

Overview (Codename One API)


Table
public Table(TableModel model)

Create a table with a new model


Parameters:
model - the model underlying this table
Table
public Table(TableModel model,
boolean includeHeader)

Create a table with a new model


Parameters:
model - the model underlying this table
includeHeader - Indicates whether the table should render a table header as
the first row

Method Detail
getSelectedRow
public int getSelectedRow()

Returns the selected row in the table


Returns:
the offset of the selected row in the table if a selection exists
includeNullValues
protected boolean includeNullValues()

By default createCell/constraint won't be invoked for null values by overriding this


method to return true you can replace this behavior
Returns:
false by default
getSelectedColumn
public int getSelectedColumn()

Returns the selected column in the table


Returns:
the offset of the selected column in the table if a selection exists
paintGlass
protected void paintGlass(Graphics g)

This method can be overriden by a component to draw on top of itself or its children
after the component or the children finished drawing in a similar way to the glass
pane but more refined per component
Overrides:
paintGlass in class Container
Parameters:
g - the graphics context
createCell
protected Component createCell(Object value,
int row,
int column,
boolean editable)

Creates a cell based on the given value


Parameters:
value - the new value object
row - row number, -1 for the header rows
column - column number
editable - true if the cell is editable

Constructor Detail

826

Overview (Codename One API)


Returns:
cell component instance
initComponent
public void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
public void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
setModel
public void setModel(TableModel model)

Replaces the underlying model


Parameters:
model - the new model
getModel
public TableModel getModel()

Returns the model instance


Returns:
the model instance
isDrawBorder
public boolean isDrawBorder()

Indicates whether the table border should be drawn


Returns:
the drawBorder
setDrawBorder
public void setDrawBorder(boolean drawBorder)

Indicates whether the table border should be drawn


Parameters:
drawBorder - the drawBorder to set
setInnerBorderMode
public void setInnerBorderMode(int innerBorder)

Sets how to draw the inner border (All of it, only rows/columns, none, groups) Note
that setting to any mode other than NONE/ALL will result in the border drawing as
collapsed whether this is a collpased border or not
Parameters:
innerBorder - one of the INNER_BORDER_* constants
getInnerBorderMode
public int getInnerBorderMode()

Returns the current inner border mode


Returns:
the current inner border mode (one of the INNER_BORDER_* constants)

Method Detail

827

Overview (Codename One API)


shouldDrawInnerBorderAfterRow
protected boolean shouldDrawInnerBorderAfterRow(int row)

Returns whether an inner border should be drawn after the specified row. This allows
customization in subclasses to create for example the effects of segments in atable,
i.e. instead of a line after each row - lines after "chunks" of rows. Note that this is
queried only when the inner border mode is set to INNER_BORDER_ROWS
Parameters:
row - The row in question
Returns:
true to draw inner border, false otherwise
setCollapseBorder
public void setCollapseBorder(boolean collapseBorder)

Indicates whether the borders of the cells should collapse to form a one line border
Parameters:
collapseBorder - true to collapse (default), false for separate borders
setDrawEmptyCellsBorder
public void setDrawEmptyCellsBorder(boolean drawEmptyCellsBorder)

Indicates whether empty cells should have borders (relevant only for separate
borders and not for collapsed)
Parameters:
drawEmptyCellsBorder - - true to draw (default), false otherwise
setBorderSpacing
public void setBorderSpacing(int horizontal,
int vertical)

Sets the spacing of cells border (relevant only for separate borders and not for
collapsed)
Parameters:
horizontal - - The horizontal spacing
vertical - - The vertical spacing
getTitleAlignment
public int getTitleAlignment()

Indicates the alignment of the title see label alignment for details
Returns:
the title alignment
See Also:
Label.setAlignment(int)

setTitleAlignment
public void setTitleAlignment(int titleAlignment)

Indicates the alignment of the title see label alignment for details
Parameters:
titleAlignment - the title alignment
See Also:
Label.setAlignment(int)

getCellColumn
public int getCellColumn(Component cell)

Returns the column in which the given cell is placed


Parameters:
cell - the component representing the cell placed in the table
Returns:
the column in which the cell was placed in the table

Method Detail

828

Overview (Codename One API)


getCellRow
public int getCellRow(Component cell)

Returns the row in which the given cell is placed


Parameters:
cell - the component representing the cell placed in the table
Returns:
the row in which the cell was placed in the table
getCellAlignment
public int getCellAlignment()

Indicates the alignment of the cells see label alignment for details
Returns:
the cell alignment
See Also:
Label.setAlignment(int)

setCellAlignment
public void setCellAlignment(int cellAlignment)

Indicates the alignment of the cells see label alignment for details
Parameters:
cellAlignment - the table cell alignment
See Also:
Label.setAlignment(int)

isIncludeHeader
public boolean isIncludeHeader()

Indicates whether the table should render a table header as the first row
Returns:
the includeHeader
setIncludeHeader
public void setIncludeHeader(boolean includeHeader)

Indicates whether the table should render a table header as the first row
Parameters:
includeHeader - the includeHeader to set
createCellConstraint
protected TableLayout.Constraint createCellConstraint(Object value,
int row,
int column)

Creates the table cell constraint for the given cell, this method can be overriden for
the purposes of modifying the table constraints.
Parameters:
value - the value of the cell
row - the table row
column - the table column
Returns:
the table constraint
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

Method Detail

829

Overview (Codename One API)


getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

830

Overview (Codename One API)


com.codename1.ui.table

Class DefaultTableModel
java.lang.Object

com.codename1.ui.table.DefaultTableModel
All Implemented Interfaces:
TableModel

public class
extends Object
implements TableModel

A default implementation of the table model based on a two dimensional array.


Form hi = new Form("Table", new BorderLayout());
TableModel model = new DefaultTableModel(new String[] {"Col 1", "Col 2", "Col 3"}, new Object[][] {
{"Row 1", "Row A", "Row X"},
{"Row 2", "Row B can now stretch", null},
{"Row 3", "Row C", "Row Z"},
{"Row 4", "Row D", "Row K"},
}) {
public boolean isCellEditable(int row, int col) {
return col != 0;
}
};
Table table = new Table(model) {
{@literal @}Override
protected Component createCell(Object value, int row, int column, boolean editable) { (1)
Component cell;
if(row == 1 && column == 1) { (2)
Picker p = new Picker();
p.setType(Display.PICKER_TYPE_STRINGS);
p.setStrings("Row B can now stretch", "This is a good value", "So Is This", "Better than text field");
p.setSelectedString((String)value); (3)
p.setUIID("TableCell");
p.addActionListener((e) -> getModel().setValueAt(row, column, p.getSelectedString())); (4)
cell = p;
} else {
cell = super.createCell(value, row, column, editable);
}
if(row > -1 && row % 2 == 0) { (5)
// pinstripe effect
cell.getAllStyles().setBgColor(0xeeeeee);
cell.getAllStyles().setBgTransparency(255);
}
return cell;
}
{@literal @}Override
protected TableLayout.Constraint createCellConstraint(Object value, int row, int column) {
TableLayout.Constraint con = super.createCellConstraint(value, row, column);
if(row == 1 && column == 1) {
con.setHorizontalSpan(2);
}
con.setWidthPercentage(33);
return con;
}
};
hi.add(BorderLayout.CENTER, table);
hi.show();

Class DefaultTableModel

831

Overview (Codename One API)

Constructor Summary
Constructor and Description
DefaultTableModel(String[] columnNames, Object[][] data)

Constructs a new table with a 2 dimensional array for row/column data


DefaultTableModel(String[] columnNames, Object[][] data, boolean editable)

Constructs a new table with a 2 dimensional array for row/column data

Method Summary
Modifier and Type
void
void
int
String
int
Object
void
boolean
void
void

Constructor Summary

Method and Description


addDataChangeListener(DataChangedListener d)

Adds a listener to the data changed event


addRow(Object... row)

Adds the given row to the table data


getColumnCount()

Returns the number of columns in the table


getColumnName(int i)

Returns the name of the column at the given offset


getRowCount()

Returns the number of rows in the table


getValueAt(int row, int column)

Returns the value of the cell at the given location


insertRow(int offset, Object... row)

Inserts the given row to the table data at the given offset
isCellEditable(int row, int column)

Returns true if the cell at the given location is an editable cell


removeDataChangeListener(DataChangedListener d)

Removes a listener to the data changed event


removeRow(int offset)

Removes the given row offset from the table

832

Overview (Codename One API)


setValueAt(int row, int column, Object o)

void

Sets the value of the cell at the given location

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DefaultTableModel
public DefaultTableModel(String[] columnNames,
Object[][] data)

Constructs a new table with a 2 dimensional array for row/column data


Parameters:
columnNames - the names of the columns
data - the data within the table
DefaultTableModel
public DefaultTableModel(String[] columnNames,
Object[][] data,
boolean editable)

Constructs a new table with a 2 dimensional array for row/column data


Parameters:
columnNames - the names of the columns
data - the data within the table
editable - indicates whether table cells are editable or not by default
See Also:
isCellEditable(int, int)

Method Detail
getRowCount
public int getRowCount()

Returns the number of rows in the table


Specified by:
getRowCount in interface TableModel
Returns:
the number of rows in the table
getColumnCount
public int getColumnCount()

Returns the number of columns in the table


Specified by:
getColumnCount in interface TableModel
Returns:
the number of columns in the table
getColumnName
public String getColumnName(int i)

Returns the name of the column at the given offset


Specified by:
getColumnName in interface TableModel
Parameters:
i - the offset for the column name
Returns:
name to display at the top of the table

Method Summary

833

Overview (Codename One API)


isCellEditable
public boolean isCellEditable(int row,
int column)

Returns true if the cell at the given location is an editable cell


Specified by:
isCellEditable in interface TableModel
Parameters:
row - the cell row
column - the cell column
Returns:
true if the cell at the given location is an editable cell
getValueAt
public Object getValueAt(int row,
int column)

Returns the value of the cell at the given location


Specified by:
getValueAt in interface TableModel
Parameters:
row - the cell row
column - the cell column
Returns:
the value of the cell at the given location
setValueAt
public void setValueAt(int row,
int column,
Object o)

Sets the value of the cell at the given location


Specified by:
setValueAt in interface TableModel
Parameters:
row - the cell row
column - the cell column
o - the value of the cell at the given location
addDataChangeListener
public void addDataChangeListener(DataChangedListener d)

Adds a listener to the data changed event


Specified by:
addDataChangeListener in interface TableModel
Parameters:
d - the new listener
removeDataChangeListener
public void removeDataChangeListener(DataChangedListener d)

Removes a listener to the data changed event


Specified by:
removeDataChangeListener in interface TableModel
Parameters:
d - the listener to remove
addRow
public void addRow(Object... row)

Adds the given row to the table data


Parameters:
row - array or row items, notice that row.length should match the column
count exactly!

Method Detail

834

Overview (Codename One API)


insertRow
public void insertRow(int offset,
Object... row)

Inserts the given row to the table data at the given offset
Parameters:
offset - position within the table that is 0 or larger yet smaller than the row
count
row - array or row items, notice that row.length should match the column
count exactly!
removeRow
public void removeRow(int offset)

Removes the given row offset from the table


Parameters:
offset - position within the table that is 0 or larger yet smaller than the row
count

Method Detail

835

Overview (Codename One API)


com.codename1.ui.spinner

Class TimeSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner

com.codename1.ui.spinner.TimeSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
DateTimeSpinner

public class
extends BaseSpinner

Allows selecting a time of day either in 24 hour batches or AM/PM format

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
TimeSpinner()

Default constructor

Method Summary
Modifier
and Type
int

Method and Description


getCurrentHour()

The hour from 1-12 or 0-23

int

getCurrentMinute()

int

getMinuteStep()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Returns the current value of the property name, this method is used by the GUI
builder

boolean

isCurrentMeridiem()
isDurationMode()

boolean

Class TimeSpinner

Duration mode uses the time spinner to indicate a duration in hours and
minutes

836

Overview (Codename One API)


boolean

isShowMeridiem()
setCurrentHour(int currentHour)

void

Set the hour from 1-12 or 0-23

void

setCurrentMeridiem(boolean currentMeridiem)

void

setCurrentMinute(int currentMinute)
setDurationMode(boolean durationMode)

void

Duration mode uses the time spinner to indicate a duration in hours and
minutes

void

setMinuteStep(int minuteStep)
setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and
null if successful.
setShowMeridiem(boolean showMeridiem)

void

Shows AM/PM indication

Methods inherited from


class com.codename1.ui.spinner.BaseSpinner
calcPreferredSize, initComponent, paintGlass, refreshTheme, setUIID

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,

Method Summary

837

Overview (Codename One API)


isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
TimeSpinner
public TimeSpinner()

Default constructor

Method Detail
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component

Methods inherited from class com.codename1.ui.Component

838

Overview (Codename One API)


Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getMinuteStep
public int getMinuteStep()

Returns:
the minuteStep
setMinuteStep
public void setMinuteStep(int minuteStep)

Parameters:
minuteStep

- the minuteStep to set

isShowMeridiem
public boolean isShowMeridiem()

Returns:
the showMeridiem
setShowMeridiem
public void setShowMeridiem(boolean showMeridiem)

Shows AM/PM indication


Parameters:
showMeridiem - the showMeridiem to set
getCurrentHour
public int getCurrentHour()

The hour from 1-12 or 0-23


Returns:
the currentHour
setCurrentHour
public void setCurrentHour(int currentHour)

Set the hour from 1-12 or 0-23


Parameters:
currentHour - the currentHour to set
getCurrentMinute
public int getCurrentMinute()

Returns:
the currentMinute

Method Detail

839

Overview (Codename One API)


setCurrentMinute
public void setCurrentMinute(int currentMinute)

Parameters:
currentMinute

- the currentMinute to set

isCurrentMeridiem
public boolean isCurrentMeridiem()

Returns:
the currentMeridiem
setCurrentMeridiem
public void setCurrentMeridiem(boolean currentMeridiem)

Parameters:
currentMeridiem

- the currentMeridiem to set

isDurationMode
public boolean isDurationMode()

Duration mode uses the time spinner to indicate a duration in hours and minutes
Returns:
the durationMode
setDurationMode
public void setDurationMode(boolean durationMode)

Duration mode uses the time spinner to indicate a duration in hours and minutes
Parameters:
durationMode - the durationMode to set

Method Detail

840

Overview (Codename One API)


com.codename1.ui.spinner

Class Picker
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.ui.spinner.Picker
All Implemented Interfaces:
Animation, StyleListener

public class
extends Button

is a component and API that allows either popping up a spinner or using the native picker API
when applicable. This is quite important for some platforms where the native spinner behavior is very
hard to replicate.
Picker

Form hi = new Form("Picker", new BoxLayout(BoxLayout.Y_AXIS));


Picker datePicker = new Picker();
datePicker.setType(Display.PICKER_TYPE_DATE);
Picker dateTimePicker = new Picker();
dateTimePicker.setType(Display.PICKER_TYPE_DATE_AND_TIME);
Picker timePicker = new Picker();
timePicker.setType(Display.PICKER_TYPE_TIME);
Picker stringPicker = new Picker();
stringPicker.setType(Display.PICKER_TYPE_STRINGS);
datePicker.setDate(new Date());
dateTimePicker.setDate(new Date());
timePicker.setTime(10 * 60); // 10:00AM = Minutes since midnight
stringPicker.setStrings("A Game of Thrones", "A Clash Of Kings", "A Storm Of Swords", "A Feast For Crows",
"A Dance With Dragons", "The Winds of Winter", "A Dream of Spring");
stringPicker.setSelectedString("A Game of Thrones");
hi.add(datePicker).add(dateTimePicker).add(timePicker).add(stringPicker);
hi.show();

Class Picker

841

Overview (Codename One API)

Class Picker

842

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.Button


STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Picker()

Default constructor

Method Summary
Modifier and
Type
Date
SimpleDateFormat
int
int

Field Summary

Method and Description


getDate()

Returns the date, this value is used both for type date/date and time.
getFormatter()

Allows us to define a date format for the display of dates/times


getPreferredPopupHeight()

The preferred height of the popup dialog.


getPreferredPopupWidth()

843

Overview (Codename One API)


The preferred width of the popup dialog.
getRenderingPrototype()

When using a lightweight spinner this will be used as the rendering


prototype

Object

getSelectedString()

String

Returns the current string

String[]

getStrings()

Returns the String array matching the metadata


getTime()

This value is only used for time type and is ignored in the case of date
and time where both are embedded within the date.

int

getType()

int

Returns the type of the picker

boolean

isShowMeridiem()

Indicates whether hours should be rendered as AM/PM or 24hr format


setDate(Date d)

void

Sets the date, this value is used both for type date/date and time.
setFormatter(SimpleDateFormat formatter)

void

Allows us to define a date format for the display of dates/times


setPreferredPopupHeight(int height)

void

The preferred height of the popup dialog for the picker.


setPreferredPopupWidth(int width)

void

The preferred width of the popup dialog for the picker.


setRenderingPrototype(Object renderingPrototype)

When using a lightweight spinner this will be used as the rendering


prototype

void

setSelectedString(String str)

void

Sets the current value in a string array picker


setShowMeridiem(boolean showMeridiem)

void

Indicates whether hours should be rendered as AM/PM or 24hr format


setStrings(String... strs)

void

Sets the string entries for the string picker


setTime(int time)

This value is only used for time type and is ignored in the case of date
and time where both are embedded within the date.

void

setTime(int hour, int minute)

void

Convenience method equivalent to invoking setTime(hour * 60 + minute);


setType(int type)

Sets the type of the picker to one of Display.PICKER_TYPE_DATE,


Display.PICKER_TYPE_DATE_AND_TIME,
Display.PICKER_TYPE_STRINGS or Display.PICKER_TYPE_TIME

void

updateValue()
protected void

Updates the display value of the picker, subclasses can override this to
invoke set text with the right value

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, calcPreferredSize, dragInitiated, fireClicked,
getActionListeners, getBorder, getCommand, getDisabledIcon,
getIconFromState, getListeners, getPressedIcon, getReleaseRadius,
getRolloverIcon, getRolloverPressedIcon, getState, isAutoRelease,
isOppositeSide, isSelectableInteraction, isSelected, isToggle, keyPressed,
keyReleased, keyRepeated, pointerDragged, pointerHover,
pointerHoverReleased, pointerPressed, pointerReleased, pressed, released,
released, removeActionListener, resetFocusable, setAlignment,
setAutoRelease, setCommand, setDisabledIcon, setPressedIcon,
setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,

Method Summary

844

Overview (Codename One API)


getGap, getIcon, getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setIcon, setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setText, setTextPosition, setTickerEnabled, setVerticalAlignment,
shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

Methods inherited from class com.codename1.ui.Label

845

Overview (Codename One API)


Picker
public Picker()

Default constructor

Method Detail
setType
public void setType(int type)

Sets the type of the picker to one of Display.PICKER_TYPE_DATE,


Display.PICKER_TYPE_DATE_AND_TIME, Display.PICKER_TYPE_STRINGS or
Display.PICKER_TYPE_TIME
Parameters:
type - the type
getType
public int getType()

Returns the type of the picker


Returns:
one of Display.PICKER_TYPE_DATE,
Display.PICKER_TYPE_DATE_AND_TIME,
Display.PICKER_TYPE_STRINGS or Display.PICKER_TYPE_TIME
getDate
public Date getDate()

Returns the date, this value is used both for type date/date and time. Notice that this
value isn't used for time
Returns:
the date object
setDate
public void setDate(Date d)

Sets the date, this value is used both for type date/date and time. Notice that this
value isn't used for time. Notice that this value will have no effect if the picker is
currently showing.
Parameters:
d - the new date
setStrings
public void setStrings(String... strs)

Sets the string entries for the string picker


Parameters:
strs - string array
getStrings
public String[] getStrings()

Returns the String array matching the metadata


Returns:
a string array
setSelectedString
public void setSelectedString(String str)

Sets the current value in a string array picker


Parameters:
str - the current value

Constructor Detail

846

Overview (Codename One API)


getSelectedString
public String getSelectedString()

Returns the current string


Returns:
the selected string
updateValue
protected void updateValue()

Updates the display value of the picker, subclasses can override this to invoke set
text with the right value
setTime
public void setTime(int time)

This value is only used for time type and is ignored in the case of date and time
where both are embedded within the date.
Parameters:
time - the time value as minutes since midnight e.g. 630 is 10:30am
setTime
public void setTime(int hour,
int minute)

Convenience method equivalent to invoking setTime(hour * 60 + minute);


Parameters:
hour - the hour in 24hr format
minute - the minute within the hour
getTime
public int getTime()

This value is only used for time type and is ignored in the case of date and time
where both are embedded within the date.
Returns:
the time value as minutes since midnight e.g. 630 is 10:30am
isShowMeridiem
public boolean isShowMeridiem()

Indicates whether hours should be rendered as AM/PM or 24hr format


Returns:
the showMeridiem
setShowMeridiem
public void setShowMeridiem(boolean showMeridiem)

Indicates whether hours should be rendered as AM/PM or 24hr format


Parameters:
showMeridiem - the showMeridiem to set
getRenderingPrototype
public Object getRenderingPrototype()

When using a lightweight spinner this will be used as the rendering prototype
Returns:
the renderingPrototype
setRenderingPrototype
public void setRenderingPrototype(Object renderingPrototype)

When using a lightweight spinner this will be used as the rendering prototype
Parameters:
renderingPrototype - the renderingPrototype to set

Method Detail

847

Overview (Codename One API)


getFormatter
public SimpleDateFormat getFormatter()

Allows us to define a date format for the display of dates/times


Returns:
the defined formatter
setFormatter
public void setFormatter(SimpleDateFormat formatter)

Allows us to define a date format for the display of dates/times


Parameters:
formatter - the new formatter
setPreferredPopupWidth
public void setPreferredPopupWidth(int width)

The preferred width of the popup dialog for the picker. This will only be used on
devices where the popup width and height are configurable, such as the iPad or
tablets. On iPhone, the picker always spans the width of the screen along the bottom.
Parameters:
width - The preferred width of the popup.
setPreferredPopupHeight
public void setPreferredPopupHeight(int height)

The preferred height of the popup dialog for the picker. This will only be used on
devices where the popup width and height are configurable, such as the iPad or
tablets. On iPhone, the picker always spans the width of the screen along the bottom.
Parameters:
width - The preferred width of the popup.
getPreferredPopupWidth
public int getPreferredPopupWidth()

The preferred width of the popup dialog. This will only be used on devices where the
popup width and height are configurable, such as the iPad or tablets. On iPhone, the
picker always spans the width of the screen along the bottom.
Returns:
getPreferredPopupHeight
public int getPreferredPopupHeight()

The preferred height of the popup dialog. This will only be used on devices where the
popup width and height are configurable, such as the iPad or tablets. On iPhone, the
picker always spans the width of the screen along the bottom.
Returns:

Method Detail

848

Overview (Codename One API)


com.codename1.ui.spinner

Class NumericSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner

com.codename1.ui.spinner.NumericSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends BaseSpinner

A spinner class that allows picking a number

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
NumericSpinner()

Default constructor

Method Summary
Modifier
and
Type
double
double

Method and Description


getMax()

The maximum value for the spinner


getMin()

The minimum value for the spinner


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this AP
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
double
double

Class NumericSpinner

This method is here to workaround an XMLVM array type bug where property types aren't id
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListMod
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder
getStep()

Step for spinner gap


getValue()

849

Overview (Codename One API)


The value for the spinner
setMax(double max)

void

The maximum value for the spinner


setMin(double min)

void

The minimum value for the spinner

String

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if success
setStep(double step)

void

Step for spinner gap


setValue(double value)

void

The value for the spinner

Methods inherited from


class com.codename1.ui.spinner.BaseSpinner
calcPreferredSize, initComponent, paintGlass, refreshTheme, setUIID

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,

Method Summary

850

Overview (Codename One API)


paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
NumericSpinner
public NumericSpinner()

Default constructor

Method Detail
getMin
public double getMin()

The minimum value for the spinner


Returns:
the min
setMin
public void setMin(double min)

The minimum value for the spinner


Parameters:
min - the min to set
getMax
public double getMax()

The maximum value for the spinner


Returns:
the max
setMax
public void setMax(double max)

The maximum value for the spinner


Parameters:
max - the max to set

Methods inherited from class com.codename1.ui.Component

851

Overview (Codename One API)


getValue
public double getValue()

The value for the spinner


Returns:
the value
setValue
public void setValue(double value)

The value for the spinner


Parameters:
value - the value to set
getStep
public double getStep()

Step for spinner gap


Returns:
the step
setStep
public void setStep(double step)

Step for spinner gap


Parameters:
step - the step to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component

Method Detail

852

Overview (Codename One API)


Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

853

Overview (Codename One API)


com.codename1.ui.spinner

Class GenericSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner

com.codename1.ui.spinner.GenericSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends BaseSpinner

A spinner class that allows arbitrary values, this is effectively a combo box replacement for platforms
where a combo box is not available

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
GenericSpinner()

Default constructor

Method Summary
Modifier and
Type
int
Object

Method and Description


getColumns()

Return the column count


getComponentState()

Some components may optionally generate a state which can then be restored usi

ListModel

getModel()

ListModel

getModel(int offset)
getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object

Class GenericSpinner

This method is here to workaround an XMLVM array type bug where property type
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI bu

854

Overview (Codename One API)


ListCellRenderer getRenderer()
ListCellRenderer getRenderer(int offset)
String
String
Object
Object

getRenderingPrototype()

Returns the rendering prototype


getRenderingPrototype(int column)

Returns the rendering prototype


getValue()

The value for the spinner


getValue(int offset)

The value for the spinner


setColumns(int columns)

void

Sets the column count


setComponentState(Object state)

void

If getComponentState returned a value the setter can update the value and restore

void

setModel(int offset, ListModel model)

void

setModel(ListModel model)

String

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null

void

setRenderer(int offset, ListCellRenderer renderer)

void

setRenderer(ListCellRenderer renderer)
setRenderingPrototype(int column, String pr)

void

The rendering prototype


setRenderingPrototype(String pr)

void

The rendering prototype


setValue(int offset, Object value)

void

The value for the spinner


setValue(Object value)

void

The value for the spinner

Methods inherited from


class com.codename1.ui.spinner.BaseSpinner
calcPreferredSize, initComponent, paintGlass, refreshTheme, setUIID

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,

Method Summary

855

Overview (Codename One API)


drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setDirtyRegion, setDisabledStyle,
setDraggable, setDropTarget, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
GenericSpinner
public GenericSpinner()

Default constructor

Method Detail
setColumns
public void setColumns(int columns)

Sets the column count


getRenderingPrototype
public String getRenderingPrototype()

Returns the rendering prototype

Methods inherited from class com.codename1.ui.Component

856

Overview (Codename One API)


Returns:
the prototype
getRenderingPrototype
public String getRenderingPrototype(int column)

Returns the rendering prototype


Returns:
the prototype
setRenderingPrototype
public void setRenderingPrototype(String pr)

The rendering prototype


Parameters:
pr - the prototype
setRenderingPrototype
public void setRenderingPrototype(int column,
String pr)

The rendering prototype


Parameters:
column - the column
pr - the prototype
getColumns
public int getColumns()

Return the column count


Returns:
the number of columns in the spinner
getValue
public Object getValue()

The value for the spinner


Returns:
the value
getValue
public Object getValue(int offset)

The value for the spinner


Returns:
the value
setValue
public void setValue(Object value)

The value for the spinner


Parameters:
value - the value to set
setValue
public void setValue(int offset,
Object value)

The value for the spinner


Parameters:
value - the value to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code

Method Detail

857

Overview (Codename One API)


Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getModel
public ListModel getModel()

Returns:
the model
getModel
public ListModel getModel(int offset)

Returns:
the model

Method Detail

858

Overview (Codename One API)


setModel
public void setModel(ListModel model)

Parameters:
model

- the model to set

setModel
public void setModel(int offset,
ListModel model)

Parameters:
model

- the model to set

getRenderer
public ListCellRenderer getRenderer(int offset)

Returns:
the renderer
setRenderer
public void setRenderer(int offset,
ListCellRenderer renderer)

Parameters:
renderer

- the renderer to set

getRenderer
public ListCellRenderer getRenderer()

Returns:
the renderer
setRenderer
public void setRenderer(ListCellRenderer renderer)

Parameters:
renderer - the renderer to set
getComponentState
public Object getComponentState()

Some components may optionally generate a state which can then be restored using
setCompnentState(). This method is used by the UIBuilder.
Overrides:
getComponentState in class Component
Returns:
the component state or null for undefined state.
setComponentState
public void setComponentState(Object state)

If getComponentState returned a value the setter can update the value and restore
the prior state.
Overrides:
setComponentState in class Component
Parameters:
state - the non-null state

Method Detail

859

Overview (Codename One API)


com.codename1.ui.spinner

Class DateTimeSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner

com.codename1.ui.spinner.TimeSpinner

com.codename1.ui.spinner.DateTimeSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends TimeSpinner

The date and time spinner extends the time spinner by allowing to pick a specific day as well

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
DateTimeSpinner()

Default constructor

Method Summary
Modifier
and Type

Method and Description

Date

getCurrentDate()

Date

getEndDate()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Returns the current value of the property name, this method is used by the
GUI builder

Date

getStartDate()

boolean

isIncludeYear()

boolean

isMarkToday()

void

setCurrentDate(Date currentDate)

void

setEndDate(Date endDate)

void

setIncludeYear(boolean includeYear)

Class DateTimeSpinner

860

Overview (Codename One API)


void

setMarkToday(boolean markToday)
setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and
null if successful.

void

setStartDate(Date startDate)

Methods inherited from


class com.codename1.ui.spinner.TimeSpinner
getCurrentHour, getCurrentMinute, getMinuteStep, isCurrentMeridiem,
isDurationMode, isShowMeridiem, setCurrentHour, setCurrentMeridiem,
setCurrentMinute, setDurationMode, setMinuteStep, setShowMeridiem

Methods inherited from


class com.codename1.ui.spinner.BaseSpinner
calcPreferredSize, initComponent, paintGlass, refreshTheme, setUIID

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,

Method Summary

861

Overview (Codename One API)


paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
DateTimeSpinner
public DateTimeSpinner()

Default constructor

Method Detail
getCurrentDate
public Date getCurrentDate()

Returns:
the currentDate
setCurrentDate
public void setCurrentDate(Date currentDate)

Parameters:
currentDate

- the currentDate to set

getStartDate
public Date getStartDate()

Returns:
the startDate
setStartDate
public void setStartDate(Date startDate)

Parameters:
startDate

- the startDate to set

getEndDate
public Date getEndDate()

Returns:
the endDate

Methods inherited from class com.codename1.ui.Component

862

Overview (Codename One API)


setEndDate
public void setEndDate(Date endDate)

Parameters:
endDate

- the endDate to set

isMarkToday
public boolean isMarkToday()

Returns:
the markToday
setMarkToday
public void setMarkToday(boolean markToday)

Parameters:
markToday

- the markToday to set

isIncludeYear
public boolean isIncludeYear()

Returns:
the includeYear
setIncludeYear
public void setIncludeYear(boolean includeYear)

Parameters:
includeYear

- the includeYear to set

getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class TimeSpinner
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class TimeSpinner
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class TimeSpinner
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Method Detail

863

Overview (Codename One API)


Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class TimeSpinner
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

864

Overview (Codename One API)


com.codename1.ui.spinner

Class DateSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner

com.codename1.ui.spinner.DateSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends BaseSpinner

A date spinner allows selecting a date value within the given date range

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
DateSpinner()

Default constructor

Method Summary
Modifier
and Type

Method and Description

int

getCurrentDay()

int

getCurrentMonth()

int

getCurrentYear()

int

getEndYear()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Returns the current value of the property name, this method is used by the GUI
builder

int

getStartYear()

boolean

isMonthDayYear()

boolean

isNumericMonths()

void

setCurrentDay(int currentDay)

Class DateSpinner

865

Overview (Codename One API)


void

setCurrentMonth(int currentMonth)

void

setCurrentYear(int currentYear)

void

setEndYear(int endYear)

void

setMonthDayYear(boolean monthDayYear)
setMonthRenderingPrototype(String monthPrototype)

void

Sets the Month Rendering Prototype to be used, useful when the language is
changed and you need the month spinner to be wider.

void

setNumericMonths(boolean numericMonths)
setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and
null if successful.

void

setStartYear(int startYear)

Methods inherited from


class com.codename1.ui.spinner.BaseSpinner
calcPreferredSize, initComponent, paintGlass, refreshTheme, setUIID

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,

Method Summary

866

Overview (Codename One API)


paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
DateSpinner
public DateSpinner()

Default constructor

Method Detail
getStartYear
public int getStartYear()

Returns:
the startYear
setStartYear
public void setStartYear(int startYear)

Parameters:
startYear

- the startYear to set

getEndYear
public int getEndYear()

Returns:
the endYear
setEndYear
public void setEndYear(int endYear)

Parameters:
endYear

- the endYear to set

getCurrentYear
public int getCurrentYear()

Returns:

Methods inherited from class com.codename1.ui.Component

867

Overview (Codename One API)


the currentYear
setCurrentYear
public void setCurrentYear(int currentYear)

Parameters:
currentYear

- the currentYear to set

getCurrentDay
public int getCurrentDay()

Returns:
the currentDay
setCurrentDay
public void setCurrentDay(int currentDay)

Parameters:
currentDay

- the currentDay to set

getCurrentMonth
public int getCurrentMonth()

Returns:
the currentMonth
setCurrentMonth
public void setCurrentMonth(int currentMonth)

Parameters:
currentMonth

- the currentMonth to set

isMonthDayYear
public boolean isMonthDayYear()

Returns:
the monthDayYear
setMonthDayYear
public void setMonthDayYear(boolean monthDayYear)

Parameters:
monthDayYear

- the monthDayYear to set

isNumericMonths
public boolean isNumericMonths()

Returns:
the numericMonths
setNumericMonths
public void setNumericMonths(boolean numericMonths)

Parameters:
numericMonths

- the numericMonths to set

getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

Method Detail

868

Overview (Codename One API)


getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
setMonthRenderingPrototype
public void setMonthRenderingPrototype(String monthPrototype)

Sets the Month Rendering Prototype to be used, useful when the language is
changed and you need the month spinner to be wider.
Parameters:
monthPrototype - a prototype to be used to calc the month cell size

Method Detail

869

Overview (Codename One API)


com.codename1.ui.spinner

Class BaseSpinner
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.spinner.BaseSpinner
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
DateSpinner, GenericSpinner, NumericSpinner, TimeSpinner

public abstract class


extends Container

Base class for spinners

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
BaseSpinner()

Default constructor

Method Summary
Modifier and
Type

Method and Description

protected
Dimension

calcPreferredSize()

protected
void

initComponent()

Calculates the preferred size based on component content.


Default constructor
paintGlass(Graphics g)

protected
void

This method can be overriden by a component to draw on top of itself or its


children after the component or the children finished drawing in a similar way
to the glass pane but more refined per component
refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY
INVOKE THIS METHOD IF YOU CHANGED THE THEME!

void

setUIID(String id)

void

This method sets the Component the Unique identifier.

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,

Class BaseSpinner

870

Overview (Codename One API)


animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paramString, pointerHover, pointerPressed, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from class com.codename1.ui.Container

871

Overview (Codename One API)

Constructor

Detail

BaseSpinner
public BaseSpinner()

Default constructor

Method Detail
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content
initComponent
protected void initComponent()

Default constructor
Overrides:
initComponent

in class Component

setUIID
public void setUIID(String id)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized
Overrides:
setUIID in class Component
Parameters:
id - UIID unique identifier for component type
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Container
Parameters:
merge - indicates if the current styles should be merged with the new styles
paintGlass
protected void paintGlass(Graphics g)

This method can be overriden by a component to draw on top of itself or its children
after the component or the children finished drawing in a similar way to the glass
pane but more refined per component
Overrides:
paintGlass in class Container
Parameters:
g - the graphics context

Constructor Detail

872

Overview (Codename One API)


com.codename1.ui.plaf

Class UIManager
java.lang.Object

com.codename1.ui.plaf.UIManager

public class
extends Object

Central point singleton managing the look of the application, this class allows us to customize the
styles (themes) as well as the look instance.

Method Summary
Modifier and Type

Method and Description


addThemeProps(Hashtable themeProps)

void

void

Adds the given theme properties on top of the existing properties


without clearing the existing theme first
addThemeRefreshListener(ActionListener l)

Adds a Theme refresh listener.


createInstance()

static UIManager

This factory method allows creating a new UIManager instance, this


is usefull where an application has some screens with different
context
getBundle()

Map<String,String>

The resource bundle allows us to implicitly localize the UI on the fly,


once its installed all internal application strings query the resource
bundle and extract their values from this table if applicable.
getComponentCustomStyle(String id, String type)

Style

Returns a custom style for the component with the given id, this
method always returns a new instance.
getComponentSelectedStyle(String id)

Style

Returns the selected style of the component with the given id or a


new instance of the default style.
getComponentStyle(String id)

Style

static UIManager
LookAndFeel

Returns the style of the component with the given id or a new


instance of the default style.
getInstance()

Singleton instance method


getLookAndFeel()

Returns the currently installed look and feel


getResourceBundle()

Hashtable

int
String
Image
Object

Method Detail

Deprecated.
this method uses the old resource bundle hashtable, use the new
getBundle() method
getThemeConstant(String constantName, int def)

Returns a theme constant defined in the resource editor


getThemeConstant(String constantName, String def)

Returns a theme constant defined in the resource editor


getThemeImageConstant(String constantName)

Returns a theme constant defined in the resource editor


getThemeMaskConstant(String constantName)

Returns a theme mask constant

String

getThemeName()

static Resources

initFirstTheme(String resourceFile)

873

Overview (Codename One API)


This is a shorthand notation for boilerplate code for initializing the first
theme in the given resource file and catching/doing nothing with the
IOException since this would be invoked too early in the program
where we would be out of options if something like that happens.
initNamedTheme(String resourceFile, String resName)
static Resources

Same as the initFirstTheme method, but unlike that method this


allows specifying the theme resource name
isThemeConstant(String constantName)

Boolean

Returns a theme constant defined in the resource editor as a boolean


value or null if the constant isn't defined
isThemeConstant(String constantName, boolean def)

boolean

Returns a theme constant defined in the resource editor as a boolean


value
localize(String key, String defaultValue)

Localizes the given string from the resource bundle if such a String
exists in the resource bundle.

String

removeThemeRefreshListener(ActionListener l)

void

Removes a Theme refresh listener.


setBundle(Map<String,String> bundle)

The resource bundle allows us to implicitly localize the UI on the fly,


once its installed all internal application strings query the resource
bundle and extract their values from this table if applicable.

void

setComponentSelectedStyle(String id, Style style)

Allows a developer to programmatically install a style into the UI


manager

void

setComponentStyle(String id, Style style)

Allows a developer to programmatically install a style into the UI


manager

void

setComponentStyle(String id, Style style, String type)

Allows a developer to programmatically install a style into the UI


manager

void

setLookAndFeel(LookAndFeel plaf)

void

Sets the currently installed look and feel


setResourceBundle(Hashtable resourceBundle)

Deprecated.
this method uses the old resource bundle hashtable, use the new
setBundle() method

void

setThemeProps(Hashtable themeProps)

void

Allows manual theme loading from a hashtable of key/value pairs

boolean

wasThemeInstalled()

Indicates if a theme was previously installed since the last reset

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
wasThemeInstalled
public boolean wasThemeInstalled()

Indicates if a theme was previously installed since the last reset


Returns:
true if setThemeProps was invoked
getInstance
public static UIManager getInstance()

Singleton instance method

Method Summary

874

Overview (Codename One API)


Returns:
Instance of the ui manager
createInstance
public static UIManager createInstance()

This factory method allows creating a new UIManager instance, this is usefull where
an application has some screens with different context
Returns:
a new UIManager instance
See Also:
Formt#setUIManager(UIManager)

getLookAndFeel
public LookAndFeel getLookAndFeel()

Returns the currently installed look and feel


Returns:
the currently installed look and feel
setLookAndFeel
public void setLookAndFeel(LookAndFeel plaf)

Sets the currently installed look and feel


Parameters:
plaf - the look and feel for the application
setComponentStyle
public void setComponentStyle(String id,
Style style)

Allows a developer to programmatically install a style into the UI manager


Parameters:
id - the component id matching the given style
style - the style object to install
setComponentStyle
public void setComponentStyle(String id,
Style style,
String type)

Allows a developer to programmatically install a style into the UI manager


Parameters:
id - the component id matching the given style
style - the style object to install
type - press, dis or other custom type
setComponentSelectedStyle
public void setComponentSelectedStyle(String id,
Style style)

Allows a developer to programmatically install a style into the UI manager


Parameters:
id - the component id matching the given style
style - the style object to install
getComponentStyle
public Style getComponentStyle(String id)

Returns the style of the component with the given id or a new instance of the default
style. This method will always return a new style instance to prevent modification of
the global style object.
Parameters:
id - the component id whose style we want
Returns:
the appropriate style (this method never returns null)

Method Detail

875

Overview (Codename One API)


getComponentSelectedStyle
public Style getComponentSelectedStyle(String id)

Returns the selected style of the component with the given id or a new instance of
the default style. This method will always return a new style instance to prevent
modification of the global style object.
Parameters:
id - the component id whose selected style we want
Returns:
the appropriate style (this method never returns null)
getComponentCustomStyle
public Style getComponentCustomStyle(String id,
String type)

Returns a custom style for the component with the given id, this method always
returns a new instance. Custom styles allow us to install application specific or
component specific style attributes such as pressed, disabled, hover etc.
Parameters:
id - the component id whose custom style we want
type - the style type
Returns:
the appropriate style (this method never returns null)
getThemeName
public String getThemeName()

Returns:
the name of the current theme for theme switching UI's
setThemeProps
public void setThemeProps(Hashtable themeProps)

Allows manual theme loading from a hashtable of key/value pairs


Parameters:
themeProps - the properties of the given theme
addThemeProps
public void addThemeProps(Hashtable themeProps)

Adds the given theme properties on top of the existing properties without clearing the
existing theme first
Parameters:
themeProps - the properties of the given theme
getThemeConstant
public int getThemeConstant(String constantName,
int def)

Returns a theme constant defined in the resource editor


Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme
getThemeConstant
public String getThemeConstant(String constantName,
String def)

Returns a theme constant defined in the resource editor


Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme

Method Detail

876

Overview (Codename One API)


isThemeConstant
public boolean isThemeConstant(String constantName,
boolean def)

Returns a theme constant defined in the resource editor as a boolean value


Parameters:
constantName - the name of the constant
def - default value
Returns:
the value of the constant or the default if the constant isn't in the theme
isThemeConstant
public Boolean isThemeConstant(String constantName)

Returns a theme constant defined in the resource editor as a boolean value or null if
the constant isn't defined
Parameters:
constantName - the name of the constant
Returns:
the value of the constant or null if the constant isn't in the theme
getThemeImageConstant
public Image getThemeImageConstant(String constantName)

Returns a theme constant defined in the resource editor


Parameters:
constantName - the name of the constant
Returns:
the image if defined
getThemeMaskConstant
public Object getThemeMaskConstant(String constantName)

Returns a theme mask constant


Parameters:
constantName - the name of the constant
Returns:
the mask if defined
getResourceBundle
public Hashtable getResourceBundle()

Deprecated. this method uses the old resource bundle hashtable, use the new
getBundle() method
The resource bundle allows us to implicitly localize the UI on the fly, once its installed
all internal application strings query the resource bundle and extract their values from
this table if applicable.
Returns:
the localization bundle
getBundle
public Map<String,String> getBundle()

The resource bundle allows us to implicitly localize the UI on the fly, once its installed
all internal application strings query the resource bundle and extract their values from
this table if applicable.
Returns:
the localization bundle
setBundle
public void setBundle(Map<String,String> bundle)

The resource bundle allows us to implicitly localize the UI on the fly, once its installed
all internal application strings query the resource bundle and extract their values from
this table if applicable.
Parameters:

Method Detail

877

Overview (Codename One API)


resourceBundle

- the localization bundle

setResourceBundle
public void setResourceBundle(Hashtable resourceBundle)

Deprecated. this method uses the old resource bundle hashtable, use the new
setBundle() method
The resource bundle allows us to implicitly localize the UI on the fly, once its installed
all internal application strings query the resource bundle and extract their values from
this table if applicable.
Parameters:
resourceBundle - the localization bundle
localize
public String localize(String key,
String defaultValue)

Localizes the given string from the resource bundle if such a String exists in the
resource bundle. If no key exists in the bundle then or a bundle is not installed the
default value is returned.
Parameters:
key - The key used to lookup in the resource bundle
defaultValue - the value returned if no such key exists
Returns:
either default value or the appropriate value
addThemeRefreshListener
public void addThemeRefreshListener(ActionListener l)

Adds a Theme refresh listener. The listenres will get a callback when setThemeProps
method is invoked.
Parameters:
l - an ActionListener to be added
removeThemeRefreshListener
public void removeThemeRefreshListener(ActionListener l)

Removes a Theme refresh listener.


Parameters:
l - an ActionListener to be removed
initFirstTheme
public static Resources initFirstTheme(String resourceFile)

This is a shorthand notation for boilerplate code for initializing the first theme in the
given resource file and catching/doing nothing with the IOException since this would
be invoked too early in the program where we would be out of options if something
like that happens. Effectively this is the same as writing:

try {
theme = Resources.openLayered(resourceFile);
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResou
} catch(IOException e){
e.printStackTrace();
}

Parameters:
- the name of the resource file starting with / and without the
res extension
Returns:
the resource file or null in case of a failure
initNamedTheme
resourceFile

public static Resources initNamedTheme(String resourceFile,


String resName)

Method Detail

878

Overview (Codename One API)


Same as the initFirstTheme method, but unlike that method this allows specifying the
theme resource name
Parameters:
resourceFile - the name of the resource file starting with / and without the
res extension
resName - the name of the theme to use from the file if it contains more than
one theme
Returns:
the resource file or null in case of a failure

Method Detail

879

Overview (Codename One API)


com.codename1.ui.plaf

Class Style
java.lang.Object

com.codename1.ui.plaf.Style

public class
extends Object

Represents the look of a given component: colors, fonts, transparency, margin and padding &
images.
Each Component contains a Style Object and allows Style modification in Runtime by Using
cmp.getStyle() The style is also used in Themeing, when a Theme is Changed the Styles Objects
are been updated automatically.
When changing a theme the elements changed manually in a style will not be updated by the theme
change by default. There are two ways to change that behavior:
1. Use the set method that accepts a second boolean argument and set it to true.
2. Create a new style object and pass all the options in the constructor (without invoking setters
manually).
The Margin and Padding is inspired by W3 Box Model
**************************
*
Margin
*
* ******************** *
* *
Padding
* *
* *
***********
* *
* *
* Content *
* *
* *
***********
* *
* *
Padding
* *
* ******************** *
*
Margin
*
**************************

Field Summary
Modifier
and Type

Field and Description

static
String

ALIGNMENT

static
String

BACKGROUND_ALIGNMENT

static
String

BACKGROUND_GRADIENT

static byte
static byte
static byte

Alignment attribute for the style event


Background attribute name for the theme hashtable
Background attribute name for the theme hashtable
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL

Indicates the background for the style would use a linear gradient
BACKGROUND_GRADIENT_LINEAR_VERTICAL

Indicates the background for the style would use a linear gradient
BACKGROUND_GRADIENT_RADIAL

Indicates the background for the style would use a radial gradient
BACKGROUND_IMAGE_ALIGNED_BOTTOM

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT

static byte

Class Style

Indicates the background for the style would use an unscaled image with an
alignment

880

Overview (Codename One API)


BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT
static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_CENTER

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_LEFT

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_RIGHT

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_TOP

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_TOP_LEFT

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT

static byte

static byte

Indicates the background for the style would use an unscaled image with an
alignment
BACKGROUND_IMAGE_SCALED

Indicates the background for the style would use a scaled image
BACKGROUND_IMAGE_SCALED_FILL

static byte

Indicates the background for the style would use a scaled image that fills all
available space while maintaining aspect ratio
BACKGROUND_IMAGE_SCALED_FIT

static byte

static byte
static byte
static byte
static byte
static byte
static byte
static byte
static byte
static byte
static byte

Field Summary

Indicates the background for the style would use a scaled image that fits to
available space while maintaining aspect ratio
BACKGROUND_IMAGE_TILE_BOTH

Indicates the background for the style would use a tiled image on both axis
BACKGROUND_IMAGE_TILE_HORIZONTAL

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_VERTICAL

Indicates the background for the style would use a vertical tiled image
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT

Indicates the background for the style would use a horizontal tiled image
BACKGROUND_NONE

Indicates the background for the style would use a scaled image

static
String

BACKGROUND_TYPE

static
String

BG_COLOR

static
String

BG_IMAGE

static
String

BORDER

static
String

FG_COLOR

Background attribute name for the theme hashtable


Background color attribute name for the theme hashtable
Background image attribute name for the theme hashtable
Border attribute name for the theme hashtable
Foreground color attribute name for the theme hashtable

881

Overview (Codename One API)


static
String

FONT

static
String

MARGIN

static
String

MARGIN_UNIT

static
String

OPACITY

static
String

PADDING

static
String

PADDING_UNIT

static
String

PAINTER

static
String

TEXT_DECORATION

static byte
static byte
static byte
static byte
static byte
static byte
static byte
static
String
static byte

Font attribute name for the theme hashtable


Margin attribute name for the theme hashtable
The units of the margin
Opacity attribute name for the theme hashtable
Padding attribute name for the theme hashtable
The units of the padding
Painter attribute name for the style event
Text decoration attribute for the style event
TEXT_DECORATION_3D

3D text effect using a font shadow


TEXT_DECORATION_3D_LOWERED

3D sunken text effect using a light font shadow


TEXT_DECORATION_3D_SHADOW_NORTH

3D text effect using a font shadow


TEXT_DECORATION_NONE

Indicates no text decoration


TEXT_DECORATION_OVERLINE

Indicates overline
TEXT_DECORATION_STRIKETHRU

Indicates a strike-through line (usually used to denote deleted text)


TEXT_DECORATION_UNDERLINE

Indicates underline
TRANSPARENCY

Transparency attribute name for the theme hashtable


UNIT_TYPE_DIPS

Indicates the unit type for padding/margin in device independent pixels.


UNIT_TYPE_PIXELS

static byte

Indicates the unit type for padding/margin, the default is in device specific
pixels
UNIT_TYPE_SCREEN_PERCENTAGE

static byte

Indicates the unit type for padding/margin in percentage of the size of the
screen

Constructor Summary
Constructor and Description
Style()

Each component when it draw itself uses this Object to determine in what colors it should
use.
Style(int fgColor, int bgColor, Font f, byte transparency)

Creates a new style with the given attributes


Style(int fgColor, int bgColor, Font f, byte transparency, Image im,
byte backgroundType)

Creates a new style with the given attributes


Style(Style style)

Creates a full copy of the given style.

Constructor Summary

882

Overview (Codename One API)

Method Summary
Modifier
and
Type
void
static
Style
int
int
float
float
float
int
byte
int
Image

Method and Description


addStyleListener(StyleListener l)

Adds a Style Listener to the Style Object.


createProxyStyle(Style... styles)

Creates a "proxy" style whose setter methods map to the methods in the given
styles passed and whose getter methods are meaningless
getAlignment()

Returns the alignment of the Label


getBackgroundGradientEndColor()

End color for the radial/linear gradient


getBackgroundGradientRelativeSize()

Background radial gradient relative size


getBackgroundGradientRelativeX()

Background radial gradient relative center position X


getBackgroundGradientRelativeY()

Background radial gradient relative center position Y


getBackgroundGradientStartColor()

Start color for the radial/linear gradient


getBackgroundType()

The type of the background defaults to BACKGROUND_IMAGE_SCALED


getBgColor()

Background color for the component


getBgImage()

Background image for the component


getBgPainter()

Painter

Return the background painter for this style, normally this would be the internal
image/color painter but can be user defined
getBgTransparency()

byte

Border
int
Font
int
int
int
int
int

Returns the transparency (opacity) level of the Component, zero indicates fully
transparent and FF indicates fully opaque.
getBorder()

Returns the border for the style


getFgColor()

Foreground color for the component


getFont()

Font for the component


getMargin(boolean rtl, int orientation)

Returns the Margin


getMargin(int orientation)

Returns the Margin


getMarginBottom()

Returns the bottom margin in pixel


getMarginRight(boolean rtl)

Returns the right margin in pixel or left margin in an RTL situation


getMarginTop()

Returns the top margin in pixel


getMarginUnit()

byte[]

int
int

Method Summary

Indicates the units used for margin elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
getMarginValue(boolean rtl, int orientation)

Returns the Margin


getOpacity()

Returns the opacity value for the component

883

Overview (Codename One API)


int
int
int
int
int
int

getPadding(boolean rtl, int orientation)

Returns the Padding in using the current unit


getPadding(int orientation)

Returns the Padding


getPaddingBottom()

Returns the bottom padding in pixel


getPaddingLeft(boolean rtl)

Returns the left padding in pixel or right padding in an RTL situation


getPaddingRight(boolean rtl)

Returns the right padding in pixel or left padding in an RTL situation


getPaddingTop()

Returns the top padding in pixel


getPaddingUnit()

byte[]

int
int
boolean
boolean

Indicates the units used for padding elements, if null pixels are used if not this is a
4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
getPaddingValue(boolean rtl, int orientation)

Returns the Padding in the internal value regardless of the unit


getTextDecoration()

Returns the text decoration of this style


is3DTextNorth()

Returns the text decoration state for the north


isLowered3DText()

Returns true if the 3D text decoration is on, false otherwise


isModified()

boolean

boolean
boolean
boolean
boolean

Returns true if the style was modified manually after it was created by the look and
feel.
isOverline()

Returns true if the overline text decoration is on, false otherwise


isRaised3DText()

Returns true if the 3D text decoration is on, false otherwise


isStrikeThru()

Returns true if the strike through text decoration is on, false otherwise
isUnderline()

Returns true if the underline text decoration is on, false otherwise


merge(Style style)

void

void
void
void
void
void
void
void

void

Merges the new style with the current style without changing the elements that
were modified.
removeListeners()

This method removes all Listeners from the Style


removeStyleListener(StyleListener l)

Removes a Style Listener from the Style Object.


set3DText(boolean t, boolean raised)

Sets the 3D text decoration for this style


set3DTextNorth(boolean north)

Sets the text decoration to 3D text


setAlignment(int align)

Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
setAlignment(int align, boolean override)

Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
setBackgroundGradientEndColor(int backgroundGradientEndColor)

Sets the background color for the component


setBackgroundGradientEndColor(int backgroundGradientEndColor,
boolean override)

Sets the background color for the component


void
void

Method Summary

setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)

Background radial gradient relative size


setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize,
boolean override)

884

Overview (Codename One API)


Background radial gradient relative size
void

void

setBackgroundGradientRelativeX(float backgroundGradientRelativeX)

Background radial gradient relative center position X


setBackgroundGradientRelativeX(float backgroundGradientRelativeX,
boolean override)

Background radial gradient relative center position X


void

void

setBackgroundGradientRelativeY(float backgroundGradientRelativeY)

Background radial gradient relative center position Y


setBackgroundGradientRelativeY(float backgroundGradientRelativeY,
boolean override)

Background radial gradient relative center position Y


void

void

setBackgroundGradientStartColor(int backgroundGradientStartColor)

Sets the background color for the component


setBackgroundGradientStartColor(int backgroundGradientStartColor,
boolean override)

Sets the background color for the component


void
void
void
void
void
void

setBackgroundType(byte backgroundType)

Sets the background type for the component


setBackgroundType(byte backgroundType, boolean override)

Sets the background type for the component


setBgColor(int bgColor)

Sets the background color for the component


setBgColor(int bgColor, boolean override)

Sets the background color for the component


setBgImage(Image bgImage)

Sets the background image for the component


setBgImage(Image bgImage, boolean override)

Sets the background image for the component


setBgPainter(Painter bgPainter)

void

Defines the background painter for this style, normally this would be the internal
image/color painter but can be user defined
setBgTransparency(byte transparency)

void

void
void
void
void
void
void
void
void
void
void
void

Sets the Component transparency (opacity) level of the Component, zero indicates
fully transparent and FF indicates fully opaque.
setBgTransparency(int transparency)

Sets the Component transparency level.


setBgTransparency(int transparency, boolean override)

Sets the Component transparency level.


setBorder(Border border)

Sets the border for the style


setBorder(Border border, boolean override)

Sets the border for the style


setFgColor(int fgColor)

Sets the foreground color for the component


setFgColor(int fgColor, boolean override)

Sets the foreground color for the component


setFont(Font font)

Sets the font for the component


setFont(Font font, boolean override)

Sets the font for the component


setMargin(int orientation, int gap)

Sets the Style Margin


setMargin(int orientation, int gap, boolean override)

Sets the Style Margin


setMargin(int top, int bottom, int left, int right)

Sets the Style Margin


setMarginBottom(int gap)

void

Sets the Style Margin on the bottom, this is equivalent to calling


setMargin(Component.BOTTOM, gap, false);

Method Summary

885

Overview (Codename One API)

setMarginLeft(int gap)

Sets the Style Margin on the left, this is equivalent to calling

void

setMargin(Component.LEFT, gap, false);


setMarginRight(int gap)

Sets the Style Margin on the right, this is equivalent to calling

void

setMargin(Component.RIGHT, gap, false);


setMarginTop(int gap)

Sets the Style margin on the top, this is equivalent to calling

void

setMargin(Component.TOP, gap, false);


setMarginUnit(byte... marginUnit)

Indicates the units used for margin elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE

void

setOpacity(int opacity)

void

Set the opacity value


setOpacity(int opacity, boolean override)

void

Sets the Component transparency level.


setOverline(boolean overline)

void

Sets the overline text decoration for this style


setPadding(int orientation, int gap)

void

Sets the Style Padding


setPadding(int orientation, int gap, boolean override)

void

Sets the Style Padding


setPadding(int top, int bottom, int left, int right)

void

Sets the Style Padding


setPaddingBottom(int gap)

Sets the Style Padding on the bottom, this is equivalent to calling

void

setPadding(Component.BOTTOM, gap, false);


setPaddingLeft(int gap)

Sets the Style Padding on the left, this is equivalent to calling

void

setPadding(Component.LEFT, gap, false);


setPaddingRight(int gap)

Sets the Style Padding on the right, this is equivalent to calling

void

setPadding(Component.RIGHT, gap, false);


setPaddingTop(int gap)

Sets the Style Padding on the top, this is equivalent to calling

void

setPadding(Component.TOP, gap, false);


setPaddingUnit(byte... paddingUnit)

Indicates the units used for padding elements, if null pixels are used if not this is a
4 element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE

void

setStrikeThru(boolean strikethru)

void

Sets the strike through text decoration for this style


setTextDecoration(int textDecoration)

void

Sets the text decoration of this style


setTextDecoration(int textDecoration, boolean override)

void

Sets the text decoration of this style


setUnderline(boolean underline)

void

Sets the underline text decoration for this style

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Methods inherited from class java.lang.Object

886

Overview (Codename One API)


BG_COLOR
public static final String BG_COLOR

Background color attribute name for the theme hashtable


See Also:
Constant Field Values
FG_COLOR
public static final String FG_COLOR

Foreground color attribute name for the theme hashtable


See Also:
Constant Field Values
BG_IMAGE
public static final String BG_IMAGE

Background image attribute name for the theme hashtable


See Also:
Constant Field Values
BACKGROUND_TYPE
public static final String BACKGROUND_TYPE

Background attribute name for the theme hashtable


See Also:
Constant Field Values
BACKGROUND_ALIGNMENT
public static final String BACKGROUND_ALIGNMENT

Background attribute name for the theme hashtable


See Also:
Constant Field Values
BACKGROUND_GRADIENT
public static final String BACKGROUND_GRADIENT

Background attribute name for the theme hashtable


See Also:
Constant Field Values
FONT
public static final String FONT

Font attribute name for the theme hashtable


See Also:
Constant Field Values
TRANSPARENCY
public static final String TRANSPARENCY

Transparency attribute name for the theme hashtable


See Also:
Constant Field Values
OPACITY
public static final String OPACITY

Opacity attribute name for the theme hashtable


See Also:
Constant Field Values

Field Detail

887

Overview (Codename One API)


MARGIN
public static final String MARGIN

Margin attribute name for the theme hashtable


See Also:
Constant Field Values
BORDER
public static final String BORDER

Border attribute name for the theme hashtable


See Also:
Constant Field Values
PADDING
public static final String PADDING

Padding attribute name for the theme hashtable


See Also:
Constant Field Values
PAINTER
public static final String PAINTER

Painter attribute name for the style event


See Also:
Constant Field Values
ALIGNMENT
public static final String ALIGNMENT

Alignment attribute for the style event


See Also:
Constant Field Values
TEXT_DECORATION
public static final String TEXT_DECORATION

Text decoration attribute for the style event


See Also:
Constant Field Values
PADDING_UNIT
public static final String PADDING_UNIT

The units of the padding


See Also:
Constant Field Values
MARGIN_UNIT
public static final String MARGIN_UNIT

The units of the margin


See Also:
Constant Field Values
BACKGROUND_NONE
public static final byte BACKGROUND_NONE

Indicates the background for the style would use a scaled image
See Also:
Constant Field Values

Field Detail

888

Overview (Codename One API)


BACKGROUND_IMAGE_SCALED
public static final byte BACKGROUND_IMAGE_SCALED

Indicates the background for the style would use a scaled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_BOTH
public static final byte BACKGROUND_IMAGE_TILE_BOTH

Indicates the background for the style would use a tiled image on both axis
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_VERTICAL
public static final byte BACKGROUND_IMAGE_TILE_VERTICAL

Indicates the background for the style would use a vertical tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_HORIZONTAL
public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_TOP
public static final byte BACKGROUND_IMAGE_ALIGNED_TOP

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_BOTTOM
public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_LEFT
public static final byte BACKGROUND_IMAGE_ALIGNED_LEFT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_RIGHT
public static final byte BACKGROUND_IMAGE_ALIGNED_RIGHT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_CENTER
public static final byte BACKGROUND_IMAGE_ALIGNED_CENTER

Indicates the background for the style would use an unscaled image with an
alignment
See Also:

Field Detail

889

Overview (Codename One API)


Constant Field Values
BACKGROUND_IMAGE_ALIGNED_TOP_LEFT
public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_LEFT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT
public static final byte BACKGROUND_IMAGE_ALIGNED_TOP_RIGHT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT
public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_LEFT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT
public static final byte BACKGROUND_IMAGE_ALIGNED_BOTTOM_RIGHT

Indicates the background for the style would use an unscaled image with an
alignment
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP
public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_TOP

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER
public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_CENTER

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM
public static final byte BACKGROUND_IMAGE_TILE_HORIZONTAL_ALIGN_BOTTOM

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT
public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_LEFT

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER
public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_CENTER

Indicates the background for the style would use a horizontal tiled image
See Also:

Field Detail

890

Overview (Codename One API)


Constant Field Values
BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT
public static final byte BACKGROUND_IMAGE_TILE_VERTICAL_ALIGN_RIGHT

Indicates the background for the style would use a horizontal tiled image
See Also:
Constant Field Values
BACKGROUND_IMAGE_SCALED_FILL
public static final byte BACKGROUND_IMAGE_SCALED_FILL

Indicates the background for the style would use a scaled image that fills all available
space while maintaining aspect ratio
See Also:
Constant Field Values
BACKGROUND_IMAGE_SCALED_FIT
public static final byte BACKGROUND_IMAGE_SCALED_FIT

Indicates the background for the style would use a scaled image that fits to available
space while maintaining aspect ratio
See Also:
Constant Field Values
BACKGROUND_GRADIENT_LINEAR_VERTICAL
public static final byte BACKGROUND_GRADIENT_LINEAR_VERTICAL

Indicates the background for the style would use a linear gradient
See Also:
Constant Field Values
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL
public static final byte BACKGROUND_GRADIENT_LINEAR_HORIZONTAL

Indicates the background for the style would use a linear gradient
See Also:
Constant Field Values
BACKGROUND_GRADIENT_RADIAL
public static final byte BACKGROUND_GRADIENT_RADIAL

Indicates the background for the style would use a radial gradient
See Also:
Constant Field Values
TEXT_DECORATION_NONE
public static final byte TEXT_DECORATION_NONE

Indicates no text decoration


See Also:
Constant Field Values
TEXT_DECORATION_UNDERLINE
public static final byte TEXT_DECORATION_UNDERLINE

Indicates underline
See Also:
Constant Field Values
TEXT_DECORATION_STRIKETHRU
public static final byte TEXT_DECORATION_STRIKETHRU

Indicates a strike-through line (usually used to denote deleted text)


See Also:
Constant Field Values

Field Detail

891

Overview (Codename One API)


TEXT_DECORATION_OVERLINE
public static final byte TEXT_DECORATION_OVERLINE

Indicates overline
See Also:
Constant Field Values
TEXT_DECORATION_3D
public static final byte TEXT_DECORATION_3D

3D text effect using a font shadow


See Also:
Constant Field Values
TEXT_DECORATION_3D_LOWERED
public static final byte TEXT_DECORATION_3D_LOWERED

3D sunken text effect using a light font shadow


See Also:
Constant Field Values
TEXT_DECORATION_3D_SHADOW_NORTH
public static final byte TEXT_DECORATION_3D_SHADOW_NORTH

3D text effect using a font shadow


See Also:
Constant Field Values
UNIT_TYPE_PIXELS
public static final byte UNIT_TYPE_PIXELS

Indicates the unit type for padding/margin, the default is in device specific pixels
See Also:
Constant Field Values
UNIT_TYPE_SCREEN_PERCENTAGE
public static final byte UNIT_TYPE_SCREEN_PERCENTAGE

Indicates the unit type for padding/margin in percentage of the size of the screen
See Also:
Constant Field Values
UNIT_TYPE_DIPS
public static final byte UNIT_TYPE_DIPS

Indicates the unit type for padding/margin in device independent pixels. Device
independent pixels try to aim at roghly 1 milimeter of the screen per DIP but make no
guarantee for accuracy.
See Also:
Constant Field Values

Constructor Detail
Style
public Style()

Each component when it draw itself uses this Object to determine in what colors it
should use. When a Component is generated it construct a default Style Object. The
Default values for each Component can be changed by using the UIManager class
Style
public Style(Style style)

Field Detail

892

Overview (Codename One API)


Creates a full copy of the given style. Notice that if the original style was modified
manually (by invoking setters on it) it would not chnage when changing a theme/look
and feel, however this newly created style would change in such a case.
Parameters:
style - the style to copy
Style
public Style(int fgColor,
int bgColor,
Font f,
byte transparency)

Creates a new style with the given attributes


Parameters:
fgColor - foreground color
bgColor - background color
f - font
transparency - transparency value
Style
public Style(int fgColor,
int bgColor,
Font f,
byte transparency,
Image im,
byte backgroundType)

Creates a new style with the given attributes


Parameters:
fgColor - foreground color
bgColor - background color
f - font
transparency - transparency value
im - background image
backgroundType - one of: BACKGROUND_IMAGE_SCALED,
BACKGROUND_IMAGE_TILE_BOTH,
BACKGROUND_IMAGE_TILE_VERTICAL,
BACKGROUND_IMAGE_TILE_HORIZONTAL,
BACKGROUND_IMAGE_ALIGNED,
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL,
BACKGROUND_GRADIENT_LINEAR_VERTICAL,
BACKGROUND_GRADIENT_RADIAL

Method Detail
createProxyStyle
public static Style createProxyStyle(Style... styles)

Creates a "proxy" style whose setter methods map to the methods in the given styles
passed and whose getter methods are meaningless
Parameters:
styles - the styles to which we will proxy
Returns:
a proxy style object
merge
public void merge(Style style)

Merges the new style with the current style without changing the elements that were
modified.
Parameters:
style - new values of styles from the current theme

Constructor Detail

893

Overview (Codename One API)


isModified
public boolean isModified()

Returns true if the style was modified manually after it was created by the look and
feel. If the style was modified manually (by one of the set methods) then it should be
merged rather than overwritten.
Returns:
true if the style was modified
getBgColor
public int getBgColor()

Background color for the component


Returns:
the background color for the component
getBgImage
public Image getBgImage()

Background image for the component


Returns:
the background image for the component
getBackgroundType
public byte getBackgroundType()

The type of the background defaults to BACKGROUND_IMAGE_SCALED


Returns:
one of: BACKGROUND_IMAGE_SCALED,
BACKGROUND_IMAGE_TILE_BOTH,
BACKGROUND_IMAGE_TILE_VERTICAL,
BACKGROUND_IMAGE_TILE_HORIZONTAL,
BACKGROUND_IMAGE_ALIGNED,
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL,
BACKGROUND_GRADIENT_LINEAR_VERTICAL,
BACKGROUND_GRADIENT_RADIAL
getBackgroundGradientStartColor
public int getBackgroundGradientStartColor()

Start color for the radial/linear gradient


Returns:
the start color for the radial/linear gradient
getBackgroundGradientEndColor
public int getBackgroundGradientEndColor()

End color for the radial/linear gradient


Returns:
the end color for the radial/linear gradient
getBackgroundGradientRelativeX
public float getBackgroundGradientRelativeX()

Background radial gradient relative center position X


Returns:
value between 0 and 1 with 0.5 representing the center of the component
getBackgroundGradientRelativeY
public float getBackgroundGradientRelativeY()

Background radial gradient relative center position Y


Returns:
value between 0 and 1 with 0.5 representing the center of the component

Method Detail

894

Overview (Codename One API)


getBackgroundGradientRelativeSize
public float getBackgroundGradientRelativeSize()

Background radial gradient relative size


Returns:
value representing the relative size of the gradient
getFgColor
public int getFgColor()

Foreground color for the component


Returns:
the foreground color for the component
getFont
public Font getFont()

Font for the component


Returns:
the font for the component
setBgColor
public void setBgColor(int bgColor)

Sets the background color for the component


Parameters:
bgColor - RRGGBB color that ignors the alpha component
setAlignment
public void setAlignment(int align)

Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
setAlignment
public void setAlignment(int align,
boolean override)

Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
Parameters:
align - alignment value
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
getAlignment
public int getAlignment()

Returns the alignment of the Label


Returns:
the alignment of the Label one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
setBgImage
public void setBgImage(Image bgImage)

Sets the background image for the component


Parameters:
bgImage - background image

Method Detail

895

Overview (Codename One API)


setBackgroundType
public void setBackgroundType(byte backgroundType)

Sets the background type for the component


Parameters:
backgroundType - one of BACKGROUND_IMAGE_SCALED,
BACKGROUND_IMAGE_TILE_BOTH,
BACKGROUND_IMAGE_TILE_VERTICAL,
BACKGROUND_IMAGE_TILE_HORIZONTAL,
BACKGROUND_IMAGE_ALIGNED,
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL,
BACKGROUND_GRADIENT_LINEAR_VERTICAL,
BACKGROUND_GRADIENT_RADIAL
setBackgroundGradientStartColor
public void setBackgroundGradientStartColor(int backgroundGradientStartColor)

Sets the background color for the component


Parameters:
backgroundGradientStartColor - start color for the linear/radial gradient
setBackgroundGradientEndColor
public void setBackgroundGradientEndColor(int backgroundGradientEndColor)

Sets the background color for the component


Parameters:
backgroundGradientEndColor - end color for the linear/radial gradient
setBackgroundGradientRelativeX
public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX)

Background radial gradient relative center position X


Parameters:
backgroundGradientRelativeX - x position of the radial gradient center
setBackgroundGradientRelativeY
public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY)

Background radial gradient relative center position Y


Parameters:
backgroundGradientRelativeY - y position of the radial gradient center
setBackgroundGradientRelativeSize
public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize)

Background radial gradient relative size


Parameters:
backgroundGradientRelativeSize

- the size of the radial gradient

setFgColor
public void setFgColor(int fgColor)

Sets the foreground color for the component


Parameters:
fgColor - foreground color
setFont
public void setFont(Font font)

Sets the font for the component


Parameters:
font - the font

Method Detail

896

Overview (Codename One API)


setUnderline
public void setUnderline(boolean underline)

Sets the underline text decoration for this style


Parameters:
underline - true to turn underline on, false to turn it off
isUnderline
public boolean isUnderline()

Returns true if the underline text decoration is on, false otherwise


Returns:
true if the underline text decoration is on, false otherwise
set3DText
public void set3DText(boolean t,
boolean raised)

Sets the 3D text decoration for this style


Parameters:
t - true to turn 3d shadow effect on, false to turn it off
raised - indicates a raised or lowered effect
set3DTextNorth
public void set3DTextNorth(boolean north)

Sets the text decoration to 3D text


Parameters:
north - true to enable 3d text with the shadow on top false otherwise
is3DTextNorth
public boolean is3DTextNorth()

Returns the text decoration state for the north


Returns:
true if that is used
isRaised3DText
public boolean isRaised3DText()

Returns true if the 3D text decoration is on, false otherwise


Returns:
true if the 3D text decoration is on, false otherwise
isLowered3DText
public boolean isLowered3DText()

Returns true if the 3D text decoration is on, false otherwise


Returns:
true if the 3D text decoration is on, false otherwise
setOverline
public void setOverline(boolean overline)

Sets the overline text decoration for this style


Parameters:
overline - true to turn overline on, false to turn it off
isOverline
public boolean isOverline()

Returns true if the overline text decoration is on, false otherwise


Returns:
true if the overline text decoration is on, false otherwise

Method Detail

897

Overview (Codename One API)


setStrikeThru
public void setStrikeThru(boolean strikethru)

Sets the strike through text decoration for this style


Parameters:
strikethru - true to turn strike through on, false to turn it off
isStrikeThru
public boolean isStrikeThru()

Returns true if the strike through text decoration is on, false otherwise
Returns:
true if the strike through text decoration is on, false otherwise
getTextDecoration
public int getTextDecoration()

Returns the text decoration of this style


Returns:
the text decoration of this style (bitmask of the TEXT_DECORATION_*
constants)
setTextDecoration
public void setTextDecoration(int textDecoration)

Sets the text decoration of this style


Parameters:
textDecoration - the textDecoration to set (bitmask of the
TEXT_DECORATION_* constants)
setTextDecoration
public void setTextDecoration(int textDecoration,
boolean override)

Sets the text decoration of this style


Parameters:
textDecoration - the textDecoration to set (bitmask of the
TEXT_DECORATION_* constants)
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
getBgTransparency
public byte getBgTransparency()

Returns the transparency (opacity) level of the Component, zero indicates fully
transparent and FF indicates fully opaque.
Returns:
the transparency level of the Component
setBgTransparency
public void setBgTransparency(byte transparency)

Sets the Component transparency (opacity) level of the Component, zero indicates
fully transparent and FF indicates fully opaque.
Parameters:
transparency - transparency level as byte
getOpacity
public int getOpacity()

Returns the opacity value for the component


Returns:
the opacity value

Method Detail

898

Overview (Codename One API)


setOpacity
public void setOpacity(int opacity)

Set the opacity value


Parameters:
opacity - the opacity value
setOpacity
public void setOpacity(int opacity,
boolean override)

Sets the Component transparency level. Valid values should be a number between
0-255
Parameters:
opacity - int value between 0-255
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBgTransparency
public void setBgTransparency(int transparency)

Sets the Component transparency level. Valid values should be a number between
0-255
Parameters:
transparency - int value between 0-255
setPadding
public void setPadding(int
int
int
int

top,
bottom,
left,
right)

Sets the Style Padding


Parameters:
top - number of pixels to padd
bottom - number of pixels to padd
left - number of pixels to padd
right - number of pixels to padd
setPadding
public void setPadding(int orientation,
int gap)

Sets the Style Padding


Parameters:
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
gap - number of pixels to padd
setMargin
public void setMargin(int
int
int
int

top,
bottom,
left,
right)

Sets the Style Margin


Parameters:
top - number of margin using the current unit
bottom - number of margin using the current unit
left - number of margin using the current unit
right - number of margin using the current unit
setMargin
public void setMargin(int orientation,
int gap)

Sets the Style Margin

Method Detail

899

Overview (Codename One API)


Parameters:
- one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
gap - number of margin using the current unit
getPaddingValue
orientation

public int getPaddingValue(boolean rtl,


int orientation)

Returns the Padding in the internal value regardless of the unit


Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the given orientation
getPaddingLeft
public int getPaddingLeft(boolean rtl)

Returns the left padding in pixel or right padding in an RTL situation


Parameters:
rtl - indicates a right to left language
Returns:
the padding in pixels
getPaddingRight
public int getPaddingRight(boolean rtl)

Returns the right padding in pixel or left padding in an RTL situation


Parameters:
rtl - indicates a right to left language
Returns:
the padding in pixels
getPaddingTop
public int getPaddingTop()

Returns the top padding in pixel


Returns:
the padding in pixels
setPaddingTop
public void setPaddingTop(int gap)

Sets the Style Padding on the top, this is equivalent to calling


setPadding(Component.TOP, gap, false);

Parameters:
gap - number of pixels to pad
setPaddingBottom
public void setPaddingBottom(int gap)

Sets the Style Padding on the bottom, this is equivalent to calling


setPadding(Component.BOTTOM, gap, false);

Parameters:
gap - number of pixels to pad
setPaddingLeft
public void setPaddingLeft(int gap)

Sets the Style Padding on the left, this is equivalent to calling


setPadding(Component.LEFT, gap, false);

Parameters:
gap - number of pixels to pad

Method Detail

900

Overview (Codename One API)


setPaddingRight
public void setPaddingRight(int gap)

Sets the Style Padding on the right, this is equivalent to calling


setPadding(Component.RIGHT, gap, false);

Parameters:
gap - number of pixels to pad
setMarginTop
public void setMarginTop(int gap)

Sets the Style margin on the top, this is equivalent to calling


setMargin(Component.TOP, gap, false);

Parameters:
gap - number of pixels to pad
setMarginBottom
public void setMarginBottom(int gap)

Sets the Style Margin on the bottom, this is equivalent to calling


setMargin(Component.BOTTOM, gap, false);

Parameters:
gap - number of pixels to pad
setMarginLeft
public void setMarginLeft(int gap)

Sets the Style Margin on the left, this is equivalent to calling


setMargin(Component.LEFT, gap, false);

Parameters:
gap - number of pixels to pad
setMarginRight
public void setMarginRight(int gap)

Sets the Style Margin on the right, this is equivalent to calling


setMargin(Component.RIGHT, gap, false);

Parameters:
gap - number of pixels to pad
getPaddingBottom
public int getPaddingBottom()

Returns the bottom padding in pixel


Returns:
the padding in pixels
getMarginRight
public int getMarginRight(boolean rtl)

Returns the right margin in pixel or left margin in an RTL situation


Parameters:
rtl - indicates a right to left language
Returns:
the margin in pixels
getMarginTop
public int getMarginTop()

Returns the top margin in pixel


Returns:
the margin in pixels

Method Detail

901

Overview (Codename One API)


getMarginBottom
public int getMarginBottom()

Returns the bottom margin in pixel


Returns:
the margin in pixels
getPadding
public int getPadding(boolean rtl,
int orientation)

Returns the Padding in using the current unit


Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the given orientation
getPadding
public int getPadding(int orientation)

Returns the Padding


Parameters:
- one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of padding pixels in the given orientation
getMargin
orientation

public int getMargin(int orientation)

Returns the Margin


Parameters:
- one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of margin using the current unit in the given orientation
getMargin
orientation

public int getMargin(boolean rtl,


int orientation)

Returns the Margin


Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of margin using the current unit in the given orientation
getMarginValue
public int getMarginValue(boolean rtl,
int orientation)

Returns the Margin


Parameters:
rtl - flag indicating whether the padding is for an RTL bidi component
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
Returns:
number of margin using the current unit in the given orientation

Method Detail

902

Overview (Codename One API)


setBgColor
public void setBgColor(int bgColor,
boolean override)

Sets the background color for the component


Parameters:
bgColor - RRGGBB color that ignors the alpha component
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBgImage
public void setBgImage(Image bgImage,
boolean override)

Sets the background image for the component


Parameters:
bgImage - background image
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBackgroundType
public void setBackgroundType(byte backgroundType,
boolean override)

Sets the background type for the component


Parameters:
backgroundType - one of BACKGROUND_IMAGE_SCALED,
BACKGROUND_IMAGE_TILE_BOTH,
BACKGROUND_IMAGE_TILE_VERTICAL,
BACKGROUND_IMAGE_TILE_HORIZONTAL,
BACKGROUND_IMAGE_ALIGNED,
BACKGROUND_GRADIENT_LINEAR_HORIZONTAL,
BACKGROUND_GRADIENT_LINEAR_VERTICAL,
BACKGROUND_GRADIENT_RADIAL
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBackgroundGradientStartColor
public void setBackgroundGradientStartColor(int backgroundGradientStartColor,
boolean override)

Sets the background color for the component


Parameters:
backgroundGradientStartColor - start color for the linear/radial gradient
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBackgroundGradientEndColor
public void setBackgroundGradientEndColor(int backgroundGradientEndColor,
boolean override)

Sets the background color for the component


Parameters:
backgroundGradientEndColor - end color for the linear/radial gradient
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBackgroundGradientRelativeX
public void setBackgroundGradientRelativeX(float backgroundGradientRelativeX,
boolean override)

Background radial gradient relative center position X


Parameters:
backgroundGradientRelativeX - x position of the radial gradient center
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel

Method Detail

903

Overview (Codename One API)


setBackgroundGradientRelativeY
public void setBackgroundGradientRelativeY(float backgroundGradientRelativeY,
boolean override)

Background radial gradient relative center position Y


Parameters:
backgroundGradientRelativeY - y position of the radial gradient center
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBackgroundGradientRelativeSize
public void setBackgroundGradientRelativeSize(float backgroundGradientRelativeSize,
boolean override)

Background radial gradient relative size


Parameters:
- the size of the radial gradient relative to
the screens larger dimension
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setFgColor
backgroundGradientRelativeSize

public void setFgColor(int fgColor,


boolean override)

Sets the foreground color for the component


Parameters:
fgColor - foreground color
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setFont
public void setFont(Font font,
boolean override)

Sets the font for the component


Parameters:
font - the font
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setBgTransparency
public void setBgTransparency(int transparency,
boolean override)

Sets the Component transparency level. Valid values should be a number between
0-255
Parameters:
transparency - int value between 0-255
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
setPadding
public void setPadding(int orientation,
int gap,
boolean override)

Sets the Style Padding


Parameters:
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
gap - number of pixels to padd
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel

Method Detail

904

Overview (Codename One API)


setMargin
public void setMargin(int orientation,
int gap,
boolean override)

Sets the Style Margin


Parameters:
orientation - one of: Component.TOP, Component.BOTTOM,
Component.LEFT, Component.RIGHT
gap - number of margin using the current unit
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
addStyleListener
public void addStyleListener(StyleListener l)

Adds a Style Listener to the Style Object.


Parameters:
l - a style listener
removeStyleListener
public void removeStyleListener(StyleListener l)

Removes a Style Listener from the Style Object.


Parameters:
l - a style listener
removeListeners
public void removeListeners()

This method removes all Listeners from the Style


setBorder
public void setBorder(Border border)

Sets the border for the style


Parameters:
border - new border object for the component
setBorder
public void setBorder(Border border,
boolean override)

Sets the border for the style


Parameters:
border - new border object for the component
override - If set to true allows the look and feel/theme to override the value in
this attribute when changing a theme/look and feel
getBorder
public Border getBorder()

Returns the border for the style


Returns:
the border
getBgPainter
public Painter getBgPainter()

Return the background painter for this style, normally this would be the internal
image/color painter but can be user defined
Returns:
the background painter

Method Detail

905

Overview (Codename One API)


setBgPainter
public void setBgPainter(Painter bgPainter)

Defines the background painter for this style, normally this would be the internal
image/color painter but can be user defined
Parameters:
bgPainter - new painter to install into the style
getPaddingUnit
public byte[] getPaddingUnit()

Indicates the units used for padding elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
Returns:
the paddingUnit
setPaddingUnit
public void setPaddingUnit(byte... paddingUnit)

Indicates the units used for padding elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
Parameters:
paddingUnit - the paddingUnit to set
getMarginUnit
public byte[] getMarginUnit()

Indicates the units used for margin elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
Returns:
the marginUnit
setMarginUnit
public void setMarginUnit(byte... marginUnit)

Indicates the units used for margin elements, if null pixels are used if not this is a 4
element array containing values of UNIT_TYPE_PIXELS, UNIT_TYPE_DIPS or
UNIT_TYPE_SCREEN_PERCENTAGE
Parameters:
marginUnit - the marginUnit to set

Method Detail

906

Overview (Codename One API)


com.codename1.ui.plaf

Class LookAndFeel
java.lang.Object

com.codename1.ui.plaf.LookAndFeel
Direct Known Subclasses:
DefaultLookAndFeel
Deprecated.
this class is still crucial for some features in Codename One. The deprecation is here to indicate our
desire to reduce usage/reliance on this class.
public abstract class
extends Object

Allows a UI developer to completely customize the look of the application by overriding drawing/sizing
methods appropriately.

Constructor Summary
Constructor and Description
LookAndFeel(UIManager manager)

Deprecated.

Method Summary
Modifier and
Type

Method and Description


bind(Component cmp)

void

Deprecated.
Every component binds itself to the look and feel thus allowing the look and feel to
customize the component.
drawButton(Graphics g, Button b)

abstract void

Deprecated.
this method is no longer used by the implementation, we shifted code away to
improve performance
drawCheckBox(Graphics g, Button cb)

abstract void

Deprecated.
Invoked for drawing a checkbox widget
drawComboBox(Graphics g, List cb)

abstract void

void

Deprecated.
Invoked for drawing a combo box widget
drawHorizontalScroll(Graphics g, Component c, float offsetRatio,
float blockSizeRatio)

Deprecated.
Draws a horizontal scroll bar in the given component
drawLabel(Graphics g, Label l)

abstract void

Deprecated.
this method is no longer used by the implementation, we shifted code away to
improve performance
drawList(Graphics g, List l)

abstract void

Deprecated.
Invoked for drawing a list widget
drawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted)

abstract void

Class LookAndFeel

Deprecated.
Paints the pull to refresh

907

Overview (Codename One API)


drawRadioButton(Graphics g, Button rb)
abstract void

Deprecated.
Invoked for drawing the radio button widget
drawTextArea(Graphics g, TextArea ta)

abstract void

Deprecated.
Draw the given text area
drawTextField(Graphics g, TextArea ta)

abstract void

Deprecated.
Draws the text field without its cursor which is drawn in a separate method input
mode indication can also be drawn using this method.
drawTextFieldCursor(Graphics g, TextArea ta)

abstract void

void

abstract
Dimension
abstract
Dimension
abstract
Dimension

Deprecated.
Draws the cursor of the text field, blinking is handled simply by avoiding a call to
this method.
drawVerticalScroll(Graphics g, Component c, float offsetRatio,
float blockSizeRatio)

Deprecated.
Draws a vertical scroll bar in the given component
getButtonPreferredSize(Button b)

Deprecated.
Calculate the preferred size of the component
getCheckBoxPreferredSize(Button cb)

Deprecated.
Calculate the preferred size of the component
getComboBoxPreferredSize(List box)

Deprecated.
Calculate the preferred size of the component
getDefaultDialogTransitionIn()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
dialog
getDefaultDialogTransitionOut()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
dialog
getDefaultFormTintColor()

int

Deprecated.
Tint color is set when a form is partially covered be it by a menu or by a dialog.
getDefaultFormTransitionIn()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
form
getDefaultFormTransitionOut()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
form
getDefaultMenuTransitionIn()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
Menu
getDefaultMenuTransitionOut()

Transition

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
Menu
getDefaultSmoothScrollingSpeed()

int

Deprecated.
Indicates the default speed for smooth scrolling
getDisableColor()

int

Deprecated.
This color is used to paint disable mode text color.

int

getFadeScrollBarSpeed()

Method Summary

908

Overview (Codename One API)


Deprecated.
getFadeScrollEdgeLength()
int

Deprecated.
Indicates the width/height of the fading edge to indicate scrolling
getHorizontalScrollHeight()

int

abstract
Dimension
abstract
Dimension

Deprecated.
Returns the default height of a horizontal scroll bar
getLabelPreferredSize(Label l)

Deprecated.
Calculate the preferred size of the component
getListPreferredSize(List l)

Deprecated.
Calculate the preferred size of the component
getMenuBarClass()

Class

Deprecated.
This method returns the MenuBar class.
getMenuIcons()

Image[]

Deprecated.
Simple getter for the menu icons
getMenuRenderer()

ListCellRenderer

Deprecated.
Returns the Menu default renderer
getPullToRefreshHeight()

abstract int

abstract
Dimension

Deprecated.
Returns the required height of the pull to refresh feature
getRadioButtonPreferredSize(Button rb)

Deprecated.
Calculate the preferred size of the component
getTactileTouchDuration()

int

abstract
Dimension

Deprecated.
Allows defining a tactile touch device that vibrates when the user presses a
component that should respond with tactile feedback on a touch device (e.g.
getTextAreaSize(TextArea ta, boolean pref)

Deprecated.
Calculate the preferred size of the component
getTextFieldCursorColor()

int

abstract
Dimension

Deprecated.
The color of the text field cursor
getTextFieldPreferredSize(TextArea ta)

Deprecated.
Calculate the preferred size of the component
getTickerSpeed()

long

Deprecated.
Gets the ticker speed
getVerticalScrollWidth()

int

Deprecated.
Returns the default width of a vertical scroll bar
isBackgroundImageDetermineSize()

boolean

Deprecated.
Indicates if the bg image of a style should determine the minimum preferred size
according to the theme
isDefaultAlwaysTensile()

boolean

Deprecated.
Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
isDefaultEndsWith3Points()

boolean

Deprecated.
Indicates whether labels should end with 3 points by default

boolean

isDefaultSmoothScrolling()

Method Summary

909

Overview (Codename One API)


Deprecated.
Indicates whether lists and containers should have smooth scrolling by default
isDefaultSnapToGrid()
boolean

Deprecated.
Indicates whether scrolling this component should jump to a specific location in a
grid
isDefaultTensileDrag()

boolean

Deprecated.
Indicates whether tensile drag should be active by default
isDefaultTensileHighlight()

boolean

Deprecated.
Indicates whether tensile highlight should be active by default
isFadeScrollBar()

boolean

Deprecated.
Indicates whether the scrollbar should fade when unused
isFadeScrollEdge()

boolean

Deprecated.
Indicates whether the edge of a scrollable area should fade out
isFocusScrolling()

boolean

Deprecated.
Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of
Codename One.
isReverseSoftButtons()

boolean

Deprecated.
Indicates whether softbuttons should be reversed from their default orientation
isRTL()

boolean

Deprecated.
Use this to check if the LookAndFeel is in RTL mode
isScrollVisible()

boolean

Deprecated.
isTouchMenus()

boolean

Deprecated.
use Display.getCommandBehavior() ==
Display.COMMAND_BEHAVIOR_TOUCH_MENU
paintTensileHighlight(Component t, Graphics g, boolean top, int opacity)

void

Deprecated.
Paints the tensile hightlight image
refreshTheme(boolean completeClear)

void

Deprecated.
This method is a callback to the LookAndFeel when a theme is being changed in
the UIManager
setBackgroundImageDetermineSize(boolean backgroundImageDetermineSize)

void

Deprecated.
Indicates if the bg image of a style should determine the minimum preferred size
according to the theme
setDefaultAlwaysTensile(boolean defaultAlwaysTensile)

void

Deprecated.
Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
setDefaultDialogTransitionIn(Transition defaultDialogTransitionIn)

void

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
dialog
setDefaultDialogTransitionOut(Transition defaultDialogTransitionOut)

void

void

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
dialog
setDefaultEndsWith3Points(boolean defaultEndsWith3Points)

Deprecated.

Method Summary

910

Overview (Codename One API)


Indicates whether labels should end with 3 points by default
setDefaultFormTintColor(int defaultFormTintColor)
void

Deprecated.
Tint color is set when a form is partially covered be it by a menu or by a dialog.
setDefaultFormTransitionIn(Transition defaultFormTransitionIn)

void

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
form
setDefaultFormTransitionOut(Transition defaultFormTransitionOut)

void

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
form
setDefaultMenuTransitionIn(Transition defaultMenuTransitionIn)

void

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
Menu
setDefaultMenuTransitionOut(Transition defaultMenuTransitionOut)

void

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a
Menu
setDefaultSmoothScrolling(boolean defaultSmoothScrolling)

void

Deprecated.
Indicates whether lists and containers should have smooth scrolling by default
setDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed)

void

Deprecated.
Indicates the default speed for smooth scrolling
setDefaultSnapToGrid(boolean defaultSnapToGrid)

void

Deprecated.
Indicates whether scrolling this component should jump to a specific location in a
grid
setDefaultTensileDrag(boolean defaultTensileDrag)

void

Deprecated.
Indicates whether tensile drag should be active by default
setDisableColor(int disableColor)

void

Deprecated.
Simple setter to disable color
setFadeScrollBar(boolean fadeScrollBar)

void

Deprecated.
Indicates whether the scrollbar should fade when unused
setFadeScrollBarSpeed(int fadeScrollBarSpeed)

void

Deprecated.
setFadeScrollEdge(boolean fadeScrollEdge)

void

Deprecated.
Indicates whether the edge of a scrollable area should fade out
setFadeScrollEdgeLength(int fadeScrollEdgeLength)

void

Deprecated.
Indicates the width/height of the fading edge to indicate scrolling
setFG(Graphics g, Component c)

void

Deprecated.
Sets the foreground color and font for a generic component, reuse-able by most
component drawing code
setFocusScrolling(boolean focusScrolling)

void

Deprecated.
Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of
Codename One.
setMenuBarClass(Class menuBar)

void

Method Summary

Deprecated.
Simple setter for the MenuBar Class

911

Overview (Codename One API)


setMenuIcons(Image select, Image cancel, Image menu)

Deprecated.
Sets globally the Menu icons

void

setMenuRenderer(ListCellRenderer menuRenderer)

Deprecated.
Sets the Menu default renderer

void

setReverseSoftButtons(boolean reverseSoftButtons)

Deprecated.
Indicates whether softbuttons should be reversed from their default orientation

void

setRTL(boolean rtl)

Deprecated.
Sets this LookAndFeel to operate in right-to-left mode.

void

setTactileTouchDuration(int tactileTouchDuration)

Deprecated.
Allows defining a tactile touch device that vibrates when the user presses a
component that should respond with tactile feedback on a touch device (e.g.

void

setTextFieldCursorColor(int textFieldCursorColor)

Deprecated.
The color of the text field cursor

void

setTickerSpeed(long tickerSpeed)

Deprecated.
Sets the ticker speed

void

setTouchMenus(boolean touchMenus)

Deprecated.
use
Display.setCommandBehavior(Display.COMMAND_BEHAVIOR_TOUCH_MENU)

void

uninstall()

Deprecated.
Invoked when a look and feel is removed, allows a look and feel to release
resources related to binding components.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
LookAndFeel
public LookAndFeel(UIManager manager)

Deprecated.

Method Detail
bind
public void bind(Component cmp)

Deprecated.
Every component binds itself to the look and feel thus allowing the look and feel to
customize the component. Binding occurs at the end of the constructor when the
component is in a valid state and ready to be used. Notice that a component might be
bound twice or more and it is the responsibility of the LookAndFeel to protect against
that.
Parameters:
cmp - component instance that may be customized by the look and feel

Methods inherited from class java.lang.Object

912

Overview (Codename One API)


uninstall
public void uninstall()

Deprecated.
Invoked when a look and feel is removed, allows a look and feel to release resources
related to binding components.
See Also:
bind(Component)

drawButton
public abstract void drawButton(Graphics g,
Button b)

Deprecated. this method is no longer used by the implementation, we shifted code


away to improve performance
Invoked for drawing a button widget
Parameters:
g - graphics context
b - component to draw
drawCheckBox
public abstract void drawCheckBox(Graphics g,
Button cb)

Deprecated.
Invoked for drawing a checkbox widget
Parameters:
g - graphics context
cb - component to draw
drawComboBox
public abstract void drawComboBox(Graphics g,
List cb)

Deprecated.
Invoked for drawing a combo box widget
Parameters:
g - graphics context
cb - component to draw
drawLabel
public abstract void drawLabel(Graphics g,
Label l)

Deprecated. this method is no longer used by the implementation, we shifted code


away to improve performance
Invoked for drawing a label widget
Parameters:
g - graphics context
l - component to draw
drawList
public abstract void drawList(Graphics g,
List l)

Deprecated.
Invoked for drawing a list widget
Parameters:
g - graphics context
l - component to draw
drawRadioButton
public abstract void drawRadioButton(Graphics g,
Button rb)

Deprecated.
Invoked for drawing the radio button widget

Method Detail

913

Overview (Codename One API)


Parameters:
g - graphics context
rb - component to draw
drawTextArea
public abstract void drawTextArea(Graphics g,
TextArea ta)

Deprecated.
Draw the given text area
Parameters:
g - graphics context
ta - component to draw
drawTextField
public abstract void drawTextField(Graphics g,
TextArea ta)

Deprecated.
Draws the text field without its cursor which is drawn in a separate method input
mode indication can also be drawn using this method.
Parameters:
g - graphics context
ta - component to draw
drawTextFieldCursor
public abstract void drawTextFieldCursor(Graphics g,
TextArea ta)

Deprecated.
Draws the cursor of the text field, blinking is handled simply by avoiding a call to this
method.
Parameters:
g - graphics context
ta - component to draw
getButtonPreferredSize
public abstract Dimension getButtonPreferredSize(Button b)

Deprecated.
Calculate the preferred size of the component
Parameters:
b - component whose size should be calculated
Returns:
the preferred size for the button
getCheckBoxPreferredSize
public abstract Dimension getCheckBoxPreferredSize(Button cb)

Deprecated.
Calculate the preferred size of the component
Parameters:
cb - component whose size should be calculated
Returns:
the preferred size for the component
getLabelPreferredSize
public abstract Dimension getLabelPreferredSize(Label l)

Deprecated.
Calculate the preferred size of the component
Parameters:
l - component whose size should be calculated
Returns:
the preferred size for the component

Method Detail

914

Overview (Codename One API)


getListPreferredSize
public abstract Dimension getListPreferredSize(List l)

Deprecated.
Calculate the preferred size of the component
Parameters:
l - component whose size should be calculated
Returns:
the preferred size for the component
getRadioButtonPreferredSize
public abstract Dimension getRadioButtonPreferredSize(Button rb)

Deprecated.
Calculate the preferred size of the component
Parameters:
rb - component whose size should be calculated
Returns:
the preferred size for the component
getTextAreaSize
public abstract Dimension getTextAreaSize(TextArea ta,
boolean pref)

Deprecated.
Calculate the preferred size of the component
Parameters:
ta - component whose size should be calculated
pref - indicates whether preferred or scroll size should be returned
Returns:
the preferred size for the component
getTextFieldPreferredSize
public abstract Dimension getTextFieldPreferredSize(TextArea ta)

Deprecated.
Calculate the preferred size of the component
Parameters:
ta - component whose size should be calculated
Returns:
the preferred size for the component
getComboBoxPreferredSize
public abstract Dimension getComboBoxPreferredSize(List box)

Deprecated.
Calculate the preferred size of the component
Parameters:
box - component whose size should be calculated
Returns:
the preferred size for the component
drawVerticalScroll
public void drawVerticalScroll(Graphics g,
Component c,
float offsetRatio,
float blockSizeRatio)

Deprecated.
Draws a vertical scroll bar in the given component
Parameters:
g - graphics context
c - component to draw on
offsetRatio - ratio of the scroll bar from 0 to 1
blockSizeRatio - block size for the scroll from 0 to 1

Method Detail

915

Overview (Codename One API)


drawHorizontalScroll
public void drawHorizontalScroll(Graphics g,
Component c,
float offsetRatio,
float blockSizeRatio)

Deprecated.
Draws a horizontal scroll bar in the given component
Parameters:
g - graphics context
c - component to draw on
offsetRatio - ratio of the scroll bar from 0 to 1
blockSizeRatio - block size for the scroll from 0 to 1
setFG
public void setFG(Graphics g,
Component c)

Deprecated.
Sets the foreground color and font for a generic component, reuse-able by most
component drawing code
Parameters:
g - graphics context
c - component from which fg styles should be set
getVerticalScrollWidth
public int getVerticalScrollWidth()

Deprecated.
Returns the default width of a vertical scroll bar
Returns:
default width of a vertical scroll bar
getHorizontalScrollHeight
public int getHorizontalScrollHeight()

Deprecated.
Returns the default height of a horizontal scroll bar
Returns:
default height of a horizontal scroll bar
getDefaultFormTransitionIn
public Transition getDefaultFormTransitionIn()

Deprecated.
Allows us to define a default animation that will draw the transition for entering a form
Returns:
default transition
setDefaultFormTransitionIn
public void setDefaultFormTransitionIn(Transition defaultFormTransitionIn)

Deprecated.
Allows us to define a default animation that will draw the transition for entering a form
Parameters:
defaultFormTransitionIn - the default transition
getDefaultFormTransitionOut
public Transition getDefaultFormTransitionOut()

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a form
Returns:
default transition

Method Detail

916

Overview (Codename One API)


setDefaultFormTransitionOut
public void setDefaultFormTransitionOut(Transition defaultFormTransitionOut)

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a form
Parameters:
defaultFormTransitionOut - the default transition
getDefaultMenuTransitionIn
public Transition getDefaultMenuTransitionIn()

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
Menu
Returns:
default transition
setDefaultMenuTransitionIn
public void setDefaultMenuTransitionIn(Transition defaultMenuTransitionIn)

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
Menu
Parameters:
defaultMenuTransitionIn - the default transition
getDefaultMenuTransitionOut
public Transition getDefaultMenuTransitionOut()

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a Menu
Returns:
default transition
setDefaultMenuTransitionOut
public void setDefaultMenuTransitionOut(Transition defaultMenuTransitionOut)

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a Menu
Parameters:
defaultMenuTransitionOut - the default transition
getDefaultDialogTransitionIn
public Transition getDefaultDialogTransitionIn()

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
dialog
Returns:
default transition
setDefaultDialogTransitionIn
public void setDefaultDialogTransitionIn(Transition defaultDialogTransitionIn)

Deprecated.
Allows us to define a default animation that will draw the transition for entering a
dialog
Parameters:
defaultDialogTransitionIn - the default transition
getDefaultDialogTransitionOut
public Transition getDefaultDialogTransitionOut()

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a dialog
Returns:

Method Detail

917

Overview (Codename One API)


default transition
setDefaultDialogTransitionOut
public void setDefaultDialogTransitionOut(Transition defaultDialogTransitionOut)

Deprecated.
Allows us to define a default animation that will draw the transition for exiting a dialog
Parameters:
defaultDialogTransitionOut - the default transition
getDefaultFormTintColor
public int getDefaultFormTintColor()

Deprecated.
Tint color is set when a form is partially covered be it by a menu or by a dialog. A look
and feel can override this default value.
Returns:
default tint color
setDefaultFormTintColor
public void setDefaultFormTintColor(int defaultFormTintColor)

Deprecated.
Tint color is set when a form is partially covered be it by a menu or by a dialog. A look
and feel can override this default value.
Parameters:
defaultFormTintColor - the default tint color
getDisableColor
public int getDisableColor()

Deprecated.
This color is used to paint disable mode text color.
Returns:
the color value
setDisableColor
public void setDisableColor(int disableColor)

Deprecated.
Simple setter to disable color
Parameters:
disableColor - the disable color value
isDefaultSmoothScrolling
public boolean isDefaultSmoothScrolling()

Deprecated.
Indicates whether lists and containers should have smooth scrolling by default
Returns:
true if smooth scrolling should be on by default
setDefaultSmoothScrolling
public void setDefaultSmoothScrolling(boolean defaultSmoothScrolling)

Deprecated.
Indicates whether lists and containers should have smooth scrolling by default
Parameters:
defaultSmoothScrolling - true if smooth scrolling should be on by default
getDefaultSmoothScrollingSpeed
public int getDefaultSmoothScrollingSpeed()

Deprecated.
Indicates the default speed for smooth scrolling
Returns:
speed for smooth scrollin

Method Detail

918

Overview (Codename One API)


setDefaultSmoothScrollingSpeed
public void setDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed)

Deprecated.
Indicates the default speed for smooth scrolling
Parameters:
defaultSmoothScrollingSpeed - speed for smooth scrollin
isReverseSoftButtons
public boolean isReverseSoftButtons()

Deprecated.
Indicates whether softbuttons should be reversed from their default orientation
Returns:
true if softbuttons should be reversed
setReverseSoftButtons
public void setReverseSoftButtons(boolean reverseSoftButtons)

Deprecated.
Indicates whether softbuttons should be reversed from their default orientation
Parameters:
reverseSoftButtons - true if softbuttons should be reversed
getMenuBarClass
public Class getMenuBarClass()

Deprecated.
This method returns the MenuBar class.
Returns:
the MenuBar class.
setMenuBarClass
public void setMenuBarClass(Class menuBar)

Deprecated.
Simple setter for the MenuBar Class
Parameters:
menuBar getMenuRenderer
public ListCellRenderer getMenuRenderer()

Deprecated.
Returns the Menu default renderer
Returns:
default renderer for the menu
setMenuRenderer
public void setMenuRenderer(ListCellRenderer menuRenderer)

Deprecated.
Sets the Menu default renderer
Parameters:
menuRenderer - default renderer for the menu
setMenuIcons
public void setMenuIcons(Image select,
Image cancel,
Image menu)

Deprecated.
Sets globally the Menu icons
Parameters:
select - select icon
cancel - cancel icon

Method Detail

919

Overview (Codename One API)


menu - menu icon
getMenuIcons
public Image[] getMenuIcons()

Deprecated.
Simple getter for the menu icons
Returns:
an Image array at size of 3, where the first is the select image the second is
the cancel image and the last is the menu image.
getTickerSpeed
public long getTickerSpeed()

Deprecated.
Gets the ticker speed
Returns:
ticker speed in milliseconds
setTickerSpeed
public void setTickerSpeed(long tickerSpeed)

Deprecated.
Sets the ticker speed
Parameters:
tickerSpeed

- the speed in milliseconds

refreshTheme
public void refreshTheme(boolean completeClear)

Deprecated.
This method is a callback to the LookAndFeel when a theme is being changed in the
UIManager
Parameters:
completeClear - indicates that the theme is set and not added
isTouchMenus
public boolean isTouchMenus()

Deprecated. use Display.getCommandBehavior() ==


Display.COMMAND_BEHAVIOR_TOUCH_MENU
Indicates whether the menu UI should target a touch based device or a standard cell
phone
Returns:
true for touch menus
setTouchMenus
public void setTouchMenus(boolean touchMenus)

Deprecated. use
Display.setCommandBehavior(Display.COMMAND_BEHAVIOR_TOUCH_MENU)
Indicates whether the menu UI should target a touch based device or a standard cell
phone
Parameters:
touchMenus - true to enable touch menus false to disable
setRTL
public void setRTL(boolean rtl)

Deprecated.
Sets this LookAndFeel to operate in right-to-left mode.
Parameters:
rtl - - true if right-to-left, false if left-to-right

Method Detail

920

Overview (Codename One API)


isRTL
public boolean isRTL()

Deprecated.
Use this to check if the LookAndFeel is in RTL mode
Returns:
true if the LookAndFeel is in right-to-left mode, false otherwise
getTactileTouchDuration
public int getTactileTouchDuration()

Deprecated.
Allows defining a tactile touch device that vibrates when the user presses a
component that should respond with tactile feedback on a touch device (e.g. vibrate).
Setting this to 0 disables tactile feedback completely
Returns:
the tactileTouchDuration
setTactileTouchDuration
public void setTactileTouchDuration(int tactileTouchDuration)

Deprecated.
Allows defining a tactile touch device that vibrates when the user presses a
component that should respond with tactile feedback on a touch device (e.g. vibrate).
Setting this to 0 disables tactile feedback completely
Parameters:
tactileTouchDuration - the duration of vibration
isDefaultEndsWith3Points
public boolean isDefaultEndsWith3Points()

Deprecated.
Indicates whether labels should end with 3 points by default
Returns:
whether labels should end with 3 points by default
setDefaultEndsWith3Points
public void setDefaultEndsWith3Points(boolean defaultEndsWith3Points)

Deprecated.
Indicates whether labels should end with 3 points by default
Parameters:
defaultEndsWith3Points - True to indicates that labels should end with 3
points by default
isDefaultTensileDrag
public boolean isDefaultTensileDrag()

Deprecated.
Indicates whether tensile drag should be active by default
Returns:
whether tensile drag should be active by default
setDefaultTensileDrag
public void setDefaultTensileDrag(boolean defaultTensileDrag)

Deprecated.
Indicates whether tensile drag should be active by default
Parameters:
defaultTensileDrag - true if tensile drag should be active by default
isFocusScrolling
public boolean isFocusScrolling()

Deprecated.

Method Detail

921

Overview (Codename One API)


Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of Codename
One.
Returns:
true if focus scrolling is enabled
setFocusScrolling
public void setFocusScrolling(boolean focusScrolling)

Deprecated.
Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of Codename
One.
Parameters:
focusScrolling - true to enable focus scrolling
isFadeScrollEdge
public boolean isFadeScrollEdge()

Deprecated.
Indicates whether the edge of a scrollable area should fade out
Returns:
the fadeScrollEdge
setFadeScrollEdge
public void setFadeScrollEdge(boolean fadeScrollEdge)

Deprecated.
Indicates whether the edge of a scrollable area should fade out
Parameters:
fadeScrollEdge - the fadeScrollEdge to set
isFadeScrollBar
public boolean isFadeScrollBar()

Deprecated.
Indicates whether the scrollbar should fade when unused
Returns:
the fadeScrollBar
setFadeScrollBar
public void setFadeScrollBar(boolean fadeScrollBar)

Deprecated.
Indicates whether the scrollbar should fade when unused
Parameters:
fadeScrollBar - the fadeScrollBar to set
getFadeScrollEdgeLength
public int getFadeScrollEdgeLength()

Deprecated.
Indicates the width/height of the fading edge to indicate scrolling
Returns:
the fadeScrollEdgeLength
setFadeScrollEdgeLength
public void setFadeScrollEdgeLength(int fadeScrollEdgeLength)

Deprecated.
Indicates the width/height of the fading edge to indicate scrolling
Parameters:
fadeScrollEdgeLength - the fadeScrollEdgeLength to set

Method Detail

922

Overview (Codename One API)


getTextFieldCursorColor
public int getTextFieldCursorColor()

Deprecated.
The color of the text field cursor
Returns:
the textFieldCursorColor
setTextFieldCursorColor
public void setTextFieldCursorColor(int textFieldCursorColor)

Deprecated.
The color of the text field cursor
Parameters:
textFieldCursorColor - the textFieldCursorColor to set
isDefaultSnapToGrid
public boolean isDefaultSnapToGrid()

Deprecated.
Indicates whether scrolling this component should jump to a specific location in a grid
Returns:
the defaultSnapToGrid
setDefaultSnapToGrid
public void setDefaultSnapToGrid(boolean defaultSnapToGrid)

Deprecated.
Indicates whether scrolling this component should jump to a specific location in a grid
Parameters:
defaultSnapToGrid - the defaultSnapToGrid to set
isDefaultAlwaysTensile
public boolean isDefaultAlwaysTensile()

Deprecated.
Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Returns:
the defaultAlwaysTensile
setDefaultAlwaysTensile
public void setDefaultAlwaysTensile(boolean defaultAlwaysTensile)

Deprecated.
Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Parameters:
defaultAlwaysTensile - the defaultAlwaysTensile to set
isDefaultTensileHighlight
public boolean isDefaultTensileHighlight()

Deprecated.
Indicates whether tensile highlight should be active by default
Returns:
the defaultTensileHighlight
paintTensileHighlight
public void paintTensileHighlight(Component t,
Graphics g,
boolean top,
int opacity)

Deprecated.
Paints the tensile hightlight image

Method Detail

923

Overview (Codename One API)


Parameters:
g - graphics destination for the tensile highlight image
top - destination of the tensile highlight image
opacity - the opacity of the image
getFadeScrollBarSpeed
public int getFadeScrollBarSpeed()

Deprecated.
Returns:
the fadeScrollBarSpeed
isScrollVisible
public boolean isScrollVisible()

Deprecated.
Returns:
scrollVisible
setFadeScrollBarSpeed
public void setFadeScrollBarSpeed(int fadeScrollBarSpeed)

Deprecated.
Parameters:
fadeScrollBarSpeed - the fadeScrollBarSpeed to set
isBackgroundImageDetermineSize
public boolean isBackgroundImageDetermineSize()

Deprecated.
Indicates if the bg image of a style should determine the minimum preferred size
according to the theme
Returns:
the backgroundImageDetermineSize
setBackgroundImageDetermineSize
public void setBackgroundImageDetermineSize(boolean backgroundImageDetermineSize)

Deprecated.
Indicates if the bg image of a style should determine the minimum preferred size
according to the theme
Parameters:
backgroundImageDetermineSize - the backgroundImageDetermineSize to set
drawPullToRefresh
public abstract void drawPullToRefresh(Graphics g,
Component cmp,
boolean taskExecuted)

Deprecated.
Paints the pull to refresh
Parameters:
g - graphics context
cmp - the Component which we draw the pull to refresh beneath it
taskExecuted - an indication if the refresh task is currently running
getPullToRefreshHeight
public abstract int getPullToRefreshHeight()

Deprecated.
Returns the required height of the pull to refresh feature

Method Detail

924

Overview (Codename One API)


com.codename1.ui.plaf

Class DefaultLookAndFeel
java.lang.Object

com.codename1.ui.plaf.LookAndFeel

com.codename1.ui.plaf.DefaultLookAndFeel
All Implemented Interfaces:
FocusListener
Deprecated.
this class is still crucial for some features in Codename One. The deprecation is here to indicate our
desire to reduce usage/reliance on this class.
public class
extends LookAndFeel
implements FocusListener

Used to render the default look of Codename One

Constructor Summary
Constructor and Description
DefaultLookAndFeel(UIManager manager)

Deprecated.
Creates a new instance of DefaultLookAndFeel

Method Summary
Modifier and
Type

Method and Description


bind(Component cmp)

void

Deprecated.
Every component binds itself to the look and feel thus allowing the look and
feel to customize the component.
drawButton(Graphics g, Button b)

void

Deprecated.
this method is no longer used by the implementation, we shifted code away to
improve performance
drawCheckBox(Graphics g, Button cb)

void

Deprecated.
Invoked for drawing a checkbox widget
drawComboBox(Graphics g, List cb)

void

Deprecated.
Invoked for drawing a combo box widget
drawLabel(Graphics g, Label l)

void

protected
int

Deprecated.
this method is no longer used by the implementation, we shifted code away to
improve performance
drawLabelText(Graphics g, Label l, String text, int x, int y,
int textSpaceW)

Deprecated.
Draws the text of a label
drawList(Graphics g, List l)

void

Deprecated.
Invoked for drawing a list widget

void

drawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted)

Deprecated.

Class DefaultLookAndFeel

925

Overview (Codename One API)


Paints the pull to refresh
drawRadioButton(Graphics g, Button rb)
void

Deprecated.
Invoked for drawing the radio button widget
drawTextArea(Graphics g, TextArea ta)

void

Deprecated.
Draw the given text area
drawTextField(Graphics g, TextArea ta)

void

Deprecated.
Draws the text field without its cursor which is drawn in a separate method
input mode indication can also be drawn using this method.
drawTextFieldCursor(Graphics g, TextArea ta)

void

Deprecated.
Draws the cursor of the text field, blinking is handled simply by avoiding a call
to this method.
focusGained(Component cmp)

void

Deprecated.
Invoked when component gains focus
focusLost(Component cmp)

void

Deprecated.
Invoked when component loses focus
getButtonPreferredSize(Button b)

Dimension

Deprecated.
Calculate the preferred size of the component
getCheckBoxFocusImages()

Image[]

Deprecated.
Returns the images used to represent the checkbox when focused
getCheckBoxImages()

Image[]

Deprecated.
Returns the images used to represent the checkbox (selected followed by
unselected).
getCheckBoxPreferredSize(Button cb)

Dimension

Deprecated.
Calculate the preferred size of the component
getComboBoxPreferredSize(List cb)

Dimension

Deprecated.
Calculate the preferred size of the component
getLabelPreferredSize(Label l)

Dimension

Deprecated.
Calculate the preferred size of the component
getListPreferredSize(List l)

Dimension

Deprecated.
Calculate the preferred size of the component
getPullToRefreshHeight()

int

Deprecated.
Returns the required height of the pull to refresh feature
getRadioButtonFocusImages()

Image[]

Deprecated.
Returns the images used to represent the radio button when in focused mode
getRadioButtonImages()

Image[]

Deprecated.
Returns the images used to represent the radio button (selected followed by
unselected).
getRadioButtonPreferredSize(Button rb)

Dimension

Deprecated.
Calculate the preferred size of the component
getTextAreaSize(TextArea ta, boolean pref)

Dimension

Deprecated.
Calculate the preferred size of the component

Dimension

getTextFieldPreferredSize(TextArea ta)

Method Summary

926

Overview (Codename One API)


Deprecated.
Calculate the preferred size of the component
protected
String

getTextFieldString(TextArea ta)

Deprecated.
Similar to getText() but works properly with password fields
isTickWhenFocused()

boolean

Deprecated.
This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to
start ticking when the text is too long.
refreshTheme(boolean b)

Deprecated.
This method is a callback to the LookAndFeel when a theme is being changed
in the UIManager

void

setCheckBoxFocusImages(Image checkedX, Image uncheckedX,


Image disabledChecked, Image disabledUnchecked)

void

Deprecated.
Sets images for checkbox when in focused mode
setCheckBoxImages(Image checkedX, Image uncheckedX)

Deprecated.
Sets images for checkbox checked/unchecked modes

void

setCheckBoxImages(Image checkedX, Image uncheckedX,


Image disabledChecked, Image disabledUnchecked)

void

Deprecated.
Sets images for checkbox checked/unchecked modes
setComboBoxImage(Image picker)

Deprecated.
Sets image for the combo box dropdown drawing

void

setPasswordChar(char c)

Deprecated.
Sets the password character to display in the TextArea and the TextField

void

setRadioButtonFocusImages(Image selected, Image unselected,


Image disabledSelected, Image disabledUnselected)

Deprecated.
Sets images for radio button selected/unselected and disabled modes, when
the radio button has focus, these are entirely optional

void

setRadioButtonImages(Image selected, Image unselected)

Deprecated.
Sets images for radio button selected/unselected modes

void

setRadioButtonImages(Image selected, Image unselected,


Image disabledSelected, Image disabledUnselected)

void

Deprecated.
Sets images for radio button selected/unselected modes
setTickWhenFocused(boolean tickWhenFocused)

Deprecated.
This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to
start ticking when the text is too long.

void

Methods inherited from


class com.codename1.ui.plaf.LookAndFeel
drawHorizontalScroll, drawVerticalScroll, getDefaultDialogTransitionIn,
getDefaultDialogTransitionOut, getDefaultFormTintColor,
getDefaultFormTransitionIn, getDefaultFormTransitionOut,
getDefaultMenuTransitionIn, getDefaultMenuTransitionOut,
getDefaultSmoothScrollingSpeed, getDisableColor, getFadeScrollBarSpeed,
getFadeScrollEdgeLength, getHorizontalScrollHeight, getMenuBarClass,
getMenuIcons, getMenuRenderer, getTactileTouchDuration,
getTextFieldCursorColor, getTickerSpeed, getVerticalScrollWidth,
isBackgroundImageDetermineSize, isDefaultAlwaysTensile,
isDefaultEndsWith3Points, isDefaultSmoothScrolling, isDefaultSnapToGrid,
isDefaultTensileDrag, isDefaultTensileHighlight, isFadeScrollBar,
isFadeScrollEdge, isFocusScrolling, isReverseSoftButtons, isRTL,
isScrollVisible, isTouchMenus, paintTensileHighlight,
setBackgroundImageDetermineSize, setDefaultAlwaysTensile,
setDefaultDialogTransitionIn, setDefaultDialogTransitionOut,

Methods inherited from class com.codename1.ui.plaf.LookAndFeel

927

Overview (Codename One API)


setDefaultEndsWith3Points, setDefaultFormTintColor,
setDefaultFormTransitionIn, setDefaultFormTransitionOut,
setDefaultMenuTransitionIn, setDefaultMenuTransitionOut,
setDefaultSmoothScrolling, setDefaultSmoothScrollingSpeed,
setDefaultSnapToGrid, setDefaultTensileDrag, setDisableColor,
setFadeScrollBar, setFadeScrollBarSpeed, setFadeScrollEdge,
setFadeScrollEdgeLength, setFG, setFocusScrolling, setMenuBarClass,
setMenuIcons, setMenuRenderer, setReverseSoftButtons, setRTL,
setTactileTouchDuration, setTextFieldCursorColor, setTickerSpeed,
setTouchMenus, uninstall

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DefaultLookAndFeel
public DefaultLookAndFeel(UIManager manager)

Deprecated.
Creates a new instance of DefaultLookAndFeel

Method Detail
bind
public void bind(Component cmp)

Deprecated.
Every component binds itself to the look and feel thus allowing the look and feel to
customize the component. Binding occurs at the end of the constructor when the
component is in a valid state and ready to be used. Notice that a component might be
bound twice or more and it is the responsibility of the LookAndFeel to protect against
that.
Overrides:
bind in class LookAndFeel
Parameters:
cmp - component instance that may be customized by the look and feel
setTickWhenFocused
public void setTickWhenFocused(boolean tickWhenFocused)

Deprecated.
This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start
ticking when the text is too long.
Parameters:
tickWhenFocused isTickWhenFocused
public boolean isTickWhenFocused()

Deprecated.
This method allows to set all Labels, Buttons, CheckBoxes, RadioButtons to start
ticking when the text is too long.
Returns:
tickWhenFocused
setCheckBoxImages
public void setCheckBoxImages(Image checkedX,
Image uncheckedX)

Deprecated.
Sets images for checkbox checked/unchecked modes

Methods inherited from class java.lang.Object

928

Overview (Codename One API)


Parameters:
checkedX - the image to draw in order to represent a checked checkbox
uncheckedX - the image to draw in order to represent an uncheck checkbox

setCheckBoxImages
public void setCheckBoxImages(Image
Image
Image
Image

checkedX,
uncheckedX,
disabledChecked,
disabledUnchecked)

Deprecated.
Sets images for checkbox checked/unchecked modes
Parameters:
checkedX - the image to draw in order to represent a checked checkbox
uncheckedX - the image to draw in order to represent an uncheck checkbox
disabledChecked - same as checked for the disabled state
disabledUnchecked - same as unchecked for the disabled state
setCheckBoxFocusImages
public void setCheckBoxFocusImages(Image
Image
Image
Image

checkedX,
uncheckedX,
disabledChecked,
disabledUnchecked)

Deprecated.
Sets images for checkbox when in focused mode
Parameters:
checkedX - the image to draw in order to represent a checked checkbox
uncheckedX - the image to draw in order to represent an uncheck checkbox
disabledChecked - same as checked for the disabled state
disabledUnchecked - same as unchecked for the disabled state
setComboBoxImage
public void setComboBoxImage(Image picker)

Deprecated.
Sets image for the combo box dropdown drawing
Parameters:
picker - picker image
setRadioButtonImages
public void setRadioButtonImages(Image selected,
Image unselected)

Deprecated.
Sets images for radio button selected/unselected modes
Parameters:
selected - the image to draw in order to represent a selected radio button
unselected - the image to draw in order to represent an unselected radio
button
setRadioButtonImages
public void setRadioButtonImages(Image
Image
Image
Image

selected,
unselected,
disabledSelected,
disabledUnselected)

Deprecated.
Sets images for radio button selected/unselected modes
Parameters:
selected - the image to draw in order to represent a selected radio button
unselected - the image to draw in order to represent an unselected radio
button
disabledSelected - same as selected for the disabled state
disabledUnselected - same as unselected for the disabled state

Method Detail

929

Overview (Codename One API)


setRadioButtonFocusImages
public void setRadioButtonFocusImages(Image
Image
Image
Image

selected,
unselected,
disabledSelected,
disabledUnselected)

Deprecated.
Sets images for radio button selected/unselected and disabled modes, when the
radio button has focus, these are entirely optional
Parameters:
selected - the image to draw in order to represent a selected radio button
unselected - the image to draw in order to represent an unselected radio
button
disabledSelected - same as selected for the disabled state
disabledUnselected - same as unselected for the disabled state
setPasswordChar
public void setPasswordChar(char c)

Deprecated.
Sets the password character to display in the TextArea and the TextField
Parameters:
the - char to display
getRadioButtonImages
public Image[] getRadioButtonImages()

Deprecated.
Returns the images used to represent the radio button (selected followed by
unselected).
Returns:
images representing the radio button or null for using the default drawing
getRadioButtonFocusImages
public Image[] getRadioButtonFocusImages()

Deprecated.
Returns the images used to represent the radio button when in focused mode
Returns:
images representing the radio button or null for using the default drawing
getCheckBoxImages
public Image[] getCheckBoxImages()

Deprecated.
Returns the images used to represent the checkbox (selected followed by
unselected).
Returns:
images representing the check box or null for using the default drawing
getCheckBoxFocusImages
public Image[] getCheckBoxFocusImages()

Deprecated.
Returns the images used to represent the checkbox when focused
Returns:
images representing the check box or null for using the default drawing
drawButton
public void drawButton(Graphics g,
Button b)

Deprecated. this method is no longer used by the implementation, we shifted code


away to improve performance
Invoked for drawing a button widget
Specified by:

Method Detail

930

Overview (Codename One API)


drawButton in class LookAndFeel
Parameters:
g - graphics context
b - component to draw
drawCheckBox
public void drawCheckBox(Graphics g,
Button cb)

Deprecated.
Invoked for drawing a checkbox widget
Specified by:
drawCheckBox in class LookAndFeel
Parameters:
g - graphics context
cb - component to draw
drawLabel
public void drawLabel(Graphics g,
Label l)

Deprecated. this method is no longer used by the implementation, we shifted code


away to improve performance
Invoked for drawing a label widget
Specified by:
drawLabel in class LookAndFeel
Parameters:
g - graphics context
l - component to draw
drawRadioButton
public void drawRadioButton(Graphics g,
Button rb)

Deprecated.
Invoked for drawing the radio button widget
Specified by:
drawRadioButton in class LookAndFeel
Parameters:
g - graphics context
rb - component to draw
drawComboBox
public void drawComboBox(Graphics g,
List cb)

Deprecated.
Invoked for drawing a combo box widget
Specified by:
drawComboBox in class LookAndFeel
Parameters:
g - graphics context
cb - component to draw
drawList
public void drawList(Graphics g,
List l)

Deprecated.
Invoked for drawing a list widget
Specified by:
drawList in class LookAndFeel
Parameters:
g - graphics context
l - component to draw

Method Detail

931

Overview (Codename One API)


drawTextArea
public void drawTextArea(Graphics g,
TextArea ta)

Deprecated.
Draw the given text area
Specified by:
drawTextArea in class LookAndFeel
Parameters:
g - graphics context
ta - component to draw
getButtonPreferredSize
public Dimension getButtonPreferredSize(Button b)

Deprecated.
Calculate the preferred size of the component
Specified by:
getButtonPreferredSize in class LookAndFeel
Parameters:
b - component whose size should be calculated
Returns:
the preferred size for the button
getCheckBoxPreferredSize
public Dimension getCheckBoxPreferredSize(Button cb)

Deprecated.
Calculate the preferred size of the component
Specified by:
getCheckBoxPreferredSize in class LookAndFeel
Parameters:
cb - component whose size should be calculated
Returns:
the preferred size for the component
getLabelPreferredSize
public Dimension getLabelPreferredSize(Label l)

Deprecated.
Calculate the preferred size of the component
Specified by:
getLabelPreferredSize in class LookAndFeel
Parameters:
l - component whose size should be calculated
Returns:
the preferred size for the component
getListPreferredSize
public Dimension getListPreferredSize(List l)

Deprecated.
Calculate the preferred size of the component
Specified by:
getListPreferredSize in class LookAndFeel
Parameters:
l - component whose size should be calculated
Returns:
the preferred size for the component
getRadioButtonPreferredSize
public Dimension getRadioButtonPreferredSize(Button rb)

Deprecated.
Calculate the preferred size of the component
Specified by:

Method Detail

932

Overview (Codename One API)


getRadioButtonPreferredSize in class LookAndFeel
Parameters:
rb - component whose size should be calculated
Returns:
the preferred size for the component
getTextAreaSize
public Dimension getTextAreaSize(TextArea ta,
boolean pref)

Deprecated.
Calculate the preferred size of the component
Specified by:
getTextAreaSize in class LookAndFeel
Parameters:
ta - component whose size should be calculated
pref - indicates whether preferred or scroll size should be returned
Returns:
the preferred size for the component
drawLabelText
protected int drawLabelText(Graphics g,
Label l,
String text,
int x,
int y,
int textSpaceW)

Deprecated.
Draws the text of a label
Parameters:
g - graphics context
l - label component
text - the text for the label
x - position for the label
y - position for the label
textSpaceW - the width available for the component
Returns:
the space used by the drawing
getComboBoxPreferredSize
public Dimension getComboBoxPreferredSize(List cb)

Deprecated.
Calculate the preferred size of the component
Specified by:
getComboBoxPreferredSize in class LookAndFeel
Parameters:
cb - component whose size should be calculated
Returns:
the preferred size for the component
getTextFieldString
protected String getTextFieldString(TextArea ta)

Deprecated.
Similar to getText() but works properly with password fields
drawTextField
public void drawTextField(Graphics g,
TextArea ta)

Deprecated.
Draws the text field without its cursor which is drawn in a separate method input
mode indication can also be drawn using this method.
Specified by:
drawTextField in class LookAndFeel

Method Detail

933

Overview (Codename One API)


Parameters:
g - graphics context
ta - component to draw
getTextFieldPreferredSize
public Dimension getTextFieldPreferredSize(TextArea ta)

Deprecated.
Calculate the preferred size of the component
Specified by:
getTextFieldPreferredSize in class LookAndFeel
Parameters:
ta - component whose size should be calculated
Returns:
the preferred size for the component
drawTextFieldCursor
public void drawTextFieldCursor(Graphics g,
TextArea ta)

Deprecated.
Draws the cursor of the text field, blinking is handled simply by avoiding a call to this
method.
Specified by:
drawTextFieldCursor in class LookAndFeel
Parameters:
g - graphics context
ta - component to draw
drawPullToRefresh
public void drawPullToRefresh(Graphics g,
Component cmp,
boolean taskExecuted)

Deprecated.
Paints the pull to refresh
Specified by:
drawPullToRefresh in class LookAndFeel
Parameters:
g - graphics context
cmp - the Component which we draw the pull to refresh beneath it
taskExecuted - an indication if the refresh task is currently running
getPullToRefreshHeight
public int getPullToRefreshHeight()

Deprecated.
Returns the required height of the pull to refresh feature
Specified by:
getPullToRefreshHeight in class LookAndFeel
focusGained
public void focusGained(Component cmp)

Deprecated.
Invoked when component gains focus
Specified by:
focusGained in interface FocusListener
Parameters:
cmp - the component that gains focus
focusLost
public void focusLost(Component cmp)

Deprecated.
Invoked when component loses focus
Specified by:

Method Detail

934

Overview (Codename One API)


focusLost in interface FocusListener
Parameters:
cmp - the component that lost focus
refreshTheme
public void refreshTheme(boolean b)

Deprecated.
This method is a callback to the LookAndFeel when a theme is being changed in the
UIManager
Overrides:
refreshTheme in class LookAndFeel
Parameters:
b - indicates that the theme is set and not added

Method Detail

935

Overview (Codename One API)


com.codename1.ui.plaf

Class Border
java.lang.Object

com.codename1.ui.plaf.Border

public class
extends Object

Base class that allows us to render a border for a component, a border is drawn before the
component and is drawn within the padding region of the component. It is the responsibility of the
component not to draw outside of the border line.
This class can be extended to provide additional border types and custom made border types.
A border can optionally paint the background of the component, this depends on the border type and
is generally required for rounded borders that "know" the area that should be filled.

Constructor Summary
Modifier

Constructor and Description


Border()

protected

Prevents usage of new operator, use the factory methods in the class or
subclass to create new border types.

Method Summary
Modifier
and Type
void

Method and Description


addOuterBorder(Border outer)

Adss a border that wraps this border


clearImageBorderSpecialTile()

void

static
Border
static
Border
static
Border
static
Border

static
Border

Class Border

Cleans the tile tracking state allowing the garbage collector to pick up the
component and the image data
createBevelLowered()

Creates a lowered bevel border with default colors, highlight is derived from the
component and shadow is a plain dark color
createBevelLowered(int highlightOuter, int highlightInner,
int shadowOuter, int shadowInner)

Creates a raised bevel border with the given colors


createBevelRaised()

Creates a lowered bevel border with default colors, highlight is derived from the
component and shadow is a plain dark color
createBevelRaised(int highlightOuter, int highlightInner,
int shadowOuter, int shadowInner)

Creates a raised bevel border with the given colors


createCompoundBorder(Border top, Border bottom, Border left,
Border right)

Creates a border that is comprised of multiple border types so one border type
can be used on top while another one can be used at the bottom.

static
Border

createDashedBorder(int thickness)

static
Border

createDashedBorder(int thickness, int color)

static
Border

createDottedBorder(int thickness)

Creates a dashed border with the specified thickness and the theme colors
Creates a dashed border with the specified thickness and color
Creates a dotted border with the specified thickness and the theme colors

936

Overview (Codename One API)


static
Border

createDottedBorder(int thickness, int color)

static
Border

createDoubleBorder(int thickness)

static
Border

createDoubleBorder(int thickness, int color)

static
Border
static
Border
static
Border
static
Border

Creates a dotted border with the specified thickness and color


Creates a double border with the specified thickness and color
Creates a double border with the specified thickness and color
createEmpty()

Creates an empty border, this is useful where we don't want a border for a
component but want a focus border etc...
createEtchedLowered()

Creates a lowered etched border with default colors, highlight is derived from the
component and shadow is a plain dark color
createEtchedLowered(int highlight, int shadow)

Creates a raised etched border with the given colors


createEtchedRaised()

Creates a lowered etched border with default colors, highlight is derived from the
component and shadow is a plain dark color

static
Border

createEtchedRaised(int highlight, int shadow)

static
Border

createGrooveBorder(int thickness)

static
Border

createGrooveBorder(int thickness, int color)

static
Border

createHorizonalImageBorder(Image left, Image right, Image center)

static
Border

static
Border

static
Border

Creates a raised etched border with the given colors


Creates a groove border with the specified thickness and theme colors
Creates a groove border with the specified thickness and color
This is an image border that can only grow horizontally
createImageBorder(Image top, Image topLeft, Image background)

The given images are tiled appropriately across the matching side of the border,
rotated and placed as expected in the four corners.
createImageBorder(Image top, Image bottom, Image left, Image right,
Image topLeft, Image topRight, Image bottomLeft, Image bottomRight,
Image background)

The given top/bottom/left/right images are tiled appropriately across the matching
sides of the border and the corners are placed as expected in the four corners.
createImageScaledBorder(Image top, Image bottom, Image left,
Image right, Image topLeft, Image topRight, Image bottomLeft,
Image bottomRight, Image background)

The given top/bottom/left/right images are scaled appropriately across the


matching sides of the border and the corners are placed as expected in the four
corners.

static
Border

createInsetBorder(int thickness)

static
Border

createInsetBorder(int thickness, int color)

static
Border

Creates an inset border with the specified thickness and theme colors
Creates an inset border with the specified thickness and color
createLineBorder(int thickness)

Creates a line border that uses the color of the component foreground for
drawing

static
Border

createLineBorder(int thickness, int color)

static
Border

createLineBorder(int thickness, int color, String title)

static
Border

createLineBorder(int thickness, String title)

static
Border

createOutsetBorder(int thickness)

static
Border

createOutsetBorder(int thickness, int color)

Creates a line border that uses the given color for the component
Creates a line border that uses the given color for the component
Creates a line border with the specified title
Creates an outset border with the specified thickness and theme colors
Creates an outset border with the specified thickness and color
createPressedVersion()

Border

When applied to buttons borders produce a version that reverses the effects of
the border providing a pressed feel
createRidgeBorder(int thickness)

Method Summary

937

Overview (Codename One API)


static
Border

Creates a ridge border with the specified thickness and theme colors

static
Border

createRidgeBorder(int thickness, int color)

Creates a ridge border with the specified thickness and color


createRoundBorder(int arcWidth, int arcHeight)

static
Border

Deprecated.
the performance of round rect borders is REALLY slow, we recommend people
use image borders which are faster, more portable and better looking
createRoundBorder(int arcWidth, int arcHeight, boolean outline)

static
Border

Deprecated.
the performance of round rect borders is REALLY slow, we recommend people
use image borders which are faster, more portable and better looking
createRoundBorder(int arcWidth, int arcHeight, int color)

static
Border

Deprecated.
the performance of round rect borders is REALLY slow, we recommend people
use image borders which are faster, more portable and better looking
createRoundBorder(int arcWidth, int arcHeight, int color,
boolean outline)

static
Border

Deprecated.
the performance of round rect borders is REALLY slow, we recommend people
use image borders which are faster, more portable and better looking

static
Border

createVerticalImageBorder(Image top, Image bottom, Image center)

boolean
Border[]
static
Border
static
Border

This is an image border that can only grow vertically


equals(Object obj)

{Indicates whether some other object is "equal to" this one.}


getCompoundBorders()

This method returns the Compound Borders array.


getDefaultBorder()

Gets the default border to the given value


getEmpty()

Deprecated.
use createEmpty instead
getFocusedInstance()

Border

Deprecated.
use the getSelectedStyle() method in the component class
getMinimumHeight()

int

Returns the minimum size required to properly display this border, normally this
is 0 but a border might deem itself undisplayable with too small a size e.g.
getMinimumWidth()

int

Border
Object

Returns the minimum size required to properly display this border, normally this
is 0 but a border might deem itself undisplayable with too small a size e.g.
getPressedInstance()

Returns the pressed version of the border if one is set by the user
getProperty(String n)

This method is for internal usage only!


getThickness()

int

This method returns how thick is the border in pixels, notice this doesn't apply to
most border types
isBackgroundPainter()

boolean

boolean

Returns true if installing this border will override the painting of the component
background
isEmptyBorder()

Indicates whether this is an empty border


isPaintOuterBorderFirst()

boolean

boolean
void

Method Summary

Allows toggling the order in which the outer and inner borders are painted for the
Outer border type
isRectangleType()

Returns true if this border type is a rectangle border.


lock()

938

Overview (Codename One API)


This callback indicates that a component pointing at this border is initialized, this
method is useful for image borders whose lock methods are implicitly invoked.
mirrorBorder()
Border

If a border is a horizontal image border it can be mirrored which is useful for an


RTL scenario
paint(Graphics g, Component c)

Draws the border for the given component, this method is called before a call to
background painting is made.

void

paintBorderBackground(Graphics g, Component c)

Has effect when the border demands responsibility for background painting
normally the painter will perform this work but in this case the border might do it
instead.

void

static
void

setDefaultBorder(Border border)

Sets the default border to the given value


setFocusedInstance(Border focused)

Deprecated.
use the getSelectedStyle() method in the component class

void

setImageBorderSpecialTile(Image tileTop, Image tileBottom,


Image tileLeft, Image tileRight, Component trackComponent)

This method is designed mainly for the purpose of creating an arrow that will
track a specific component using the image border the tile given would be an
arrow like image just like the ones used for the top/bottom/left/right images.

void

setImageBorderSpecialTile(Image tileTop, Image tileBottom,


Image tileLeft, Image tileRight, Rectangle trackComponent)

This method is designed mainly for the purpose of creating an arrow that will
track a specific component using the image border the tile given would be an
arrow like image just like the ones used for the top/bottom/left/right images.

void

setPaintOuterBorderFirst(boolean paintOuterBorderFirst)

Allows toggling the order in which the outer and inner borders are painted for the
Outer border type

void

setPressedInstance(Border pressed)

void

Allows us to define a border that will act as the pressed version of this border
setThickness(int thickness)

This method returns sets the border thickness in pixels, notice this doesn't apply
to most border types

void

unlock()

This callback indicates that a component pointing at this border is now


deinitilized This method may be invoked multiple times.

void

Methods inherited from class java.lang.Object


getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Border
protected Border()

Prevents usage of new operator, use the factory methods in the class or subclass to
create new border types.

Method Detail
mirrorBorder
public Border mirrorBorder()

Methods inherited from class java.lang.Object

939

Overview (Codename One API)


If a border is a horizontal image border it can be mirrored which is useful for an RTL
scenario
Returns:
the current border or a mirrored instance
setImageBorderSpecialTile
public void setImageBorderSpecialTile(Image tileTop,
Image tileBottom,
Image tileLeft,
Image tileRight,
Component trackComponent)

This method is designed mainly for the purpose of creating an arrow that will track a
specific component using the image border the tile given would be an arrow like
image just like the ones used for the top/bottom/left/right images. This image would
be positioned so it points at the center of the track component
Parameters:
tileTop - an image that will replace one of the tiles on the top if the track
component is there
tileBottom - an image that will replace one of the tiles on the bottom if the
track component is there
tileLeft - an image that will replace one of the tiles on the left if the track
component is there
tileRight - an image that will replace one of the tiles on the right if the track
component is there
trackComponent - the component that will be tracked for the positioning of the
tile
setImageBorderSpecialTile
public void setImageBorderSpecialTile(Image tileTop,
Image tileBottom,
Image tileLeft,
Image tileRight,
Rectangle trackComponent)

This method is designed mainly for the purpose of creating an arrow that will track a
specific component using the image border the tile given would be an arrow like
image just like the ones used for the top/bottom/left/right images. This image would
be positioned so it points at the center of the track component
Parameters:
tileTop - an image that will replace one of the tiles on the top if the track
component is there
tileBottom - an image that will replace one of the tiles on the bottom if the
track component is there
tileLeft - an image that will replace one of the tiles on the left if the track
component is there
tileRight - an image that will replace one of the tiles on the right if the track
component is there
trackComponent - the component that will be tracked for the positioning of the
tile
clearImageBorderSpecialTile
public void clearImageBorderSpecialTile()

Cleans the tile tracking state allowing the garbage collector to pick up the component
and the image data
addOuterBorder
public void addOuterBorder(Border outer)

Adss a border that wraps this border


Parameters:
outer - The outer border
getMinimumHeight
public int getMinimumHeight()

Method Detail

940

Overview (Codename One API)


Returns the minimum size required to properly display this border, normally this is 0
but a border might deem itself undisplayable with too small a size e.g. for the case of
an image border the minimum height would be top + bottom and the minimum width
would be left+right
Returns:
0 if not applicable or a dimension if it is.
getMinimumWidth
public int getMinimumWidth()

Returns the minimum size required to properly display this border, normally this is 0
but a border might deem itself undisplayable with too small a size e.g. for the case of
an image border the minimum height would be top + bottom and the minimum width
would be left+right
Returns:
0 if not applicable or a dimension if it is.
getEmpty
public static Border getEmpty()

Deprecated. use createEmpty instead


Returns an empty border, this is mostly useful for overriding components that have a
border by default
Returns:
a border than draws nothing
createEmpty
public static Border createEmpty()

Creates an empty border, this is useful where we don't want a border for a
component but want a focus border etc...
Returns:
a border than draws nothing
isEmptyBorder
public boolean isEmptyBorder()

Indicates whether this is an empty border


Returns:
true if this is an empty border
createImageBorder
public static Border createImageBorder(Image
Image
Image
Image
Image
Image
Image
Image
Image

top,
bottom,
left,
right,
topLeft,
topRight,
bottomLeft,
bottomRight,
background)

The given top/bottom/left/right images are tiled appropriately across the matching
sides of the border and the corners are placed as expected in the four corners. The
background image is optional and it will be tiled in the background if necessary.
By default this border does not override background unless a background image is
specified
Parameters:
top - the image of the top line
bottom - the image of the bottom line
left - the image of the left line
right - the image of the right line
topLeft - the image of the top left corner
topRight - the image of the top right corner
bottomLeft - the image of the bottom left corner
bottomRight - the image of the bottom right corner

Method Detail

941

Overview (Codename One API)


background - the image of the background (optional)
Returns:
new border instance
createImageScaledBorder
public static Border createImageScaledBorder(Image
Image
Image
Image
Image
Image
Image
Image
Image

top,
bottom,
left,
right,
topLeft,
topRight,
bottomLeft,
bottomRight,
background)

The given top/bottom/left/right images are scaled appropriately across the matching
sides of the border and the corners are placed as expected in the four corners. The
background image is optional and it will be tiled in the background if necessary.
By default this border does not override background unless a background image is
specified
Parameters:
top - the image of the top line
bottom - the image of the bottom line
left - the image of the left line
right - the image of the right line
topLeft - the image of the top left corner
topRight - the image of the top right corner
bottomLeft - the image of the bottom left corner
bottomRight - the image of the bottom right corner
background - the image of the background (optional)
Returns:
new border instance
createHorizonalImageBorder
public static Border createHorizonalImageBorder(Image left,
Image right,
Image center)

This is an image border that can only grow horizontally


Parameters:
left - the image of the left side
right - the image of the right side
center - the image of the center
Returns:
new border instance
createVerticalImageBorder
public static Border createVerticalImageBorder(Image top,
Image bottom,
Image center)

This is an image border that can only grow vertically


Parameters:
top - the image of the top
bottom - the image of the bottom
center - the image of the center
Returns:
new border instance
createImageBorder
public static Border createImageBorder(Image top,
Image topLeft,
Image background)

The given images are tiled appropriately across the matching side of the border,
rotated and placed as expected in the four corners. The background image is optional
and it will be tiled in the background if necessary.

Method Detail

942

Overview (Codename One API)


By default this border does not override background unless a background image is
specified.
Notice that this version of the method is potentially much more efficient since images
are rotated internally and this might save quite a bit of memory!
The top and topLeft images must be square! The width and height of these
images must be equal otherwise rotation won't work as you expect.
Parameters:
top - the image of the top line
topLeft - the image of the top left corner
background - the image of the background (optional)
Returns:
new border instance
createLineBorder
public static Border createLineBorder(int thickness)

Creates a line border that uses the color of the component foreground for drawing
Parameters:
thickness - thickness of the border in pixels
Returns:
new border instance
createDottedBorder
public static Border createDottedBorder(int thickness,
int color)

Creates a dotted border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createDashedBorder
public static Border createDashedBorder(int thickness,
int color)

Creates a dashed border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createDoubleBorder
public static Border createDoubleBorder(int thickness,
int color)

Creates a double border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createDottedBorder
public static Border createDottedBorder(int thickness)

Creates a dotted border with the specified thickness and the theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border

Method Detail

943

Overview (Codename One API)


createDashedBorder
public static Border createDashedBorder(int thickness)

Creates a dashed border with the specified thickness and the theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border
createDoubleBorder
public static Border createDoubleBorder(int thickness)

Creates a double border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
Returns:
The border
createOutsetBorder
public static Border createOutsetBorder(int thickness)

Creates an outset border with the specified thickness and theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border
createOutsetBorder
public static Border createOutsetBorder(int thickness,
int color)

Creates an outset border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createInsetBorder
public static Border createInsetBorder(int thickness)

Creates an inset border with the specified thickness and theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border
createInsetBorder
public static Border createInsetBorder(int thickness,
int color)

Creates an inset border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createGrooveBorder
public static Border createGrooveBorder(int thickness)

Creates a groove border with the specified thickness and theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border

Method Detail

944

Overview (Codename One API)


createGrooveBorder
public static Border createGrooveBorder(int thickness,
int color)

Creates a groove border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createRidgeBorder
public static Border createRidgeBorder(int thickness)

Creates a ridge border with the specified thickness and theme colors
Parameters:
thickness - The border thickness in pixels
Returns:
The border
createRidgeBorder
public static Border createRidgeBorder(int thickness,
int color)

Creates a ridge border with the specified thickness and color


Parameters:
thickness - The border thickness in pixels
color - The border color
Returns:
The border
createLineBorder
public static Border createLineBorder(int thickness,
String title)

Creates a line border with the specified title


Parameters:
thickness - thickness of the border in pixels
title - The border's title
Returns:
new border instance
createLineBorder
public static Border createLineBorder(int thickness,
int color,
String title)

Creates a line border that uses the given color for the component
Parameters:
thickness - thickness of the border in pixels
color - the color for the border
title - The border's title
Returns:
new border instance
createLineBorder
public static Border createLineBorder(int thickness,
int color)

Creates a line border that uses the given color for the component
Parameters:
thickness - thickness of the border in pixels
color - the color for the border
Returns:
new border instance

Method Detail

945

Overview (Codename One API)


createRoundBorder
public static Border createRoundBorder(int arcWidth,
int arcHeight)

Deprecated. the performance of round rect borders is REALLY slow, we recommend


people use image borders which are faster, more portable and better looking
Creates a rounded corner border that uses the color of the component foreground for
drawing. Due to technical issues (lack of shaped clipping) performance and memory
overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a
painter.
Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.

Returns:
new border instance
createRoundBorder
public static Border createRoundBorder(int arcWidth,
int arcHeight,
boolean outline)

Deprecated. the performance of round rect borders is REALLY slow, we recommend


people use image borders which are faster, more portable and better looking
Creates a rounded corner border that uses the color of the component foreground for
drawing. Due to technical issues (lack of shaped clipping) performance and memory
overhead of round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a
painter.
Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
outline - whether the round rect border outline should be drawn

Returns:
new border instance
createRoundBorder
public static Border createRoundBorder(int arcWidth,
int arcHeight,
int color)

Deprecated. the performance of round rect borders is REALLY slow, we recommend


people use image borders which are faster, more portable and better looking
Creates a rounded border that uses the given color for the component. Due to
technical issues (lack of shaped clipping) performance and memory overhead of
round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a
painter.
Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
color - the color for the border

Returns:
new border instance
createRoundBorder
public static Border createRoundBorder(int arcWidth,
int arcHeight,
int color,
boolean outline)

Method Detail

946

Overview (Codename One API)


Deprecated. the performance of round rect borders is REALLY slow, we recommend
people use image borders which are faster, more portable and better looking
Creates a rounded border that uses the given color for the component. Due to
technical issues (lack of shaped clipping) performance and memory overhead of
round borders can be low if used with either a bgImage or translucency!
This border overrides any painter used on the component and would ignor such a
painter.
Parameters:
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
color - the color for the border
outline - whether the round rect border outline should be drawn

Returns:
new border instance
createEtchedLowered
public static Border createEtchedLowered()

Creates a lowered etched border with default colors, highlight is derived from the
component and shadow is a plain dark color
Returns:
new border instance
createEtchedLowered
public static Border createEtchedLowered(int highlight,
int shadow)

Creates a raised etched border with the given colors


Parameters:
highlight - color RGB value
shadow - color RGB value
Returns:
new border instance
createEtchedRaised
public static Border createEtchedRaised()

Creates a lowered etched border with default colors, highlight is derived from the
component and shadow is a plain dark color
Returns:
new border instance
createEtchedRaised
public static Border createEtchedRaised(int highlight,
int shadow)

Creates a raised etched border with the given colors


Parameters:
highlight - color RGB value
shadow - color RGB value
Returns:
new border instance
equals
public boolean equals(Object obj)

{Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The

Method Detail

947

Overview (Codename One API)


equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).}
Overrides:
equals in class Object
createCompoundBorder
public static Border createCompoundBorder(Border
Border
Border
Border

top,
bottom,
left,
right)

Creates a border that is comprised of multiple border types so one border type can
be used on top while another one can be used at the bottom. Notice that this doesn't
work well with all border types (e.g. image borders)
Parameters:
top - the top border
bottom - the bottom border
left - the left border
right - the right border
Returns:
a compound border
isBackgroundPainter
public boolean isBackgroundPainter()

Returns true if installing this border will override the painting of the component
background
Returns:
true if this border replaces the painter
isRectangleType
public boolean isRectangleType()

Returns true if this border type is a rectangle border.


Returns:
true if this border is rectangle
createBevelLowered
public static Border createBevelLowered()

Creates a lowered bevel border with default colors, highlight is derived from the
component and shadow is a plain dark color
Returns:
new border instance
createBevelLowered
public static Border createBevelLowered(int
int
int
int

highlightOuter,
highlightInner,
shadowOuter,
shadowInner)

Creates a raised bevel border with the given colors


Parameters:
highlightOuter - RGB of the outer edge of the highlight area
highlightInner - RGB of the inner edge of the highlight area
shadowOuter - RGB of the outer edge of the shadow area
shadowInner - RGB of the inner edge of the shadow area
Returns:
new border instance
createBevelRaised
public static Border createBevelRaised()

Creates a lowered bevel border with default colors, highlight is derived from the
component and shadow is a plain dark color
Returns:
new border instance

Method Detail

948

Overview (Codename One API)


createBevelRaised
public static Border createBevelRaised(int
int
int
int

highlightOuter,
highlightInner,
shadowOuter,
shadowInner)

Creates a raised bevel border with the given colors


Parameters:
highlightOuter - RGB of the outer edge of the highlight area
highlightInner - RGB of the inner edge of the highlight area
shadowOuter - RGB of the outer edge of the shadow area
shadowInner - RGB of the inner edge of the shadow area
Returns:
new border instance
setPressedInstance
public void setPressedInstance(Border pressed)

Allows us to define a border that will act as the pressed version of this border
Parameters:
pressed - a border that will be returned by the pressed version method
setFocusedInstance
public void setFocusedInstance(Border focused)

Deprecated. use the getSelectedStyle() method in the component class


Allows us to define a border that will act as the focused version of this border
Parameters:
focused - a border that will be returned by the focused version method
getFocusedInstance
public Border getFocusedInstance()

Deprecated. use the getSelectedStyle() method in the component class


Returns the focused version of the border if one is installed
Returns:
a focused version of this border if one exists
getPressedInstance
public Border getPressedInstance()

Returns the pressed version of the border if one is set by the user
Returns:
the pressed instance of this border
createPressedVersion
public Border createPressedVersion()

When applied to buttons borders produce a version that reverses the effects of the
border providing a pressed feel
Returns:
a border that will make the button feel pressed
paintBorderBackground
public void paintBorderBackground(Graphics g,
Component c)

Has effect when the border demands responsibility for background painting normally
the painter will perform this work but in this case the border might do it instead.
Parameters:
g - graphics context to draw onto
c - component whose border should be drawn

Method Detail

949

Overview (Codename One API)


paint
public void paint(Graphics g,
Component c)

Draws the border for the given component, this method is called before a call to
background painting is made.
Parameters:
g - graphics context to draw onto
c - component whose border should be drawn
setDefaultBorder
public static void setDefaultBorder(Border border)

Sets the default border to the given value


Parameters:
border - new border value
getDefaultBorder
public static Border getDefaultBorder()

Gets the default border to the given value


Returns:
the default border
getThickness
public int getThickness()

This method returns how thick is the border in pixels, notice this doesn't apply to most
border types
Returns:
the Border thickness
setThickness
public void setThickness(int thickness)

This method returns sets the border thickness in pixels, notice this doesn't apply to
most border types
Parameters:
thickness - the Border thickness
setPaintOuterBorderFirst
public void setPaintOuterBorderFirst(boolean paintOuterBorderFirst)

Allows toggling the order in which the outer and inner borders are painted for the
Outer border type
Parameters:
paintOuterBorderFirst - whether the outside border should be painter first
isPaintOuterBorderFirst
public boolean isPaintOuterBorderFirst()

Allows toggling the order in which the outer and inner borders are painted for the
Outer border type
Returns:
whether the outside border should be painter first
getCompoundBorders
public Border[] getCompoundBorders()

This method returns the Compound Borders array. The array size is 4 and the
borders arranged as follows : Border[] borders = getCompoundBorders(); Border top
= borders[Component.TOP]; Border bottom = borders[Component.BOTTOM]; Border
left = borders[Component.LEFT]; Border right = borders[Component.RIGHT];
Returns:
the borders array or null if this is not a Compound Border

Method Detail

950

Overview (Codename One API)


lock
public void lock()

This callback indicates that a component pointing at this border is initialized, this
method is useful for image borders whose lock methods are implicitly invoked. This
method may be invoked multiple times.
unlock
public void unlock()

This callback indicates that a component pointing at this border is now deinitilized
This method may be invoked multiple times.
getProperty
public Object getProperty(String n)

This method is for internal usage only!

Method Detail

951

Overview (Codename One API)


com.codename1.ui.painter

Class PainterChain
java.lang.Object

com.codename1.ui.painter.PainterChain
All Implemented Interfaces:
Painter

public class
extends Object
implements Painter

A painter chain allows us to chain together several painters to provide a "layer" effect where each
painter only draws one element.

Constructor Summary
Constructor and Description
PainterChain(Painter painter)

Create a new painter chain which will paint all of the elements in the chain in sequence from
0 to the last element
PainterChain(Painter[] chain)

Create a new painter chain which will paint all of the elements in the chain in sequence from
0 to the last element

Method Summary
Modifier and
Type

Method and Description


addPainter(Painter p)

PainterChain

Painter[]

Creates a new chain based on the existing chain with the new element
added at the end
getChain()

Allows us to traverse the painter chain


installGlassPane(Form f, Painter p)

static void

Installs a glass pane on the given form making sure to make it a painter
chain only if required by existing painter
paint(Graphics g, Rectangle rect)

void

Draws inside the given rectangle clipping area.


prependPainter(Painter p)

PainterChain

Creates a new chain based on the existing chain with the new element
added at the beginning
removeGlassPane(Form f, Painter p)

static void

Removes a glass pane from the given form, this is the opposite operation
for the install glass pane

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class PainterChain

952

Overview (Codename One API)


PainterChain
public PainterChain(Painter[] chain)

Create a new painter chain which will paint all of the elements in the chain in
sequence from 0 to the last element
Parameters:
chain - the chain of components in the painter
PainterChain
public PainterChain(Painter painter)

Create a new painter chain which will paint all of the elements in the chain in
sequence from 0 to the last element
Parameters:
painter - the chain first Painter

Method Detail
addPainter
public PainterChain addPainter(Painter p)

Creates a new chain based on the existing chain with the new element added at the
end
Parameters:
p - new painter
Returns:
new chain element
prependPainter
public PainterChain prependPainter(Painter p)

Creates a new chain based on the existing chain with the new element added at the
beginning
Parameters:
p - new painter
Returns:
new chain element
paint
public void paint(Graphics g,
Rectangle rect)

Draws inside the given rectangle clipping area.


Specified by:
paint in interface Painter
Parameters:
g - the Graphics object
rect - the given rectangle cliping area
installGlassPane
public static void installGlassPane(Form f,
Painter p)

Installs a glass pane on the given form making sure to make it a painter chain only if
required by existing painter
Parameters:
f - form on which to install the chain
p - painter to install
getChain
public Painter[] getChain()

Allows us to traverse the painter chain


Returns:

Constructor Detail

953

Overview (Codename One API)


the internal painter chain
removeGlassPane
public static void removeGlassPane(Form f,
Painter p)

Removes a glass pane from the given form, this is the opposite operation for the
install glass pane
Parameters:
f - form from which to remove the chain
p - painter to remove

Method Detail

954

Overview (Codename One API)


com.codename1.ui.painter

Class BackgroundPainter
java.lang.Object

com.codename1.ui.painter.BackgroundPainter
All Implemented Interfaces:
Painter

public class
extends Object
implements Painter

A painter that draws the background of a component based on its style

Constructor Summary
Constructor and Description
BackgroundPainter(Component parent)

Construct a background painter for the given component

Method Summary
Modifier and Type

Method and Description


paint(Graphics g, Rectangle rect)

void

Draws inside the given rectangle clipping area.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
BackgroundPainter
public BackgroundPainter(Component parent)

Construct a background painter for the given component


Parameters:
parent - the parent component

Method Detail
paint
public void paint(Graphics g,
Rectangle rect)

Draws inside the given rectangle clipping area.


Specified by:
paint in interface Painter
Parameters:
g - the Graphics object
rect - the given rectangle cliping area

Class BackgroundPainter

955

Overview (Codename One API)


com.codename1.ui.list

Class MultiList
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.List

com.codename1.ui.list.MultiList
All Implemented Interfaces:
Animation, StyleListener

public class
extends List

A list with a MultiButton renderer. This simplifies the process of working with the list and its model as
the renderer comes pre-configured for common use cases.
private void showMultiList() {
Form hi = new Form("MultiList", new BorderLayout());
ArrayList<Map<String, Object>> data = new ArrayList<>();
data.add(createListEntry("A Game of Thrones", "1996"), icon1);
data.add(createListEntry("A Clash Of Kings", "1998"), icon2);
data.add(createListEntry("A Storm Of Swords", "2000"), icon3);
data.add(createListEntry("A Feast For Crows", "2005"), icon4);
data.add(createListEntry("A Dance With Dragons", "2011"), icon5);
data.add(createListEntry("The Winds of Winter", "2016 (please, please, please)"), icon6);
data.add(createListEntry("A Dream of Spring", "Ugh"), icon7);
DefaultListModel<Map<String, Object>> model = new DefaultListModel<>(data);
MultiList ml = new MultiList(model);
hi.add(BorderLayout.CENTER, ml);
hi.show();
}
private Map<String, Object> createListEntry(String name, String date, Image icon) {
Map<String, Object> entry = new HashMap<>();
entry.put("Line1", name);
entry.put("Line2", date);
entry.put("icon", icon);
return entry;
}

Method Detail

956

Overview (Codename One API)


Field

Summary

Fields inherited from class com.codename1.ui.List


FIXED_CENTER, FIXED_LEAD, FIXED_NONE, FIXED_NONE_CYCLIC,
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE, FIXED_TRAIL, HORIZONTAL, VERTICAL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
MultiList()

Constructor for the GUI builder


MultiList(ListModel model)

Constructor that accepts a model for the list

Method Summary
Modifier and
Type
protected
void

Method and Description


deinitialize()

Invoked to indicate that the component initialization is being reversed since


the component was detached from the container hierarchy.
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the
GUI builder

Object

getSelectedButton()
MultiButton

Allows developers to customize the properties of the selected multi-button in


code
getUnselectedButton()

MultiButton

protected
void

Allows developers to customize the properties of the unselected multi-button


in code
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and


"ready for action" component state
setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed
and null if successful.

Methods inherited from class com.codename1.ui.List


addActionListener, addItem, addSelectionListener, animate,
calcPreferredSize, fireActionEvent, fireActionEvent, fireClicked,
getActionListeners, getCurrentSelected, getDragRegionStatus,
getFixedSelection, getGridPosX, getGridPosY, getHint, getHintIcon,
getItemGap, getListeners, getListSizeCalculationSampleCount,
getMaxElementHeight, getMinElementHeight, getModel, getOrientation,
getRenderer, getRenderingPrototype, getSelectedIndex, getSelectedItem,

Field Summary

957

Overview (Codename One API)

getSelectedRect, getSideGap, getVisibleBounds, initLaf, isCommandList,


isDefaultFireOnClick, isDefaultIgnoreFocusComponentWhenUnfocused,
isIgnoreFocusComponentWhenUnfocused, isLongPointerPressActionEnabled,
isMutableRendererBackgrounds, isNumericKeyActions, isScrollableX,
isScrollableY, isSelectableInteraction, isTactileTouch, keyPressed,
keyReleased, laidOut, listSelectionChanged, longPointerPress, modelChanged,
paint, paramString, pointerDragged, pointerHover, pointerHoverReleased,
pointerPressed, pointerReleased, refreshTheme, removeActionListener,
removeSelectionListener, scrollRectToVisible, setCommandList,
setDefaultFireOnClick, setDefaultIgnoreFocusComponentWhenUnfocused,
setFireOnClick, setFixedSelection, setHandlesInput, setHint, setHint,
setHintIcon, setIgnoreFocusComponentWhenUnfocused, setInputOnFocus,
setItemGap, setListCellRenderer, setListSizeCalculationSampleCount,
setLongPointerPressActionEnabled, setMaxElementHeight, setMinElementHeight,
setModel, setMutableRendererBackgrounds, setNumericKeyActions,
setOrientation, setPaintFocusBehindList, setRenderer,
setRenderingPrototype, setScrollToSelected, setSelectedIndex,
setSelectedIndex, setSelectedItem, setShouldCalcPreferredSize,
shouldRenderSelection, size

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles,
getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedStyle, getStyle, getTensileLength,
getUIID, getUIManager, getUnselectedStyle, getWidth, getX, getY,
growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, longKeyPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from class com.codename1.ui.List

958

Overview (Codename One API)


Constructor

Detail

MultiList
public MultiList(ListModel model)

Constructor that accepts a model for the list


Parameters:
model - the model object to assign to the list
MultiList
public MultiList()

Constructor for the GUI builder

Method Detail
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Description copied from class: Component


Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
getSelectedButton
public MultiButton getSelectedButton()

Allows developers to customize the properties of the selected multi-button in code


Returns:
the selected multi button
getUnselectedButton
public MultiButton getUnselectedButton()

Allows developers to customize the properties of the unselected multi-button in code


Returns:
the unselected multi button
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

Constructor Detail

959

Overview (Codename One API)

getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

960

Overview (Codename One API)


com.codename1.ui.list

Interface ListModel<T>
All Known Implementing Classes:
CloudListModel, ContactsModel, DefaultListModel, FilterProxyListModel

public interface

Represents the data structure of the list, thus allowing a list to represent any potential data source by
referencing different implementations of this interface. E.g. a list model can be implemented in such a
way that it retrieves data directly from storage (although caching would be recommended).
It is the responsibility of the list to notify observers (specifically the view List of any changes to its
state (items removed/added/changed etc.) thus the data would get updated on the view.
class GRMMModel implements ListModel<Map<String,Object>> {
{@literal @}Override
public Map<String, Object> getItemAt(int index) {
int idx = index % 7;
switch(idx) {
case 0:
return createListEntry("A Game of Thrones " + index, "1996");
case 1:
return createListEntry("A Clash Of Kings " + index, "1998");
case 2:
return createListEntry("A Storm Of Swords " + index, "2000");
case 3:
return createListEntry("A Feast For Crows " + index, "2005");
case 4:
return createListEntry("A Dance With Dragons " + index, "2011");
case 5:
return createListEntry("The Winds of Winter " + index, "2016 (please, please, please)");
default:
return createListEntry("A Dream of Spring " + index, "Ugh");
}
}
{@literal @}Override
public int getSize() {
return 1000000;
}
{@literal @}Override
public int getSelectedIndex() {
return 0;
}
{@literal @}Override
public void setSelectedIndex(int index) {
}
{@literal @}Override
public void addDataChangedListener(DataChangedListener l) {
}
{@literal @}Override
public void removeDataChangedListener(DataChangedListener l) {
}
{@literal @}Override
public void addSelectionListener(SelectionListener l) {
}
{@literal @}Override
public void removeSelectionListener(SelectionListener l) {
}
{@literal @}Override
public void addItem(Map<String, Object> item) {
}
{@literal @}Override
public void removeItem(int index) {
}
}

Interface ListModel<T>

961

Overview (Codename One API)

A ListModel can be used in conjunction with an ImageViewer to fetch images dynamically into the
view:
Form hi = new Form("ImageViewer", new BorderLayout());
final EncodedImage placeholder = EncodedImage.createFromImage(
FontImage.createMaterial(FontImage.MATERIAL_SYNC, s).
scaled(300, 300), false);
class ImageList implements ListModel<Image> {
private int selection;
private String[] imageURLs = {
"http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/300px-AGameOfThrones.jpg",
"http://awoiaf.westeros.org/images/thumb/3/39/AClashOfKings.jpg/300px-AClashOfKings.jpg",
"http://awoiaf.westeros.org/images/thumb/2/24/AStormOfSwords.jpg/300px-AStormOfSwords.jpg",
"http://awoiaf.westeros.org/images/thumb/a/a3/AFeastForCrows.jpg/300px-AFeastForCrows.jpg",
"http://awoiaf.westeros.org/images/7/79/ADanceWithDragons.jpg"
};
private Image[] images;
private EventDispatcher listeners = new EventDispatcher();
public ImageList() {
this.images = new EncodedImage[imageURLs.length];
}
public Image getItemAt(final int index) {
if(images[index] == null) {
images[index] = placeholder;
Util.downloadUrlToStorageInBackground(imageURLs[index], "list" + index, (e) -> {
try {
images[index] = EncodedImage.create(Storage.getInstance().createInputStream("list" + index));
listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
} catch(IOException err) {
err.printStackTrace();
}
});
}
return images[index];
}
public int getSize() {
return imageURLs.length;
}
public int getSelectedIndex() {
return selection;
}
public void setSelectedIndex(int index) {
selection = index;
}
public void addDataChangedListener(DataChangedListener l) {
listeners.addListener(l);
}

Interface ListModel<T>

962

Overview (Codename One API)


public void removeDataChangedListener(DataChangedListener l) {
listeners.removeListener(l);
}
public void addSelectionListener(SelectionListener l) {
}
public void removeSelectionListener(SelectionListener l) {
}
public void addItem(Image item) {
}
public void removeItem(int index) {
}
};
ImageList imodel = new ImageList();
ImageViewer iv = new ImageViewer(imodel.getItemAt(0));
iv.setImageList(imodel);
hi.add(BorderLayout.CENTER, iv);

Method Summary
Modifier and Type
void
void
void
T
int
int
void

Method Summary

Method and Description


addDataChangedListener(DataChangedListener l)

Invoked to indicate interest in future change events


addItem(T item)

Adds the specified item to the end of this list.


addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


getItemAt(int index)

Returns the item at the given offset


getSelectedIndex()

Returns the selected list offset


getSize()

Returns the number of items in the list


removeDataChangedListener(DataChangedListener l)

Invoked to indicate no further interest in future change events

963

Overview (Codename One API)


removeItem(int index)

void

Removes the item at the specified position in this list.


removeSelectionListener(SelectionListener l)

void

Invoked to indicate no further interest in future selection events


setSelectedIndex(int index)

void

Sets the selected list offset can be set to -1 to clear selection

Method Detail
getItemAt
T getItemAt(int index)

Returns the item at the given offset


Parameters:
index - an index into this list
Returns:
the item at the specified index
getSize
int getSize()

Returns the number of items in the list


Returns:
the number of items in the list
getSelectedIndex
int getSelectedIndex()

Returns the selected list offset


Returns:
the selected list index
setSelectedIndex
void setSelectedIndex(int index)

Sets the selected list offset can be set to -1 to clear selection


Parameters:
index - an index into this list
addDataChangedListener
void addDataChangedListener(DataChangedListener l)

Invoked to indicate interest in future change events


Parameters:
l - a data changed listener
removeDataChangedListener
void removeDataChangedListener(DataChangedListener l)

Invoked to indicate no further interest in future change events


Parameters:
l - a data changed listener
addSelectionListener
void addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


Parameters:
l - a selection listener

Method Detail

964

Overview (Codename One API)


removeSelectionListener
void removeSelectionListener(SelectionListener l)

Invoked to indicate no further interest in future selection events


Parameters:
l - a selection listener
addItem
void addItem(T item)

Adds the specified item to the end of this list. An optional operation for mutable lists, it
can throw an unsupported operation exception if a list model is not mutable.
Parameters:
item - the item to be added
removeItem
void removeItem(int index)

Removes the item at the specified position in this list.


Parameters:
index - the index of the item to removed

Method Detail

965

Overview (Codename One API)


com.codename1.ui.list

Interface ListCellRenderer<T>
All Known Implementing Classes:
DefaultListCellRenderer, GenericListCellRenderer

public interface

A "rubber stamp" tool that allows us to extract a component (often the same component instance for
all invocations) that is initialized to the value of the current item extracted from the model, this
component is drawn on the list and discarded. No state of the component is kept and the component
is essentially discarded.
This is a very advanced interface it is recommended that you use either the
DefaultListCellRenderer or GenericListCellRenderer whenever possible to avoid mistakes.
An instance of a renderer can be developed as such:
public class MyYesNoRenderer extends Label implements ListCellRenderer {
Label label = new label(" ");
public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
if( ((Boolean)value).booleanValue() ) {
setText("Yes");
} else {
setText("No");
}
return this;
}
public Component getListFocusComponent(List list) {
return label;
}
}

Method Summary
Modifier and
Type
Component

Method and Description


getListCellRendererComponent(List list, T value, int index,
boolean isSelected)

Returns a component instance that is already set to render "value".


getListFocusComponent(List list)
Component

Returns a component instance that is painted under the currently focused


renderer and is animated to provide smooth scrolling.

Method Detail

getListCellRendererComponent
Component getListCellRendererComponent(List list,
T value,
int index,
boolean isSelected)

Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Parameters:
list - the list component
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:

Interface ListCellRenderer<T>

966

Overview (Codename One API)


a component to paint within the list
getListFocusComponent
Component getListFocusComponent(List list)

Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

Method Detail

967

Overview (Codename One API)


com.codename1.ui.list

Class GenericListCellRenderer<T>
java.lang.Object

com.codename1.ui.list.GenericListCellRenderer<T>
All Implemented Interfaces:
CellRenderer<T>, ListCellRenderer<T>

public class
extends Object
implements ListCellRenderer<T>, CellRenderer<T>

The generic list cell renderer can display containers or arbitrary Codename One components as items
in a list. It relies on the source data being a Map object. It extracts values from the Map using the
component name as an indication to the Map key lookup.
This renderer supports label tickering, check boxes/radio buttons etc. seamlessly.
Please notice that you must use at least two distinct instances of the component when passing them
to the constructor, reusing the same instance WILL NOT WORK!
Furthermore, the renderer instance cannot be reused for multiple lists, each list will need a new
instance of this renderer!
Sample usage for this renderer follows:
com.codename1.ui.List list = new com.codename1.ui.List(createGenericListCellRendererModelData());
list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));

private Container createGenericRendererContainer() {


Label name = new Label();
name.setFocusable(true);
name.setName("Name");
Label surname = new Label();
surname.setFocusable(true);
surname.setName("Surname");
CheckBox selected = new CheckBox();
selected.setName("Selected");
selected.setFocusable(true);
Container c = BorderLayout.center(name).
add(BorderLayout.SOUTH, surname).
add(BorderLayout.WEST, selected);
c.setUIID("ListRenderer");
return c;
}
private Object[] createGenericListCellRendererModelData() {
Map<String,Object>[] data = new HashMap[5];
data[0] = new HashMap<>();
data[0].put("Name", "Shai");
data[0].put("Surname", "Almog");
data[0].put("Selected", Boolean.TRUE);
data[1] = new HashMap<>();
data[1].put("Name", "Chen");
data[1].put("Surname", "Fishbein");
data[1].put("Selected", Boolean.TRUE);
data[2] = new HashMap<>();
data[2].put("Name", "Ofir");
data[2].put("Surname", "Leitner");
data[3] = new HashMap<>();
data[3].put("Name", "Yaniv");
data[3].put("Surname", "Vakarat");
data[4] = new HashMap<>();
data[4].put("Name", "Meirav");
data[4].put("Surname", "Nachmanovitch");
return data;
}

Class GenericListCellRenderer<T>

968

Overview (Codename One API)

com.codename1.ui.List list = new com.codename1.ui.List(createGenericListCellRendererModelData());


list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));

private Container createGenericRendererContainer() {


Label name = new Label();
name.setFocusable(true);
name.setName("Name");
Label surname = new Label();
surname.setFocusable(true);
surname.setName("Surname");
CheckBox selected = new CheckBox();
selected.setName("Selected");
selected.setFocusable(true);
Container c = BorderLayout.center(name).
add(BorderLayout.SOUTH, surname).
add(BorderLayout.WEST, selected);
c.setUIID("ListRenderer");
return c;
}
private Object[] createGenericListCellRendererModelData() {
Map<String,Object>[] data = new HashMap[5];
data[0] = new HashMap<>();
data[0].put("Name", "Shai");
data[0].put("Surname", "Almog");
data[0].put("Selected", Boolean.TRUE);
data[1] = new HashMap<>();
data[1].put("Name", "Chen");
data[1].put("Surname", "Fishbein");
data[1].put("Selected", Boolean.TRUE);
data[2] = new HashMap<>();
data[2].put("Name", "Ofir");
data[2].put("Surname", "Leitner");
data[3] = new HashMap<>();
data[3].put("Name", "Yaniv");
data[3].put("Surname", "Vakarat");
data[4] = new HashMap<>();
data[4].put("Name", "Meirav");
data[4].put("Surname", "Nachmanovitch");
return data;
}

Field Summary
Modifier and
Type

Field and Description


ENABLED

Field Summary

969

Overview (Codename One API)


static
String
static
String

If this flag exists in a Map of data the renderer will enable/disable the entries,
the flag assumes either Boolean.TRUE or Boolean.FALSE.
SELECT_ALL_FLAG

Put this flag as a Map key to indicate that a checkbox entry rendered by this
renderer should act as a "select all" entry and toggle all other entries.

Constructor Summary
Constructor and Description
GenericListCellRenderer(Component selected, Component unselected)

Constructs a generic renderer with the given selected/unselected components


GenericListCellRenderer(Component odd, Component oddUnselected, Component even,
Component evenUnselected)

Constructs a generic renderer with the given selected/unselected components for odd/even
values allowing a "pinstripe" effect

Method Summary
Modifier and Type
Button
URLImage.ImageAdapter

Component

static
URLImage.ImageAdapter

Method and Description


extractLastClickedComponent()

Allows partitioning the renderer into "areas" that can be clicked.


getAdapter()

The adapter used when dealing with image URL's


getCellRendererComponent(Component list, Object model,
T value, int index, boolean isSelected)

Returns a component instance that is already set to render


"value".
getDefaultAdapter()

The default adapter to use for image URLs


getFocusComponent(Component list)

Component

Component

Returns a component instance that is painted under the currently


focused renderer and is animated to provide smooth scrolling.
getListCellRendererComponent(List list, T value,
int index, boolean isSelected)

Returns a component instance that is already set to render


"value".
getListFocusComponent(List list)

Component

Returns a component instance that is painted under the currently


focused renderer and is animated to provide smooth scrolling.

Component

getSelected()

Component

getSelectedEven()

Component

getUnselected()

Component

getUnselectedEven()
isFisheye()

boolean

In fisheye rendering mode the renderer maintains selected


component drawing

boolean

isSelectionListener()

void
static void

setAdapter(URLImage.ImageAdapter adapter)

The adapter used when dealing with image URL's


setDefaultAdapter(URLImage.ImageAdapter aDefaultAdapter)

The default adapter to use for image URLs


setFisheye(boolean fisheye)

void

In fisheye rendering mode the renderer maintains selected


component drawing

void

setSelectionListener(boolean selectionListener)

void

updateIconPlaceholders()

Constructor Summary

970

Overview (Codename One API)


Updates the placeholder instances, this is useful for changing the
URLImage placeholder in runtime as might happen in the
designer

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ENABLED
public static final String ENABLED

If this flag exists in a Map of data the renderer will enable/disable the entries, the flag
assumes either Boolean.TRUE or Boolean.FALSE. Notice that just setting it to false
when necessary will not work, when its used it must be applied to all entries
otherwise the reuse of the renderer component will break this feature.
See Also:
Constant Field Values
SELECT_ALL_FLAG
public static final String SELECT_ALL_FLAG

Put this flag as a Map key to indicate that a checkbox entry rendered by this renderer
should act as a "select all" entry and toggle all other entries. The value for this entry is
ignored
See Also:
Constant Field Values

Constructor Detail
GenericListCellRenderer
public GenericListCellRenderer(Component selected,
Component unselected)

Constructs a generic renderer with the given selected/unselected components


Parameters:
selected - indicates the selected value for the renderer
unselected - indicates the unselected value for the renderer
GenericListCellRenderer
public GenericListCellRenderer(Component
Component
Component
Component

odd,
oddUnselected,
even,
evenUnselected)

Constructs a generic renderer with the given selected/unselected components for


odd/even values allowing a "pinstripe" effect
Parameters:
odd - indicates the selected value for the renderer
oddUnselected - indicates the unselected value for the renderer
even - indicates the selected value for the renderer
evenUnselected - indicates the unselected value for the renderer

Method Detail

Method Summary

971

Overview (Codename One API)


getDefaultAdapter
public static URLImage.ImageAdapter getDefaultAdapter()

The default adapter to use for image URLs


Returns:
the defaultAdapter
setDefaultAdapter
public static void setDefaultAdapter(URLImage.ImageAdapter aDefaultAdapter)

The default adapter to use for image URLs


Parameters:
aDefaultAdapter - the defaultAdapter to set
updateIconPlaceholders
public void updateIconPlaceholders()

Updates the placeholder instances, this is useful for changing the URLImage
placeholder in runtime as might happen in the designer
extractLastClickedComponent
public Button extractLastClickedComponent()

Allows partitioning the renderer into "areas" that can be clicked. When receiving an
action event in the list this method allows a developer to query the renderer to "see"
whether a button within the component was "touched" by the user on a touch screen
device. This method will reset the value to null after returning a none-null value!
Returns:
a button or null
getCellRendererComponent
public Component getCellRendererComponent(Component list,
Object model,
T value,
int index,
boolean isSelected)

Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Specified by:
getCellRendererComponent in interface CellRenderer<T>
Parameters:
list - the list component
model - the model behind the render
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list
getListCellRendererComponent
public Component getListCellRendererComponent(List list,
T value,
int index,
boolean isSelected)

Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Specified by:
getListCellRendererComponent in interface ListCellRenderer<T>
Parameters:

Method Detail

972

Overview (Codename One API)


list - the list component
value - the value to render
index - the index in the list
isSelected - whether the entry

is selected
Returns:
a component to paint within the list
getListFocusComponent
public Component getListFocusComponent(List list)

Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Specified by:
getListFocusComponent in interface ListCellRenderer<T>
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

getFocusComponent
public Component getFocusComponent(Component list)

Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Specified by:
getFocusComponent in interface CellRenderer<T>
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

isSelectionListener
public boolean isSelectionListener()

Returns:
the selectionListener
setSelectionListener
public void setSelectionListener(boolean selectionListener)

Parameters:
selectionListener

- the selectionListener to set

getSelected
public Component getSelected()

Returns:
the selected
getUnselected
public Component getUnselected()

Returns:
the unselected

Method Detail

973

Overview (Codename One API)


getSelectedEven
public Component getSelectedEven()

Returns:
the selectedEven
getUnselectedEven
public Component getUnselectedEven()

Returns:
the unselectedEven
isFisheye
public boolean isFisheye()

In fisheye rendering mode the renderer maintains selected component drawing


Returns:
the fisheye
setFisheye
public void setFisheye(boolean fisheye)

In fisheye rendering mode the renderer maintains selected component drawing


Parameters:
fisheye - the fisheye to set
getAdapter
public URLImage.ImageAdapter getAdapter()

The adapter used when dealing with image URL's


Returns:
the adapter
setAdapter
public void setAdapter(URLImage.ImageAdapter adapter)

The adapter used when dealing with image URL's


Parameters:
adapter - the adapter to set

Method Detail

974

Overview (Codename One API)


com.codename1.ui.list

Class FilterProxyListModel<T>
java.lang.Object

com.codename1.ui.list.FilterProxyListModel<T>
All Implemented Interfaces:
DataChangedListener, ListModel<T>

public class
extends Object
implements ListModel<T>, DataChangedListener

This class allows filtering/sorting a list model dynamically using a text field

Field Summary

Fields inherited from


interface com.codename1.ui.events.DataChangedListener
ADDED, CHANGED, REMOVED

Constructor Summary
Constructor and Description
FilterProxyListModel(ListModel<T> underlying)

The proxy is applied to the actual model and effectively hides it

Method Summary
Modifier
and Type
void
void
void
protected
boolean
protected
int
void
void
T
int
int

Method and Description


addDataChangedListener(DataChangedListener l)

Invoked to indicate interest in future change events


addItem(T item)

Adds the specified item to the end of this list.


addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


check(Object o, String str)

Checks whether the filter condition is matched, receives an uppercase version


of the filter string to match against
compare(Object a, Object b, boolean ascending)

This method can be overriden by subclasses to allow sorting arbitrary objects


within the list, it follows the traditional contract of the compare method in Java
dataChanged(int type, int index)

Invoked when there was a change in the underlying model


filter(String str)

Filters the list based on the given string


getItemAt(int index)

Returns the item at the given offset


getSelectedIndex()

Returns the selected list offset


getSize()

Returns the number of items in the list

Class FilterProxyListModel<T>

975

Overview (Codename One API)


ListModel
static void
static void

getUnderlying()

Returns the underlying model which is needed to perform mutations on the list.
install(TextField search, ContainerList l)

Installs a search field on a list making sure the filter method is invoked properly
install(TextField search, List l)

Installs a search field on a list making sure the filter method is invoked properly
isStartsWithMode()

boolean

When enabled this makes the filter check that the string starts with rather than
within the index
removeDataChangedListener(DataChangedListener l)

void

Invoked to indicate no further interest in future change events


removeItem(int index)

void

Removes the item at the specified position in this list.


removeSelectionListener(SelectionListener l)

void

Invoked to indicate no further interest in future selection events


setSelectedIndex(int index)

void

Sets the selected list offset can be set to -1 to clear selection


setStartsWithMode(boolean startsWithMode)

When enabled this makes the filter check that the string starts with rather than
within the index

void

sort(boolean ascending)

This method performs a sort of the list, to determine the sort order this class
should be derived and the compare() method should be overriden

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FilterProxyListModel
public FilterProxyListModel(ListModel<T> underlying)

The proxy is applied to the actual model and effectively hides it


Parameters:
underlying - the "real" model for the list

Method Detail
sort
public void sort(boolean ascending)

This method performs a sort of the list, to determine the sort order this class should
be derived and the compare() method should be overriden
Parameters:
ascending - sort in ascending order
compare
protected int compare(Object a,
Object b,
boolean ascending)

This method can be overriden by subclasses to allow sorting arbitrary objects within
the list, it follows the traditional contract of the compare method in Java
Parameters:
a - first object
b - second object
ascending - direction of sort

Method Summary

976

Overview (Codename One API)


Returns:
1, 0 or -1 to indicate the larger/smaller object
getUnderlying
public ListModel getUnderlying()

Returns the underlying model which is needed to perform mutations on the list.
Returns:
the underlying model
check
protected boolean check(Object o,
String str)

Checks whether the filter condition is matched, receives an uppercase version of the
filter string to match against
Parameters:
o - the object being compared
str - the string
Returns:
true if match is checked
filter
public void filter(String str)

Filters the list based on the given string


Parameters:
str - the string to filter the list by
getItemAt
public T getItemAt(int index)

Returns the item at the given offset


Specified by:
getItemAt in interface ListModel<T>
Parameters:
index - an index into this list
Returns:
the item at the specified index
getSize
public int getSize()

Returns the number of items in the list


Specified by:
getSize in interface ListModel<T>
Returns:
the number of items in the list
getSelectedIndex
public int getSelectedIndex()

Returns the selected list offset


Specified by:
getSelectedIndex in interface ListModel<T>
Returns:
the selected list index
setSelectedIndex
public void setSelectedIndex(int index)

Sets the selected list offset can be set to -1 to clear selection


Specified by:
setSelectedIndex in interface ListModel<T>
Parameters:
index - an index into this list

Method Detail

977

Overview (Codename One API)


addDataChangedListener
public void addDataChangedListener(DataChangedListener l)

Invoked to indicate interest in future change events


Specified by:
addDataChangedListener in interface ListModel<T>
Parameters:
l - a data changed listener
removeDataChangedListener
public void removeDataChangedListener(DataChangedListener l)

Invoked to indicate no further interest in future change events


Specified by:
removeDataChangedListener in interface ListModel<T>
Parameters:
l - a data changed listener
addSelectionListener
public void addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


Specified by:
addSelectionListener in interface ListModel<T>
Parameters:
l - a selection listener
removeSelectionListener
public void removeSelectionListener(SelectionListener l)

Invoked to indicate no further interest in future selection events


Specified by:
removeSelectionListener in interface ListModel<T>
Parameters:
l - a selection listener
addItem
public void addItem(T item)

Adds the specified item to the end of this list. An optional operation for mutable lists, it
can throw an unsupported operation exception if a list model is not mutable.
Specified by:
addItem in interface ListModel<T>
Parameters:
item - the item to be added
removeItem
public void removeItem(int index)

Removes the item at the specified position in this list.


Specified by:
removeItem in interface ListModel<T>
Parameters:
index - the index of the item to removed
dataChanged
public void dataChanged(int type,
int index)

Invoked when there was a change in the underlying model


Specified by:
dataChanged in interface DataChangedListener
Parameters:
type - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model

Method Detail

978

Overview (Codename One API)


install
public static void install(TextField search,
List l)

Installs a search field on a list making sure the filter method is invoked properly
install
public static void install(TextField search,
ContainerList l)

Installs a search field on a list making sure the filter method is invoked properly
isStartsWithMode
public boolean isStartsWithMode()

When enabled this makes the filter check that the string starts with rather than within
the index
Returns:
the startsWithMode
setStartsWithMode
public void setStartsWithMode(boolean startsWithMode)

When enabled this makes the filter check that the string starts with rather than within
the index
Parameters:
startsWithMode - the startsWithMode to set

Method Detail

979

Overview (Codename One API)


com.codename1.ui.list

Class DefaultListModel<T>
java.lang.Object

com.codename1.ui.list.DefaultListModel<T>
All Implemented Interfaces:
ListModel<T>
Direct Known Subclasses:
ContactsModel

public class
extends Object
implements ListModel<T>

Default implementation of the list model based on a List of elements. The list model is an observable
set of objects that List uses to pull the data to display.
private void showMultiList() {
Form hi = new Form("MultiList", new BorderLayout());
ArrayList<Map<String, Object>> data = new ArrayList<>();
data.add(createListEntry("A Game of Thrones", "1996"), icon1);
data.add(createListEntry("A Clash Of Kings", "1998"), icon2);
data.add(createListEntry("A Storm Of Swords", "2000"), icon3);
data.add(createListEntry("A Feast For Crows", "2005"), icon4);
data.add(createListEntry("A Dance With Dragons", "2011"), icon5);
data.add(createListEntry("The Winds of Winter", "2016 (please, please, please)"), icon6);
data.add(createListEntry("A Dream of Spring", "Ugh"), icon7);
DefaultListModel<Map<String, Object>> model = new DefaultListModel<>(data);
MultiList ml = new MultiList(model);
hi.add(BorderLayout.CENTER, ml);
hi.show();
}
private Map<String, Object> createListEntry(String name, String date, Image icon) {
Map<String, Object> entry = new HashMap<>();
entry.put("Line1", name);
entry.put("Line2", date);
entry.put("icon", icon);
return entry;
}

Class DefaultListModel<T>

980

Overview (Codename One API)

Constructor

Summary

Constructor and Description


DefaultListModel()

Creates a new instance of DefaultListModel


DefaultListModel(Collection<T> items)

Creates a new instance of DefaultListModel


DefaultListModel(T... items)

Creates a new instance of DefaultListModel


DefaultListModel(Vector<T> items)

Creates a new instance of DefaultListModel

Method Summary
Modifier and
Type

Method and Description


addDataChangedListener(DataChangedListener l)

void

Invoked to indicate interest in future change events


addItem(T item)

void

Adds the specified item to the end of this list.


addItemAtIndex(T item, int index)

void

Adding an item to list at given index


addSelectionListener(SelectionListener l)

void

Invoked to indicate interest in future selection events

protected void

fireDataChangedEvent(int status, int index)

Broadcast a change event to all listeners


getItemAt(int index)

Returns the item at the given offset


getList()

List<T>

Returns the internal list of items which makes traversal using iterators
easier.
getSelectedIndex()

int

Returns the selected list offset


getSize()

int

Returns the number of items in the list


removeAll()

void

Removes all elements from the model


removeDataChangedListener(DataChangedListener l)

void

Invoked to indicate no further interest in future change events


removeItem(int index)

void

Removes the item at the specified position in this list.


removeSelectionListener(SelectionListener l)

void

Invoked to indicate no further interest in future selection events


setItem(int index, T item)

void

Change the item at the given index


setSelectedIndex(int index)

void

Sets the selected list offset can be set to -1 to clear selection

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Constructor Summary

981

Overview (Codename One API)


DefaultListModel
public DefaultListModel()

Creates a new instance of DefaultListModel


DefaultListModel
public DefaultListModel(Vector<T> items)

Creates a new instance of DefaultListModel


Parameters:
items - the items in the model
DefaultListModel
public DefaultListModel(Collection<T> items)

Creates a new instance of DefaultListModel


Parameters:
items - the items in the model
DefaultListModel
public DefaultListModel(T... items)

Creates a new instance of DefaultListModel


Parameters:
items - the items in the model

Method Detail
getItemAt
public T getItemAt(int index)

Returns the item at the given offset


Specified by:
getItemAt in interface ListModel<T>
Parameters:
index - an index into this list
Returns:
the item at the specified index
getSize
public int getSize()

Returns the number of items in the list


Specified by:
getSize in interface ListModel<T>
Returns:
the number of items in the list
getSelectedIndex
public int getSelectedIndex()

Returns the selected list offset


Specified by:
getSelectedIndex in interface ListModel<T>
Returns:
the selected list index
addItem
public void addItem(T item)

Adds the specified item to the end of this list. An optional operation for mutable lists, it
can throw an unsupported operation exception if a list model is not mutable.

Constructor Detail

982

Overview (Codename One API)


Specified by:
addItem

in interface ListModel<T>

Parameters:
item

- the item to be added

setItem
public void setItem(int index,
T item)

Change the item at the given index


Parameters:
index - the offset for the item
item - the value to set
addItemAtIndex
public void addItemAtIndex(T item,
int index)

Adding an item to list at given index


Parameters:
item - - the item to add
index - - the index position in the list
removeItem
public void removeItem(int index)

Removes the item at the specified position in this list.


Specified by:
removeItem in interface ListModel<T>
Parameters:
index - the index of the item to removed
removeAll
public void removeAll()

Removes all elements from the model


setSelectedIndex
public void setSelectedIndex(int index)

Sets the selected list offset can be set to -1 to clear selection


Specified by:
setSelectedIndex in interface ListModel<T>
Parameters:
index - an index into this list
addDataChangedListener
public void addDataChangedListener(DataChangedListener l)

Invoked to indicate interest in future change events


Specified by:
addDataChangedListener in interface ListModel<T>
Parameters:
l - a data changed listener
removeDataChangedListener
public void removeDataChangedListener(DataChangedListener l)

Invoked to indicate no further interest in future change events


Specified by:
removeDataChangedListener in interface ListModel<T>
Parameters:
l - a data changed listener

Method Detail

983

Overview (Codename One API)


fireDataChangedEvent
protected void fireDataChangedEvent(int status,
int index)

Broadcast a change event to all listeners


Parameters:
status - the status of the event
index - the index changed
addSelectionListener
public void addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


Specified by:
addSelectionListener in interface ListModel<T>
Parameters:
l - a selection listener
removeSelectionListener
public void removeSelectionListener(SelectionListener l)

Invoked to indicate no further interest in future selection events


Specified by:
removeSelectionListener in interface ListModel<T>
Parameters:
l - a selection listener
getList
public List<T> getList()

Returns the internal list of items which makes traversal using iterators easier.
Returns:
the list, notice that you shouldn't modify it

Method Detail

984

Overview (Codename One API)


com.codename1.ui.list

Class DefaultListCellRenderer<T>
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.list.DefaultListCellRenderer<T>
All Implemented Interfaces:
Animation, StyleListener, CellRenderer<T>, ListCellRenderer<T>

public class
extends Label
implements ListCellRenderer<T>, CellRenderer<T>

Default implementation of the renderer based on a label see the ListCellRenderer for more
information about the use and purpose of this class

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
DefaultListCellRenderer()

Creates a new instance of DefaultCellRenderer


DefaultListCellRenderer(boolean showNumbers)

Creates a new instance of DefaultCellRenderer

Method Summary
Modifier
and Type
Component

Method and Description


getCellRendererComponent(Component list, Object model, T value,
int index, boolean isSelected)

Returns a component instance that is already set to render "value".


getFocusComponent(Component list)
Component

Component

Returns a component instance that is painted under the currently focused


renderer and is animated to provide smooth scrolling.
getListCellRendererComponent(List list, T value, int index,
boolean isSelected)

Returns a component instance that is already set to render "value".


getListFocusComponent(List list)
Component

int
Style

Returns a component instance that is painted under the currently focused


renderer and is animated to provide smooth scrolling.
getSelectionTransparency()

The background transparency factor to apply to the selection focus


getStyle()

Returns the current Component Style allowing code to draw the current
component, you should normally use getUnselected/Pressed/DisabledStyle()

Class DefaultListCellRenderer<T>

985

Overview (Codename One API)


and not this method since it will return different values based on component
state.
protected
void

initLaf(UIManager uim)

This method initializes the Component defaults constants


isAlwaysRenderSelection()

boolean

Indicates that selection should always be rendered regardless of the status of


the shouldRenderSelection flag

boolean

isRightAlignNumbers()

boolean
static
boolean

isShowNumbers()

Indicate whether numbering should exist for the default cell renderer
isShowNumbersDefault()

Inidicates whether the default list cell renderer will show numbers by default
when constructed
refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE
THIS METHOD IF YOU CHANGED THE THEME!

void

repaint()

Overriden to do nothing and remove a performance issue where renderer


changes perform needless repaint calls

void

setAlwaysRenderSelection(boolean alwaysRenderSelection)
void

Indicates that selection should always be rendered regardless of the status of


the shouldRenderSelection flag

void

setRightAlignNumbers(boolean rightAlignNumbers)
setSelectionTransparency(int selectionTransparency)

void

The background transparency factor to apply to the selection focus


setShowNumbers(boolean showNumbers)

void

Indicate whether numbering should exist for the default cell renderer

static
void

setShowNumbersDefault(boolean def)

Inidicates whether the default list cell renderer will show numbers by default
when constructed

Methods inherited from class com.codename1.ui.Label


animate, bindProperty, calcPreferredSize, getAlignment, getBaseline,
getBaselineResizeBehavior, getBindablePropertyNames,
getBindablePropertyTypes, getBoundPropertyValue, getGap, getIcon, getMask,
getMaskedIcon, getMaskName, getPropertyNames, getPropertyTypeNames,
getPropertyTypes, getPropertyValue, getShiftMillimeters, getShiftText,
getStringWidth, getText, getTextPosition, getVerticalAlignment,
isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer,
isShouldLocalize, isShowEvenIfBlank, isTickerEnabled, isTickerRunning,
paint, paramString, setAlignment, setBoundPropertyValue,
setDefaultTickerEnabled, setEndsWith3Points, setGap, setIcon,
setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setText, setTextPosition, setTickerEnabled, setVerticalAlignment,
shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,

Method Summary

986

Overview (Codename One API)


getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled,
isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX,
isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated,
laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased,
pointerPressed, pointerPressed, pointerReleased, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
DefaultListCellRenderer
public DefaultListCellRenderer()

Creates a new instance of DefaultCellRenderer


DefaultListCellRenderer
public DefaultListCellRenderer(boolean showNumbers)

Creates a new instance of DefaultCellRenderer


Parameters:
showNumbers - indicates numbers should be shown

Method Detail
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Component

Methods inherited from class com.codename1.ui.Component

987

Overview (Codename One API)


refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Component
Parameters:
merge - indicates if the current styles should be merged with the new styles
getCellRendererComponent
public Component getCellRendererComponent(Component list,
Object model,
T value,
int index,
boolean isSelected)

Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Specified by:
getCellRendererComponent in interface CellRenderer<T>
Parameters:
list - the list component
model - the model behind the render
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list
getStyle
public Style getStyle()

Returns the current Component Style allowing code to draw the current component,
you should normally use getUnselected/Pressed/DisabledStyle() and not this method
since it will return different values based on component state.
Overrides:
getStyle in class Component
Returns:
the component Style object
getListCellRendererComponent
public Component getListCellRendererComponent(List list,
T value,
int index,
boolean isSelected)

Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Specified by:
getListCellRendererComponent in interface ListCellRenderer<T>
Parameters:
list - the list component
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list

Method Detail

988

Overview (Codename One API)


getListFocusComponent
public Component getListFocusComponent(List list)

Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Specified by:
getListFocusComponent in interface ListCellRenderer<T>
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

repaint
public void repaint()

Overriden to do nothing and remove a performance issue where renderer changes


perform needless repaint calls
Overrides:
repaint in class Component
See Also:
Display

isShowNumbers
public boolean isShowNumbers()

Indicate whether numbering should exist for the default cell renderer
Returns:
true if numers are shown by the numbers
setShowNumbers
public void setShowNumbers(boolean showNumbers)

Indicate whether numbering should exist for the default cell renderer
Parameters:
showNumbers - indicate whether numbering should exist for the default cell
renderer
getSelectionTransparency
public int getSelectionTransparency()

The background transparency factor to apply to the selection focus


Returns:
selection transperancy value
setSelectionTransparency
public void setSelectionTransparency(int selectionTransparency)

The background transparency factor to apply to the selection focus


Parameters:
selectionTransparency - the selection transperancy value
setShowNumbersDefault
public static void setShowNumbersDefault(boolean def)

Inidicates whether the default list cell renderer will show numbers by default when
constructed
Parameters:
def - true to show numbers for all renderers created in the future

Method Detail

989

Overview (Codename One API)


isShowNumbersDefault
public static boolean isShowNumbersDefault()

Inidicates whether the default list cell renderer will show numbers by default when
constructed
Returns:
true when showing numbers, false otherwise
getFocusComponent
public Component getFocusComponent(Component list)

Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Specified by:
getFocusComponent in interface CellRenderer<T>
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

isRightAlignNumbers
public boolean isRightAlignNumbers()

Returns:
the rightAlignNumbers
setRightAlignNumbers
public void setRightAlignNumbers(boolean rightAlignNumbers)

Parameters:
rightAlignNumbers

- the rightAlignNumbers to set

isAlwaysRenderSelection
public boolean isAlwaysRenderSelection()

Indicates that selection should always be rendered regardless of the status of the
shouldRenderSelection flag
Returns:
the alwaysRenderSelection
setAlwaysRenderSelection
public void setAlwaysRenderSelection(boolean alwaysRenderSelection)

Indicates that selection should always be rendered regardless of the status of the
shouldRenderSelection flag
Parameters:
alwaysRenderSelection - the alwaysRenderSelection to set

Method Detail

990

Overview (Codename One API)


com.codename1.ui.list

Class ContainerList
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.list.ContainerList
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Deprecated.
the performance of ContainerList is worse than the performance of List or Container. The
API/behaviors are problematic and we don't think its the right choice for any project. It is our
recommendation that you use Container, InfiniteContainer etc.
public class
extends Container

This is a "list component" implemented as a container with a layout manager which provides some of
the ui advantages of a Container and some of a list while pulling out some of the drawbacks of both.
This container uses the model/renderer approach for populating itself, adding/removing entries will
probably break it. It still provides most of the large size advantages a list offers since the components
within it are very simple and don't contain any actual state other than layout information. The big
advantage with this class is the ability to leverage elaborate CodenameOne layouts such as Grid,
Table & flow layout to provide other ways of rendering the content of a list model.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ContainerList()

Deprecated.
Default constructor
ContainerList(Layout l, ListModel m)

Deprecated.
Constructs a container list with the given model and layout
ContainerList(ListModel m)

Deprecated.
Constructs a container list with the given model

Method Summary
Modifier and
Type

Method and Description


addActionListener(ActionListener l)

void

Deprecated.
Allows binding a listener to user selection actions
deinitialize()

Class ContainerList

991

Overview (Codename One API)


protected
void

protected
void

Deprecated.
Invoked to indicate that the component initialization is being reversed since the compon
the container hierarchy.
fireActionEvent(ActionEvent evt)

Deprecated.
Triggers the event to the listeners
getActionListeners()

Vector

Deprecated.
use getListeners instead
getDragRegionStatus(int x, int y)

protected
int

Deprecated.
Indicates if the section within the X/Y area is a "drag region" where we expect people to
case we can instantly start dragging making perceived performance faster.
getListeners()

Collection

Deprecated.
This method allows extracting the action listeners from the current list
getModel()

ListModel

Deprecated.
Returns the list model
getPropertyNames()

String[]

Deprecated.
A component may expose mutable property names for a UI designer to manipulate, this
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Deprecated.
This method is here to workaround an XMLVM array type bug where property types are
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],Lis
getPropertyTypes()

Class[]

Deprecated.
Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Deprecated.
Returns the current value of the property name, this method is used by the GUI builder
getRenderer()

CellRenderer

Deprecated.
The renderer used to draw the container list elements
getSelectedIndex()

int

Deprecated.
Returns the current selected offset in the list
getSelectedItem()

Object

Deprecated.
Returns the current/last selected item
getSelectedRect()

Rectangle

protected
void

Deprecated.
Returns the component bounds with absolute screen coordinates, for components that
selection behavior and are not containers (currently only List) this method allows return
selection itself which is useful for things such as the popup dialog and similar UI's that n
position of the selection externally
initComponent()

Deprecated.
Allows subclasses to bind functionality that relies on fully initialized and "ready for actio
removeActionListener(ActionListener l)

void

Deprecated.
Allows binding a listener to user selection actions
setModel(ListModel model)

void

Deprecated.
Set the model for the container list
setPropertyValue(String name, Object value)

String

Method Summary

Deprecated.
Sets a new value to the given property, returns an error message if failed and null if suc

992

Overview (Codename One API)


setRenderer(CellRenderer r)

Deprecated.
The renderer used to draw the container list elements

void

setSelectedIndex(int index)

Deprecated.
Sets the current selected offset in the list, by default this implementation will scroll the li
selection is outside of the screen

void

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,

Methods inherited from class com.codename1.ui.Container

993

Overview (Codename One API)


setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ContainerList
public ContainerList()

Deprecated.
Default constructor
ContainerList
public ContainerList(ListModel m)

Deprecated.
Constructs a container list with the given model
Parameters:
m - the model
ContainerList
public ContainerList(Layout l,
ListModel m)

Deprecated.
Constructs a container list with the given model and layout
Parameters:
l - layout manager
m - the model

Method Detail
setRenderer
public void setRenderer(CellRenderer r)

Deprecated.
The renderer used to draw the container list elements
Parameters:
r - renderer instance
getRenderer
public CellRenderer getRenderer()

Deprecated.
The renderer used to draw the container list elements
getModel
public ListModel getModel()

Deprecated.
Returns the list model
Returns:
the list model

Methods inherited from class com.codename1.ui.Component

994

Overview (Codename One API)


addActionListener
public void addActionListener(ActionListener l)

Deprecated.
Allows binding a listener to user selection actions
Parameters:
l - the action listener to be added
getActionListeners
public Vector getActionListeners()

Deprecated. use getListeners instead


This method allows extracting the action listeners from the current list
Returns:
vector containing the action listeners on the list
getListeners
public Collection getListeners()

Deprecated.
This method allows extracting the action listeners from the current list
Returns:
Collection containing the action listeners on the list
removeActionListener
public void removeActionListener(ActionListener l)

Deprecated.
Allows binding a listener to user selection actions
Parameters:
l - the action listener to be removed
initComponent
protected void initComponent()

Deprecated.
Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Deprecated.
Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
setModel
public void setModel(ListModel model)

Deprecated.
Set the model for the container list
Parameters:
model - a model class that is mapped into the internal components
getSelectedItem
public Object getSelectedItem()

Deprecated.
Returns the current/last selected item
Returns:

Method Detail

995

Overview (Codename One API)


selected item or null
getSelectedIndex
public int getSelectedIndex()

Deprecated.
Returns the current selected offset in the list
Returns:
the current selected offset in the list
setSelectedIndex
public void setSelectedIndex(int index)

Deprecated.
Sets the current selected offset in the list, by default this implementation will scroll the
list to the selection if the selection is outside of the screen
Parameters:
index - the current selected offset in the list
fireActionEvent
protected void fireActionEvent(ActionEvent evt)

Deprecated.
Triggers the event to the listeners
Parameters:
evt - the event to fire
getPropertyNames
public String[] getPropertyNames()

Deprecated.
A component may expose mutable property names for a UI designer to manipulate,
this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Deprecated.
Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

Deprecated.
This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Deprecated.
Returns the current value of the property name, this method is used by the GUI
builder

Method Detail

996

Overview (Codename One API)


Overrides:
getPropertyValue

in class Component

Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Deprecated.
Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getSelectedRect
public Rectangle getSelectedRect()

Deprecated.
Description copied from class: Component
Returns the component bounds with absolute screen coordinates, for components
that include an internal selection behavior and are not containers (currently only List)
this method allows returning the position of the selection itself which is useful for
things such as the popup dialog and similar UI's that need to reference the position of
the selection externally
Overrides:
getSelectedRect in class Component
Returns:
the bounds of the component with absolute screen coordinates
getDragRegionStatus
protected int getDragRegionStatus(int x,
int y)

Deprecated.
Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Overrides:
getDragRegionStatus in class Component
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values

Method Detail

997

Overview (Codename One API)


com.codename1.ui.list

Interface CellRenderer<T>
All Known Implementing Classes:
DefaultListCellRenderer, GenericListCellRenderer
Deprecated.
this interface was added for ContainerList which is now deprecated. Use GenericListCellRenderer or
ListCellRenderer instead
public interface

This class is geared to replace the ListCellRenderer in the long run to provide a more generic
rendering API. A "rubber stamp" tool that allows us to extract a component (often the same
component instance for all invocations) that is initialized to the value of the current item extracted from
the model, this component is drawn on the list and discarded. No state of the component is kept and
the component is essentially discarded.
An instance of a renderer can be developed as such:

public class MyYesNoRenderer extends Label implements ListCellRenderer {


public Component getListCellRendererComponent(List list, Object value, int index, boolean isSe
if( ((Boolean)value).booleanValue() ) {
setText("Yes");
} else {
setText("No");
}
return this;
}
public Component getListFocusComponent(List list) {
Label label = new label("");
label.getStyle().setBgTransparency(100);
return label;
}
}

It is recommended that the component whose values are manipulated would not support features
such as repaint(). This is accomplished by overriding repaint in the subclass with an empty
implementation. This is advised for performance reasons, otherwise every change made to the
component might trigger a repaint that wouldn't do anything but still cost in terms of processing.
See Also:
GenericListCellRenderer, ListCellRenderer

Method Summary
Modifier and
Type
Component

Method and Description


getCellRendererComponent(Component list, Object model, T value,
int index, boolean isSelected)

Deprecated.
Returns a component instance that is already set to render "value".
getFocusComponent(Component list)

Component

Deprecated.
Returns a component instance that is painted under the currently focused
renderer and is animated to provide smooth scrolling.

Method Detail

Interface CellRenderer<T>

998

Overview (Codename One API)


getCellRendererComponent
Component getCellRendererComponent(Component list,
Object model,
T value,
int index,
boolean isSelected)

Deprecated.
Returns a component instance that is already set to render "value". While it is not a
requirement many renderes often derive from a component (such as a label) and
return "this". Notice that a null value for the value argument might be sent when
refreshing the theme of the list.
Parameters:
list - the list component
model - the model behind the render
value - the value to render
index - the index in the list
isSelected - whether the entry is selected
Returns:
a component to paint within the list
getFocusComponent
Component getFocusComponent(Component list)

Deprecated.
Returns a component instance that is painted under the currently focused renderer
and is animated to provide smooth scrolling. When the selection moves, this
component is drawn above/bellow the list items - it is recommended to give this
component some level of transparency (see above code example). This method is
optional an implementation can choose to return null.
Parameters:
list - the parent list
Returns:
a component to use as focus
See Also:
Component.setSmoothScrolling(boolean)

Method Detail

999

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class UnitValue
java.lang.Object

com.codename1.ui.layouts.mig.UnitValue

public final class


extends Object

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Class UnitValue

Field and Description


ADD

An operation indicating a addition of two sub units.


ALIGN

A unit indicating alignment.


BUTTON

A unit indicating botton size.


CM

A unit indicating centimeters.


DIV

An operation indicating a division of two sub units.


INCH

A unit indicating inches.


LABEL_ALIGN

A unit indicating label alignment.


LINK_H

A unit indicating linking to height.


LINK_W

A unit indicating linking to width.


LINK_X

A unit indicating linking to x.


LINK_X2

A unit indicating linking to x2.


LINK_XPOS

A unit indicating linking to x position on screen.


LINK_Y

A unit indicating linking to y.


LINK_Y2

A unit indicating linking to y2.


LINK_YPOS

A unit indicating linking to y position on screen.


LOOKUP

A unit indicating a lookup.


LPX

A unit indicating logical horizontal pixels.


LPY

A unit indicating logical vertical pixels.


MAX

An operation indicating the maximum of two sub units


MAX_SIZE

A unit indicating maximum size.


MID

An operation indicating the middle value of two sub units

1000

Overview (Codename One API)


MIN

static int

An operation indicating the minimum of two sub units


MIN_SIZE

static int

A unit indicating minimum size.


MM

static int

A unit indicating millimeters.


MUL

static int

An operation indicating a multiplication of two sub units.


PERCENT

static int

A unit indicating percent.


PIXEL

static int

A unit indicating pixels.


PREF_SIZE

static int

A unit indicating preferred size.


PT

static int

A unit indicating points.


SPX

static int

A unit indicating screen percentage width.


SPY

static int

A unit indicating screen percentage height.


STATIC

static int

An operation indicating a static value.


SUB

static int

An operation indicating a subtraction of two sub units

Constructor Summary
Constructor and Description
UnitValue(float value)
UnitValue(float value, int unit, String createString)

Method Summary
Modifier and Type
static void
String

Method and Description


addGlobalUnitConverter(UnitConverter conv)

Adds a global unit converter that can convert from some unit to pixels.
getConstraintString()

Returns the creation string for this object.


getDefaultUnit()

static int

Deprecated.
Use PlatformDefaults.getDefaultHorizontalUnit() and
PlatformDefaults.getDefaultVerticalUnit() instead.

static
UnitConverter[]

getGlobalUnitConverters()

int

getOperation()

int

getPixels(float refValue, ContainerWrapper parent,


ComponentWrapper comp)

Returns the global converters currently registered.

Returns the size in pixels rounded.


float

getPixelsExact(float refValue, ContainerWrapper parent,


ComponentWrapper comp)

Returns the size in pixels.

Field Summary

UnitValue[]

getSubUnits()

int

getUnit()

String

getUnitString()

float

getValue()

1001

Overview (Codename One API)


hashCode()

int

Returns a hash code value for the object.

boolean
static boolean

isHorizontal()
removeGlobalUnitConverter(UnitConverter unit)

Removed the converter.


setDefaultUnit(int unit)

static void

Deprecated.
Use PlatformDefaults.setDefaultHorizontalUnit(int) and
PlatformDefaults.setDefaultVerticalUnit(int) instead.
toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, notify, notifyAll, wait, wait, wait

Field Detail
STATIC
public static final int STATIC

An operation indicating a static value.


See Also:
Constant Field Values
ADD
public static final int ADD

An operation indicating a addition of two sub units.


See Also:
Constant Field Values
SUB
public static final int SUB

An operation indicating a subtraction of two sub units


See Also:
Constant Field Values
MUL
public static final int MUL

An operation indicating a multiplication of two sub units.


See Also:
Constant Field Values
DIV
public static final int DIV

An operation indicating a division of two sub units.


See Also:
Constant Field Values
MIN
public static final int MIN

An operation indicating the minimum of two sub units


See Also:
Constant Field Values

Method Summary

1002

Overview (Codename One API)


MAX
public static final int MAX

An operation indicating the maximum of two sub units


See Also:
Constant Field Values
MID
public static final int MID

An operation indicating the middle value of two sub units


See Also:
Constant Field Values
PIXEL
public static final int PIXEL

A unit indicating pixels.


See Also:
Constant Field Values
LPX
public static final int LPX

A unit indicating logical horizontal pixels.


See Also:
Constant Field Values
LPY
public static final int LPY

A unit indicating logical vertical pixels.


See Also:
Constant Field Values
MM
public static final int MM

A unit indicating millimeters.


See Also:
Constant Field Values
CM
public static final int CM

A unit indicating centimeters.


See Also:
Constant Field Values
INCH
public static final int INCH

A unit indicating inches.


See Also:
Constant Field Values
PERCENT
public static final int PERCENT

A unit indicating percent.


See Also:
Constant Field Values

Field Detail

1003

Overview (Codename One API)


PT
public static final int PT

A unit indicating points.


See Also:
Constant Field Values
SPX
public static final int SPX

A unit indicating screen percentage width.


See Also:
Constant Field Values
SPY
public static final int SPY

A unit indicating screen percentage height.


See Also:
Constant Field Values
ALIGN
public static final int ALIGN

A unit indicating alignment.


See Also:
Constant Field Values
MIN_SIZE
public static final int MIN_SIZE

A unit indicating minimum size.


See Also:
Constant Field Values
PREF_SIZE
public static final int PREF_SIZE

A unit indicating preferred size.


See Also:
Constant Field Values
MAX_SIZE
public static final int MAX_SIZE

A unit indicating maximum size.


See Also:
Constant Field Values
BUTTON
public static final int BUTTON

A unit indicating botton size.


See Also:
Constant Field Values
LINK_X
public static final int LINK_X

A unit indicating linking to x.


See Also:
Constant Field Values

Field Detail

1004

Overview (Codename One API)


LINK_Y
public static final int LINK_Y

A unit indicating linking to y.


See Also:
Constant Field Values
LINK_W
public static final int LINK_W

A unit indicating linking to width.


See Also:
Constant Field Values
LINK_H
public static final int LINK_H

A unit indicating linking to height.


See Also:
Constant Field Values
LINK_X2
public static final int LINK_X2

A unit indicating linking to x2.


See Also:
Constant Field Values
LINK_Y2
public static final int LINK_Y2

A unit indicating linking to y2.


See Also:
Constant Field Values
LINK_XPOS
public static final int LINK_XPOS

A unit indicating linking to x position on screen.


See Also:
Constant Field Values
LINK_YPOS
public static final int LINK_YPOS

A unit indicating linking to y position on screen.


See Also:
Constant Field Values
LOOKUP
public static final int LOOKUP

A unit indicating a lookup.


See Also:
Constant Field Values
LABEL_ALIGN
public static final int LABEL_ALIGN

A unit indicating label alignment.


See Also:
Constant Field Values

Field Detail

1005

Overview (Codename One API)


Constructor

Detail

UnitValue
public UnitValue(float value)

UnitValue
public UnitValue(float value,
int unit,
String createString)

Method Detail
getPixels
public final int getPixels(float refValue,
ContainerWrapper parent,
ComponentWrapper comp)

Returns the size in pixels rounded.


Parameters:
refValue - The reference value. Normally the size of the parent. For unit
ALIGN the current size of the component should be sent in.
parent - The parent. May be null for testing the validity of the value, but
should normally not and are not required to return any usable value if null.
comp - The component, if any, that the value is for. Might be null if the value
is not connected to any component.
Returns:
The size in pixels.
getPixelsExact
public final float getPixelsExact(float refValue,
ContainerWrapper parent,
ComponentWrapper comp)

Returns the size in pixels.


Parameters:
refValue - The reference value. Normally the size of the parent. For unit
ALIGN the current size of the component should be sent in.
parent - The parent. May be null for testing the validity of the value, but
should normally not and are not required to return any usable value if null.
comp - The component, if any, that the value is for. Might be null if the value
is not connected to any component.
Returns:
The size in pixels.
getSubUnits
public final UnitValue[] getSubUnits()

getUnit
public final int getUnit()

getUnitString
public final String getUnitString()

getOperation
public final int getOperation()

getValue
public final float getValue()

isHorizontal
public final boolean isHorizontal()

Constructor Detail

1006

Overview (Codename One API)


toString
public final String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
getConstraintString
public final String getConstraintString()

Returns the creation string for this object. Note that


LayoutUtil.setDesignTime(ContainerWrapper, boolean)

must be set to true for the

creation strings to be stored.


Returns:
The constraint string or null if none is registered.
hashCode
public final int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
addGlobalUnitConverter
public static void addGlobalUnitConverter(UnitConverter conv)

Adds a global unit converter that can convert from some unit to pixels.
This converter will be asked before the platform converter so the values for it (e.g.
"related" and "unrelated") can be overridden. It is however not possible to override
the built in ones (e.g. "mm", "pixel" or "lp").
Parameters:
conv - The converter. Not null.
removeGlobalUnitConverter
public static boolean removeGlobalUnitConverter(UnitConverter unit)

Removed the converter.


Parameters:

Method Detail

1007

Overview (Codename One API)


unit - The converter.
Returns:
If there was a converter found and thus removed.
getGlobalUnitConverters
public static UnitConverter[] getGlobalUnitConverters()

Returns the global converters currently registered. The platform converter will not be
in this list.
Returns:
The converters. Never null.
getDefaultUnit
public static int getDefaultUnit()

Deprecated. Use PlatformDefaults.getDefaultHorizontalUnit() and


PlatformDefaults.getDefaultVerticalUnit() instead.
Returns the current default unit. The default unit is the unit used if no unit is set. E.g.
"width 10".
Returns:
The current default unit.
See Also:
PIXEL, LPX
setDefaultUnit
public static void setDefaultUnit(int unit)

Deprecated. Use PlatformDefaults.setDefaultHorizontalUnit(int) and


PlatformDefaults.setDefaultVerticalUnit(int) instead.
Sets the default unit. The default unit is the unit used if no unit is set. E.g. "width 10".
Parameters:
unit - The new default unit.
See Also:
PIXEL, LPX

Method Detail

1008

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class UnitConverter
java.lang.Object

com.codename1.ui.layouts.mig.UnitConverter

public abstract class


extends Object

Field Summary
Modifier and
Type

Field and Description


UNABLE

static int

Value to return if this converter can not handle the unit sent in as an
argument to the convert method.

Constructor Summary
Constructor and Description
UnitConverter()

Method Summary
Modifier and
Type

Method and Description

convertToPixels(float value, String unit, boolean isHor,


abstract int float refValue, ContainerWrapper parent, ComponentWrapper comp)
Converts value to pixels.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
UNABLE
public static final int UNABLE

Value to return if this converter can not handle the unit sent in as an argument to the
convert method.
See Also:
Constant Field Values

Constructor Detail
UnitConverter
public UnitConverter()

Class UnitConverter

1009

Overview (Codename One API)


Method

Detail

convertToPixels
public abstract int convertToPixels(float value,
String unit,
boolean isHor,
float refValue,
ContainerWrapper parent,
ComponentWrapper comp)

Converts value to pixels.


Parameters:
value - The value to be converted.
unit - The unit of value. Never null and at least one character.
refValue - Some reference value that may of may not be used. If the unit is
percent for instance this value is the value to take the percent from. Usually
the size of the parent component in the appropriate dimension.
isHor - If the value is horizontal (true) or vertical (false).
parent - The parent of the target component that value is to be applied to.
Might for instance be needed to get the screen that the component is on in a
multi screen environment.
May be null in which case a "best guess" value should be returned.
comp - The component, if applicable, or null if none.
Returns:
The number of pixels if unit is handled by this converter,
UnitConverter.UNABLE if not.

Method Detail

1010

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class PlatformDefaults
java.lang.Object

com.codename1.ui.layouts.mig.PlatformDefaults

public final class


extends Object

Currently handles Windows, Mac OS X, and GNOME spacing.

Field Summary
Modifier and
Type

Field and Description


BASE_FONT_SIZE

static int

I value indicating that the size of the font for the container of the component
will be used as a base for calculating the logical pixel size.
BASE_REAL_PIXEL

static int

I value indicating that the size of a logical pixel should always be a real pixel
and thus no compensation will be made.
BASE_SCALE_FACTOR

static int

I value indicating that the screen DPI will be used as a base for calculating
the logical pixel size.

static int

GNOME

static int

MAC_OSX

static
String
static int

VISUAL_PADDING_PROPERTY

Property to use in LAF settings and as JComponent client property to specify


the visual padding.
WINDOWS_XP

Method Summary
Modifier and Type
static String
static int
static int
static int
static boolean
static int
static int[]
static UnitValue
static
InCellGapProvider
static BoundSize

Class PlatformDefaults

Method and Description


getButtonOrder()

Returns the order for the typical buttons in a standard button bar.
getCurrentPlatform()

Returns the platform that the JRE is running on currently.


getDefaultDPI()
getDefaultHorizontalUnit()

Returns the current default unit.


getDefaultRowAlignmentBaseline()

The default alignment for rows.


getDefaultVerticalUnit()

Returns the current default unit.


getDefaultVisualPadding(String key)

Returns the visual bounds for a component type.


getDialogInsets(int side)

Returns the default dialog inset depending of the current platform.


getGapProvider()

Returns the current gap provider or null if none is set and "related"
should always be used.
getGridGapX()

1011

Overview (Codename One API)


Returns the platform recommended inter-cell gap in the horizontal
(x) dimension..
getGridGapY()
static BoundSize

static Float

Returns the platform recommended inter-cell gap in the vertical (x)


dimension..
getHorizontalScaleFactor()

The forced scale factor that all screen relative units (e.g.
getLabelAlignPercentage()

static float

static int

Returns the percentage used for alignment for labels (0 is left, 50 is


center and 100 is right).
getLogicalPixelBase()

What base value should be used to calculate logical pixel sizes.


getMinimumButtonWidth()

static UnitValue

static int
static UnitValue
static int
static int
static UnitValue
static UnitValue
static Float

Returns the recommended minimum button width depending on the


current set platform.
getModCount()

Returns how many times the defaults has been changed.


getPanelInsets(int side)

Returns the default panel inset depending of the current platform.


getPlatform()

Returns the current platform


getPlatformDPI(int plaf)
getUnitValueX(String unit)

Returns the unit value associated with the unit.


getUnitValueY(String unit)

Returns the unit value associated with the unit.


getVerticalScaleFactor()

The forced scale factor that all screen relative units (e.g.
invalidate()

void

static void
static void
static void
static void
static void
static void

static void

Tells all layout manager instances to revalidate and recalculated


everything.
setButtonOrder(String order)

Sets the order for the typical buttons in a standard button bar.
setDefaultDPI(Integer dpi)

Sets the default platform DPI.


setDefaultHorizontalUnit(int unit)

Sets the default unit.


setDefaultRowAlignmentBaseline(boolean b)

The default alignment for rows.


setDefaultVerticalUnit(int unit)

Sets the default unit.


setDefaultVisualPadding(String key, int[] insets)

Sets the visual bounds for a component type.


setDialogInsets(UnitValue top, UnitValue left,
UnitValue bottom, UnitValue right)

Sets the default insets for a dialog.


static void

setGapProvider(InCellGapProvider provider)
Sets the current gap provider or null if none is set

and "related"

should always be used.


static void
static void
static void
static void
static void

Method Summary

setGridCellGap(UnitValue x, UnitValue y)

Sets gap between two cells in the grid.


setHorizontalScaleFactor(Float f)

The forced scale factor that all screen relative units (e.g.
setIndentGap(UnitValue x, UnitValue y)

Sets gap value for components that are "intended".


setLogicalPixelBase(int base)

What base value should be used to calculate logical pixel sizes.


setMinimumButtonWidth(UnitValue width)

1012

Overview (Codename One API)


Sets the recommended minimum button width.
static void

setPanelInsets(UnitValue top, UnitValue left,


UnitValue bottom, UnitValue right)

Sets the default insets for a dialog.


static void
static void
static void
static void
static void
static void

setParagraphGap(UnitValue x, UnitValue y)

Sets paragraph gap value for components.


setPlatform(int plaf)

Set the defaults to the default for the platform


setRelatedGap(UnitValue x, UnitValue y)

Sets gap value for components that are "related".


setUnitValue(String[] unitStrings, UnitValue x, UnitValue y)

Sets the unit value associated with a unit string.


setUnrelatedGap(UnitValue x, UnitValue y)

Sets gap value for components that are "unrelated".


setVerticalScaleFactor(Float f)

The forced scale factor that all screen relative units (e.g.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
VISUAL_PADDING_PROPERTY
public static String VISUAL_PADDING_PROPERTY

Property to use in LAF settings and as JComponent client property to specify the
visual padding.
WINDOWS_XP
public static final int WINDOWS_XP

See Also:
Constant Field Values
MAC_OSX
public static final int MAC_OSX

See Also:
Constant Field Values
GNOME
public static final int GNOME

See Also:
Constant Field Values
BASE_FONT_SIZE
public static final int BASE_FONT_SIZE

I value indicating that the size of the font for the container of the component will be
used as a base for calculating the logical pixel size. This is much as how Windows
calculated DLU (dialog units).
See Also:
net.miginfocom.layout.UnitValue#LPX,
net.miginfocom.layout.UnitValue#LPY, setLogicalPixelBase(int),
Constant Field Values

Methods inherited from class java.lang.Object

1013

Overview (Codename One API)


BASE_SCALE_FACTOR
public static final int BASE_SCALE_FACTOR

I value indicating that the screen DPI will be used as a base for calculating the logical
pixel size.
This is the default value.
See Also:
net.miginfocom.layout.UnitValue#LPX,
net.miginfocom.layout.UnitValue#LPY, setLogicalPixelBase(int),
setVerticalScaleFactor(Float), setHorizontalScaleFactor(Float),

Constant Field Values


BASE_REAL_PIXEL
public static final int BASE_REAL_PIXEL

I value indicating that the size of a logical pixel should always be a real pixel and thus
no compensation will be made.
See Also:
net.miginfocom.layout.UnitValue#LPX,
net.miginfocom.layout.UnitValue#LPY, setLogicalPixelBase(int),
Constant Field Values

Method Detail
getCurrentPlatform
public static int getCurrentPlatform()

Returns the platform that the JRE is running on currently.


Returns:
The platform that the JRE is running on currently. E.g. MAC_OSX, WINDOWS_XP,
or GNOME.
setPlatform
public static void setPlatform(int plaf)

Set the defaults to the default for the platform


Parameters:
plaf - The platform. PlatformDefaults.WINDOWS_XP,
PlatformDefaults.MAC_OSX, or PlatformDefaults.GNOME.
setDefaultVisualPadding
public static void setDefaultVisualPadding(String key,
int[] insets)

Sets the visual bounds for a component type.


Parameters:
key - The component type. E.g. "TabbedPane.visualPadding" or
"ComboBox.editable.isSquare.visualPadding". See source code for list.
insets - Top, left, bottom, right. Always length 4 or null.
See Also:
net.miginfocom.layout.ComponentWrapper#getVisualPadding()

getDefaultVisualPadding
public static int[] getDefaultVisualPadding(String key)

Returns the visual bounds for a component type.


Parameters:
key - The component type. E.g. "TabbedPane.visualPadding" or
"ComboBox.editable.isSquare.visualPadding". See source code for list.
Returns:
insets Top, left, bottom, right. Always length 4 or null. Live object, MUST NOT
BE CHANGED!.

Field Detail

1014

Overview (Codename One API)


See Also:
net.miginfocom.layout.ComponentWrapper#getVisualPadding()

getPlatformDPI
public static int getPlatformDPI(int plaf)

getPlatform
public static int getPlatform()

Returns the current platform


Returns:
PlatformDefaults.WINDOWS

or PlatformDefaults.MAC_OSX

getDefaultDPI
public static int getDefaultDPI()

setDefaultDPI
public static void setDefaultDPI(Integer dpi)

Sets the default platform DPI. Normally this is set in the setPlatform(int) for the
different platforms but it can be tweaked here. For instance SWT on Mac does this.
Note that this is not the actual current DPI, but the base DPI for the toolkit.
Parameters:
dpi - The base DPI. If null the default DPI is reset to the platform base DPI.
getHorizontalScaleFactor
public static Float getHorizontalScaleFactor()

The forced scale factor that all screen relative units (e.g. millimeters, inches and
logical pixels) will be multiplied with. If null this will default to a scale that will scale
the current screen to the default screen resolution (72 DPI for Mac and 92 DPI for
Windows).
Returns:
The forced scale or null for default scaling.
See Also:
getHorizontalScaleFactor(), ComponentWrapper.getHorizontalScreenDPI()
setHorizontalScaleFactor
public static void setHorizontalScaleFactor(Float f)

The forced scale factor that all screen relative units (e.g. millimeters, inches and
logical pixels) will be multiplied with. If null this will default to a scale that will scale
the current screen to the default screen resolution (72 DPI for Mac and 92 DPI for
Windows).
Parameters:
f - The forced scale or null for default scaling.
See Also:
getHorizontalScaleFactor(), ComponentWrapper.getHorizontalScreenDPI()
getVerticalScaleFactor
public static Float getVerticalScaleFactor()

The forced scale factor that all screen relative units (e.g. millimeters, inches and
logical pixels) will be multiplied with. If null this will default to a scale that will scale
the current screen to the default screen resolution (72 DPI for Mac and 92 DPI for
Windows).
Returns:
The forced scale or null for default scaling.
See Also:
getHorizontalScaleFactor(), ComponentWrapper.getVerticalScreenDPI()
setVerticalScaleFactor
public static void setVerticalScaleFactor(Float f)

Method Detail

1015

Overview (Codename One API)


The forced scale factor that all screen relative units (e.g. millimeters, inches and
logical pixels) will be multiplied with. If null this will default to a scale that will scale
the current screen to the default screen resolution (72 DPI for Mac and 92 DPI for
Windows).
Parameters:
f - The forced scale or null for default scaling.
See Also:
getHorizontalScaleFactor(), ComponentWrapper.getVerticalScreenDPI()
getLogicalPixelBase
public static int getLogicalPixelBase()

What base value should be used to calculate logical pixel sizes.


Returns:
The current base. Default is BASE_SCALE_FACTOR
See Also:
BASE_FONT_SIZE, BASE_SCALE_FACTOR, BASE_REAL_PIXEL
setLogicalPixelBase
public static void setLogicalPixelBase(int base)

What base value should be used to calculate logical pixel sizes.


Parameters:
base - The new base. Default is BASE_SCALE_FACTOR
See Also:
BASE_FONT_SIZE, BASE_SCALE_FACTOR, BASE_REAL_PIXEL
setRelatedGap
public static void setRelatedGap(UnitValue x,
UnitValue y)

Sets gap value for components that are "related".


Parameters:
x - The value that will be transformed to pixels. If null the current value will
not change.
y - The value that will be transformed to pixels. If null the current value will
not change.
setUnrelatedGap
public static void setUnrelatedGap(UnitValue x,
UnitValue y)

Sets gap value for components that are "unrelated".


Parameters:
x - The value that will be transformed to pixels. If null the current value will
not change.
y - The value that will be transformed to pixels. If null the current value will
not change.
setParagraphGap
public static void setParagraphGap(UnitValue x,
UnitValue y)

Sets paragraph gap value for components.


Parameters:
x - The value that will be transformed to pixels. If null the current value will
not change.
y - The value that will be transformed to pixels. If null the current value will
not change.
setIndentGap
public static void setIndentGap(UnitValue x,
UnitValue y)

Sets gap value for components that are "intended".


Parameters:

Method Detail

1016

Overview (Codename One API)


- The value that will be transformed to pixels. If null the current value will
not change.
y - The value that will be transformed to pixels. If null the current value will
not change.
setGridCellGap
x

public static void setGridCellGap(UnitValue x,


UnitValue y)

Sets gap between two cells in the grid. Note that this is not a gap between
component IN a cell, that has to be set on the component constraints. The value will
be the min and preferred size of the gap.
Parameters:
x - The value that will be transformed to pixels. If null the current value will
not change.
y - The value that will be transformed to pixels. If null the current value will
not change.
setMinimumButtonWidth
public static void setMinimumButtonWidth(UnitValue width)

Sets the recommended minimum button width.


Parameters:
width - The recommended minimum button width.
getMinimumButtonWidth
public static UnitValue getMinimumButtonWidth()

Returns the recommended minimum button width depending on the current set
platform.
Returns:
The recommended minimum button width depending on the current set
platform.
getUnitValueX
public static UnitValue getUnitValueX(String unit)

Returns the unit value associated with the unit. (E.i. "related" or "indent"). Must be
lower case.
Parameters:
unit - The unit string.
Returns:
The unit value associated with the unit. null for unrecognized units.
getUnitValueY
public static UnitValue getUnitValueY(String unit)

Returns the unit value associated with the unit. (E.i. "related" or "indent"). Must be
lower case.
Parameters:
unit - The unit string.
Returns:
The unit value associated with the unit. null for unrecognized units.
setUnitValue
public static void setUnitValue(String[] unitStrings,
UnitValue x,
UnitValue y)

Sets the unit value associated with a unit string. This may be used to store values for
new unit strings or modify old. Note that if a built in unit (such as "related") is modified
all versions of it must be set (I.e. "r", "rel" and "related"). The build in values will be
reset to the default ones if the platform is re-set.
Parameters:
unitStrings - The unit strings. E.g. "mu", "myunit". Will be converted to lower
case and trimmed. Not null.
x - The value for the horizontal dimension. If null the value is not changed.

Method Detail

1017

Overview (Codename One API)


- The value for the vertical dimension. Might be same object as for x. If null
the value is not changed.
getButtonOrder
y

public static String getButtonOrder()

Returns the order for the typical buttons in a standard button bar. It is one letter per
button type.
Returns:
The button order.
See Also:
setButtonOrder(String)

setButtonOrder
public static void setButtonOrder(String order)

Sets the order for the typical buttons in a standard button bar. It is one letter per
button type.
Letter in upper case will get the minimum button width that the
getMinimumButtonWidth() specifies and letters in lower case will get the width the
current look&feel specifies.
Gaps will never be added to before the first component or after the last component.
However, '+' (push) will be applied before and after as well, but with a minimum size
of 0 if first/last so there will not be a gap before or after.
If gaps are explicitly set on buttons they will never be reduced, but they may be
increased.
These are the characters that can be used:
'L' - Buttons with this style tag will staticall end up on the left end of the bar.
'R' - Buttons with this style tag will staticall end up on the right end of the bar.
'H' - A tag for the "help" button that normally is supposed to be on the right.
'E' - A tag for the "help2" button that normally is supposed to be on the left.
'Y' - A tag for the "yes" button.
'N' - A tag for the "no" button.
'X' - A tag for the "next >" or "forward >" button.
'B' - A tag for the "< back>" or "< previous" button.
'I' - A tag for the "finish".
'A' - A tag for the "apply" button.
'C' - A tag for the "cancel" or "close" button.
'O' - A tag for the "ok" or "done" button.
'U' - All Uncategorized, Other, or "Unknown" buttons. Tag will be "other".
'+' - A glue push gap that will take as much space as it can and at least an
"unrelated" gap. (Platform dependant)
'_' - (underscore) An "unrelated" gap. (Platform dependant)
Even though the style tags are normally applied to buttons this works with all
components.
The normal style for MAC OS X is "L_HE+U+FBI_NYCOA_R", for Windows is
"L_E+U+FBI_YNOCAH_R", and for GNOME is "L_HE+UNYACBXIO_R".
Parameters:
order

- The new button order for the current platform.

getGridGapX
public static BoundSize getGridGapX()

Returns the platform recommended inter-cell gap in the horizontal (x) dimension..
Returns:
The platform recommended inter-cell gap in the horizontal (x) dimension..

Method Detail

1018

Overview (Codename One API)


getGridGapY
public static BoundSize getGridGapY()

Returns the platform recommended inter-cell gap in the vertical (x) dimension..
Returns:
The platform recommended inter-cell gap in the vertical (x) dimension..
getDialogInsets
public static UnitValue getDialogInsets(int side)

Returns the default dialog inset depending of the current platform.


Parameters:
side - top == 0, left == 1, bottom = 2, right = 3.
Returns:
The inset. Never null.
setDialogInsets
public static void setDialogInsets(UnitValue
UnitValue
UnitValue
UnitValue

top,
left,
bottom,
right)

Sets the default insets for a dialog. Values that are null will not be changed.
Parameters:
top - The top inset. May be null.
left - The left inset. May be null.
bottom - The bottom inset. May be null.
right - The right inset. May be null.
getPanelInsets
public static UnitValue getPanelInsets(int side)

Returns the default panel inset depending of the current platform.


Parameters:
side - top == 0, left == 1, bottom = 2, right = 3.
Returns:
The inset. Never null.
setPanelInsets
public static void setPanelInsets(UnitValue
UnitValue
UnitValue
UnitValue

top,
left,
bottom,
right)

Sets the default insets for a dialog. Values that are null will not be changed.
Parameters:
top - The top inset. May be null.
left - The left inset. May be null.
bottom - The bottom inset. May be null.
right - The right inset. May be null.
getLabelAlignPercentage
public static float getLabelAlignPercentage()

Returns the percentage used for alignment for labels (0 is left, 50 is center and 100 is
right).
Returns:
The percentage used for alignment for labels
getGapProvider
public static InCellGapProvider getGapProvider()

Returns the current gap provider or null if none is set and "related" should always be
used.
Returns:
The current gap provider or null if none is set and "related" should always be
used.

Method Detail

1019

Overview (Codename One API)


setGapProvider
public static void setGapProvider(InCellGapProvider provider)

Sets the current gap provider or null if none is set and "related" should always be
used.
Parameters:
provider - The current gap provider or null if none is set and "related"
should always be used.
getModCount
public static int getModCount()

Returns how many times the defaults has been changed. This can be used as a light
weight check to see if layout caches needs to be refreshed.
Returns:
How many times the defaults has been changed.
invalidate
public void invalidate()

Tells all layout manager instances to revalidate and recalculated everything.


getDefaultHorizontalUnit
public static int getDefaultHorizontalUnit()

Returns the current default unit. The default unit is the unit used if no unit is set. E.g.
"width 10".
Returns:
The current default unit.
See Also:
UnitValue.PIXEL, UnitValue.LPX
setDefaultHorizontalUnit
public static void setDefaultHorizontalUnit(int unit)

Sets the default unit. The default unit is the unit used if no unit is set. E.g. "width 10".
Parameters:
unit - The new default unit.
See Also:
UnitValue.PIXEL, UnitValue.LPX
getDefaultVerticalUnit
public static int getDefaultVerticalUnit()

Returns the current default unit. The default unit is the unit used if no unit is set. E.g.
"width 10".
Returns:
The current default unit.
See Also:
UnitValue.PIXEL, UnitValue.LPY
setDefaultVerticalUnit
public static void setDefaultVerticalUnit(int unit)

Sets the default unit. The default unit is the unit used if no unit is set. E.g. "width 10".
Parameters:
unit - The new default unit.
See Also:
UnitValue.PIXEL, UnitValue.LPY
getDefaultRowAlignmentBaseline
public static boolean getDefaultRowAlignmentBaseline()

The default alignment for rows. Pre v3.5 this was false but now it is true.
Returns:
The current value. Default is true.

Method Detail

1020

Overview (Codename One API)


Since:
3.5
setDefaultRowAlignmentBaseline
public static void setDefaultRowAlignmentBaseline(boolean b)

The default alignment for rows. Pre v3.5 this was false but now it is true.
Parameters:
b - The new value. Default is true from v3.5.
Since:
3.5

Method Detail

1021

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class MigLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.mig.MigLayout

Deprecated.
this is currently an experimental integration and has known bugs do not rely on this layout for
production
public final class
extends Layout

A very flexible layout manager.


Read the documentation that came with this layout manager for information on usage.

Constructor Summary
Constructor and Description
MigLayout()

Deprecated.
Constructor with no constraints.
MigLayout(LC layoutConstraints)

Deprecated.
Constructor.
MigLayout(LC layoutConstraints, AC colConstraints)

Deprecated.
Constructor.
MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)

Deprecated.
Constructor.
MigLayout(String layoutConstraints)

Deprecated.
Constructor.
MigLayout(String layoutConstraints, String colConstraints)

Deprecated.
Constructor.
MigLayout(String layoutConstraints, String colConstraints, String rowConstraints)

Deprecated.
Constructor.

Method Summary
Modifier and Type

Method and Description


addLayoutCallback(LayoutCallback callback)

void

Deprecated.
Adds the callback function that will be called at different stages of
the layout cylce.
addLayoutComponent(Component comp, Object constraints)

void

Deprecated.

void

addLayoutComponent(Object value, Component comp,


Container c)

Deprecated.

Class MigLayout

1022

Overview (Codename One API)


Some layouts can optionally track the addition of elements with
meta-data that allows the user to "hint" on object positioning.
findType(Class<E> clazz, Component comp)
static <E> E

Deprecated.
getColumnConstraints()

Object

Deprecated.
Returns the column layout constraints either as a String or
net.miginfocom.layout.AC.
getComponentConstraint(Component comp)

Object

Deprecated.
Returns the optional component constraint
getComponentConstraints(Component comp)

Object

Deprecated.
Returns the component constraints as a String representation.
getConstraintMap()

Map<Component,Object>

Deprecated.
Returns a shallow copy of the constraints map.
getLayoutAlignmentX(Container parent)

float

Deprecated.
getLayoutAlignmentY(Container parent)

float

Deprecated.
getLayoutConstraints()

Object

Deprecated.
Returns layout constraints either as a String or
net.miginfocom.layout.LC depending what was sent in to the
constructor or set with setLayoutConstraints(Object).
getPreferredSize(Container parent)

Dimension

Deprecated.
Returns the container preferred size
getRowConstraints()

Object

Deprecated.
Returns the row layout constraints either as a String or
net.miginfocom.layout.AC.
invalidateLayout(Container target)

void

Deprecated.
isConstraintTracking()

boolean

Deprecated.
If this method returns true, the addLayoutComponent method will
be called when replacing a layout for every component within the
container
isManagingComponent(Component c)

boolean

Deprecated.
Returns if this layout manager is currently managing this
component.
layoutContainer(Container parent)

void

Deprecated.
Layout the given parent container children
maximumLayoutSize(Container parent)

Dimension

Deprecated.
minimumLayoutSize(Container parent)

Dimension

Deprecated.
preferredLayoutSize(Container parent)

Dimension

Method Summary

Deprecated.

1023

Overview (Codename One API)


removeLayoutCallback(LayoutCallback callback)

Deprecated.
Removes the callback if it exists.

void

removeLayoutComponent(Component comp)

Deprecated.
Removes the component from the layout this operation is only
useful if the layout maintains references to components within it

void

setColumnConstraints(Object constr)

Deprecated.
Sets the column layout constraints for the layout manager
instance as a String.

void

setComponentConstraints(Component comp, Object constr)

Deprecated.
Sets the component constraint for the component that already
must be handled by this layout manager.

void

setConstraintMap(Map<Component,Object> map)

Deprecated.
Sets the constraints map.

void

setLayoutConstraints(Object constr)

Deprecated.
Sets the layout constraints for the layout manager instance as a
String.

void

setRowConstraints(Object constr)

Deprecated.
Sets the row layout constraints for the layout manager instance as
a String.

void

Methods inherited from class com.codename1.ui.layouts.Layout


equals, hashCode, isOverlapSupported, obscuresPotential

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MigLayout
public MigLayout()

Deprecated.
Constructor with no constraints.
MigLayout
public MigLayout(String layoutConstraints)

Deprecated.
Constructor.
Parameters:
layoutConstraints

- The constraints that concern the whole layout. null will

be treated as "".
MigLayout
public MigLayout(String layoutConstraints,
String colConstraints)

Deprecated.
Constructor.
Parameters:
layoutConstraints

- The constraints that concern the whole layout. null will

be treated as "".

Methods inherited from class com.codename1.ui.layouts.Layout

1024

Overview (Codename One API)


colConstraints

- The constraints for the columns in the grid. null will be

treated as "".
MigLayout
public MigLayout(String layoutConstraints,
String colConstraints,
String rowConstraints)

Deprecated.
Constructor.
Parameters:
layoutConstraints

- The constraints that concern the whole layout. null will

be treated as "".
colConstraints

- The constraints for the columns in the grid. null will be

treated as "".
rowConstraints

- The constraints for the rows in the grid. null will be treated

as "".
MigLayout
public MigLayout(LC layoutConstraints)

Deprecated.
Constructor.
Parameters:
- The constraints that concern the whole layout. null will
be treated as an empty constraint.
MigLayout
layoutConstraints

public MigLayout(LC layoutConstraints,


AC colConstraints)

Deprecated.
Constructor.
Parameters:
- The constraints that concern the whole layout. null will
be treated as an empty constraint.
colConstraints - The constraints for the columns in the grid. null will be
treated as an empty constraint.
MigLayout
layoutConstraints

public MigLayout(LC layoutConstraints,


AC colConstraints,
AC rowConstraints)

Deprecated.
Constructor.
Parameters:
- The constraints that concern the whole layout. null will
be treated as an empty constraint.
colConstraints - The constraints for the columns in the grid. null will be
treated as an empty constraint.
rowConstraints - The constraints for the rows in the grid. null will be treated
as an empty constraint.
layoutConstraints

Method Detail
getLayoutConstraints
public Object getLayoutConstraints()

Deprecated.
Returns layout constraints either as a String or net.miginfocom.layout.LC
depending what was sent in to the constructor or set with
setLayoutConstraints(Object).
Returns:

Constructor Detail

1025

Overview (Codename One API)


The layout constraints either as a String or net.miginfocom.layout.LC
depending what was sent in to the constructor or set with
setLayoutConstraints(Object). Never null.
setLayoutConstraints
public void setLayoutConstraints(Object constr)

Deprecated.
Sets the layout constraints for the layout manager instance as a String.
See the class JavaDocs for information on how this string is formatted.
Parameters:
- The layout constraints as a String pr net.miginfocom.layout.LC
representation. null is converted to "" for storage.
constr

Throws:
RuntimeException

- if the constraint was not valid.

getColumnConstraints
public Object getColumnConstraints()

Deprecated.
Returns the column layout constraints either as a String or
net.miginfocom.layout.AC.
Returns:
The column constraints either as a String or net.miginfocom.layout.AC
depending what was sent in to the constructor or set with
setColumnConstraints(Object). Never null.
setColumnConstraints
public void setColumnConstraints(Object constr)

Deprecated.
Sets the column layout constraints for the layout manager instance as a String.
See the class JavaDocs for information on how this string is formatted.
Parameters:
constr - The column layout constraints as a String or
net.miginfocom.layout.AC representation. null is converted

to "" for

storage.
Throws:
RuntimeException

- if the constraint was not valid.

getRowConstraints
public Object getRowConstraints()

Deprecated.
Returns the row layout constraints either as a String or net.miginfocom.layout.AC.
Returns:
The row constraints either as a String or net.miginfocom.layout.AC
depending what was sent in to the constructor or set with
setRowConstraints(Object). Never null.
setRowConstraints
public void setRowConstraints(Object constr)

Deprecated.
Sets the row layout constraints for the layout manager instance as a String.
See the class JavaDocs for information on how this string is formatted.
Parameters:
- The row layout constraints as a String or net.miginfocom.layout.AC
representation. null is converted to "" for storage.
constr

Throws:

Method Detail

1026

Overview (Codename One API)


RuntimeException

- if the constraint was not valid.

getConstraintMap
public Map<Component,Object> getConstraintMap()

Deprecated.
Returns a shallow copy of the constraints map.
Returns:
A shallow copy of the constraints map. Never null.
setConstraintMap
public void setConstraintMap(Map<Component,Object> map)

Deprecated.
Sets the constraints map.
Parameters:
map - The map. Will be copied.
getComponentConstraints
public Object getComponentConstraints(Component comp)

Deprecated.
Returns the component constraints as a String representation. This string is the exact
string as set with #setComponentConstraints(java.awt.Component, Object) or set
when adding the component to the parent component.
See the class JavaDocs for information on how this string is formatted.
Parameters:
comp - The component to return the constraints for.
Returns:
The component constraints as a String representation or null if the
component is not registered with this layout manager. The returned values is
either a String or a net.miginfocom.layout.CC depending on what constraint
was sent in when the component was added. May be null.
setComponentConstraints
public void setComponentConstraints(Component comp,
Object constr)

Deprecated.
Sets the component constraint for the component that already must be handled by
this layout manager.
See the class JavaDocs for information on how this string is formatted.
Parameters:
constr - The component constraints as a String or
net.miginfocom.layout.CC. null is ok.
comp - The component to set the constraints for.

Throws:
RuntimeException - if the constraint was not valid.
IllegalArgumentException - If the component is not

handling the component.

isManagingComponent
public boolean isManagingComponent(Component c)

Deprecated.
Returns if this layout manager is currently managing this component.
Parameters:
c - The component to check. If null then false will be returned.
Returns:
If this layout manager is currently managing this component.

Method Detail

1027

Overview (Codename One API)


addLayoutCallback
public void addLayoutCallback(LayoutCallback callback)

Deprecated.
Adds the callback function that will be called at different stages of the layout cylce.
Parameters:
callback - The callback. Not null.
removeLayoutCallback
public void removeLayoutCallback(LayoutCallback callback)

Deprecated.
Removes the callback if it exists.
Parameters:
callback - The callback. May be null.
layoutContainer
public void layoutContainer(Container parent)

Deprecated.
Description copied from class: Layout
Layout the given parent container children
Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
findType
public static <E> E findType(Class<E> clazz,
Component comp)

Deprecated.
minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)

Deprecated.
preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)

Deprecated.
maximumLayoutSize
public Dimension maximumLayoutSize(Container parent)

Deprecated.
getLayoutAlignmentX
public float getLayoutAlignmentX(Container parent)

Deprecated.
getLayoutAlignmentY
public float getLayoutAlignmentY(Container parent)

Deprecated.
addLayoutComponent
public void addLayoutComponent(Object value,
Component comp,
Container c)

Deprecated.
Description copied from class: Layout
Some layouts can optionally track the addition of elements with meta-data that allows
the user to "hint" on object positioning.

Method Detail

1028

Overview (Codename One API)


Overrides:
addLayoutComponent

in class Layout

Parameters:
value - optional meta data information, like
comp - the added component to the layout
c - the parent container

alignment orientation

addLayoutComponent
public void addLayoutComponent(Component comp,
Object constraints)

Deprecated.
isConstraintTracking
public boolean isConstraintTracking()

Deprecated.
Description copied from class: Layout
If this method returns true, the addLayoutComponent method will be called when
replacing a layout for every component within the container
Overrides:
isConstraintTracking in class Layout
Returns:
false by default
getComponentConstraint
public Object getComponentConstraint(Component comp)

Deprecated.
Description copied from class: Layout
Returns the optional component constraint
Overrides:
getComponentConstraint in class Layout
Parameters:
comp - the component whose constraint should be returned
Returns:
the optional component constraint
removeLayoutComponent
public void removeLayoutComponent(Component comp)

Deprecated.
Description copied from class: Layout
Removes the component from the layout this operation is only useful if the layout
maintains references to components within it
Overrides:
removeLayoutComponent in class Layout
Parameters:
comp - the removed component from layout
invalidateLayout
public void invalidateLayout(Container target)

Deprecated.
getPreferredSize
public Dimension getPreferredSize(Container parent)

Deprecated.
Description copied from class: Layout
Returns the container preferred size
Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size

Method Detail

1029

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class LinkHandler
java.lang.Object

com.codename1.ui.layouts.mig.LinkHandler

public final class


extends Object

Field Summary
Modifier and Type Field and Description
static int

HEIGHT

static int

WIDTH

static int

static int

X2

static int

static int

Y2

Method Summary
Modifier and
Type
static boolean

Method and Description


clearBounds(Object layout, String key)
clearWeakReferencesNow()

static void

This method clear any weak references right away instead of waiting for
the GC.

static Integer

getValue(Object layout, String key, int type)

static boolean

setBounds(Object layout, String key, int x, int y, int width,


int height)

Sets a key that can be linked to from any component.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
X
public static final int X

See Also:
Constant Field Values
Y
public static final int Y

See Also:
Constant Field Values

Class LinkHandler

1030

Overview (Codename One API)


WIDTH
public static final int WIDTH

See Also:
Constant Field Values
HEIGHT
public static final int HEIGHT

See Also:
Constant Field Values
X2
public static final int X2

See Also:
Constant Field Values
Y2
public static final int Y2

See Also:
Constant Field Values

Method Detail
getValue
public static Integer getValue(Object layout,
String key,
int type)

setBounds
public static boolean setBounds(Object layout,
String key,
int x,
int y,
int width,
int height)

Sets a key that can be linked to from any component.


Parameters:
layout - The MigLayout instance
key - The key to link to. This is the same as the ID in a component constraint.
x-x
y-y
width - Width
height - Height
Returns:
If the value was changed
clearWeakReferencesNow
public static void clearWeakReferencesNow()

This method clear any weak references right away instead of waiting for the GC. This
might be advantageous if lots of layout are created and disposed of quickly to keep
memory consumption down.
Since:
3.7.4
clearBounds
public static boolean clearBounds(Object layout,
String key)

Field Detail

1031

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class LayoutUtil
java.lang.Object

com.codename1.ui.layouts.mig.LayoutUtil

public final class


extends Object

A utility class that has only static helper methods.

Field Summary
Modifier and Type

Field and Description

static boolean

HAS_BEANS

static int

HORIZONTAL

static int

INF

A substitute value for aa really large value.

static int

MAX

static int

MIN

static int

PREF

static int

VERTICAL

Method Summary
Modifier and
Type
static int
static int
static Object
static int
static String
static boolean
static boolean
static void
static void
static void
static void

Method Detail

Method and Description


getDesignTimeEmptySize()

The size of an empty row or columns in a grid during design time.


getGlobalDebugMillis()

If global debug should be on or off.


getSerializedObject(Object caller)

Returns the serialized object that are associated with caller.


getSizeSafe(int[] sizes, int sizeType)
getVersion()

Returns the current version of MiG Layout.


isDesignTime(ContainerWrapper cw)

Returns if design time is turned on for a Container in ContainerWrapper.


isLeftToRight(LC lc, ContainerWrapper container)

Returns if left-to-right orientation is used.


setDesignTime(ContainerWrapper cw, boolean b)
Sets if design time is turned on for a Container in ContainerWrapper.
setDesignTimeEmptySize(int pixels)

The size of an empty row or columns in a grid during design time.


setGlobalDebugMillis(int millis)

If global debug should be on or off.


setSerializedObject(Object caller, Object o)
Sets the serialized object and associates it with caller.

1032

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
INF
public static final int INF

A substitute value for aa really large value. Integer.MAX_VALUE is not used since
that means a lot of defensive code for potential overflow must exist in many places.
This value is large enough for being unreasonable yet it is hard to overflow.
See Also:
Constant Field Values
MIN
public static final int MIN

See Also:
Constant Field Values
PREF
public static final int PREF

See Also:
Constant Field Values
MAX
public static final int MAX

See Also:
Constant Field Values
HORIZONTAL
public static final int HORIZONTAL

See Also:
Constant Field Values
VERTICAL
public static final int VERTICAL

See Also:
Constant Field Values
HAS_BEANS
public static final boolean HAS_BEANS

Method Detail
getVersion
public static String getVersion()

Returns the current version of MiG Layout.


Returns:
The current version of MiG Layout. E.g. "3.6.3" or "4.0"
getGlobalDebugMillis
public static int getGlobalDebugMillis()

If global debug should be on or off. If > 0 then debug is turned on for all MigLayout
instances.

Methods inherited from class java.lang.Object

1033

Overview (Codename One API)


Returns:
The current debug milliseconds.
See Also:
LC.setDebugMillis(int)

setGlobalDebugMillis
public static void setGlobalDebugMillis(int millis)

If global debug should be on or off. If > 0 then debug is turned on for all MigLayout
instances.
Note! This is a passive value and will be read by panels when the needed, which is
normally when they repaint/layout.
Parameters:
- The new debug milliseconds. 0 turns of global debug and leaves
debug up to every individual panel.
See Also:
millis

LC.setDebugMillis(int)

setDesignTime
public static void setDesignTime(ContainerWrapper cw,
boolean b)

Sets if design time is turned on for a Container in ContainerWrapper.


Parameters:
cw - The container to set design time for. null is legal and can be used as a
key to turn on/off design time "in general". Note though that design time "in
general" is always on as long as there is at least one ContainerWrapper with
design time.
If this method has not ever been called it will default to what
Beans.isDesignTime() returns. This means that if you call this method you
indicate that you will take responsibility for the design time value.
b - true means design time on.
isDesignTime
public static boolean isDesignTime(ContainerWrapper cw)

Returns if design time is turned on for a Container in ContainerWrapper.


Parameters:
cw - The container to set design time for. null is legal will return true if there
is at least one ContainerWrapper (or null) that have design time turned on.
Returns:
If design time is set for cw.
getDesignTimeEmptySize
public static int getDesignTimeEmptySize()

The size of an empty row or columns in a grid during design time.


Returns:
The number of pixels. Default is 15.
setDesignTimeEmptySize
public static void setDesignTimeEmptySize(int pixels)

The size of an empty row or columns in a grid during design time.


Parameters:
pixels - The number of pixels. Default is 0 (it was 15 prior to v3.7.2, but since
that meant different behaviour under design time by default it was changed to
be 0, same as non-design time). IDE vendors can still set it to 15 to get the
old behaviour.
getSizeSafe
public static int getSizeSafe(int[] sizes,
int sizeType)

Method Detail

1034

Overview (Codename One API)


isLeftToRight
public static boolean isLeftToRight(LC lc,
ContainerWrapper container)

Returns if left-to-right orientation is used. If not set explicitly in the layout constraints
the Locale of the parent is used.
Parameters:
lc - The constraint if there is one. Can be null.
container - The parent that may be used to get the left-to-right if ffc does not
specify this.
Returns:
If left-to-right orientation is currently used.
setSerializedObject
public static void setSerializedObject(Object caller,
Object o)

Sets the serialized object and associates it with caller.


Parameters:
caller - The object created o
o - The just serialized object.
getSerializedObject
public static Object getSerializedObject(Object caller)

Returns the serialized object that are associated with caller. It also removes it from
the list.
Parameters:
caller - The original creator of the object.
Returns:
The object.

Method Detail

1035

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class LayoutCallback
java.lang.Object

com.codename1.ui.layouts.mig.LayoutCallback

public abstract class


extends Object

A class to extend if you want to provide more control over where a component is placed or the size of
it.
Note! Returned arrays from this class will never be altered. This means that caching of arrays in these
methods is OK.

Constructor Summary
Constructor and Description
LayoutCallback()

Method Summary
Modifier and
Type

Method and Description


correctBounds(ComponentWrapper comp)

void

A last minute change of the bounds.

UnitValue[]

getPosition(ComponentWrapper comp)

Returns a position similar to the "pos" the component constraint.


getSize(ComponentWrapper comp)

BoundSize[]

Returns a size similar to the "width" and "height" in the component


constraint.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
LayoutCallback
public LayoutCallback()

Method Detail
getPosition
public UnitValue[] getPosition(ComponentWrapper comp)

Returns a position similar to the "pos" the component constraint.


Parameters:
comp - The component wrapper that holds the actual component
(JComponent is Swing and Control in SWT). Should not be altered.
Returns:

Class LayoutCallback

1036

Overview (Codename One API)


The [x, y, x2, y2] as explained in the documentation for "pos". If null is
returned nothing is done and this is the default.
See Also:
UnitValue,
net.miginfocom.layout.ConstraintParser#parseUnitValue(String,
boolean)

getSize
public BoundSize[] getSize(ComponentWrapper comp)

Returns a size similar to the "width" and "height" in the component constraint.
Parameters:
comp - The component wrapper that holds the actual component
(JComponent is Swing and Control in SWT). Should not be altered.
Returns:
The [width, height] as explained in the documentation for "width" and
"height". If null is returned nothing is done and this is the default.
See Also:
net.miginfocom.layout.BoundSize,
net.miginfocom.layout.ConstraintParser#parseBoundSize(String,
boolean, boolean)

correctBounds
public void correctBounds(ComponentWrapper comp)

A last minute change of the bounds. The bound for the layout cycle has been set and
you can correct there after any set of rules you like.
Parameters:
comp - The component wrapper that holds the actual component
(JComponent is Swing and Control in SWT).

Method Detail

1037

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class LC
java.lang.Object

com.codename1.ui.layouts.mig.LC

public final class


extends Object

Contains the constraints for an instance of the LC layout manager.

Constructor Summary
Constructor and Description
LC()

Empty constructor.

Method Summary
Modifier and
Type
LC

Method and Description


align(String ax, String ay)

Sets both the alignX and alignY as the same time.


alignX(String align)

LC

Same functionality as
setAlignX(ConstraintParser.parseUnitValueOrAlign(unitValue, true))
only this method returns this for chaining multiple calls.
alignY(String align)

LC

Same functionality as
setAlignY(ConstraintParser.parseUnitValueOrAlign(align, false))
this method returns this for chaining multiple calls.

only

bottomToTop()
LC

Same functionality as calling setTopToBottom(boolean) with false only this


method returns this for chaining multiple calls.

LC

debug()
Calls debug(int)

LC

debug(int repaintMillis)
Same functionality as setDebugMillis(int repaintMillis)
returns this for chaining multiple calls.

with 300 as an argument.


only this method

fill()
LC

Same functionality as calling setFillX(boolean) with true and


setFillY(boolean) with true conmbined.T his method returns this for
chaining multiple calls.
fillX()

LC

Same functionality as calling setFillX(boolean) with true only this method


returns this for chaining multiple calls.
fillY()

LC

Same functionality as calling setFillY(boolean) with true only this method


returns this for chaining multiple calls.
flowX()

LC

Same functionality as calling setFlowX(boolean) with true only this method


returns this for chaining multiple calls.
flowY()

LC

Class LC

Same functionality as calling setFlowX(boolean) with false only this method


returns this for chaining multiple calls.

1038

Overview (Codename One API)


getAlignX()
UnitValue

If the laid out components' bounds in total is less than the final size of the
container these align values will be used to align the components in the
parent.
getAlignY()

UnitValue

int

If the laid out components' bounds in total is less than the final size of the
container these align values will be used to align the components in the
parent.
getDebugMillis()
If > 0 the debug decorations

BoundSize

getGridGapX()
If non-null (null

BoundSize

getGridGapY()
If non-null (null

will be repainted every millis.

is default) these value will be used as the default gaps


between the columns in the grid.
is default) these value will be used as the default gaps
between the rows in the grid.
getHeight()

BoundSize

int
UnitValue[]
Boolean
BoundSize

Returns the minimum/preferred/maximum size for the container that this


layout constraint is set for.
getHideMode()

How a component that is hidden (not visible) should be treated by default.


getInsets()

The insets for the layed out panel.


getLeftToRight()

If the layout should be forced to be left-to-right or right-to-left.


getPackHeight()

Returns the "pack height" for the window that this container is located in.
getPackHeightAlign()

float

BoundSize

If there is a resize of the window due to packing (see


setPackHeight(BoundSize) this value, which is between 0f and 1f, decides
where the extra/superfluous size is placed.
getPackWidth()

Returns the "pack width" for the window that this container is located in.
getPackWidthAlign()

float

If there is a resize of the window due to packing (see


setPackHeight(BoundSize) this value, which is between 0f and 1f, decides
where the extra/superfluous size is placed.
getWidth()

BoundSize

int
LC

Returns the minimum/preferred/maximum size for the container that this


layout constraint is set for.
getWrapAfter()

Returns after what cell the grid should always auto wrap.
gridGap(String gapx, String gapy)

Sets both grid gaps at the same time.


gridGapX(String boundsSize)

LC

Same functionality as
setGridGapX(ConstraintParser.parseBoundSize(boundsSize, true, true))
only this method returns this for chaining multiple calls.
gridGapY(String boundsSize)

LC

Same functionality as
setGridGapY(ConstraintParser.parseBoundSize(boundsSize, true, false))
only this method returns this for chaining multiple calls.
height(String height)

LC

The height for the container as a min and/or preferred and/or maximum
height.
hideMode(int mode)

LC

LC

Method Summary

Same functionality as setHideMode(int mode) only this method returns this


for chaining multiple calls.
insets(String s)

Same functionality as setInsets(ConstraintParser.parseInsets(s, true)).

1039

Overview (Codename One API)


LC
LC

insets(String top, String left, String bottom, String right)


Sets the different insets (expressed as a UnitValues, e.g.
insetsAll(String allSides)

Sets the same inset (expressed as a UnitValue, e.g.


isFillX()

boolean

If the layout should always claim the whole bounds of the laid out container
even if the preferred size is smaller.
isFillY()

boolean

boolean

If the layout should always claim the whole bounds of the laid out container
even if the preferred size is smaller.
isFlowX()

The default flow direction.


isNoCache()

boolean

boolean

If components have sizes or positions linked to the bounds of the parent in


some way (as for instance the "%" unit has) the cache must be turned off for
the panel.
isNoGrid()

If the whole layout should be non grid based.


isTopToBottom()

boolean

If the layout should go from the default top-to-bottom in the grid instead of the
optinal bottom-to-top.
isVisualPadding()

boolean

LC

If visual padding should be automatically used and compensated for by this


layout instance.
leftToRight(boolean b)
Same functionality as setLeftToRight(Boolean)

only this method returns this

for chaining multiple calls.


LC
LC
LC
LC

maxHeight(String height)

The maximum height for the container.


maxWidth(String width)

The maximum width for the container.


minHeight(String height)

The minimum height for the container.


minWidth(String width)

The minimum width for the container.


noCache()

LC

Same functionality as calling setNoCache(boolean) with true only this method


returns this for chaining multiple calls.
noGrid()

LC

Same functionality as calling setNoGrid(boolean) with true only this method


returns this for chaining multiple calls.
noVisualPadding()

LC

LC
LC
LC

Same functionality as calling setVisualPadding(boolean) with false only this


method returns this for chaining multiple calls.
pack()

Short for, and thus same as, .pack("pref", "pref").


pack(String width, String height)

Sets the pack width and height.


packAlign(float alignX, float alignY)

Sets the pack width and height alignment.


rightToLeft()

LC

Same functionality as setLeftToRight(false) only this method returns this for


chaining multiple calls.
setAlignX(UnitValue uv)

void

void

Method Summary

If the laid out components' bounds in total is less than the final size of the
container these align values will be used to align the components in the
parent.
setAlignY(UnitValue uv)

1040

Overview (Codename One API)


If the laid out components' bounds in total is less than the final size of the
container these align values will be used to align the components in the
parent.
void

setDebugMillis(int millis)
If > 0 the debug decorations will

be repainted every millis.

setFillX(boolean b)
void

If the layout should always claim the whole bounds of the laid out container
even if the preferred size is smaller.
setFillY(boolean b)

void

void

If the layout should always claim the whole bounds of the laid out container
even if the preferred size is smaller.
setFlowX(boolean b)

The default flow direction.

void

setGridGapX(BoundSize x)
If non-null (null is default)

void

setGridGapY(BoundSize y)
If non-null (null is default)

these value will be used as the default gaps


between the columns in the grid.
these value will be used as the default gaps
between the rows in the grid.
setHeight(BoundSize size)

void

void
void
void

Sets the minimum/preferred/maximum size for the container that this layout
constraint is set for.
setHideMode(int mode)

How a component that is hidden (not visible) should be treated.


setInsets(UnitValue[] ins)

The insets for the layed out panel.


setLeftToRight(Boolean b)

If the layout should be forced to be left-to-right or right-to-left.


setNoCache(boolean b)

void

void
void

If components have sizes or positions linked to the bounds of the parent in


some way (as for instance the "%" unit has) the cache must be turned off for
the panel.
setNoGrid(boolean b)

If the whole layout should be non grid based.


setPackHeight(BoundSize size)

Sets the "pack height" for the window that this container is located in.
setPackHeightAlign(float align)

void

void

If there is a resize of the window due to packing (see


setPackHeight(BoundSize) this value, which is between 0f and 1f, decides
where the extra/superfluous size is placed.
setPackWidth(BoundSize size)

Sets the "pack width" for the window that this container is located in.
setPackWidthAlign(float align)

void

If there is a resize of the window due to packing (see


setPackHeight(BoundSize) this value, which is between 0f and 1f, decides
where the extra/superfluous size is placed.
setTopToBottom(boolean b)

void

If the layout should go from the default top-to-bottom in the grid instead of the
optinal bottom-to-top.
setVisualPadding(boolean b)

void

If visual padding should be automatically used and compensated for by this


layout instance.
setWidth(BoundSize size)

void

void
LC

Sets the minimum/preferred/maximum size for the container that this layout
constraint is set for.
setWrapAfter(int count)

Sets after what cell the grid should always auto wrap.
topToBottom()

Same functionality as calling setTopToBottom(boolean) with true only this

Method Summary

1041

Overview (Codename One API)


method returns this for chaining multiple calls.
width(String width)

LC

The width for the container as a min and/or preferred and/or maximum width.
wrap()

Sets a wrap after the number of columns/rows that is defined in the


net.miginfocom.layout.AC.

LC

wrapAfter(int count)
Same functionality as setWrapAfter(int)

LC

only this method returns this for

chaining multiple calls.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
LC
public LC()

Empty constructor.

Method Detail
isNoCache
public boolean isNoCache()

If components have sizes or positions linked to the bounds of the parent in some way
(as for instance the "%" unit has) the cache must be turned off for the panel. If
components does not get the correct or expected size or position try to set this
property to true.
Returns:
true means no cache and slightly slower layout.
setNoCache
public void setNoCache(boolean b)

If components have sizes or positions linked to the bounds of the parent in some way
(as for instance the "%" unit has) the cache must be turned off for the panel. If
components does not get the correct or expected size or position try to set this
property to true.
Parameters:
b - true means no cache and slightly slower layout.
getAlignX
public final UnitValue getAlignX()

If the laid out components' bounds in total is less than the final size of the container
these align values will be used to align the components in the parent. null is default
and that means top/left alignment. The relative distances between the components
will not be affected by this property.
Returns:
The current alignment.
setAlignX
public final void setAlignX(UnitValue uv)

If the laid out components' bounds in total is less than the final size of the container
these align values will be used to align the components in the parent. null is default
and that means top/left alignment. The relative distances between the components
will not be affected by this property.

Methods inherited from class java.lang.Object

1042

Overview (Codename One API)


Parameters:
uv - The new alignment. Use
ConstraintParser.parseAlignKeywords(String, boolean)
UnitValue. May be null.

to create the

getAlignY
public final UnitValue getAlignY()

If the laid out components' bounds in total is less than the final size of the container
these align values will be used to align the components in the parent. null is default
and that means top/left alignment. The relative distances between the components
will not be affected by this property.
Returns:
The current alignment.
setAlignY
public final void setAlignY(UnitValue uv)

If the laid out components' bounds in total is less than the final size of the container
these align values will be used to align the components in the parent. null is default
and that means top/left alignment. The relative distances between the components
will not be affected by this property.
Parameters:
uv - The new alignment. Use
ConstraintParser.parseAlignKeywords(String, boolean) to create the
UnitValue. May be null.
getDebugMillis
public final int getDebugMillis()

If > 0 the debug decorations will be repainted every millis. No debug information if
<= 0 (default).
Returns:
The current debug repaint interval.
setDebugMillis
public final void setDebugMillis(int millis)

If > 0 the debug decorations will be repainted every millis. No debug information if
<= 0 (default).
Parameters:
millis - The new debug repaint interval.
isFillX
public final boolean isFillX()

If the layout should always claim the whole bounds of the laid out container even if
the preferred size is smaller.
Returns:
true means fill. false is default.
setFillX
public final void setFillX(boolean b)

If the layout should always claim the whole bounds of the laid out container even if
the preferred size is smaller.
Parameters:
b - true means fill. false is default.
isFillY
public final boolean isFillY()

If the layout should always claim the whole bounds of the laid out container even if
the preferred size is smaller.
Returns:
true means fill. false is default.

Method Detail

1043

Overview (Codename One API)


setFillY
public final void setFillY(boolean b)

If the layout should always claim the whole bounds of the laid out container even if
the preferred size is smaller.
Parameters:
b - true means fill. false is default.
isFlowX
public final boolean isFlowX()

The default flow direction. Normally (which is true) this is horizontal and that means
that the "next" component will be put in the cell to the right (or to the left if left-to-right
is false).
Returns:
true is the default flow horizontally.
See Also:
setLeftToRight(Boolean)

setFlowX
public final void setFlowX(boolean b)

The default flow direction. Normally (which is true) this is horizontal and that means
that the "next" component will be put in the cell to the right (or to the left if left-to-right
is false).
Parameters:
b - true is the default flow horizontally.
See Also:
setLeftToRight(Boolean)

getGridGapX
public final BoundSize getGridGapX()

If non-null (null is default) these value will be used as the default gaps between the
columns in the grid.
Returns:
The default grid gap between columns in the grid. null if the platform default
is used.
setGridGapX
public final void setGridGapX(BoundSize x)

If non-null (null is default) these value will be used as the default gaps between the
columns in the grid.
Parameters:
x - The default grid gap between columns in the grid. If null the platform
default is used.
getGridGapY
public final BoundSize getGridGapY()

If non-null (null is default) these value will be used as the default gaps between the
rows in the grid.
Returns:
The default grid gap between rows in the grid. null if the platform default is
used.
setGridGapY
public final void setGridGapY(BoundSize y)

If non-null (null is default) these value will be used as the default gaps between the
rows in the grid.
Parameters:
y - The default grid gap between rows in the grid. If null the platform default
is used.

Method Detail

1044

Overview (Codename One API)


getHideMode
public final int getHideMode()

How a component that is hidden (not visible) should be treated by default.


Returns:
The mode:
0 == Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
setHideMode
public final void setHideMode(int mode)

How a component that is hidden (not visible) should be treated.


Parameters:
mode - The mode:
0 == Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
getInsets
public final UnitValue[] getInsets()

The insets for the layed out panel. The insets will be an empty space around the
components in the panel. null values means that the default panel insets for the
platform is used. See
PlatformDefaults#setDialogInsets(net.miginfocom.layout.UnitValue,
net.miginfocom.layout.UnitValue, net.miginfocom.layout.UnitValue,
net.miginfocom.layout.UnitValue).

Returns:
The insets. Of length 4 (top, left, bottom, right) or null. The elements (1 to 4)
may be null. The array is a copy and can be used freely.
See Also:
net.miginfocom.layout.ConstraintParser#parseInsets(String, boolean)

setInsets
public final void setInsets(UnitValue[] ins)

The insets for the layed out panel. The insets will be an empty space around the
components in the panel. null values means that the default panel insets for the
platform is used. See
PlatformDefaults#setDialogInsets(net.miginfocom.layout.UnitValue,
net.miginfocom.layout.UnitValue, net.miginfocom.layout.UnitValue,
net.miginfocom.layout.UnitValue).

Parameters:
ins - The new insets. Must be of length 4 (top, left, bottom, right) or null. The
elements (1 to 4) may be null to use the platform default for that side. The
array is copied for storage.
See Also:
net.miginfocom.layout.ConstraintParser#parseInsets(String, boolean)

getLeftToRight
public final Boolean getLeftToRight()

If the layout should be forced to be left-to-right or right-to-left. A value of null is


default and means that this will be picked up from the Locale that the container being
layed out is reporting.
Returns:
Boolean.TRUE if force left-to-right. Boolean.FALSE if force tight-to-left. null for
the default "let the current Locale decide".

Method Detail

1045

Overview (Codename One API)


setLeftToRight
public final void setLeftToRight(Boolean b)

If the layout should be forced to be left-to-right or right-to-left. A value of null is


default and means that this will be picked up from the Locale that the container being
layed out is reporting.
Parameters:
b - Boolean.TRUE to force left-to-right. Boolean.FALSE to force tight-to-left. null
for the default "let the current Locale decide".
isNoGrid
public final boolean isNoGrid()

If the whole layout should be non grid based. It is the same as setting the "nogrid"
property on every row/column in the grid.
Returns:
true means not grid based. false is default.
setNoGrid
public final void setNoGrid(boolean b)

If the whole layout should be non grid based. It is the same as setting the "nogrid"
property on every row/column in the grid.
Parameters:
b - true means no grid. false is default.
isTopToBottom
public final boolean isTopToBottom()

If the layout should go from the default top-to-bottom in the grid instead of the optinal
bottom-to-top.
Returns:
true for the default top-to-bottom.
setTopToBottom
public final void setTopToBottom(boolean b)

If the layout should go from the default top-to-bottom in the grid instead of the optinal
bottom-to-top.
Parameters:
b - true for the default top-to-bottom.
isVisualPadding
public final boolean isVisualPadding()

If visual padding should be automatically used and compensated for by this layout
instance.
Returns:
true if visual padding.
setVisualPadding
public final void setVisualPadding(boolean b)

If visual padding should be automatically used and compensated for by this layout
instance.
Parameters:
b - true turns on visual padding.
getWrapAfter
public final int getWrapAfter()

Returns after what cell the grid should always auto wrap.
Returns:
After what cell the grid should always auto wrap. If 0 the number of
columns/rows in the net.miginfocom.layout.AC is used. LayoutUtil.INF is
used for no auto wrap.

Method Detail

1046

Overview (Codename One API)


setWrapAfter
public final void setWrapAfter(int count)

Sets after what cell the grid should always auto wrap.
Parameters:
count - After what cell the grid should always auto wrap. If 0 the number of
columns/rows in the net.miginfocom.layout.AC is used. LayoutUtil.INF is
used for no auto wrap.
getPackWidth
public final BoundSize getPackWidth()

Returns the "pack width" for the window that this container is located in. When the
size of this container changes the size of the window will be corrected to be within
this BoundsSize. It can be used to set the minimum and/or maximum size of the
window as well as the size window should optimally get. This optimal size is normally
its "preferred" size which is why "preferred" is the normal value to set here.
":push" can be appended to the bound size to only push the size bigger and never
shrink it if the preferred size gets smaller.
E.g. "pref", "100:pref", "pref:700", "300::700", "pref:push"
Returns:
The current value. Never null. Check if not set with .isUnset().
Since:
3.5
setPackWidth
public final void setPackWidth(BoundSize size)

Sets the "pack width" for the window that this container is located in. When the size
of this container changes the size of the window will be corrected to be within this
BoundsSize. It can be used to set the minimum and/or maximum size of the window
as well as the size window should optimally get. This optimal size is normally its
"preferred" size which is why "preferred" is the normal value to set here.
":push" can be appended to the bound size to only push the size bigger and never
shrink it if the preferred size gets smaller.
E.g. "pref", "100:pref", "pref:700", "300::700", "pref:push"
Parameters:
size

- The new pack size. If null it will be corrected to an "unset" BoundSize.

Since:
3.5
getPackHeight
public final BoundSize getPackHeight()

Returns the "pack height" for the window that this container is located in. When the
size of this container changes the size of the window will be corrected to be within
this BoundsSize. It can be used to set the minimum and/or maximum size of the
window as well as the size window should optimally get. This optimal size is normally
its "preferred" size which is why "preferred" is the normal value to set here.
":push" can be appended to the bound size to only push the size bigger and never
shrink it if the preferred size gets smaller.
E.g. "pref", "100:pref", "pref:700", "300::700", "pref:push"
Returns:
The current value. Never null. Check if not set with .isUnset().
Since:
3.5

Method Detail

1047

Overview (Codename One API)


setPackHeight
public final void setPackHeight(BoundSize size)

Sets the "pack height" for the window that this container is located in. When the size
of this container changes the size of the window will be corrected to be within this
BoundsSize. It can be used to set the minimum and/or maximum size of the window
as well as the size window should optimally get. This optimal size is normally its
"preferred" size which is why "preferred" is the normal value to set here.
":push" can be appended to the bound size to only push the size bigger and never
shrink it if the preferred size gets smaller.
E.g. "pref", "100:pref", "pref:700", "300::700", "pref:push"
Parameters:
size

- The new pack size. If null it will be corrected to an "unset" BoundSize.

Since:
3.5
getPackHeightAlign
public final float getPackHeightAlign()

If there is a resize of the window due to packing (see setPackHeight(BoundSize) this


value, which is between 0f and 1f, decides where the extra/superfluous size is
placed. 0f means that the window will resize so that the upper part moves up and the
lower side stays in the same place. 0.5f will expand/reduce the window equally
upwards and downwards. 1f will do the opposite of 0f of course.
Returns:
The pack alignment. Always between 0f and 1f, inclusive.
Since:
3.5
setPackHeightAlign
public final void setPackHeightAlign(float align)

If there is a resize of the window due to packing (see setPackHeight(BoundSize) this


value, which is between 0f and 1f, decides where the extra/superfluous size is
placed. 0f means that the window will resize so that the upper part moves up and the
lower side stays in the same place. 0.5f will expand/reduce the window equally
upwards and downwards. 1f will do the opposite of 0f of course.
Parameters:
align - The pack alignment. Always between 0f and 1f, inclusive. Values
outside this will be truncated.
Since:
3.5
getPackWidthAlign
public final float getPackWidthAlign()

If there is a resize of the window due to packing (see setPackHeight(BoundSize) this


value, which is between 0f and 1f, decides where the extra/superfluous size is
placed. 0f means that the window will resize so that the left part moves left and the
right side stays in the same place. 0.5f will expand/reduce the window equally to the
right and lefts. 1f will do the opposite of 0f of course.
Returns:
The pack alignment. Always between 0f and 1f, inclusive.
Since:
3.5
setPackWidthAlign
public final void setPackWidthAlign(float align)

If there is a resize of the window due to packing (see setPackHeight(BoundSize) this


value, which is between 0f and 1f, decides where the extra/superfluous size is
placed. 0f means that the window will resize so that the left part moves left and the

Method Detail

1048

Overview (Codename One API)


right side stays in the same place. 0.5f will expand/reduce the window equally to the
right and lefts. 1f will do the opposite of 0f of course.
Parameters:
align - The pack alignment. Always between 0f and 1f, inclusive. Values
outside this will be truncated.
Since:
3.5
getWidth
public final BoundSize getWidth()

Returns the minimum/preferred/maximum size for the container that this layout
constraint is set for. Any of these sizes that is not null will be returned directly
instead of determining the corresponding size through asking the components in this
container.
Returns:
The width for the container that this layout constraint is set for. Not null but
all sizes can be null.
Since:
3.5
setWidth
public final void setWidth(BoundSize size)

Sets the minimum/preferred/maximum size for the container that this layout constraint
is set for. Any of these sizes that is not null will be returned directly instead of
determining the corresponding size through asking the components in this container.
Parameters:
size - The width for the container that this layout constraint is set for. null is
translated to a bound size containing only null sizes.
Since:
3.5
getHeight
public final BoundSize getHeight()

Returns the minimum/preferred/maximum size for the container that this layout
constraint is set for. Any of these sizes that is not null will be returned directly
instead of determining the corresponding size through asking the components in this
container.
Returns:
The height for the container that this layout constraint is set for. Not null but
all sizes can be null.
Since:
3.5
setHeight
public final void setHeight(BoundSize size)

Sets the minimum/preferred/maximum size for the container that this layout constraint
is set for. Any of these sizes that is not null will be returned directly instead of
determining the corresponding size through asking the components in this container.
Parameters:
size - The height for the container that this layout constraint is set for. null is
translated to a bound size containing only null sizes.
Since:
3.5
pack
public final LC pack()

Short for, and thus same as, .pack("pref", "pref").


Same functionality as setPackHeight(BoundSize) and
#setPackWidth(net.miginfocom.layout.BoundSize) only this method returns this for
chaining multiple calls.

Method Detail

1049

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.5
pack
public final LC pack(String width,
String height)

Sets the pack width and height.


Same functionality as setPackHeight(BoundSize) and
#setPackWidth(net.miginfocom.layout.BoundSize) only this method returns this for
chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
width - The pack width. May be null.
height - The pack height. May be null.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.5
packAlign
public final LC packAlign(float alignX,
float alignY)

Sets the pack width and height alignment.


Same functionality as setPackHeightAlign(float) and setPackWidthAlign(float)
only this method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
alignX
alignY

- The pack width alignment. 0.5f is default.


- The pack height alignment. 0.5f is default.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.5
wrap
public final LC wrap()

Sets a wrap after the number of columns/rows that is defined in the


net.miginfocom.layout.AC.
Same functionality as calling setWrapAfter(int) with 0 only this method returns this
for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:

Method Detail

1050

Overview (Codename One API)


this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

wrapAfter
public final LC wrapAfter(int count)

Same functionality as setWrapAfter(int) only this method returns this for chaining
multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- After what cell the grid should always auto wrap. If 0 the number of
columns/rows in the
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
noCache
count

public final LC noCache()

Same functionality as calling setNoCache(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

flowY
public final LC flowY()

Same functionality as calling setFlowX(boolean) with false only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

flowX
public final LC flowX()

Same functionality as calling setFlowX(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

fill
public final LC fill()

Same functionality as calling setFillX(boolean) with true and setFillY(boolean)


with true conmbined.T his method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.

Method Detail

1051

Overview (Codename One API)


Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

fillX
public final LC fillX()

Same functionality as calling setFillX(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

fillY
public final LC fillY()

Same functionality as calling setFillY(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

leftToRight
public final LC leftToRight(boolean b)

Same functionality as setLeftToRight(Boolean) only this method returns this for


chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true for forcing left-to-right. false for forcing right-to-left.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
rightToLeft
public final LC rightToLeft()

Same functionality as setLeftToRight(false) only this method returns this for chaining
multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.7.2
bottomToTop
public final LC bottomToTop()

Same functionality as calling setTopToBottom(boolean) with false only this method


returns this for chaining multiple calls.

Method Detail

1052

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

topToBottom
public final LC topToBottom()

Same functionality as calling setTopToBottom(boolean) with true only this method


returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.7.2
noGrid
public final LC noGrid()

Same functionality as calling setNoGrid(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

noVisualPadding
public final LC noVisualPadding()

Same functionality as calling setVisualPadding(boolean) with false only this method


returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

insetsAll
public final LC insetsAll(String allSides)

Sets the same inset (expressed as a UnitValue, e.g. "10px" or "20mm") all around.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The unit value to set for all sides. May be null which means that
the default panel insets for the platform is used.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
allSides

setInsets(UnitValue[])

Method Detail

1053

Overview (Codename One API)


insets
public final LC insets(String s)

Same functionality as setInsets(ConstraintParser.parseInsets(s, true)). This


method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The string to parse. E.g. "10 10 10 10" or "20". If less than 4 groups the
last will be used for the missing.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
setInsets(UnitValue[])

insets
public final LC insets(String
String
String
String

top,
left,
bottom,
right)

Sets the different insets (expressed as a UnitValues, e.g. "10px" or "20mm") for the
corresponding sides.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
top - The top inset. E.g. "10px" or "10mm" or "related". May be null in which
case the default inset for this side for the platform will be used.
left - The left inset. E.g. "10px" or "10mm" or "related". May be null in which
case the default inset for this side for the platform will be used.
bottom - The bottom inset. E.g. "10px" or "10mm" or "related". May be null in
which case the default inset for this side for the platform will be used.
right - The right inset. E.g. "10px" or "10mm" or "related". May be null in
which case the default inset for this side for the platform will be used.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
setInsets(UnitValue[])

alignX
public final LC alignX(String align)

Same functionality as
setAlignX(ConstraintParser.parseUnitValueOrAlign(unitValue, true))
method returns this for chaining multiple calls.

only this

For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The align keyword or for instance "100px". E.g "left", "right", "leading"
or "trailing".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
align

setAlignX(UnitValue)

Method Detail

1054

Overview (Codename One API)


alignY
public final LC alignY(String align)

Same functionality as setAlignY(ConstraintParser.parseUnitValueOrAlign(align,


false)) only this method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
align

- The align keyword or for instance "100px". E.g "top" or "bottom".

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setAlignY(UnitValue)

align
public final LC align(String ax,
String ay)

Sets both the alignX and alignY as the same time.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
ax - The align keyword or for instance "100px". E.g "left", "right", "leading" or
"trailing".
ay - The align keyword or for instance "100px". E.g "top" or "bottom".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
alignX(String), alignY(String)
gridGapX
public final LC gridGapX(String boundsSize)

Same functionality as setGridGapX(ConstraintParser.parseBoundSize(boundsSize,


true, true)) only this method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The BoundSize of the gap. This is a minimum and/or preferred
and/or maximum size. E.g. "50:100:200" or "100px".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
boundsSize

setGridGapX(BoundSize)

gridGapY
public final LC gridGapY(String boundsSize)

Same functionality as setGridGapY(ConstraintParser.parseBoundSize(boundsSize,


true, false)) only this method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The BoundSize of the gap. This is a minimum and/or preferred
and/or maximum size. E.g. "50:100:200" or "100px".
boundsSize

Method Detail

1055

Overview (Codename One API)


Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setGridGapY(BoundSize)

gridGap
public final LC gridGap(String gapx,
String gapy)

Sets both grid gaps at the same time. see gridGapX(String) and gridGapY(String).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The BoundSize of the gap. This is a minimum and/or preferred and/or
maximum size. E.g. "50:100:200" or "100px".
gapy - The BoundSize of the gap. This is a minimum and/or preferred and/or
maximum size. E.g. "50:100:200" or "100px".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
gridGapX(String), gridGapY(String)
debug
gapx

public final LC debug()

Calls debug(int) with 300 as an argument.


Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setDebugMillis(int)

debug
public final LC debug(int repaintMillis)

Same functionality as setDebugMillis(int repaintMillis) only this method returns


this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
repaintMillis

- The new debug repaint interval.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setDebugMillis(int)

hideMode
public final LC hideMode(int mode)

Same functionality as setHideMode(int mode) only this method returns this for
chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The mode:
0 == Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
mode

Method Detail

1056

Overview (Codename One API)


3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
See Also:
setHideMode(int)

minWidth
public final LC minWidth(String width)

The minimum width for the container. The value will override any value that is set on
the container itself.
For a more thorough explanation of what this constraint does see the white paper or
Cheat Sheet at www.migcontainers.com.
Parameters:
width

- The width expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

width
public final LC width(String width)

The width for the container as a min and/or preferred and/or maximum width. The
value will override any value that is set on the container itself.
For a more thorough explanation of what this constraint does see the white paper or
Cheat Sheet at www.migcontainers.com.
Parameters:
- The width expressed as a BoundSize. E.g. "50:100px:200mm" or
"100px".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
maxWidth
width

public final LC maxWidth(String width)

The maximum width for the container. The value will override any value that is set on
the container itself.
For a more thorough explanation of what this constraint does see the white paper or
Cheat Sheet at www.migcontainers.com.
Parameters:
width

- The width expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

minHeight
public final LC minHeight(String height)

The minimum height for the container. The value will override any value that is set on
the container itself.
For a more thorough explanation of what this constraint does see the white paper or
Cheat Sheet at www.migcontainers.com.
Parameters:
height

- The height expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:

Method Detail

1057

Overview (Codename One API)


this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

height
public final LC height(String height)

The height for the container as a min and/or preferred and/or maximum height. The
value will override any value that is set on the container itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcontainers.com.
Parameters:
- The height expressed as a BoundSize. E.g. "50:100px:200mm" or
"100px".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
maxHeight
height

public final LC maxHeight(String height)

The maximum height for the container. The value will override any value that is set on
the container itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcontainers.com.
Parameters:
height

- The height expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Method Detail

1058

Overview (Codename One API)


com.codename1.ui.layouts.mig

Interface InCellGapProvider

public interface

An interface to implement if you want to decide the gaps between two types of components within the
same cell.
E.g.:
if (adjacentComp == null || adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.TOP)
return null;
boolean isHor = (adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.RIGHT);

if (adjacentComp.getComponentType(false) == ComponentWrapper.TYPE_LABEL && comp.getComponentType(false) == ComponentW


return isHor ? UNRELATED_Y : UNRELATED_Y;
return (adjacentSide == SwingConstants.LEFT || adjacentSide == SwingConstants.RIGHT) ? RELATED_X : RELATED_Y;

Method Summary
Modifier and
Type
BoundSize

Method and Description


getDefaultGap(ComponentWrapper comp, ComponentWrapper adjacentComp,
int adjacentSide, String tag, boolean isLTR)

Returns the default gap between two components that are in the same cell.

Method Detail
getDefaultGap
BoundSize getDefaultGap(ComponentWrapper comp,
ComponentWrapper adjacentComp,
int adjacentSide,
String tag,
boolean isLTR)

Returns the default gap between two components that are in the same cell.
Parameters:
comp - The component that the gap is for. Never null.
adjacentComp - The adjacent component if any. May be null.
adjacentSide - What side the adjacentComp is on. SwingConstants.TOP or
SwingConstants.LEFT or SwingConstants.BOTTOM or SwingConstants.RIGHT.
tag - The tag string that the component might be tagged with in the
component constraints. May be null.
isLTR - If it is left-to-right.
Returns:
The default gap between two components or null if there should be no gap.

Interface InCellGapProvider

1059

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class Grid
java.lang.Object

com.codename1.ui.layouts.mig.Grid

public final class


extends Object

Holds components in a grid. Does most of the logic behind the layout manager.

Field Summary
Modifier and Type Field and Description
static boolean

TEST_GAPS

Constructor Summary
Constructor and Description
Grid(ContainerWrapper container, LC lc, AC rowConstr, AC colConstr, Map<? extends
ComponentWrapper,CC> ccMap, ArrayList<LayoutCallback> callbackList)

Constructor.

Method Summary
Modifier and
Type

Method and Description

ContainerWrapper getContainer()
int[]

getHeight()

int[]

getHeight(int refWidth)

int[]

getWidth()

int[]

getWidth(int refHeight)
invalidateContainerSize()

If the container (parent) that this grid is laying out has changed its
bounds, call this method to clear any cached values min/pref/max sizes
of the components and rows/columns.

void

boolean

layout(int[] bounds, UnitValue alignX, UnitValue alignY,


boolean debug)

Does the actual layout.


layout(int[] bounds, UnitValue alignX, UnitValue alignY,
boolean debug, boolean notUsed)
boolean

Deprecated.
since 5.0 Last boolean is not needed and is gotten from the new
net.miginfocom.layout.ComponentWrapper#getContentBias() instead;

void

paintDebug()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

1060

Overview (Codename One API)


Field

Detail
TEST_GAPS
public static final boolean TEST_GAPS

See Also:
Constant Field Values

Constructor Detail
Grid
public Grid(ContainerWrapper container,
LC lc,
AC rowConstr,
AC colConstr,
Map<? extends ComponentWrapper,CC> ccMap,
ArrayList<LayoutCallback> callbackList)

Constructor.
Parameters:
container - The container that will be laid out.
lc - The form flow constraints.
rowConstr - The rows specifications. If more cell

rows are required, the last


element will be used for when there is no corresponding element in this array.
colConstr - The columns specifications. If more cell rows are required, the
last element will be used for when there is no corresponding element in this
array.
ccMap - The map containing the parsed constraints for each child component
of parent. Will not be altered. Can have null CC which will use a common
cached one.
callbackList - A list of callbacks or null if none. Will not be altered.

Method Detail
invalidateContainerSize
public void invalidateContainerSize()

If the container (parent) that this grid is laying out has changed its bounds, call this
method to clear any cached values min/pref/max sizes of the components and
rows/columns.
If any component can have changed cell the grid needs to be recreated.
layout
public boolean layout(int[] bounds,
UnitValue alignX,
UnitValue alignY,
boolean debug,
boolean notUsed)

Deprecated. since 5.0 Last boolean is not needed and is gotten from the new
net.miginfocom.layout.ComponentWrapper#getContentBias() instead;
layout
public boolean layout(int[] bounds,
UnitValue alignX,
UnitValue alignY,
boolean debug)

Does the actual layout. Uses many values calculated in the constructor.
Parameters:

Field Detail

1061

Overview (Codename One API)

- The bounds to layout against. Normally that of the parent. [x, y,


width, height].
alignX - The alignment for the x-axis. Can be null.
alignY - The alignment for the y-axis. Can be null.
debug - If debug information should be saved in debugRects.
Returns:
If the layout has changed the preferred size and there is need for a new
layout. This can happen if one or more components in the grid has a content
bias according to
net.miginfocom.layout.ComponentWrapper#getContentBias().
Since:
5.0
paintDebug
bounds

public void paintDebug()

getContainer
public ContainerWrapper getContainer()

getWidth
public final int[] getWidth()

getWidth
public final int[] getWidth(int refHeight)

getHeight
public final int[] getHeight()

getHeight
public final int[] getHeight(int refWidth)

Method Detail

1062

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class DimConstraint
java.lang.Object

com.codename1.ui.layouts.mig.DimConstraint

public final class


extends Object

A simple value holder for a constraint for one dimension.

Constructor Summary
Constructor and Description
DimConstraint()

Empty constructor.

Method Summary
Modifier
and Type

Method and Description


getAlign()

UnitValue

Returns the alignment used either as a default value for sub-entities or for this
entity.

UnitValue

getAlignOrDefault(boolean isCols)
getEndGroup()

String

BoundSize
BoundSize
Float
int
Float
int

Returns the end group that this entity should be in for the demension that this
object is describing.
getGapAfter()

Returns the gap after this entity.


getGapBefore()

Returns the gap before this entity.


getGrow()

Returns the grow weight.


getGrowPriority()

Returns the grow priority.


getShrink()

Returns the shrink priority.


getShrinkPriority()

Returns the shrink priority.


getSize()

BoundSize

Returns the min/preferred/max size for the entity in the dimension that this
object describes.
getSizeGroup()

String

Returns the size group that this entity should be in for the dimension that this
object is describing.
isFill()

boolean

boolean
void

Class DimConstraint

Returns if the component in the row/column that this constraint should default
be grown in the same dimension that this constraint represents (width for
column and height for a row).
isNoGrid()

Returns if the row/column should default to flow and not to grid behaviour.
setAlign(UnitValue uv)

1063

Overview (Codename One API)


Sets the alignment used wither as a default value for sub-entities or for this
entity.
setEndGroup(String s)

Sets the end group that this entity should be in for the demension that this
object is describing.

void

setFill(boolean b)

Sets if the component in the row/column that this constraint should default be
grown in the same dimension that this constraint represents (width for column
and height for a row).

void

setGapAfter(BoundSize size)

void

Sets the gap after this entity.


setGapBefore(BoundSize size)

void

Sets the gap before this entity.


setGrow(Float weight)

void

Sets the grow weight.


setGrowPriority(int p)

void

Sets the grow priority.


setNoGrid(boolean b)

void

Sets if the row/column should default to flow and not to grid behaviour.
setShrink(Float weight)

void

Sets the shrink priority.


setShrinkPriority(int p)

void

Sets the shrink priority.


setSize(BoundSize size)

Sets the min/preferred/max size for the entity in the dimension that this object
describes.

void

setSizeGroup(String s)

Sets the size group that this entity should be in for the dimension that this
object is describing.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DimConstraint
public DimConstraint()

Empty constructor.

Method Detail
getGrowPriority
public int getGrowPriority()

Returns the grow priority. Relative priority is used for determining which entities gets
the extra space first.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The grow priority.

Method Summary

1064

Overview (Codename One API)


setGrowPriority
public void setGrowPriority(int p)

Sets the grow priority. Relative priority is used for determining which entities gets the
extra space first.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The new grow priority.
getGrow
public Float getGrow()

Returns the grow weight.


Grow weight is how flexible the entity should be, relative to other entities, when it
comes to growing. null or zero mean it will never grow. An entity that has twice the
grow weight compared to another entity will get twice as much of available space.
GrowWeight are only compared within the same GrowPrio.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current grow weight.
setGrow
public void setGrow(Float weight)

Sets the grow weight.


Grow weight is how flexible the entity should be, relative to other entities, when it
comes to growing. null or zero mean it will never grow. An entity that has twice the
grow weight compared to another entity will get twice as much of available space.
GrowWeight are only compared within the same GrowPrio.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
weight - The new grow weight.
getShrinkPriority
public int getShrinkPriority()

Returns the shrink priority. Relative priority is used for determining which entities gets
smaller first when space is scarce.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The shrink priority.
setShrinkPriority
public void setShrinkPriority(int p)

Sets the shrink priority. Relative priority is used for determining which entities gets
smaller first when space is scarce.

Method Detail

1065

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The new shrink priority.
getShrink
public Float getShrink()

Returns the shrink priority. Relative priority is used for determining which entities gets
smaller first when space is scarce. Shrink weight is how flexible the entity should be,
relative to other entities, when it comes to shrinking. null or zero mean it will never
shrink (default). An entity that has twice the shrink weight compared to another entity
will get twice as much of available space.
Shrink(Weight) are only compared within the same ShrinkPrio.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current shrink weight.
setShrink
public void setShrink(Float weight)

Sets the shrink priority. Relative priority is used for determining which entities gets
smaller first when space is scarce. Shrink weight is how flexible the entity should be,
relative to other entities, when it comes to shrinking. null or zero mean it will never
shrink (default). An entity that has twice the shrink weight compared to another entity
will get twice as much of available space.
Shrink(Weight) are only compared within the same ShrinkPrio.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
weight - The new shrink weight.
getAlignOrDefault
public UnitValue getAlignOrDefault(boolean isCols)

getAlign
public UnitValue getAlign()

Returns the alignment used either as a default value for sub-entities or for this entity.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The alignment.
setAlign
public void setAlign(UnitValue uv)

Sets the alignment used wither as a default value for sub-entities or for this entity.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
uv - The new shrink priority. E.g. UnitValue.CENTER or
net.miginfocom.layout.UnitValue#LEADING.

Method Detail

1066

Overview (Codename One API)


getGapAfter
public BoundSize getGapAfter()

Returns the gap after this entity. The gap is an empty space and can have a
min/preferred/maximum size so that it can shrink and grow depending on available
space. Gaps are against other entities' edges and not against other entities' gaps.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The gap after this entity
setGapAfter
public void setGapAfter(BoundSize size)

Sets the gap after this entity. The gap is an empty space and can have a
min/preferred/maximum size so that it can shrink and grow depending on available
space. Gaps are against other entities' edges and not against other entities' gaps.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size

- The new gap.

See Also:
net.miginfocom.layout.ConstraintParser#parseBoundSize(String,
boolean, boolean)

getGapBefore
public BoundSize getGapBefore()

Returns the gap before this entity. The gap is an empty space and can have a
min/preferred/maximum size so that it can shrink and grow depending on available
space. Gaps are against other entities' edges and not against other entities' gaps.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The gap before this entity
setGapBefore
public void setGapBefore(BoundSize size)

Sets the gap before this entity. The gap is an empty space and can have a
min/preferred/maximum size so that it can shrink and grow depending on available
space. Gaps are against other entities' edges and not against other entities' gaps.
See also net.miginfocom.layout.ConstraintParser#parseBoundSize(String,
boolean, boolean). For a more thorough explanation of what this constraint does see
the white paper or cheat Sheet at www.migcomponents.com.
Parameters:
size

- The new gap.

getSize
public BoundSize getSize()

Returns the min/preferred/max size for the entity in the dimension that this object
describes.
See also net.miginfocom.layout.ConstraintParser#parseBoundSize(String,
boolean, boolean). For a more thorough explanation of what this constraint does see
the white paper or cheat Sheet at www.migcomponents.com.

Method Detail

1067

Overview (Codename One API)


Returns:
The current size. Never null since v3.5.
setSize
public void setSize(BoundSize size)

Sets the min/preferred/max size for the entity in the dimension that this object
describes.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size - The new size. May be null.
getSizeGroup
public String getSizeGroup()

Returns the size group that this entity should be in for the dimension that this object is
describing. If this constraint is in a size group that is specified here. null means no
size group and all other values are legal. Comparison with .equals().
Components/columnss/rows in the same size group will have the same
min/preferred/max size; that of the largest in the group for the first two and the
smallest for max.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current size group. May be null.
setSizeGroup
public void setSizeGroup(String s)

Sets the size group that this entity should be in for the dimension that this object is
describing. If this constraint is in a size group that is specified here. null means no
size group and all other values are legal. Comparison with .equals().
Components/columnss/rows in the same size group will have the same
min/preferred/max size; that of the largest in the group for the first two and the
smallest for max.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The new size group. null disables size grouping.
getEndGroup
public String getEndGroup()

Returns the end group that this entity should be in for the demension that this object
is describing. If this constraint is in an end group that is specified here. null means
no end group and all other values are legal. Comparison with .equals(). Components
in the same end group will have the same end coordinate.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current end group. null may be returned.
setEndGroup
public void setEndGroup(String s)

Sets the end group that this entity should be in for the demension that this object is
describing. If this constraint is in an end group that is specified here. null means no

Method Detail

1068

Overview (Codename One API)


end group and all other values are legal. Comparison with .equals(). Components in
the same end group will have the same end coordinate.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The new end group. null disables end grouping.
isFill
public boolean isFill()

Returns if the component in the row/column that this constraint should default be
grown in the same dimension that this constraint represents (width for column and
height for a row).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
true

means that components should grow.

setFill
public void setFill(boolean b)

Sets if the component in the row/column that this constraint should default be grown
in the same dimension that this constraint represents (width for column and height for
a row).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true means that components should grow.
isNoGrid
public boolean isNoGrid()

Returns if the row/column should default to flow and not to grid behaviour. This
means that the whole row/column will be one cell and all components will end up in
that cell.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
true

means that the whole row/column should be one cell.

setNoGrid
public void setNoGrid(boolean b)

Sets if the row/column should default to flow and not to grid behaviour. This means
that the whole row/column will be one cell and all components will end up in that cell.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true means that the whole row/column should be one cell.

Method Detail

1069

Overview (Codename One API)


com.codename1.ui.layouts.mig

Interface ContainerWrapper
All Superinterfaces:
ComponentWrapper

public interface
extends ComponentWrapper

A class that wraps a container that contains components.

Field Summary

Fields inherited from


interface com.codename1.ui.layouts.mig.ComponentWrapper
TYPE_BUTTON, TYPE_CHECK_BOX, TYPE_COMBO_BOX, TYPE_CONTAINER, TYPE_IMAGE,
TYPE_LABEL, TYPE_LIST, TYPE_PANEL, TYPE_PROGRESS_BAR, TYPE_SCROLL_BAR,
TYPE_SCROLL_PANE, TYPE_SEPARATOR, TYPE_SLIDER, TYPE_SPINNER,
TYPE_TABBED_PANE, TYPE_TABLE, TYPE_TEXT_AREA, TYPE_TEXT_FIELD, TYPE_TREE,
TYPE_UNKNOWN, TYPE_UNSET

Method Summary
Modifier and Type

Method and Description


getComponentCount()

int

Returns the number of components that this parent has.

ComponentWrapper[]

getComponents()

Returns the components of the container that wrapper is wrapping.


getLayout()
Returns the LayoutHandler

Object

(in Swing terms) that is handling the layout

of this container.
boolean

isLeftToRight()

Returns if this container is using left-to-right component ordering.


paintDebugCell(int x, int y, int width, int height)

void

Paints a cell to indicate where it is.

Methods inherited from


interface com.codename1.ui.layouts.mig.ComponentWrapper
getBaseline, getComponent, getComponentType, getContentBias, getHeight,
getHorizontalScreenDPI, getLayoutHashCode, getLinkId, getMaximumHeight,
getMaximumWidth, getMinimumHeight, getMinimumWidth, getParent,
getPixelUnitFactor, getPreferredHeight, getPreferredWidth, getScreenHeight,
getScreenLocationX, getScreenLocationY, getScreenWidth,
getVerticalScreenDPI, getVisualPadding, getWidth, getX, getY, hasBaseline,
isVisible, paintDebugOutline, setBounds

Method Detail
getComponents
ComponentWrapper[] getComponents()

Returns the components of the container that wrapper is wrapping.


Returns:
The components of the container that wrapper is wrapping. Never null.

Interface ContainerWrapper

1070

Overview (Codename One API)


getComponentCount
int getComponentCount()

Returns the number of components that this parent has.


Returns:
The number of components that this parent has.
getLayout
Object getLayout()

Returns the LayoutHandler (in Swing terms) that is handling the layout of this
container. If there exist no such class the method should return the same as
ComponentWrapper.getComponent(), which is the container itself.
Returns:
The layout handler instance. Never null.
isLeftToRight
boolean isLeftToRight()

Returns if this container is using left-to-right component ordering.


Returns:
If this container is using left-to-right component ordering.
paintDebugCell
void paintDebugCell(int
int
int
int

x,
y,
width,
height)

Paints a cell to indicate where it is.


Parameters:
x - The x coordinate to start the drwaing.
y - The x coordinate to start the drwaing.
width - The width to draw/fill
height - The height to draw/fill

Method Detail

1071

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class ConstraintParser
java.lang.Object

com.codename1.ui.layouts.mig.ConstraintParser

public final class


extends Object

Parses string constraints.

Method Summary
Modifier and Type
static BoundSize
static AC
static CC
static
Map<ComponentWrapper,CC>
static UnitValue[]

Method and Description


parseBoundSize(String s, boolean isGap, boolean isHor)

Parses a single "min:pref:max" value.


parseColumnConstraints(String s)

Parses the column or rows constraints.


parseComponentConstraint(String s)

Parses one component constraint and returns the parsed value.

parseComponentConstraints(Map<ComponentWrapper,String> constrMa

Parses all component constraints and stores the parsed values in the
transient (cache) member variables.
parseInsets(String s, boolean acceptPanel)
Parses insets which consists of 1-4 UnitValues.
parseLayoutConstraint(String s)

static LC

static AC
static UnitValue

static UnitValue

static String

Parses the layout constraints and stores the parsed values in the transi
(cache) member varables.
parseRowConstraints(String s)

Parses the column or rows constraints.


parseUnitValue(String s, boolean isHor)

Parses a single unit value.


parseUnitValueOrAlign(String s, boolean isHor,
UnitValue emptyReplacement)

Parses a single unit value that may also be an alignment as parsed by


parseAlignKeywords(String, boolean).
prepare(String s)
Makes null "", trims

and converts to lower case.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
parseLayoutConstraint
public static LC parseLayoutConstraint(String s)

Parses the layout constraints and stores the parsed values in the transient (cache)
member varables.
Parameters:
s - The String to parse. Should not be null and must be lower case and
trimmed.
Returns:

Class ConstraintParser

1072

Overview (Codename One API)


The parsed constraint. Never null.
Throws:
RuntimeException

- if the constaint was not valid.

parseRowConstraints
public static AC parseRowConstraints(String s)

Parses the column or rows constraints. They normally looks something like
"[min:pref]rel[10px][]".
Parameters:
s - The string to parse. Not null.
Returns:
An array of DimConstraints that is as many are there exist "[...]" sections in
the string that is parsed.
Throws:
RuntimeException - if the constraint was not valid.
parseColumnConstraints
public static AC parseColumnConstraints(String s)

Parses the column or rows constraints. They normally looks something like
"[min:pref]rel[10px][]".
Parameters:
s - The string to parse. Not null.
Returns:
An array of DimConstraints that is as many are there exist "[...]" sections in
the string that is parsed.
Throws:
RuntimeException - if the constraint was not valid.
parseComponentConstraints

public static Map<ComponentWrapper,CC> parseComponentConstraints(Map<ComponentWrappe

Parses all component constraints and stores the parsed values in the transient
(cache) member variables.
Parameters:
constrMap - The constraints as Strings. Strings must be lower case and
trimmed
Returns:
The parsed constraints. Never null.
parseComponentConstraint
public static CC parseComponentConstraint(String s)

Parses one component constraint and returns the parsed value.


Parameters:
s - The string to parse. Should not be null and must be lower case and
trimmed.
Returns:
The parsed constraint. Never null.
Throws:
RuntimeException - if the constraint was not valid.
parseInsets
public static UnitValue[] parseInsets(String s,
boolean acceptPanel)

Parses insets which consists of 1-4 UnitValues.


Parameters:
s - The string to parse. E.g. "10 10 10 10" or "20". If less than 4 groups the
last will be used for the missing.
acceptPanel - If "panel" and "dialog" should be accepted. They are used to
access platform defaults.
Returns:
An array of length 4 with the parsed insets.
Throws:
IllegalArgumentException - if the parsing could not be done.

Method Detail

1073

Overview (Codename One API)


parseBoundSize
public static BoundSize parseBoundSize(String s,
boolean isGap,
boolean isHor)

Parses a single "min:pref:max" value. May look something like "10px:20lp:30%" or


"pref!".
Parameters:
s - The string to parse. Not null.
isGap - If this bound size is a gap (different empty string handling).
isHor - If the size is for the horizontal dimension.
Returns:
A bound size that may be null if the string was "null", "n" or null.
parseUnitValueOrAlign
public static UnitValue parseUnitValueOrAlign(String s,
boolean isHor,
UnitValue emptyReplacement)

Parses a single unit value that may also be an alignment as parsed by


parseAlignKeywords(String, boolean).
Parameters:
s - The string to parse. Not null. May look something like "10px" or "5dlu".
isHor - If the value is for the horizontal dimension.
emptyReplacement - A replacement if s is empty. May be null.
Returns:
The parsed unit value. May be null.
parseUnitValue
public static UnitValue parseUnitValue(String s,
boolean isHor)

Parses a single unit value. E.g. "10px" or "5in"


Parameters:
s - The string to parse. Not null. May look something like "10px" or "5dlu".
isHor - If the value is for the horizontal dimension.
Returns:
The parsed unit value. null is empty string,
prepare
public static String prepare(String s)

Makes null "", trims and converts to lower case.


Parameters:
s - The string
Returns:
Not null.

Method Detail

1074

Overview (Codename One API)


com.codename1.ui.layouts.mig

Interface ComponentWrapper
All Known Subinterfaces:
ContainerWrapper

public interface

A class that wraps the important parts of a Component.


NOTE!.equals() and .hashcode() should be forwarded to the wrapped component. E.g.
public int hashCode()
{
return getComponent().hashCode();
}
public final boolean equals(Object o)
{
if (o instanceof ComponentWrapper == false)
return false;
return getComponent().equals(((ComponentWrapper) o).getComponent());
}

Field Summary
Modifier and Type Field and Description
static int

TYPE_BUTTON

static int

TYPE_CHECK_BOX

static int

TYPE_COMBO_BOX

static int

TYPE_CONTAINER

static int

TYPE_IMAGE

static int

TYPE_LABEL

static int

TYPE_LIST

static int

TYPE_PANEL

static int

TYPE_PROGRESS_BAR

static int

TYPE_SCROLL_BAR

static int

TYPE_SCROLL_PANE

static int

TYPE_SEPARATOR

static int

TYPE_SLIDER

static int

TYPE_SPINNER

static int

TYPE_TABBED_PANE

static int

TYPE_TABLE

static int

TYPE_TEXT_AREA

static int

TYPE_TEXT_FIELD

static int

TYPE_TREE

static int

TYPE_UNKNOWN

static int

TYPE_UNSET

Interface ComponentWrapper

1075

Overview (Codename One API)

Method Summary
Modifier and
Type
int
Object
int

Method and Description


getBaseline(int width, int height)

Returns the baseline for the component given the suggested height.
getComponent()

Returns the actual object that this wrapper is aggregating.


getComponentType(boolean disregardScrollPane)

Returns the type of component that this wrapper is wrapping.


getContentBias()

int

int

Returns in what way the min/pref/max sizes relates to it's height or width
for the current settings of the component (like wrapText).
getHeight()

Returns the current height for this component.


getHorizontalScreenDPI()

int

Returns the DPI (Dots Per Inch) of the screen the component is currently
in or for the default screen if the component is not visible.
getLayoutHashCode()

int

Returns a hash code that should be reasonably different for anything


that might change the layout.
getLinkId()

String

int
int
int
int
ContainerWrapper
float
int
int

Returns a String id that can be used to reference the component in link


constraints.
getMaximumHeight(int wHint)

Returns the maximum height of the component.


getMaximumWidth(int hHint)

Returns the maximum width of the component.


getMinimumHeight(int wHint)

Returns the minimum height of the component.


getMinimumWidth(int hHint)

Returns the minimum width of the component.


getParent()

Returns the container for this component.


getPixelUnitFactor(boolean isHor)

Returns the pixel unit factor for the horizontal or vertical dimension.
getPreferredHeight(int wHint)

Returns the preferred height of the component.


getPreferredWidth(int hHint)

Returns the preferred width of the component.


getScreenHeight()

int

Returns the pixel size of the screen that the component is currently in or
for the default screen if the component is not visible or null.
getScreenLocationX()

int

Returns the screen x-coordinate for the upper left coordinate of the
component layout-able bounds.
getScreenLocationY()

int

Returns the screen y-coordinate for the upper left coordinate of the
component layout-able bounds.
getScreenWidth()

int

Returns the pixel size of the screen that the component is currently in or
for the default screen if the component is not visible or null.
getVerticalScreenDPI()

int

int[]
int

Method Summary

Returns the DPI (Dots Per Inch) of the screen the component is currently
in or for the default screen if the component is not visible.
getVisualPadding()

Returns the padding on a component by component basis.


getWidth()

1076

Overview (Codename One API)

Returns the current width for this component.


getX()

int

Returns the current x coordinate for this component.


getY()

int

Returns the current y coordinate for this component.

boolean
boolean

Returns if the component has a baseline and if it can be retrieved.


isVisible()

Returns if the component's visibility is set to true.


paintDebugOutline(boolean showVisualPadding)

void

Paints component outline to indicate where it is.


setBounds(int x, int y, int width, int height)

void

hasBaseline()

Sets the component's bounds.

Field Detail
TYPE_UNSET
static final int TYPE_UNSET

See Also:
Constant Field Values
TYPE_UNKNOWN
static final int TYPE_UNKNOWN

See Also:
Constant Field Values
TYPE_CONTAINER
static final int TYPE_CONTAINER

See Also:
Constant Field Values
TYPE_LABEL
static final int TYPE_LABEL

See Also:
Constant Field Values
TYPE_TEXT_FIELD
static final int TYPE_TEXT_FIELD

See Also:
Constant Field Values
TYPE_TEXT_AREA
static final int TYPE_TEXT_AREA

See Also:
Constant Field Values
TYPE_BUTTON
static final int TYPE_BUTTON

See Also:
Constant Field Values

Field Detail

1077

Overview (Codename One API)


TYPE_LIST
static final int TYPE_LIST

See Also:
Constant Field Values
TYPE_TABLE
static final int TYPE_TABLE

See Also:
Constant Field Values
TYPE_SCROLL_PANE
static final int TYPE_SCROLL_PANE

See Also:
Constant Field Values
TYPE_IMAGE
static final int TYPE_IMAGE

See Also:
Constant Field Values
TYPE_PANEL
static final int TYPE_PANEL

See Also:
Constant Field Values
TYPE_COMBO_BOX
static final int TYPE_COMBO_BOX

See Also:
Constant Field Values
TYPE_SLIDER
static final int TYPE_SLIDER

See Also:
Constant Field Values
TYPE_SPINNER
static final int TYPE_SPINNER

See Also:
Constant Field Values
TYPE_PROGRESS_BAR
static final int TYPE_PROGRESS_BAR

See Also:
Constant Field Values
TYPE_TREE
static final int TYPE_TREE

See Also:
Constant Field Values
TYPE_CHECK_BOX
static final int TYPE_CHECK_BOX

See Also:
Constant Field Values

Field Detail

1078

Overview (Codename One API)


TYPE_SCROLL_BAR
static final int TYPE_SCROLL_BAR

See Also:
Constant Field Values
TYPE_SEPARATOR
static final int TYPE_SEPARATOR

See Also:
Constant Field Values
TYPE_TABBED_PANE
static final int TYPE_TABBED_PANE

See Also:
Constant Field Values

Method Detail
getComponent
Object getComponent()

Returns the actual object that this wrapper is aggregating. This might be needed for
getting information about the object that the wrapper interface does not provide.
If this is a container the container should be returned instead.
Returns:
The actual object that this wrapper is aggregating. Not null.
getX
int getX()

Returns the current x coordinate for this component.


Returns:
The current x coordinate for this component.
getY
int getY()

Returns the current y coordinate for this component.


Returns:
The current y coordinate for this component.
getWidth
int getWidth()

Returns the current width for this component.


Returns:
The current width for this component.
getHeight
int getHeight()

Returns the current height for this component.


Returns:
The current height for this component.
getScreenLocationX
int getScreenLocationX()

Returns the screen x-coordinate for the upper left coordinate of the component
layout-able bounds.

Field Detail

1079

Overview (Codename One API)


Returns:
The screen x-coordinate for the upper left coordinate of the component
layout-able bounds.
getScreenLocationY
int getScreenLocationY()

Returns the screen y-coordinate for the upper left coordinate of the component
layout-able bounds.
Returns:
The screen y-coordinate for the upper left coordinate of the component
layout-able bounds.
getMinimumWidth
int getMinimumWidth(int hHint)

Returns the minimum width of the component.


Parameters:
hHint - The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The minimum width of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
getMinimumHeight
int getMinimumHeight(int wHint)

Returns the minimum height of the component.


Parameters:
wHint - The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The minimum height of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
getPreferredWidth
int getPreferredWidth(int hHint)

Returns the preferred width of the component.


Parameters:
hHint - The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The preferred width of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
getPreferredHeight
int getPreferredHeight(int wHint)

Returns the preferred height of the component.


Parameters:

Method Detail

1080

Overview (Codename One API)


- The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The preferred height of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
getMaximumWidth
wHint

int getMaximumWidth(int hHint)

Returns the maximum width of the component.


Parameters:
hHint - The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The maximum width of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
getMaximumHeight
int getMaximumHeight(int wHint)

Returns the maximum height of the component.


Parameters:
wHint - The Size hint for the other dimension. An implementation can use this
value or the current size for the widget in this dimension, or a combination of
both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns:
The maximum height of the component.
Since:
3.5. Added the hint as a parameter knowing that a correction and
recompilation is necessary for any implementing classes. This change was
worth it though.
setBounds
void setBounds(int
int
int
int

x,
y,
width,
height)

Sets the component's bounds.


Parameters:
x - The x coordinate.
y - The y coordinate.
width - The width.
height - The height.
isVisible
boolean isVisible()

Returns if the component's visibility is set to true. This should not return if the
component is actually visible, but if the visibility is set to true or not.
Returns:
true means visible.

Method Detail

1081

Overview (Codename One API)


getBaseline
int getBaseline(int width,
int height)

Returns the baseline for the component given the suggested height.
Parameters:
width - The width to calculate for if other than the current. If -1 the current
size should be used.
height - The height to calculate for if other than the current. If -1 the current
size should be used.
Returns:
The baseline from the top or -1 if not applicable.
hasBaseline
boolean hasBaseline()

Returns if the component has a baseline and if it can be retrieved. Should for
instance return false for Swing before mustang.
Returns:
If the component has a baseline and if it can be retrieved.
getParent
ContainerWrapper getParent()

Returns the container for this component.


Returns:
The container for this component. Will return null if the component has no
parent.
getPixelUnitFactor
float getPixelUnitFactor(boolean isHor)

Returns the pixel unit factor for the horizontal or vertical dimension.
The factor is 1 for both dimensions on the normal font in a JPanel on Windows. The
factor should increase with a bigger "X".
This is the Swing version:
Rectangle2D r = fm.getStringBounds("X", parent.getGraphics());
wFactor = r.getWidth() / 6;
hFactor = r.getHeight() / 13.27734375f;

Parameters:
isHor - If it is the horizontal factor that should be returned.
Returns:
The factor.
getHorizontalScreenDPI
int getHorizontalScreenDPI()

Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the
default screen if the component is not visible.
If headless mode net.miginfocom.layout.PlatformDefaults#getDefaultDPI will be
returned.
Returns:
The DPI.
getVerticalScreenDPI
int getVerticalScreenDPI()

Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the
default screen if the component is not visible.

Method Detail

1082

Overview (Codename One API)


If headless mode net.miginfocom.layout.PlatformDefaults#getDefaultDPI will be
returned.
Returns:
The DPI.
getScreenWidth
int getScreenWidth()

Returns the pixel size of the screen that the component is currently in or for the
default screen if the component is not visible or null.
If in headless mode 1024 is returned.
Returns:
The screen size. E.g. 1280.
getScreenHeight
int getScreenHeight()

Returns the pixel size of the screen that the component is currently in or for the
default screen if the component is not visible or null.
If in headless mode 768 is returned.
Returns:
The screen size. E.g. 1024.
getLinkId
String getLinkId()

Returns a String id that can be used to reference the component in link constraints.
This value should return the default id for the component. The id can be set for a
component in the constraints and if so the value returned by this method will never be
used. If there are no sensible id for the component null should be returned.
For instance the Swing implementation returns the string returned from
Component.getName().
Returns:
The string link id or null.
getLayoutHashCode
int getLayoutHashCode()

Returns a hash code that should be reasonably different for anything that might
change the layout. This value is used to know if the component layout needs to clear
any caches.
Returns:
A hash code that should be reasonably different for anything that might
change the layout. Returns -1 if the widget is disposed.
getVisualPadding
int[] getVisualPadding()

Returns the padding on a component by component basis. This method can be


overridden to return padding to compensate for example for borders that have
shadows or where the outer most pixel is not the visual "edge" to align to.
Default implementation returns null for all components except for Windows XP's
JTabbedPane which will return new Insets(0, 0, 2, 2).
NOTE! To reduce generated garbage the returned padding should never be changed
so that the same insets can be returned many times.
Returns:

Method Detail

1083

Overview (Codename One API)


if no padding. NOTE! To reduce generated garbage the returned
padding should never be changed so that the same insets can be returned
many times. [top, left, bottom, right]
paintDebugOutline
null

void paintDebugOutline(boolean showVisualPadding)

Paints component outline to indicate where it is.


Parameters:
showVisualPadding - If the visual padding should be shown in the debug
drawing.
getComponentType
int getComponentType(boolean disregardScrollPane)

Returns the type of component that this wrapper is wrapping.


This method can be invoked often so the result should be cached.
Parameters:
- Is true any wrapping scroll pane should be
disregarded and the type of the scrolled component should be returned.
Returns:
The type of component that this wrapper is wrapping. E.g. TYPE_LABEL.
getContentBias
disregardScrollPane

int getContentBias()

Returns in what way the min/pref/max sizes relates to it's height or width for the
current settings of the component (like wrapText). If the min/pref/max height depends
on it's width return net.miginfocom.layout.LayoutUtil#HORIZONTAL If the
min/pref/max width depends on it's height (not common) return
net.miginfocom.layout.LayoutUtil#VERTICAL If there is no connection between the
preferred min/pref/max and the size of the component return -1.
Since:
5.0

Method Detail

1084

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class CC
java.lang.Object

com.codename1.ui.layouts.mig.CC

public final class


extends Object

A simple value holder for one component's constraint.

Constructor Summary
Constructor and Description
CC()

Empty constructor.

Method Summary
Modifier and
Type

Method and Description


alignX(String align)

CC

Same functionality as
getHorizontal().setAlign(ConstraintParser.parseUnitValue(unitValue,
true)) only this method returns this for chaining multiple calls.
alignY(String align)

CC

CC

Same functionality as
getVertical().setAlign(ConstraintParser.parseUnitValue(unitValue,
true)) only this method returns this for chaining multiple calls.
cell(int... colRowWidthHeight)

Set the cell(s) that the component should occupy in the grid.
dockEast()

CC

Same functionality as calling setDockSide(int) with 3 only this method


returns this for chaining multiple calls.
dockNorth()

CC

Same functionality as calling setDockSide(int) with 0 only this method


returns this for chaining multiple calls.
dockSouth()

CC

Same functionality as calling setDockSide(int) with 2 only this method


returns this for chaining multiple calls.
dockWest()

CC

CC

Same functionality as calling setDockSide(int) with 1 only this method


returns this for chaining multiple calls.
endGroup(String... xy)

The end group(s) that this component should be placed in.


endGroupX(String s)

CC

CC

Specifies that the component should be put in the end group s and will thus
share the same ending coordinate as them within the group.
endGroupY(String s)

The end group that this component should be placed in.


external()

Class CC

CC

Same functionality as calling setExternal(boolean) with true only this


method returns this for chaining multiple calls.

CC

flowX()

1085

Overview (Codename One API)


Same functionality as calling setFlowX(Boolean) with Boolean.TRUE only this
method returns this for chaining multiple calls.
flowY()
CC

CC
CC
CC
CC
CC
CC
CC
CC

Same functionality as calling setFlowX(Boolean) with Boolean.FALSE only


this method returns this for chaining multiple calls.
gap(String... args)

Corresponds exactly to the "gap left right top bottom" keyword.


gapAfter(String boundsSize)

Sets the horizontal gap after the component.


gapBefore(String boundsSize)

Sets the horizontal gap before the component.


gapBottom(String boundsSize)

Sets the gap below the component.


gapLeft(String boundsSize)

Sets the gap to the left the component.


gapRight(String boundsSize)

Sets the gap to the right of the component.


gapTop(String boundsSize)

Sets the gap above the component.


gapX(String before, String after)

The horizontal gap before and/or after the component.


gapY(String before, String after)

CC

The vertical gap before (normally above) and/or after (normally below) the
component.
getCellX()

int

Returns the absolute cell position in the grid or -1 if cell positioning is not
used.
getCellY()

int

DimConstraint
int
Boolean

Returns the absolute cell position in the grid or -1 if cell positioning is not
used.
getDimConstraint(boolean isHor)

Returns the vertical or horizontal dim constraint.


getDockSide()

Sets the docking side.


getFlowX()

Returns if the flow in the cell is in the horizontal dimension.


getHideMode()

int

DimConstraint
String
BoundSize
UnitValue[]
UnitValue[]

Sets how a component that is hidden (not visible) should be treated by


default.
getHorizontal()

Returns the horizontal dimension constraint for this component constraint.


getId()

Returns the id used to reference this component in some constraints.


getNewlineGapSize()

Returns the newline size if it is a custom size.


getPadding()

Returns the absolute resizing in the last stage of the layout cycle.
getPos()

Returns the absolute positioning of one or more of the edges.


getPushX()

Float

"pushx" indicates that the column that this component is in (this first if the
component spans) should default to growing.
getPushY()

Float

"pushx" indicates that the row that this component is in (this first if the
component spans) should default to growing.
getSkip()

int

Method Summary

Returns how many cells in the grid that should be skipped before the
component that this constraint belongs to.

1086

Overview (Codename One API)


getSpanX()
int

Returns the number of cells the cell that this constraint's component will
span in the indicated dimension.
getSpanY()

int

Returns the number of cells the cell that this constraint's component will
span in the indicated dimension.
getSplit()

int

String
DimConstraint
UnitValue[]
BoundSize
CC
CC
CC
CC
CC
CC
CC
CC
CC
CC
CC
CC

Returns in how many parts the current cell (that this constraint's component
will be in) should be split in.
getTag()

Tags the component with metadata.


getVertical()

Returns the vertical dimension constraint for this component constraint.


getVisualPadding()

Returns the visual padding used when laying out this Component.
getWrapGapSize()

Returns the wrap size if it is a custom size.


grow()

Same functionality as growX() and growY().


grow(float... widthHeight)

grow weight for the component horizontally and optionally vertically.


growPrio(int... widthHeight)

Grow priority for the component horizontally and optionally vertically.


growPrioX(int p)

The grow priority compared to other components in the same cell.


growPrioY(int p)

The grow priority compared to other components in the same cell.


growX()

Grow weight for the component horizontally.


growX(float w)

Grow weight for the component horizontally.


growY()

Grow weight for the component vertically.


growY(Float w)

Grow weight for the component vertically.


height(String size)

The size for the component as a min and/or preferred and/or maximum size.
hideMode(int mode)

How this component, if hidden (not visible), should be treated.


id(String s)

The id used to reference this component in some constraints.


isBoundsInGrid()

boolean

Returns if the absolute pos value should be corrections to the component


that is in a normal cell.
isExternal()

boolean

Returns if this component should have its bounds handled by an external


source and not this layout manager.
isNewline()

boolean

Returns if the flow should wrap to the next line/column before the
component that this constraint belongs to.
isWrap()

boolean

CC
CC
CC

Method Summary

Returns if the flow should wrap to the next line/column after the component
that this constraint belongs to.
maxHeight(String size)

The maximum size for the component.


maxWidth(String size)

The maximum size for the component.


minHeight(String size)

The minimum size for the component.

1087

Overview (Codename One API)


CC

minWidth(String size)

The minimum size for the component.


newline()

CC

CC

CC

Same functionality as calling setNewline(boolean) with true only this


method returns this for chaining multiple calls.
newline(String gapSize)
Same functionality as setNewlineGapSize(BoundSize)
returns this for chaining multiple calls.
pad(int top, int left, int bottom, int right)
Same functionality as setPadding(UnitValue[]) but

only this method

the unit values as

absolute pixels.
pad(String pad)
CC

Same functionality as setPadding(ConstraintParser.parseInsets(pad,


false))} only this method returns this for chaining multiple calls.

CC

pos(String x, String y)
Same functionality as x(String x)

CC

pos(String x, String y, String x2, String y2)


Same functionality as x(String x), y(String y), y2(String y)
y2(String y) toghether.

and y(String y) toghether.


and

push()
CC

CC

Same functionality as pushX().pushY() which means this cell will push in


both x and y dimensions.
push(Float weightX, Float weightY)
Same functionality as pushX(weightX).pushY(weightY)

which means this

cell will push in both x and y dimensions.


pushX()
CC

Same functionality as setPushX(Float) which means this cell will push the
rest of the row.
pushX(Float weight)

CC

Same functionality as setPushX(Float weight) only this method returns


this for chaining multiple calls.
pushY()

CC

Same functionality as setPushY(Float) which means this cell will push the
rest of the column.
pushY(Float weight)

CC

void
void
void

Same functionality as setPushY(Float weight) only this method returns


this for chaining multiple calls.
setCellX(int x)

Set an absolute cell x-position in the grid.


setCellY(int y)

Set an absolute cell x-position in the grid.


setDockSide(int side)

Sets the docking side.


setExternal(boolean b)

void

void

If this boolean is true this component is not handled in any way by the layout
manager and the component can have its bounds set by an external handler
which is normally by the use of some component.setBounds(x, y, width,
height) directly (for Swing).
setFlowX(Boolean b)

Sets if the flow in the cell is in the horizontal dimension.


setHideMode(int mode)

void

void
void

Sets how a component that is hidden (not visible) should be treated by


default.
setHorizontal(DimConstraint h)

Sets the horizontal dimension constraint for this component constraint.


setId(String id)

Sets the id used to reference this component in some constraints.


setNewline(boolean b)

void

Method Summary

Sets if the flow should wrap to the next line/column before the component
that this constraint belongs to.

1088

Overview (Codename One API)


void
void
void

setNewlineGapSize(BoundSize s)

Set the newline size and turns newline on if != null.


setPadding(UnitValue[] sides)

Sets the absolute resizing in the last stage of the layout cycle.
setPos(UnitValue[] pos)

Sets absolute positioning of one or more of the edges.


setPushX(Float weight)

void

"pushx" indicates that the column that this component is in (this first if the
component spans) should default to growing.
setPushY(Float weight)

void

"pushx" indicates that the row that this component is in (this first if the
component spans) should default to growing.
setSkip(int cells)

void

Sets how many cells in the grid that should be skipped before the
component that this constraint belongs to.
setSpanX(int cells)

void

Sets the number of cells the cell that this constraint's component will span in
the indicated dimension.
setSpanY(int cells)

void

Sets the number of cells the cell that this constraint's component will span in
the indicated dimension.
setSplit(int parts)

void

void
void
void

Sets in how many parts the current cell (that this constraint's component will
be in) should be split in.
setTag(String tag)

Optinal tag that gives more context to this constraint's component.


setVertical(DimConstraint v)

Sets the vertical dimension constraint for this component constraint.


setVisualPadding(UnitValue[] sides)

Sets the visual padding used when laying out this Component.
setWrap(boolean b)

void

void
CC
CC
CC
CC
CC
CC
CC

Sets if the flow should wrap to the next line/column after the component that
this constraint belongs to.
setWrapGapSize(BoundSize s)

Set the wrap size and turns wrap on if != null.


shrink(float... widthHeight)

Shrink weight for the component horizontally and optionally vertically.


shrinkPrio(int... widthHeight)

Shrink priority for the component horizontally and optionally vertically.


shrinkPrioX(int p)

The shrink priority compared to other components in the same cell.


shrinkPrioY(int p)

The shrink priority compared to other components in the same cell.


shrinkX(float w)

Shrink weight for the component horizontally.


shrinkY(float w)

Shrink weight for the component horizontally.


sizeGroup(String... xy)

The size group(s) that this component should be placed in.


sizeGroupX(String s)

CC

CC
CC

Specifies that the component should be put in the size group s and will thus
share the same size as them within the group.
sizeGroupY(String s)

The size group that this component should be placed in.


skip()

Same functionality as skip(1).


skip(int cells)

CC

Method Summary

Same functionality as setSkip(int) only this method returns this for


chaining multiple calls.

1089

Overview (Codename One API)


span(int... cells)

Same functionality as spanX(cellsX).spanY(cellsY) which means this cell


will span cells in both x and y.

CC

spanX()

Same functionality as setSpanX(int) which means this cell will span the rest
of the row.

CC

spanX(int cells)

Same functionality as setSpanX(int) only this method returns this for


chaining multiple calls.

CC

spanY()

Same functionality as calling setSpanY(int) with LayoutUtil.INF which


means this cell will span the rest of the column.

CC

spanY(int cells)

Same functionality as setSpanY(int) only this method returns this for


chaining multiple calls.

CC

split()

Same functionality as split(LayoutUtil.INF), which means split until one of the


keywords that breaks the split is found for a component after this one (e.g.

CC

split(int parts)

Same functionality as setSplit(int parts) only this method returns this


for chaining multiple calls.

CC

tag(String tag)

Same functionality as setTag(String tag) only this method returns this for
chaining multiple calls.

CC

width(String size)

CC

The size for the component as a min and/or preferred and/or maximum size.
wrap()

Same functionality as calling setWrap(boolean) with true only this method


returns this for chaining multiple calls.

CC

wrap(String gapSize)
Same functionality as setWrapGapSize(BoundSize)
this for chaining multiple calls.

CC

only this method returns

x(String x)

CC

Sets the x-coordinate for the component.


x2(String x2)

CC

Sets the x2-coordinate for the component (right side).


y(String y)

CC

Sets the y-coordinate for the component.


y2(String y2)

CC

Sets the y2-coordinate for the component (bottom side).

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CC
public CC()

Empty constructor.

Method Detail

Methods inherited from class java.lang.Object

1090

Overview (Codename One API)


endGroupX
public final CC endGroupX(String s)

Specifies that the component should be put in the end group s and will thus share the
same ending coordinate as them within the group.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - A name to associate on the group that should be the same for other
rows/columns in the same group.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
sizeGroupX
public final CC sizeGroupX(String s)

Specifies that the component should be put in the size group s and will thus share the
same size as them within the group.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - A name to associate on the group that should be the same for other
rows/columns in the same group.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
minWidth
public final CC minWidth(String size)

The minimum size for the component. The value will override any value that is set on
the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size

- The size expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

width
public final CC width(String size)

The size for the component as a min and/or preferred and/or maximum size. The
value will override any value that is set on the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The size expressed as a BoundSize. E.g. "50:100px:200mm" or
"100px".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
size

Method Detail

1091

Overview (Codename One API)


maxWidth
public final CC maxWidth(String size)

The maximum size for the component. The value will override any value that is set on
the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size

- The size expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

gapX
public final CC gapX(String before,
String after)

The horizontal gap before and/or after the component. The gap is towards cell
bounds and/or other component bounds.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
after - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
alignX
before

public final CC alignX(String align)

Same functionality as
getHorizontal().setAlign(ConstraintParser.parseUnitValue(unitValue, true))
only this method returns this for chaining multiple calls.

For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The align keyword or for instance "100px". E.g "left", "right", "leading"
or "trailing".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
growPrioX
align

public final CC growPrioX(int p)

The grow priority compared to other components in the same cell.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The grow priority.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Method Detail

1092

Overview (Codename One API)


growPrio
public final CC growPrio(int... widthHeight)

Grow priority for the component horizontally and optionally vertically.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
widthHeight

- The new shrink weight and height. 1-2 arguments, never null.

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
growX
public final CC growX()

Grow weight for the component horizontally. It default to weight 100.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
growX(float)

growX
public final CC growX(float w)

Grow weight for the component horizontally.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new grow weight.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

grow
public final CC grow(float... widthHeight)

grow weight for the component horizontally and optionally vertically.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
widthHeight

- The new shrink weight and height. 1-2 arguments, never null.

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
shrinkPrioX
public final CC shrinkPrioX(int p)

The shrink priority compared to other components in the same cell.

Method Detail

1093

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The shrink priority.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

shrinkPrio
public final CC shrinkPrio(int... widthHeight)

Shrink priority for the component horizontally and optionally vertically.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
widthHeight

- The new shrink weight and height. 1-2 arguments, never null.

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
shrinkX
public final CC shrinkX(float w)

Shrink weight for the component horizontally.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new shrink weight.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

shrink
public final CC shrink(float... widthHeight)

Shrink weight for the component horizontally and optionally vertically.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
widthHeight

- The new shrink weight and height. 1-2 arguments, never null.

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
endGroupY
public final CC endGroupY(String s)

The end group that this component should be placed in.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The name of the group. If null that means no group (default)
Returns:

Method Detail

1094

Overview (Codename One API)


this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

endGroup
public final CC endGroup(String... xy)

The end group(s) that this component should be placed in.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
xy - The end group for x and y respectively. 1-2 arguments, not null.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
Since:
3.7.2
sizeGroupY
public final CC sizeGroupY(String s)

The size group that this component should be placed in.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The name of the group. If null that means no group (default)
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
sizeGroup
public final CC sizeGroup(String... xy)

The size group(s) that this component should be placed in.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
xy - The size group for x and y respectively. 1-2 arguments, not null.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
Since:
3.7.2
minHeight
public final CC minHeight(String size)

The minimum size for the component. The value will override any value that is set on
the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size

- The size expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Method Detail

1095

Overview (Codename One API)


height
public final CC height(String size)

The size for the component as a min and/or preferred and/or maximum size. The
value will override any value that is set on the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The size expressed as a BoundSize. E.g. "50:100px:200mm" or
"100px".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
maxHeight
size

public final CC maxHeight(String size)

The maximum size for the component. The value will override any value that is set on
the component itself.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
size

- The size expressed as a UnitValue. E.g. "100px" or "200mm".

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

gapY
public final CC gapY(String before,
String after)

The vertical gap before (normally above) and/or after (normally below) the
component. The gap is towards cell bounds and/or other component bounds.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
after - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
alignY
before

public final CC alignY(String align)

Same functionality as
getVertical().setAlign(ConstraintParser.parseUnitValue(unitValue, true))
only this method returns this for chaining multiple calls.

For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
align

- The align keyword or for instance "100px". E.g "top" or "bottom".

Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Method Detail

1096

Overview (Codename One API)


growPrioY
public final CC growPrioY(int p)

The grow priority compared to other components in the same cell.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The grow priority.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

growY
public final CC growY()

Grow weight for the component vertically. Defaults to 100.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
growY(Float)

growY
public final CC growY(Float w)

Grow weight for the component vertically.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new grow weight.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

shrinkPrioY
public final CC shrinkPrioY(int p)

The shrink priority compared to other components in the same cell.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The shrink priority.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

shrinkY
public final CC shrinkY(float w)

Shrink weight for the component horizontally.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new shrink weight.

Method Detail

1097

Overview (Codename One API)


Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

hideMode
public final CC hideMode(int mode)

How this component, if hidden (not visible), should be treated.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The mode. Default to the mode in the net.miginfocom.layout.LC. 0 ==
Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
id
mode

public final CC id(String s)

The id used to reference this component in some constraints.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The id or null. May consist of a groupID and an componentID which are
separated by a dot: ".". E.g. "grp1.id1". The dot should never be first or last if
present.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
tag
public final CC tag(String tag)

Same functionality as setTag(String tag) only this method returns this for chaining
multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
tag - The new tag. May be null.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setTag(String)

cell
public final CC cell(int... colRowWidthHeight)

Set the cell(s) that the component should occupy in the grid. Same functionality as
setCellX(int col) and setCellY(int row) together with setSpanX(int width) and
setSpanY(int height). This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.

Method Detail

1098

Overview (Codename One API)


Parameters:
- cellX, cellY, spanX, spanY repectively. 1-4 arguments,
not null.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2. Replacing cell(int, int) and cell(int, int, int, int)
See Also:
setCellX(int), setCellY(int), setSpanX(int), setSpanY(int)
span
colRowWidthHeight

public final CC span(int... cells)

Same functionality as spanX(cellsX).spanY(cellsY) which means this cell will span


cells in both x and y. This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com. Since 3.7.2 this takes an array/vararg
whereas it previously only took two specific values, xSpan and ySpan.
Parameters:
cells

- spanX and spanY, when present, and in that order.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

Since:
3.7.2 Replaces span(int, int).
See Also:
setSpanY(int), setSpanX(int), spanY(), spanX()
gap
public final CC gap(String... args)

Corresponds exactly to the "gap left right top bottom" keyword.


Parameters:
args - Same as for the "gap" keyword. Length 1-4, never null buf elements
can be null.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapBefore
public final CC gapBefore(String boundsSize)

Sets the horizontal gap before the component.


Note! This is currently same as gapLeft(). This might change in 4.x.
Parameters:
- The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapAfter
boundsSize

public final CC gapAfter(String boundsSize)

Sets the horizontal gap after the component.


Note! This is currently same as gapLeft(). This might change in 4.x.

Method Detail

1099

Overview (Codename One API)


Parameters:
- The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapTop
boundsSize

public final CC gapTop(String boundsSize)

Sets the gap above the component.


Parameters:
boundsSize - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapLeft
public final CC gapLeft(String boundsSize)

Sets the gap to the left the component.


Parameters:
boundsSize - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapBottom
public final CC gapBottom(String boundsSize)

Sets the gap below the component.


Parameters:
boundsSize - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
gapRight
public final CC gapRight(String boundsSize)

Sets the gap to the right of the component.


Parameters:
boundsSize - The size of the gap expressed as a BoundSize. E.g.
"50:100px:200mm" or "100px!".
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().
Since:
3.7.2
spanY
public final CC spanY()

Same functionality as calling setSpanY(int) with LayoutUtil.INF which means this


cell will span the rest of the column. This method returns this for chaining multiple

Method Detail

1100

Overview (Codename One API)


calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setSpanY(int), spanY()

spanY
public final CC spanY(int cells)

Same functionality as setSpanY(int) only this method returns this for chaining
multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
cells

- The number of cells to span (i.e. merge).

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setSpanY(int)

spanX
public final CC spanX()

Same functionality as setSpanX(int) which means this cell will span the rest of the
row. This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setSpanX(int), spanX()

spanX
public final CC spanX(int cells)

Same functionality as setSpanX(int) only this method returns this for chaining
multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
cells

- The number of cells to span (i.e. merge).

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setSpanY(int)

push
public final CC push()

Same functionality as pushX().pushY() which means this cell will push in both x and
y dimensions. This method returns this for chaining multiple calls.

Method Detail

1101

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushX(Float), setPushX(Float), pushY(), pushX()

push
public final CC push(Float weightX,
Float weightY)

Same functionality as pushX(weightX).pushY(weightY) which means this cell will


push in both x and y dimensions. This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
weightX
weightY

- The weight used in the push.


- The weight used in the push.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushY(Float), setPushX(Float), pushY(), pushX()

pushY
public final CC pushY()

Same functionality as setPushY(Float) which means this cell will push the rest of the
column. This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushY(Float)

pushY
public final CC pushY(Float weight)

Same functionality as setPushY(Float weight) only this method returns this for
chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
weight

- The weight used in the push.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushY(Float)

pushX
public final CC pushX()

Same functionality as setPushX(Float) which means this cell will push the rest of the
row. This method returns this for chaining multiple calls.

Method Detail

1102

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushX(Float)

pushX
public final CC pushX(Float weight)

Same functionality as setPushX(Float weight) only this method returns this for
chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
weight

- The weight used in the push.

Returns:
this so it is possible to chain calls. E.g. new
LayoutConstraint().noGrid().gap().fill().

See Also:
setPushY(Float)

split
public final CC split(int parts)

Same functionality as setSplit(int parts) only this method returns this for
chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
parts

- The number of parts (i.e. component slots) the cell should be divided

into.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setSplit(int)

split
public final CC split()

Same functionality as split(LayoutUtil.INF), which means split until one of the


keywords that breaks the split is found for a component after this one (e.g. wrap,
newline and skip).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
See Also:
setSplit(int)

skip
public final CC skip(int cells)

Same functionality as setSkip(int) only this method returns this for chaining
multiple calls.

Method Detail

1103

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- How many cells in the grid that should be skipped before the
component that this constraint belongs to
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
cells

setSkip(int)

skip
public final CC skip()

Same functionality as skip(1).


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Since:
3.7.2
See Also:
setSkip(int)

external
public final CC external()

Same functionality as calling setExternal(boolean) with true only this method


returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setExternal(boolean)

flowX
public final CC flowX()

Same functionality as calling setFlowX(Boolean) with Boolean.TRUE only this method


returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setFlowX(Boolean)

flowY
public final CC flowY()

Same functionality as calling setFlowX(Boolean) with Boolean.FALSE only this method


returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.

Method Detail

1104

Overview (Codename One API)


Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setFlowX(Boolean)

grow
public final CC grow()

Same functionality as growX() and growY().


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
growX(), growY()

newline
public final CC newline()

Same functionality as calling setNewline(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setNewline(boolean)

newline
public final CC newline(String gapSize)

Same functionality as setNewlineGapSize(BoundSize) only this method returns this


for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The gap size that will override the gap size in the row/colum
constraints if != null. E.g. "5px" or "unrel". If null or "" the newline size will
be set to the default size and turned on. This is different compared to
setNewlineGapSize(BoundSize).
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
gapSize

setNewlineGapSize(BoundSize)

wrap
public final CC wrap()

Same functionality as calling setWrap(boolean) with true only this method returns
this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

Method Detail

1105

Overview (Codename One API)


See Also:
setWrap(boolean)

wrap
public final CC wrap(String gapSize)

Same functionality as setWrapGapSize(BoundSize) only this method returns this for


chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The gap size that will override the gap size in the row/colum
constraints if != null. E.g. "5px" or "unrel". If null or "" the wrap size will be
set to the default size and turned on. This is different compared to
setWrapGapSize(BoundSize).
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
gapSize

setWrapGapSize(BoundSize)

dockNorth
public final CC dockNorth()

Same functionality as calling setDockSide(int) with 0 only this method returns this
for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setDockSide(int)

dockWest
public final CC dockWest()

Same functionality as calling setDockSide(int) with 1 only this method returns this
for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setDockSide(int)

dockSouth
public final CC dockSouth()

Same functionality as calling setDockSide(int) with 2 only this method returns this
for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setDockSide(int)

Method Detail

1106

Overview (Codename One API)


dockEast
public final CC dockEast()

Same functionality as calling setDockSide(int) with 3 only this method returns this
for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setDockSide(int)

x
public final CC x(String x)

Sets the x-coordinate for the component. This is used to set the x coordinate position
to a specific value. The component bounds is still precalculated to the grid cell and
this method should be seen as a way to correct the x position.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
x - The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setPos(UnitValue[]), setBoundsInGrid(boolean)
y
public final CC y(String y)

Sets the y-coordinate for the component. This is used to set the y coordinate position
to a specific value. The component bounds is still precalculated to the grid cell and
this method should be seen as a way to correct the y position.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
y - The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setPos(UnitValue[]), setBoundsInGrid(boolean)
x2
public final CC x2(String x2)

Sets the x2-coordinate for the component (right side). This is used to set the x2
coordinate position to a specific value. The component bounds is still precalculated to
the grid cell and this method should be seen as a way to correct the x position.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
x2 - The x2 side's position as a UnitValue. E.g. "10" or "40mm" or
"container.x2 - 10".
Returns:

Method Detail

1107

Overview (Codename One API)


this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().

See Also:
setPos(UnitValue[]), setBoundsInGrid(boolean)

y2
public final CC y2(String y2)

Sets the y2-coordinate for the component (bottom side). This is used to set the y2
coordinate position to a specific value. The component bounds is still precalculated to
the grid cell and this method should be seen as a way to correct the y position.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
y2 - The y2 side's position as a UnitValue. E.g. "10" or "40mm" or
"container.x2 - 10".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setPos(UnitValue[]), setBoundsInGrid(boolean)
pos
public final CC pos(String x,
String y)

Same functionality as x(String x) and y(String y) toghether.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
x - The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
y - The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setPos(UnitValue[])

pos
public final CC pos(String
String
String
String

x,
y,
x2,
y2)

Same functionality as x(String x), y(String y), y2(String y) and y2(String y)


toghether.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
x - The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
y - The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
x2 - The x2 side's position as a UnitValue. E.g. "10" or "40mm" or
"container.x2 - 10".
y2 - The y2 side's position as a UnitValue. E.g. "10" or "40mm" or
"container.x2 - 10".
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setPos(UnitValue[])

Method Detail

1108

Overview (Codename One API)


pad
public final CC pad(int
int
int
int

top,
left,
bottom,
right)

Same functionality as setPadding(UnitValue[]) but the unit values as absolute


pixels. This method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
top - The top padding that will be added to the y coordinate at the last stage
in the layout.
left - The top padding that will be added to the x coordinate at the last stage
in the layout.
bottom - The top padding that will be added to the y2 coordinate at the last
stage in the layout.
right - The top padding that will be added to the x2 coordinate at the last
stage in the layout.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setTag(String)

pad
public final CC pad(String pad)

Same functionality as setPadding(ConstraintParser.parseInsets(pad, false))}


only this method returns this for chaining multiple calls.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
pad - The string to parse. E.g. "10 10 10 10" or "20". If less than 4 groups the
last will be used for the missing.
Returns:
this so it is possible to chain calls. E.g. new
ComponentConstraint().noGrid().gap().fill().
See Also:
setTag(String)

getHorizontal
public DimConstraint getHorizontal()

Returns the horizontal dimension constraint for this component constraint. It has
constraints for the horizontal size and grow/shink priorities and weights.
Note! If any changes is to be made it must be made direct when the object is
returned. It is not allowed to save the constraint for later use.
Returns:
The current dimension constraint. Never null.
setHorizontal
public void setHorizontal(DimConstraint h)

Sets the horizontal dimension constraint for this component constraint. It has
constraints for the horizontal size and grow/shrink priorities and weights.
Parameters:
h - The new dimension constraint. If null it will be reset to new
DimConstraint();

Method Detail

1109

Overview (Codename One API)


getVertical
public DimConstraint getVertical()

Returns the vertical dimension constraint for this component constraint. It has
constraints for the vertical size and grow/shrink priorities and weights.
Note! If any changes is to be made it must be made direct when the object is
returned. It is not allowed to save the constraint for later use.
Returns:
The current dimension constraint. Never null.
setVertical
public void setVertical(DimConstraint v)

Sets the vertical dimension constraint for this component constraint. It has constraints
for the vertical size and grow/shrink priorities and weights.
Parameters:
v - The new dimension constraint. If null it will be reset to new
DimConstraint();

getDimConstraint
public DimConstraint getDimConstraint(boolean isHor)

Returns the vertical or horizontal dim constraint.


Note! If any changes is to be made it must be made direct when the object is
returned. It is not allowed to save the constraint for later use.
Parameters:
isHor - If the horizontal constraint should be returned.
Returns:
The dim constraint. Never null.
getPos
public UnitValue[] getPos()

Returns the absolute positioning of one or more of the edges. This will be applied last
in the layout cycle and will not affect the flow or grid positions. The positioning is
relative to the parent and can not (as padding) be used to adjust the edges relative to
the old value. May be null and elements may be null. null value(s) for the x2 and
y2 will be interpreted as to keep the preferred size and thus the x1 and x2 will just
absolutely positions the component.
Note that setBoundsInGrid(boolean) changes the interpretation of thisproperty
slightly.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value as a new array, free to modify.
setPos
public void setPos(UnitValue[] pos)

Sets absolute positioning of one or more of the edges. This will be applied last in the
layout cycle and will not affect the flow or grid positions. The positioning is relative to
the parent and can not (as padding) be used to adjust the edges relative to the old
value. May be null and elements may be null. null value(s) for the x2 and y2 will be
interpreted as to keep the preferred size and thus the x1 and x2 will just absolutely
positions the component.
Note that setBoundsInGrid(boolean) changes the interpretation of thisproperty
slightly.

Method Detail

1110

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
pos - UnitValue[] {x, y, x2, y2}. Must be null or of length 4. Elements
can be null.
isBoundsInGrid
public boolean isBoundsInGrid()

Returns if the absolute pos value should be corrections to the component that is in a
normal cell. If false the value of pos is truly absolute in that it will not affect the grid or
have a default bounds in the grid.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
See Also:
getPos()

getCellX
public int getCellX()

Returns the absolute cell position in the grid or -1 if cell positioning is not used.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setCellX
public void setCellX(int x)

Set an absolute cell x-position in the grid. If >= 0 this point points to the absolute cell
that this constaint's component should occupy. If there's already a component in that
cell they will split the cell. The flow will then continue after this cell.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
x - The x-position or -1 to disable cell positioning.
getCellY
public int getCellY()

Returns the absolute cell position in the grid or -1 if cell positioning is not used.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setCellY
public void setCellY(int y)

Set an absolute cell x-position in the grid. If >= 0 this point points to the absolute cell
that this constaint's component should occupy. If there's already a component in that
cell they will split the cell. The flow will then continue after this cell.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.

Method Detail

1111

Overview (Codename One API)


Parameters:
y - The y-position or -1 to disable cell positioning.
getDockSide
public int getDockSide()

Sets the docking side. -1 means no docking.


Valid sides are: north = 0, west = 1, south = 2, east = 3.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current side.
setDockSide
public void setDockSide(int side)

Sets the docking side. -1 means no docking.


Valid sides are: north = 0, west = 1, south = 2, east = 3.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
side

- -1 or 0-3.

isExternal
public boolean isExternal()

Returns if this component should have its bounds handled by an external source and
not this layout manager.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setExternal
public void setExternal(boolean b)

If this boolean is true this component is not handled in any way by the layout
manager and the component can have its bounds set by an external handler which is
normally by the use of some component.setBounds(x, y, width, height) directly
(for Swing).
The bounds will not affect the minimum and preferred size of the container.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true means that the bounds are not changed.
getFlowX
public Boolean getFlowX()

Returns if the flow in the cell is in the horizontal dimension. Vertical if false. Only the
first component is a cell can set the flow.
If null the flow direction is inherited by from the net.miginfocom.layout.LC.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.

Method Detail

1112

Overview (Codename One API)


Returns:
The current value.
setFlowX
public void setFlowX(Boolean b)

Sets if the flow in the cell is in the horizontal dimension. Vertical if false. Only the
first component is a cell can set the flow.
If null the flow direction is inherited by from the net.miginfocom.layout.LC.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - Boolean.TRUE means horizontal flow in the cell.
getHideMode
public int getHideMode()

Sets how a component that is hidden (not visible) should be treated by default. For a
more thorough explanation of what this constraint does see the white paper or cheat
Sheet at www.migcomponents.com.
Returns:
The mode:
0 == Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
setHideMode
public void setHideMode(int mode)

Sets how a component that is hidden (not visible) should be treated by default.
Parameters:
mode - The mode:
0 == Normal. Bounds will be calculated as if the component was visible.
1 == If hidden the size will be 0, 0 but the gaps remain.
2 == If hidden the size will be 0, 0 and gaps set to zero.
3 == If hidden the component will be disregarded completely and not take up
a cell in the grid..
getId
public String getId()

Returns the id used to reference this component in some constraints.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The id or null. May consist of a groupID and an componentID which are
separated by a dot: ".". E.g. "grp1.id1". The dot should never be first or last if
present.
setId
public void setId(String id)

Sets the id used to reference this component in some constraints.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:

Method Detail

1113

Overview (Codename One API)


- The id or null. May consist of a groupID and an componentID which are
separated by a dot: ".". E.g. "grp1.id1". The dot should never be first or last if
present.
getPadding
id

public UnitValue[] getPadding()

Returns the absolute resizing in the last stage of the layout cycle. May be null and
elements may be null.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value. null or of length 4.
setPadding
public void setPadding(UnitValue[] sides)

Sets the absolute resizing in the last stage of the layout cycle. These values are
added to the edges and can thus for instance be used to grow or reduce the size or
move the component an absolute number of pixels. May be null and elements may
be null.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
sides - top, left, bottom right. Must be null or of length 4.
getVisualPadding
public UnitValue[] getVisualPadding()

Returns the visual padding used when laying out this Component. May be null and
elements may be null.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value. null or of length 4.
setVisualPadding
public void setVisualPadding(UnitValue[] sides)

Sets the visual padding used when laying out this Component.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
sides

- top, left, bottom right. Must be null or of length 4.

getSkip
public int getSkip()

Returns how many cells in the grid that should be skipped before the component that
this constraint belongs to.
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value. 0 if no skip.

Method Detail

1114

Overview (Codename One API)


setSkip
public void setSkip(int cells)

Sets how many cells in the grid that should be skipped before the component that
this constraint belongs to.
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- How many cells in the grid that should be skipped before the
component that this constraint belongs to
getSpanX
cells

public int getSpanX()

Returns the number of cells the cell that this constraint's component will span in the
indicated dimension. 1 is default and means that it only spans the current cell.
LayoutUtil.INF is used to indicate a span to the end of the column/row.
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setSpanX
public void setSpanX(int cells)

Sets the number of cells the cell that this constraint's component will span in the
indicated dimension. 1 is default and means that it only spans the current cell.
LayoutUtil.INF is used to indicate a span to the end of the column/row.
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
cells

- The number of cells to span (i.e. merge).

getSpanY
public int getSpanY()

Returns the number of cells the cell that this constraint's component will span in the
indicated dimension. 1 is default and means that it only spans the current cell.
LayoutUtil.INF is used to indicate a span to the end of the column/row.
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setSpanY
public void setSpanY(int cells)

Sets the number of cells the cell that this constraint's component will span in the
indicated dimension. 1 is default and means that it only spans the current cell.

Method Detail

1115

Overview (Codename One API)


LayoutUtil.INF

is used to indicate a span to the end of the column/row.

Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
cells

- The number of cells to span (i.e. merge).

getPushX
public Float getPushX()

"pushx" indicates that the column that this component is in (this first if the component
spans) should default to growing. If any other column has been set to grow this push
value on the component does nothing as the column's explicit grow weight will take
precedence. Push is normally used when the grid has not been defined in the layout.
If multiple components in a column has push weights set the largest one will be used
for the column.
Returns:
The current push value. Default is null.
setPushX
public void setPushX(Float weight)

"pushx" indicates that the column that this component is in (this first if the component
spans) should default to growing. If any other column has been set to grow this push
value on the component does nothing as the column's explicit grow weight will take
precedence. Push is normally used when the grid has not been defined in the layout.
If multiple components in a column has push weights set the largest one will be used
for the column.
Parameters:
weight

- The new push value. Default is null.

getPushY
public Float getPushY()

"pushx" indicates that the row that this component is in (this first if the component
spans) should default to growing. If any other row has been set to grow this push
value on the component does nothing as the row's explicit grow weight will take
precedence. Push is normally used when the grid has not been defined in the layout.
If multiple components in a row has push weights set the largest one will be used for
the row.
Returns:
The current push value. Default is null.
setPushY
public void setPushY(Float weight)

"pushx" indicates that the row that this component is in (this first if the component
spans) should default to growing. If any other row has been set to grow this push
value on the component does nothing as the row's explicit grow weight will take
precedence. Push is normally used when the grid has not been defined in the layout.
If multiple components in a row has push weights set the largest one will be used for
the row.
Parameters:
weight

Method Detail

- The new push value. Default is null.

1116

Overview (Codename One API)


getSplit
public int getSplit()

Returns in how many parts the current cell (that this constraint's component will be in)
should be split in. If for instance it is split in two, the next component will also share
the same cell. Note that the cell can also span a number of cells, which means that
you can for instance span three cells and split that big cell for two components. Split
can be set to a very high value to make all components in the same row/column
share the same cell (e.g. LayoutUtil.INF).
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setSplit
public void setSplit(int parts)

Sets in how many parts the current cell (that this constraint's component will be in)
should be split in. If for instance it is split in two, the next component will also share
the same cell. Note that the cell can also span a number of cells, which means that
you can for instance span three cells and split that big cell for two components. Split
can be set to a very high value to make all components in the same row/column
share the same cell (e.g. LayoutUtil.INF).
Note that only the first component will be checked for this property.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
parts

- The number of parts (i.e. component slots) the cell should be divided

into.
getTag
public String getTag()

Tags the component with metadata. Currently only used to tag buttons with for
instance "cancel" or "ok" to make them show up in the correct order depending on
platform. See PlatformDefaults.setButtonOrder(String) for information.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value. May be null.
setTag
public void setTag(String tag)

Optinal tag that gives more context to this constraint's component. It is for instance
used to tag buttons in a button bar with the button type such as "ok", "help" or
"cancel".
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
tag - The new tag. May be null.

Method Detail

1117

Overview (Codename One API)


isWrap
public boolean isWrap()

Returns if the flow should wrap to the next line/column after the component that this
constraint belongs to.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.
setWrap
public void setWrap(boolean b)

Sets if the flow should wrap to the next line/column after the component that this
constraint belongs to.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true means wrap after.
getWrapGapSize
public BoundSize getWrapGapSize()

Returns the wrap size if it is a custom size. If wrap was set to true with
setWrap(boolean) then this method will return null since that means that the gap
size should be the default one as defined in the rows spec.
Returns:
The custom gap size. NOTE! Will return null for both no wrap and default
wrap.
Since:
2.4.2
See Also:
isWrap(), setWrap(boolean)
setWrapGapSize
public void setWrapGapSize(BoundSize s)

Set the wrap size and turns wrap on if != null.


Parameters:
s - The custom gap size. NOTE! null will not turn on or off wrap, it will only
set the wrap gap size to "default". A non-null value will turn on wrap though.
Since:
2.4.2
See Also:
isWrap(), setWrap(boolean)
isNewline
public boolean isNewline()

Returns if the flow should wrap to the next line/column before the component that
this constraint belongs to.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
The current value.

Method Detail

1118

Overview (Codename One API)


setNewline
public void setNewline(boolean b)

Sets if the flow should wrap to the next line/column before the component that this
constraint belongs to.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
b - true means wrap before.
getNewlineGapSize
public BoundSize getNewlineGapSize()

Returns the newline size if it is a custom size. If newline was set to true with
setNewline(boolean) then this method will return null since that means that the gap
size should be the default one as defined in the rows spec.
Returns:
The custom gap size. NOTE! Will return null for both no newline and default
newline.
Since:
2.4.2
See Also:
isNewline(), setNewline(boolean)
setNewlineGapSize
public void setNewlineGapSize(BoundSize s)

Set the newline size and turns newline on if != null.


Parameters:
s - The custom gap size. NOTE! null will not turn on or off newline, it will only
set the newline gap size to "default". A non-null value will turn on newline
though.
Since:
2.4.2
See Also:
isNewline(), setNewline(boolean)

Method Detail

1119

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class BoundSize
java.lang.Object

com.codename1.ui.layouts.mig.BoundSize

public class
extends Object

A size that contains minimum, preferred and maximum size of type UnitValue.
This class is a simple value container and it is immutable.
If a size is missing (i.e., null) that boundary should be considered "not in use".
You can create a BoundSize from a String with the use of
ConstraintParser.parseBoundSize(String, boolean, boolean)

Field Summary
Modifier and Type Field and Description
static BoundSize

NULL_SIZE

static BoundSize

ZERO_PIXEL

Constructor Summary
Constructor and Description
BoundSize(UnitValue minMaxPref, String createString)

Constructor that use the same value for min/preferred/max size.


BoundSize(UnitValue min, UnitValue preferred, UnitValue max, boolean gapPush,
String createString)

Constructor.
BoundSize(UnitValue min, UnitValue preferred, UnitValue max, String createString)

Constructor.

Method Summary
Modifier and
Type
int

Method and Description


constrain(int size, float refValue, ContainerWrapper parent)
Makes sure that size is within min and max of this size.
getGapPush()

boolean

UnitValue
UnitValue
UnitValue

If the size should be hinted as "pushing" and thus want to occupy free
space if noone else is claiming it.
getMax()

Returns the maximum size as sent into the constructor.


getMin()

Returns the minimum size as sent into the constructor.


getPreferred()

Returns the preferred size as sent into the constructor.


isUnset()

boolean

Class BoundSize

Returns if this bound size has no min, preferred and maximum size set
(they are all null)

1120

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
NULL_SIZE
public static final BoundSize NULL_SIZE

ZERO_PIXEL
public static final BoundSize ZERO_PIXEL

Constructor Detail
BoundSize
public BoundSize(UnitValue minMaxPref,
String createString)

Constructor that use the same value for min/preferred/max size.


Parameters:
minMaxPref - The value to use for min/preferred/max size.
createString - The string used to create the BoundsSize.
BoundSize
public BoundSize(UnitValue min,
UnitValue preferred,
UnitValue max,
String createString)

Constructor. This method is here for serilization only and should normally not
be used. Use ConstraintParser.parseBoundSize(String, boolean, boolean)
instead.
Parameters:
min - The minimum size. May be null.
preferred - The preferred size. May be null.
max - The maximum size. May be null.
createString - The string used to create the BoundsSize.
BoundSize
public BoundSize(UnitValue min,
UnitValue preferred,
UnitValue max,
boolean gapPush,
String createString)

Constructor. This method is here for serilization only and should normally not
be used. Use ConstraintParser.parseBoundSize(String, boolean, boolean)
instead.
Parameters:
min - The minimum size. May be null.
preferred - The preferred size. May be null.
max - The maximum size. May be null.
gapPush - If the size should be hinted as "pushing" and thus want to occupy
free space if no one else is claiming it.
createString - The string used to create the BoundsSize.

Method Detail

Methods inherited from class java.lang.Object

1121

Overview (Codename One API)


getMin
public final UnitValue getMin()

Returns the minimum size as sent into the constructor.


Returns:
The minimum size as sent into the constructor. May be null.
getPreferred
public final UnitValue getPreferred()

Returns the preferred size as sent into the constructor.


Returns:
The preferred size as sent into the constructor. May be null.
getMax
public final UnitValue getMax()

Returns the maximum size as sent into the constructor.


Returns:
The maximum size as sent into the constructor. May be null.
getGapPush
public boolean getGapPush()

If the size should be hinted as "pushing" and thus want to occupy free space if noone
else is claiming it.
Returns:
The value.
isUnset
public boolean isUnset()

Returns if this bound size has no min, preferred and maximum size set (they are all
null)
Returns:
If unset.
constrain
public int constrain(int size,
float refValue,
ContainerWrapper parent)

Makes sure that size is within min and max of this size.
Parameters:
size - The size to constrain.
refValue - The reference to use for relative sizes.
parent - The parent container.
Returns:
The size, constrained within min and max.

Method Detail

1122

Overview (Codename One API)


com.codename1.ui.layouts.mig

Class AC
java.lang.Object

com.codename1.ui.layouts.mig.AC

public final class


extends Object

A constraint that holds the column or row constraints for the grid. It also holds the gaps between the
rows and columns.
This class is a holder and builder for a number of net.miginfocom.layout.DimConstraints.
For a more thorough explanation of what these constraints do, and how to build the constraints, see
the White Paper or Cheat Sheet at www.migcomponents.com.
Note that there are two way to build this constraint. Through String (e.g. "[100]3[200,fill]" or
through API (E.g. new AC().size("100").gap("3").size("200").fill().

Constructor Summary
Constructor and Description
AC()

Constructor.

Method Summary
Modifier and
Type

Method and Description


align(String side)

AC

Specifies the current row/column's columns default alignment for its


components.
align(String side, int... indexes)

AC

AC

Specifies the indicated rows'/columns' columns default alignment for its


components.
count(int size)

Sets the total number of rows/columns to size.


fill()

AC

Specifies that the current row/column's component should grow by


default.
fill(int... indexes)

AC

Specifies that the indicated rows'/columns' component should grow by


default.
gap()

AC

AC
AC
DimConstraint[]
int

Class AC

Specifies the gap size to be the default one AND moves to the next
column/row.
gap(String size)

Specifies the gap size to size AND moves to the next column/row.
gap(String size, int... indexes)

Specifies the indicated rows'/columns' gap size to size.


getConstaints()

Property.
getCount()

Returns the number of rows/columns that this constraints currently have.

1123

Overview (Codename One API)


grow()
AC

Specifies the current row/column's grow weight within columns/rows with


the grow priority 100f.
grow(float w)

AC

Specifies the current row/column's grow weight within columns/rows with


the same grow priority.
grow(float w, int... indexes)

AC

AC
AC
AC
AC
AC

void

Specifies the indicated rows'/columns' grow weight within columns/rows


with the same grow priority.
growPrio(int p)

Specifies the current row/column's grow priority.


growPrio(int p, int... indexes)

Specifies the indicated rows'/columns' grow priority.


index(int i)

Sets the current row/column to i.


noGrid()

Specifies that the current row/column should not be grid-like.


noGrid(int... indexes)

Specifies that the indicated rows/columns should not be grid-like.


setConstaints(DimConstraint[] constr)
Sets the different net.miginfocom.layout.DimConstraints

that this

object should consists of.


shrink()
AC

Specifies that the current row/column's shrink weight withing the


columns/rows with the shrink priority 100f.
shrink(float w)

AC

Specifies that the current row/column's shrink weight withing the


columns/rows with the same shrink priority.
shrink(float w, int... indexes)

AC

AC
AC

Specifies the indicated rows'/columns' shrink weight withing the


columns/rows with the same shrink priority.
shrinkPrio(int p)

Specifies the current row/column's shrink priority.


shrinkPrio(int p, int... indexes)

Specifies the indicated rows'/columns' shrink priority.


shrinkWeight(float w)

AC

Deprecated.
in 3.7.2. Use shrink(float) instead.
shrinkWeight(float w, int... indexes)

AC

AC

Deprecated.
in 3.7.2. Use shrink(float, int...) instead.
size(String s)

Specifies the current row/column's min and/or preferred and/or max size.
size(String size, int... indexes)

AC

Specifies the indicated rows'/columns' min and/or preferred and/or max


size.
sizeGroup()

AC

Specifies that the current row/column should be put in the size group s
and will thus share the same size constraints as the other components in
the group.
sizeGroup(String s)

AC

Specifies that the current row/column should be put in the size group s
and will thus share the same size constraints as the other components in
the group.
sizeGroup(String s, int... indexes)

AC

Method Summary

Specifies that the indicated rows/columns should be put in the size group
s and will thus share the same size constraints as the other components
in the group.

1124

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
AC
public AC()

Constructor. Creates an instance that can be configured manually. Will be initialized


with a default net.miginfocom.layout.DimConstraint.

Method Detail
getConstaints
public final DimConstraint[] getConstaints()

Property. The different net.miginfocom.layout.DimConstraints that this object


consists of. These DimConstraints contains all information in this class.
Yes, we are embarrassingly aware that the method is misspelled.
Returns:
The different net.miginfocom.layout.DimConstraints that this object
consists of. A new list and never null.
setConstaints
public final void setConstaints(DimConstraint[] constr)

Sets the different net.miginfocom.layout.DimConstraints that this object should


consists of.
Yes, we are embarrassingly aware that the method is misspelled.
Parameters:
- The different net.miginfocom.layout.DimConstraints that this
object consists of. The list will be copied for storage. null or and empty array
will reset the constraints to one DimConstraint with default values.
getCount
constr

public int getCount()

Returns the number of rows/columns that this constraints currently have.


Returns:
The number of rows/columns that this constraints currently have. At least 1.
count
public final AC count(int size)

Sets the total number of rows/columns to size. If the number of rows/columns is


already more than size nothing will happen.
Parameters:
size - The total number of rows/columns
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
noGrid
public final AC noGrid()

Methods inherited from class java.lang.Object

1125

Overview (Codename One API)


Specifies that the current row/column should not be grid-like. The while row/colum will
have its components layed out in one single cell. It is the same as to say that the cells
in this column/row will all be merged (a.k.a spanned).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

noGrid
public final AC noGrid(int... indexes)

Specifies that the indicated rows/columns should not be grid-like. The while
row/colum will have its components layed out in one single cell. It is the same as to
say that the cells in this column/row will all be merged (a.k.a spanned).
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
index
indexes

public final AC index(int i)

Sets the current row/column to i. If the current number of rows/columns is less than i
a call to count(int) will set the size accordingly.
The next call to any of the constraint methods (e.g.
net.miginfocom.layout.AC#noGrid) will be carried out on this new row/column.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
i - The new current row/column.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
fill
public final AC fill()

Specifies that the current row/column's component should grow by default. It does not
affect the size of the row/column.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

fill
public final AC fill(int... indexes)

Specifies that the indicated rows'/columns' component should grow by default. It does
not affect the size of the row/column.

Method Detail

1126

Overview (Codename One API)


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
sizeGroup
indexes

public final AC sizeGroup()

Specifies that the current row/column should be put in the size group s and will thus
share the same size constraints as the other components in the group.
Same as sizeGroup("")
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

Since:
3.7.2
sizeGroup
public final AC sizeGroup(String s)

Specifies that the current row/column should be put in the size group s and will thus
share the same size constraints as the other components in the group.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - A name to associate on the group that should be the same for other
rows/columns in the same group.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
sizeGroup
public final AC sizeGroup(String s,
int... indexes)

Specifies that the indicated rows/columns should be put in the size group s and will
thus share the same size constraints as the other components in the group.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - A name to associate on the group that should be the same for other
rows/columns in the same group.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
size
public final AC size(String s)

Method Detail

1127

Overview (Codename One API)


Specifies the current row/column's min and/or preferred and/or max size. E.g. "10px"
or "50:100:200".
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
s - The minimum and/or preferred and/or maximum size of this row. The
string will be interpreted as a BoundSize. For more info on how BoundSize
is formatted see the documentation.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
size
public final AC size(String size,
int... indexes)

Specifies the indicated rows'/columns' min and/or preferred and/or max size. E.g.
"10px" or "50:100:200".
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The minimum and/or preferred and/or maximum size of this row. The
string will be interpreted as a BoundSize. For more info on how BoundSize
is formatted see the documentation.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
gap
size

public final AC gap()

Specifies the gap size to be the default one AND moves to the next column/row. The
method is called .gap() rather the more natural .next() to indicate that it is very
much related to the other .gap(..) methods.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

gap
public final AC gap(String size)

Specifies the gap size to size AND moves to the next column/row.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- minimum and/or preferred and/or maximum size of the gap between
this and the next row/column. The string will be interpreted as a BoundSize.
For more info on how BoundSize is formatted see the documentation.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
size

Method Detail

1128

Overview (Codename One API)


gap
public final AC gap(String size,
int... indexes)

Specifies the indicated rows'/columns' gap size to size.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- minimum and/or preferred and/or maximum size of the gap between
this and the next row/column. The string will be interpreted as a BoundSize.
For more info on how BoundSize is formatted see the documentation.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
align
size

public final AC align(String side)

Specifies the current row/column's columns default alignment for its components. It
does not affect the positioning or size of the columns/row itself. For columns it is the
horizonal alignment (e.g. "left") and for rows it is the vertical alignment (e.g. "top").
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The default side to align the components. E.g. "top" or "left", or
"leading" or "trailing" or "bottom" or "right".
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
align
side

public final AC align(String side,


int... indexes)

Specifies the indicated rows'/columns' columns default alignment for its


components. It does not affect the positioning or size of the columns/row itself. For
columns it is the horizonal alignment (e.g. "left") and for rows it is the vertical
alignment (e.g. "top").
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
- The default side to align the components. E.g. "top" or "left", or
"before" or "after" or "bottom" or "right".
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
growPrio
side

public final AC growPrio(int p)

Specifies the current row/column's grow priority.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:

Method Detail

1129

Overview (Codename One API)


p

- The new grow priority.

Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

growPrio
public final AC growPrio(int p,
int... indexes)

Specifies the indicated rows'/columns' grow priority.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The new grow priority.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
grow
public final AC grow()

Specifies the current row/column's grow weight within columns/rows with the grow
priority 100f.
Same as grow(100f)
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

Since:
3.7.2
grow
public final AC grow(float w)

Specifies the current row/column's grow weight within columns/rows with the same
grow priority.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new grow weight.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
grow
public final AC grow(float w,
int... indexes)

Specifies the indicated rows'/columns' grow weight within columns/rows with the
same grow priority.
For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
w - The new grow weight.

Method Detail

1130

Overview (Codename One API)


- The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
shrinkPrio
indexes

public final AC shrinkPrio(int p)

Specifies the current row/column's shrink priority.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The new shrink priority.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
shrinkPrio
public final AC shrinkPrio(int p,
int... indexes)

Specifies the indicated rows'/columns' shrink priority.


For a more thorough explanation of what this constraint does see the white paper or
cheat Sheet at www.migcomponents.com.
Parameters:
p - The new shrink priority.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
shrink
public final AC shrink()

Specifies that the current row/column's shrink weight withing the columns/rows with
the shrink priority 100f.
Same as shrink(100f).
For a more thorough explanation of what this constraint does see the White Paper or
Cheat Sheet at www.migcomponents.com.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

Since:
3.7.2
shrink
public final AC shrink(float w)

Specifies that the current row/column's shrink weight withing the columns/rows with
the same shrink priority.
For a more thorough explanation of what this constraint does see the White Paper or
Cheat Sheet at www.migcomponents.com.
Parameters:
w - The shrink weight.
Returns:

Method Detail

1131

Overview (Codename One API)


this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

Since:
3.7.2
shrink
public final AC shrink(float w,
int... indexes)

Specifies the indicated rows'/columns' shrink weight withing the columns/rows with
the same shrink priority.
For a more thorough explanation of what this constraint does see the White Paper or
Cheat Sheet at www.migcomponents.com.
Parameters:
w - The shrink weight.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
Since:
3.7.2
shrinkWeight
public final AC shrinkWeight(float w)

Deprecated. in 3.7.2. Use shrink(float) instead.


Specifies that the current row/column's shrink weight withing the columns/rows with
the same shrink priority.
For a more thorough explanation of what this constraint does see the White Paper or
Cheat Sheet at www.migcomponents.com.
Parameters:
w - The shrink weight.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().
shrinkWeight
public final AC shrinkWeight(float w,
int... indexes)

Deprecated. in 3.7.2. Use shrink(float, int...) instead.


Specifies the indicated rows'/columns' shrink weight withing the columns/rows with
the same shrink priority.
For a more thorough explanation of what this constraint does see the White Paper or
Cheat Sheet at www.migcomponents.com.
Parameters:
w - The shrink weight.
indexes - The index(es) (0-based) of the columns/rows that should be
affected by this constraint.
Returns:
this so it is possible to chain calls. E.g. new
AxisConstraint().noGrid().gap().fill().

Method Detail

1132

Overview (Codename One API)


com.codename1.ui.layouts

Class LayoutStyle
java.lang.Object

com.codename1.ui.layouts.LayoutStyle

public class
extends Object

LayoutStyle is used to determine how much space to place between components during layout.
LayoutStyle can be obtained for two components, or for a component relative to an edge of a parent
container. The amount of space can vary depending upon whether or not the components are
logically grouped together (RELATED).
This class is primarily useful for JREs prior to 1.6. In 1.6 API for this was added to Swing. When run
on a JRE of 1.6 or greater this will call into the appropriate methods in Swing.
Version:
$Revision: 1.10 $

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


INDENT

Possible argument to getPreferredGap.


RELATED

Possible argument to getPreferredGap.


UNRELATED

Possible argument to getPreferredGap.

Constructor Summary
Constructor and Description
LayoutStyle()

Method Summary
Modifier and
Type
int

Method and Description


getContainerGap(Component component, int position,
Container parent)

Returns the amount of space to position a component inside its parent.


int

getPreferredGap(Component component1, Component component2,


int type, int position, Container parent)

Returns the amount of space to use between two components.


static
LayoutStyle
static void

Class LayoutStyle

getSharedInstance()

Factory methods for obtaining the current LayoutStyle object appropriate


for the current look and feel.
setSharedInstance(LayoutStyle layout)

Sets the LayoutStyle instance to use for this look and feel.

1133

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RELATED
public static final int RELATED

Possible argument to getPreferredGap. Used to indicate the two components are


grouped together.
See Also:
Constant Field Values
UNRELATED
public static final int UNRELATED

Possible argument to getPreferredGap. Used to indicate the two components are not
grouped together.
See Also:
Constant Field Values
INDENT
public static final int INDENT

Possible argument to getPreferredGap. Used to indicate the distance to indent a


component is being requested. To visually indicate a set of related components they
will often times be horizontally indented, the INDENT constant for this. For example, to
indent a check box relative to a label use this constant to getPreferredGap.
See Also:
Constant Field Values

Constructor Detail
LayoutStyle
public LayoutStyle()

Method Detail
setSharedInstance
public static void setSharedInstance(LayoutStyle layout)

Sets the LayoutStyle instance to use for this look and feel. You generally don't need
to invoke this, instead use the getter which will return the LayoutStyle appropriate for
the current look and feel.
Parameters:
layout - the LayoutStyle to use; a value of null indicates the default should be
used
getSharedInstance
public static LayoutStyle getSharedInstance()

Factory methods for obtaining the current LayoutStyle object appropriate for the
current look and feel.
Returns:
the current LayoutStyle instance

Methods inherited from class java.lang.Object

1134

Overview (Codename One API)


getPreferredGap
public int getPreferredGap(Component component1,
Component component2,
int type,
int position,
Container parent)

Returns the amount of space to use between two components. The return value
indicates the distance to place component2 relative to component1. For example, the
following returns the amount of space to place between component2 and component1
when component2 is placed vertically above component1:
int gap = getPreferredGap(component1, component2,
LayoutStyle.RELATED,
SwingConstants.NORTH, parent);

The type parameter indicates the type of gap being requested. It can be one of the
following values:
If the two components will be contained in the same parent and are
showing similar logically related items, use RELATED.
If the two components will be contained in the same parent but show
UNRELATED
logically unrelated items use UNRELATED.
Used to obtain the preferred distance to indent a component relative to
INDENT
another. For example, if you want to horizontally indent a JCheckBox
relative to a JLabel use INDENT. This is only useful for the horizontal axis.
It's important to note that some look and feels may not distinguish between RELATED
and UNRELATED.
RELATED

The return value is not intended to take into account the current size and position of
component2 or component1. The return value may take into consideration various
properties of the components. For example, the space may vary based on font size,
or the preferred size of the component.
Parameters:
component1 - the JComponent component2 is being placed relative to
component2 - the JComponent being placed
type - how the two components are being placed
position - the position component2 is being placed relative to component1;
one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST
or SwingConstants.WEST
parent - the parent of component2; this may differ from the actual parent and

may be null
Returns:
the amount of space to place between the two components
Throws:
IllegalArgumentException - if position is not one of SwingConstants.NORTH,
SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST; type
not one of INDENT, RELATED or UNRELATED; or component1 or component2 is null
getContainerGap
public int getContainerGap(Component component,
int position,
Container parent)

Returns the amount of space to position a component inside its parent.


Parameters:
component - the Component being positioned
position - the position component is being placed relative to its parent; one of
SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or
SwingConstants.WEST
parent - the parent of component;

this may differ from the actual parent and


may be null
Returns:
the amount of space to place between the component and specified edge

Method Detail

1135

Overview (Codename One API)


Throws:
IllegalArgumentException - if position is not one of SwingConstants.NORTH,
SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST; or
component is null

Method Detail

1136

Overview (Codename One API)


com.codename1.ui.layouts

Class Layout
java.lang.Object

com.codename1.ui.layouts.Layout
Direct Known Subclasses:
BorderLayout, BoxLayout, CoordinateLayout, FlowLayout, GridBagLayout, GridLayout,
GroupLayout, LayeredLayout, MigLayout, TableLayout

public abstract class


extends Object

Abstract class that can be used to arrange components in a container using a predefined algorithm.
This class may be implemented externally and is similar in spirit to the AWT/Swing layout managers.

Constructor Summary
Constructor and Description
Layout()

Method Summary
Modifier and
Type

Method and Description


addLayoutComponent(Object value, Component comp, Container c)

Some layouts can optionally track the addition of elements with meta-data
that allows the user to "hint" on object positioning.

void

boolean

equals(Object o)

Indicates whether some other object is "equal to" this one.


getComponentConstraint(Component comp)

Object

Returns the optional component constraint

abstract
Dimension

getPreferredSize(Container parent)

Returns the container preferred size


hashCode()

int

Returns a hash code value for the object.


isConstraintTracking()

boolean

boolean
abstract void

If this method returns true, the addLayoutComponent method will be called


when replacing a layout for every component within the container
isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


layoutContainer(Container parent)

Layout the given parent container children


obscuresPotential(Container parent)

boolean

Some layout managers can obscure their child components in some cases
this returns true if the basic underpinnings are in place for that.
removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only useful if the
layout maintains references to components within it

void

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Class Layout

1137

Overview (Codename One API)


Constructor

Detail

Layout
public Layout()

Method Detail
layoutContainer
public abstract void layoutContainer(Container parent)

Layout the given parent container children


Parameters:
parent - the given parent container
getPreferredSize
public abstract Dimension getPreferredSize(Container parent)

Returns the container preferred size


Parameters:
parent - the parent container
Returns:
the container preferred size
addLayoutComponent
public void addLayoutComponent(Object value,
Component comp,
Container c)

Some layouts can optionally track the addition of elements with meta-data that allows
the user to "hint" on object positioning.
Parameters:
value - optional meta data information, like alignment orientation
comp - the added component to the layout
c - the parent container
removeLayoutComponent
public void removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only useful if the layout
maintains references to components within it
Parameters:
comp - the removed component from layout
getComponentConstraint
public Object getComponentConstraint(Component comp)

Returns the optional component constraint


Parameters:
comp - the component whose constraint should be returned
Returns:
the optional component constraint
isOverlapSupported
public boolean isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


Returns:
true if Components may intersect in this layout
equals
public boolean equals(Object o)

Constructor Detail

1138

Overview (Codename One API)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
isConstraintTracking
public boolean isConstraintTracking()

If this method returns true, the addLayoutComponent method will be called when
replacing a layout for every component within the container
Returns:
false by default
obscuresPotential
public boolean obscuresPotential(Container parent)

Some layout managers can obscure their child components in some cases this
returns true if the basic underpinnings are in place for that. This method doesn't take
padding/margin etc. into account since that is checked by the caller
Parameters:
parent - parent container
Returns:
true if there is a chance that this layout manager can fully obscure the
background, when in doubt return false...

Method Detail

1139

Overview (Codename One API)


com.codename1.ui.layouts

Class LayeredLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.LayeredLayout

public class
extends Layout

The LayeredLayout places the components in order one on top of the other and sizes them all to the
size of the largest component. This is useful when trying to create an overlay on top of an existing
component. E.g. an "x" button to allow removing the component as shown here

The code to generate this UI is slightly complex and contains very little relevant pieces. The only truly
relevant piece the last line of code:
*
Form hi = new Form("Layered Layout");
int w = Math.min(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight());
Button settingsLabel = new Button("");
Style settingsStyle = settingsLabel.getAllStyles();
settingsStyle.setFgColor(0xff);
settingsStyle.setBorder(null);
settingsStyle.setBgColor(0xff00);
settingsStyle.setBgTransparency(255);
settingsStyle.setFont(settingsLabel.getUnselectedStyle().getFont().derive(w / 3, Font.STYLE_PLAIN));
FontImage.setMaterialIcon(settingsLabel, FontImage.MATERIAL_SETTINGS);
Button close = new Button("");
close.setUIID("Container");
close.getAllStyles().setFgColor(0xff0000);
FontImage.setMaterialIcon(close, FontImage.MATERIAL_CLOSE);
hi.add(LayeredLayout.encloseIn(settingsLabel,
FlowLayout.encloseRight(close)));

We are doing three distinct things here:


.

Class LayeredLayout

1140

Overview (Codename One API)


We are adding a layered layout to the form.
We are creating a layered layout and placing two components within. This would be the
equivalent of just creating a LayeredLaout Container and invoking `add` twice.
.*
We use
https://www.codenameone.com/javadoc/com/codename1/ui/layouts/FlowLayout.html[FlowLayout]
to position the `X` close button in the right position.
A common use case for LayeredLayout is the iOS carousel effect which we can achieve by combing
the LayeredLayout with Tabs.
Form hi = new Form("Swipe Tabs", new LayeredLayout());
Tabs t = new Tabs();
t.hideTabs();

Style s = UIManager.getInstance().getComponentStyle("Button");
FontImage radioEmptyImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, s);
FontImage radioFullImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, s);
((DefaultLookAndFeel)UIManager.getInstance().getLookAndFeel()).setRadioButtonImages(radioFullImage, radioEmptyImage, r
Container container1 = BoxLayout.encloseY(new Label("Swipe the tab to see more"),
new Label("You can put anything here"));
t.addTab("Tab1", container1);
t.addTab("Tab2", new SpanLabel("Some text directly in the tab"));
RadioButton firstTab = new RadioButton("");
RadioButton secondTab = new RadioButton("");
firstTab.setUIID("Container");
secondTab.setUIID("Container");
new ButtonGroup(firstTab, secondTab);
firstTab.setSelected(true);
Container tabsFlow = FlowLayout.encloseCenter(firstTab, secondTab);
hi.add(t);
hi.add(BorderLayout.south(tabsFlow));
t.addSelectionListener((i1, i2) -> {
switch(i2) {
case 0:
if(!firstTab.isSelected()) {
firstTab.setSelected(true);
}
break;
case 1:
if(!secondTab.isSelected()) {
secondTab.setSelected(true);
}
break;
}
});

Class LayeredLayout

1141

Overview (Codename One API)


Notice that the layered layout sizes all components to the exact same size one on top of the other. It
usually requires that we use another container within; in order to position the components correctly.
Forms have a built in layered layout that you can access via `getLayeredPane()`, this allows you to
overlay elements on top of the content pane.
The layered pane is used internally by components such as InteractionDialog,
com.codename1.u./AutoCompleteTextField etc.
Warning: Placing native widgets within a layered layout is problematic due to the behavior of peer
components. Sample of peer components include the BrowserComponent, video playback etc.
See Also:
Form.getLayeredPane(), Form.getLayeredPane(java.lang.Class, boolean),
Form.setGlassPane(com.codename1.ui.Painter)

Constructor Summary
Constructor and Description
LayeredLayout()

Method Summary
Modifier and
Type
static
Container
Dimension
boolean

Method and Description


encloseIn(Component... cmps)

Shorthand for Container.encloseIn(new LayeredLayout(), cmps);


getPreferredSize(Container parent)

Returns the container preferred size


isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


layoutContainer(Container parent)

void

Layout the given parent container children


obscuresPotential(Container parent)

boolean

String

Some layout managers can obscure their child components in some cases
this returns true if the basic underpinnings are in place for that.
toString()

Returns a string representation of the object.

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, equals, getComponentConstraint, hashCode,
isConstraintTracking, removeLayoutComponent

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
LayeredLayout
public LayeredLayout()

Method Detail

Constructor Summary

1142

Overview (Codename One API)


layoutContainer
public void layoutContainer(Container parent)

Layout the given parent container children


Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
isOverlapSupported
public boolean isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


Overrides:
isOverlapSupported in class Layout
Returns:
true if Components may intersect in this layout
obscuresPotential
public boolean obscuresPotential(Container parent)

Some layout managers can obscure their child components in some cases this
returns true if the basic underpinnings are in place for that. This method doesn't take
padding/margin etc. into account since that is checked by the caller
Overrides:
obscuresPotential in class Layout
Parameters:
parent - parent container
Returns:
true if there is a chance that this layout manager can fully obscure the
background, when in doubt return false...
encloseIn
public static Container encloseIn(Component... cmps)

Shorthand for Container.encloseIn(new LayeredLayout(), cmps);


Parameters:
cmps - the components to add to a new layered layout container
Returns:
a newly created layered layout

Method Detail

1143

Overview (Codename One API)


com.codename1.ui.layouts

Class Insets
java.lang.Object

com.codename1.ui.layouts.Insets

public class
extends Object

Port of Insets from Harmony for the use of the GridBag code

Field Summary
Modifier and Type Field and Description
int

bottom

int

left

int

right

int

top

Constructor Summary
Constructor and Description
Insets(int top, int left, int bottom, int right)

Method Summary
Modifier and Type
Object

Method and Description


clone()

boolean

equals(Object o)

Indicates whether some other object is "equal to" this one.


hashCode()

int

Returns a hash code value for the object.

void

set(int top, int left, int bottom, int right)


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
top
public int top

left
public int left

Class Insets

1144

Overview (Codename One API)


bottom
public int bottom

right
public int right

Constructor Detail
Insets
public Insets(int
int
int
int

top,
left,
bottom,
right)

Method Detail
hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
clone
public Object clone()

equals
public boolean equals(Object o)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object

Field Detail

1145

Overview (Codename One API)


toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
set
public void set(int
int
int
int

Method Detail

top,
left,
bottom,
right)

1146

Overview (Codename One API)


com.codename1.ui.layouts

Class GroupLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.GroupLayout

public class
extends Layout

GroupLayout is a LayoutManager that hierarchically groups components to achieve common, and not
so common, layouts. Grouping is done by instances of the Group class. GroupLayout supports two
types of groups:
Sequential: A sequential group positions its child elements sequentially, one after another.
Parallel:
A parallel group positions its child elements in the same space on top of each other.
Parallel groups can also align the child elements along their baseline.
Each Group can contain any number of child groups, Components or gaps. GroupLayout treats each
axis independently. That is, there is a group representing the horizontal axis, and a separate group
representing the vertical axis. The horizontal group is responsible for setting the x and width of its
contents, where as the vertical group is responsible for setting the y and height of its contents.
The following code builds a simple layout consisting of two labels in one column, followed by two
textfields in the next column:
Container panel = ...;
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutocreateGaps(true);
layout.setAutocreateContainerGaps(true);
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
hGroup.add(layout.createParallelGroup().add(label1).add(label2)).
add(layout.createParallelGroup().add(tf1).add(tf2));
layout.setHorizontalGroup(hGroup);
GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
vGroup.add(layout.createParallelGroup(GroupLayout.BASELINE).add(label1).add(tf1)).
add(layout.createParallelGroup(GroupLayout.BASELINE).add(label2).add(tf2));
layout.setVerticalGroup(vGroup);

This layout consists of the following:


The horizontal axis consists of a sequential group containing two parallel groups. The first
parallel group consists of the labels, with the second parallel group consisting of the text
fields.
The vertical axis similarly consists of a sequential group containing two parallel groups. The
parallel groups align their contents along the baseline. The first parallel group consists of the
first label and text field, and the second group consists of the second label and text field.
There are a couple of things to notice in this code:
You need not explicitly add the components to the container, this is indirectly done by using
one of the add methods.
The various add methods of Groups return themselves. This allows for easy chaining of
invocations. For example, group.add(label1).add(label2); is equivalent to
group.add(label1);group.add(label2);.
There are no public constructors for the Groups, instead use the create methods of
GroupLayout.
GroupLayout offer the ability to automatically insert the appropriate gap between components. This
can be turned on using the setAutocreateGaps() method. Similarly you can use the
setAutocreateContainerGaps() method to insert gaps between the components and the container.
Version:
$Revision: 1.25 $

Class GroupLayout

1147

Overview (Codename One API)


Nested

Class Summary

Modifier
and Type

Class and Description


GroupLayout.Group

Group provides for commonality between the two types of operations supported
by GroupLayout: laying out components one after another (SequentialGroup) or
layout on top of each other (ParallelGroup).

class

class

GroupLayout.ParallelGroup
A Group that lays out its elements

on top of each other.

class

GroupLayout.SequentialGroup
A Group that lays out its elements

sequentially, one after another.

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Field and Description


BASELINE

Possible alignment type.


CENTER

Possible alignment type.


DEFAULT_SIZE

Possible value for the add methods that takes a Component.


EAST

Compass-direction east (right).


HORIZONTAL

Possible argument when linking sizes of components.


LEADING

Possible alignment type.


NORTH

Compass-direction North (up).


PREFERRED_SIZE

Possible value for the add methods that takes a Component.


SOUTH

Compass-direction south (down).


TRAILING

Possible alignment type.


VERTICAL

Possible argument when linking sizes of components.


WEST

Compass-direction west (left).

Constructor Summary
Constructor and Description
GroupLayout(Container host)

Creates a GroupLayout for the specified Container.

Method Summary
Modifier and Type
GroupLayout.ParallelGroup

Method and Description


createBaselineGroup(boolean resizable,
boolean anchorBaselineToTop)
Creates and returns a ParallelGroup that aligns

it's

elements along the baseline.

Nested Class Summary

1148

Overview (Codename One API)


GroupLayout.ParallelGroup

createParallelGroup()
Creates and returns a ParallelGroup

with a LEADING

alignment.
GroupLayout.ParallelGroup

createParallelGroup(int alignment)
Creates and returns an ParallelGroup.

GroupLayout.ParallelGroup

createParallelGroup(int alignment, boolean resizable)


Creates and returns an ParallelGroup.

GroupLayout.SequentialGroup

createSequentialGroup()
Creates and returns a SequentialGroup.
getAutocreateContainerGaps()

boolean

Returns whether or not gaps between the container and the


first/last components should automatically be created.
getAutocreateGaps()

boolean

Returns true if gaps between components are automatically


be created.
getHonorsVisibility()

boolean

GroupLayout.Group

Returns whether component visibility is considered when


sizing and positioning components.
getHorizontalGroup()
Returns the Group that is

responsible for layout along the

horizontal axis.
LayoutStyle
Dimension

GroupLayout.Group

getLayoutStyle()

Returns the LayoutStyle instance to use


getPreferredSize(Container parent)

Returns the preferred size for the specified container.


getVerticalGroup()
Returns the ParallelGroup

that is responsible for layout

along the vertical axis.


void
void
void

void

layoutContainer(Container parent)

Lays out the specified container.


linkSize(Component[] components)

Forces the set of components to have the same size.


linkSize(Component[] components, int axis)

Forces the set of components to have the same size.


removeLayoutComponent(Component component)
Notification that a Component has been removed

from the

parent container.
void

replace(Component existingComponent,
Component newComponent)

Removes an existing component replacing it with the


specified component.
setAutocreateContainerGaps(boolean autocreatePadding)

void

Sets whether or not gaps between the container and the


first/last components should automatically be created.
setAutocreateGaps(boolean autocreatePadding)

void

Sets whether or not a gap between components should


automatically be created.
setHonorsVisibility(boolean honorsVisibility)

void

void

void

Sets whether component visibility is considered when sizing


and positioning components.
setHonorsVisibility(Component component,
Boolean honorsVisibility)

Sets whether the component's visibility is considered for


sizing and positioning.
setHorizontalGroup(GroupLayout.Group group)
Sets the Group that is responsible for layout along

the

horizontal axis.
void
void

Method Summary

setLayoutStyle(LayoutStyle layoutStyle)

Sets the LayoutStyle this GroupLayout is to use.


setVerticalGroup(GroupLayout.Group group)

1149

Overview (Codename One API)

Sets the Group that is responsible for layout along the


vertical axis.
toString()

String

Returns a textual description of this GroupLayout.

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, equals, getComponentConstraint, hashCode,
isConstraintTracking, isOverlapSupported, obscuresPotential

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
NORTH
public static final int NORTH

Compass-direction North (up).


See Also:
Constant Field Values
EAST
public static final int EAST

Compass-direction east (right).


See Also:
Constant Field Values
SOUTH
public static final int SOUTH

Compass-direction south (down).


See Also:
Constant Field Values
WEST
public static final int WEST

Compass-direction west (left).


See Also:
Constant Field Values
HORIZONTAL
public static final int HORIZONTAL

Possible argument when linking sizes of components. Specifies the the two
component should share the same size along the horizontal axis.
See Also:
linkSize(Component[], int), Constant Field Values
VERTICAL
public static final int VERTICAL

Possible argument when linking sizes of components. Specifies the the two
component should share the same size along the vertical axis.
See Also:
linkSize(Component[],int), Constant Field Values

Methods inherited from class com.codename1.ui.layouts.Layout

1150

Overview (Codename One API)


LEADING
public static final int LEADING

Possible alignment type. Indicates the elements should be aligned to the origin. For
the horizontal axis with a left to right orientation this means aligned to the left.
See Also:
createParallelGroup(int), Constant Field Values
TRAILING
public static final int TRAILING

Possible alignment type. Indicates the elements should be aligned to the end. For the
horizontal axis with a left to right orientation this means aligned to the right.
See Also:
createParallelGroup(int), Constant Field Values
CENTER
public static final int CENTER

Possible alignment type. Indicates the elements should centered in the spaced
provided.
See Also:
createParallelGroup(int), Constant Field Values
BASELINE
public static final int BASELINE

Possible alignment type. Indicates the elements should aligned along their baseline.
See Also:
createParallelGroup(int), Constant Field Values
DEFAULT_SIZE
public static final int DEFAULT_SIZE

Possible value for the add methods that takes a Component. Indicates the size from
the component should be used.
See Also:
Constant Field Values
PREFERRED_SIZE
public static final int PREFERRED_SIZE

Possible value for the add methods that takes a Component. Indicates the preferred
size should be used.
See Also:
Constant Field Values

Constructor Detail
GroupLayout
public GroupLayout(Container host)

Creates a GroupLayout for the specified Container.


Parameters:
host - the Container to layout
Throws:
IllegalArgumentException - if host is null

Method Detail

Field Detail

1151

Overview (Codename One API)


setHonorsVisibility
public void setHonorsVisibility(boolean honorsVisibility)

Sets whether component visibility is considered when sizing and positioning


components. A value of true indicates that non-visible components should not be
treated as part of the layout. A value of false indicates that components should be
positioned and sized regardless of visibility.
A value of false is useful when the visibility of components is dynamically adjusted
and you don't want surrounding components and the sizing to change.
The specified value is used for components that do not have an explicit visibility
specified.
The default is true.
Parameters:
- whether component visibility is considered when sizing
and positioning components
See Also:
honorsVisibility

setHonorsVisibility(Component,Boolean)

getHonorsVisibility
public boolean getHonorsVisibility()

Returns whether component visibility is considered when sizing and positioning


components.
Returns:
whether component visibility is considered when sizing and positioning
components
setHonorsVisibility
public void setHonorsVisibility(Component component,
Boolean honorsVisibility)

Sets whether the component's visibility is considered for sizing and positioning. A
value of Boolean.TRUE indicates that if component is not visible it should not be treated
as part of the layout. A value of false indicates that component is positioned and
sized regardless of it's visibility. A value of null indicates the value specified by the
single argument method setHonorsVisibility should be used.
If component is not a child of the Container this GroupLayout is managing, it will be
added to the Container.
Parameters:
component - the component
honorsVisibility - whether component's

visibility should be considered for

sizing and positioning


Throws:
IllegalArgumentException

- if component is null

See Also:
setHonorsVisibility(boolean)

toString
public String toString()

Returns a textual description of this GroupLayout. The return value is intended for
debugging purposes only.
Overrides:
toString in class Object
Returns:
textual description of this GroupLayout

Method Detail

1152

Overview (Codename One API)


setAutocreateGaps
public void setAutocreateGaps(boolean autocreatePadding)

Sets whether or not a gap between components should automatically be created. For
example, if this is true and you add two components to a SequentialGroup a gap
between the two will automatically be created. The default is false.
Parameters:
autocreatePadding - whether or not to automatically created a gap between
components and the container
getAutocreateGaps
public boolean getAutocreateGaps()

Returns true if gaps between components are automatically be created.


Returns:
true if gaps between components should automatically be created
setAutocreateContainerGaps
public void setAutocreateContainerGaps(boolean autocreatePadding)

Sets whether or not gaps between the container and the first/last components should
automatically be created. The default is false.
Parameters:
autocreatePadding - whether or not to automatically create gaps between the
container and first/last components.
getAutocreateContainerGaps
public boolean getAutocreateContainerGaps()

Returns whether or not gaps between the container and the first/last components
should automatically be created. The default is false.
Returns:
whether or not the gaps between the container and the first/last components
should automatically be created
setHorizontalGroup
public void setHorizontalGroup(GroupLayout.Group group)

Sets the Group that is responsible for layout along the horizontal axis.
Parameters:
group - Group responsible for layout along the horizontal axis
Throws:
IllegalArgumentException - if group is null
getHorizontalGroup
public GroupLayout.Group getHorizontalGroup()

Returns the Group that is responsible for layout along the horizontal axis.
Returns:
ParallelGroup responsible for layout along the horizontal axis.
setVerticalGroup
public void setVerticalGroup(GroupLayout.Group group)

Sets the Group that is responsible for layout along the vertical axis.
Parameters:
group - Group responsible for layout along the vertical axis.
Throws:
IllegalArgumentException - if group is null.
getVerticalGroup
public GroupLayout.Group getVerticalGroup()

Returns the ParallelGroup that is responsible for layout along the vertical axis.
Returns:
ParallelGroup responsible for layout along the vertical axis.

Method Detail

1153

Overview (Codename One API)


createSequentialGroup
public GroupLayout.SequentialGroup createSequentialGroup()

Creates and returns a SequentialGroup.


Returns:
a new SequentialGroup
createParallelGroup
public GroupLayout.ParallelGroup createParallelGroup()

Creates and returns a ParallelGroup with a LEADING alignment. This is a cover


method for the more general createParallelGroup(int) method.
Returns:
a new ParallelGroup
See Also:
createParallelGroup(int)

createParallelGroup
public GroupLayout.ParallelGroup createParallelGroup(int alignment)

Creates and returns an ParallelGroup. The alignment specifies how children


elements should be positioned when the the parallel group is given more space than
necessary. For example, if a ParallelGroup with an alignment of TRAILING is given
100 pixels and a child only needs 50 pixels, the child will be positioned at the position
50.
Parameters:
alignment - alignment for the elements of the Group, one of LEADING,
TRAILING, CENTER or BASELINE.
Returns:
a new ParallelGroup
Throws:
IllegalArgumentException - if alignment is not one of LEADING, TRAILING,
CENTER or BASELINE
createParallelGroup
public GroupLayout.ParallelGroup createParallelGroup(int alignment,
boolean resizable)

Creates and returns an ParallelGroup. The alignment specifies how children


elements should be positioned when the the parallel group is given more space than
necessary. For example, if a ParallelGroup with an alignment of TRAILING is given
100 pixels and a child only needs 50 pixels, the child will be positioned at the position
50.
Parameters:
alignment - alignment for the elements of the Group, one of LEADING,
TRAILING, CENTER or BASELINE.
resizable - whether or not the group is resizable. If the group is not resizable
the min/max size will be the same as the preferred.
Returns:
a new ParallelGroup
Throws:
IllegalArgumentException - if alignment is not one of LEADING, TRAILING,
CENTER or BASELINE
createBaselineGroup
public GroupLayout.ParallelGroup createBaselineGroup(boolean resizable,
boolean anchorBaselineToTop)

Creates and returns a ParallelGroup that aligns it's elements along the baseline.
Parameters:
resizable - whether the group is resizable
anchorBaselineToTop - whether the baseline is anchored to the top or bottom
of the group
Returns:
parallel group
See Also:

Method Detail

1154

Overview (Codename One API)


createBaselineGroup(boolean, boolean), GroupLayout.ParallelGroup

linkSize
public void linkSize(Component[] components)

Forces the set of components to have the same size. This can be used multiple times
to force any number of components to share the same size.
Linked Components are not be resizable.
Parameters:
components

- Components to force to have same size.

Throws:
IllegalArgumentException

- if components is null, or contains null.

linkSize
public void linkSize(Component[] components,
int axis)

Forces the set of components to have the same size. This can be used multiple times
to force any number of components to share the same size.
Linked Components are not be resizable.
Parameters:
components - Components to force to have same size.
axis - Axis to bind size, one of HORIZONTAL, VERTICAL

or HORIZONTAL |

VERTICAL
Throws:
IllegalArgumentException
IllegalArgumentException

- if components is null, or contains null.


- if axis does not contain HORIZONTAL or VERTICAL

replace
public void replace(Component existingComponent,
Component newComponent)

Removes an existing component replacing it with the specified component.


Parameters:
existingComponent - the Component that should be removed and replaced
with newComponent
newComponent - the Component to put in existingComponents place
Throws:
IllegalArgumentException - is either of the Components are null or if
existingComponent is not being managed by this layout manager
setLayoutStyle
public void setLayoutStyle(LayoutStyle layoutStyle)

Sets the LayoutStyle this GroupLayout is to use. A value of null can be used to
indicate the shared instance of LayoutStyle should be used.
Parameters:
layoutStyle - the LayoutStyle to use
getLayoutStyle
public LayoutStyle getLayoutStyle()

Returns the LayoutStyle instance to use


Returns:
the LayoutStyle instance to use
removeLayoutComponent
public void removeLayoutComponent(Component component)

Notification that a Component has been removed from the parent container. You
should not invoke this method directly, instead invoke removeComponent on the parent
Container.
Overrides:

Method Detail

1155

Overview (Codename One API)


removeLayoutComponent

in class Layout

Parameters:
component

- the component to be removed

See Also:
Container.removeComponent(com.codename1.ui.Component)

getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the preferred size for the specified container.


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the container to return size for
Returns:
the container preferred size
Throws:
IllegalArgumentException - if parent is not the same Container that this
was created with
IllegalStateException - if any of the components added to this layout are
not in both a horizontal and vertical group
See Also:
Component.getPreferredSize()

layoutContainer
public void layoutContainer(Container parent)

Lays out the specified container.


Specified by:
layoutContainer in class Layout
Parameters:
parent - the container to be laid out
Throws:
IllegalStateException - if any of the components added to this layout are
not in both a horizontal and vertical group

Method Detail

1156

Overview (Codename One API)


com.codename1.ui.layouts

Class GroupLayout.SequentialGroup
java.lang.Object

com.codename1.ui.layouts.GroupLayout.Group

com.codename1.ui.layouts.GroupLayout.SequentialGroup
Enclosing class:
GroupLayout

public class
extends GroupLayout.Group

A Group that lays out its elements sequentially, one after another. This class has no public
constructor, use the createSequentialGroup method to create one.
See Also:
GroupLayout.createSequentialGroup()

Method Summary
Modifier and Type

Method and Description

add(boolean useAsBaseline, Component component)


GroupLayout.SequentialGroup
Adds a Component to this Group.
add(boolean useAsBaseline, Component component,
GroupLayout.SequentialGroup int min, int pref, int max)
Adds a Component to this Group with the specified size.
GroupLayout.SequentialGroup
GroupLayout.SequentialGroup

add(boolean useAsBaseline, GroupLayout.Group group)


Adds a Group to this Group.
add(Component component)

Adds the specified Component.

GroupLayout.SequentialGroup

add(Component component, int min, int pref, int max)


Adds the specified Component.

GroupLayout.SequentialGroup

add(GroupLayout.Group group)
Adds the specified Group to this SequentialGroup

GroupLayout.SequentialGroup
GroupLayout.SequentialGroup

add(int pref)

Adds a rigid gap.


add(int min, int pref, int max)

Adds a gap with the specified size.


addContainerGap()

GroupLayout.SequentialGroup

Adds an element representing the preferred gap between


one edge of the container and the next/previous Component.
addContainerGap(int pref, int max)

GroupLayout.SequentialGroup

GroupLayout.SequentialGroup

GroupLayout.SequentialGroup

Adds an element representing the preferred gap between


one edge of the container and the next/previous Component.
addPreferredGap(Component comp1, Component comp2,
int type)

Adds an element representing the preferred gap between


the two components.
addPreferredGap(Component comp1, Component comp2,
int type, boolean canGrow)

Adds an element representing the preferred gap between


the two components.
addPreferredGap(int type)

GroupLayout.SequentialGroup

Adds an element representing the preferred gap between


the nearest components.
addPreferredGap(int type, int pref, int max)

GroupLayout.SequentialGroup

Class GroupLayout.SequentialGroup

Adds an element for the preferred gap between the nearest


components.

1157

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
add
public GroupLayout.SequentialGroup add(GroupLayout.Group group)

Adds the specified Group to this SequentialGroup


Parameters:
group - the Group to add
Returns:
this Group
add
public GroupLayout.SequentialGroup add(boolean useAsBaseline,
GroupLayout.Group group)

Adds a Group to this Group.


Parameters:
group - the Group to add
useAsBaseline - whether the specified Group should be used to calculate the
baseline for this Group
Returns:
this Group
add
public GroupLayout.SequentialGroup add(Component component)

Adds the specified Component. If the Component's min/max are different from its pref
than the component will be resizable.
Parameters:
component - the Component to add
Returns:
this SequentialGroup
add
public GroupLayout.SequentialGroup add(boolean useAsBaseline,
Component component)

Adds a Component to this Group.


Parameters:
useAsBaseline - whether the specified Component should be used to calculate
the baseline for this Group
component - the Component to add
Returns:
this Group
add
public GroupLayout.SequentialGroup add(Component component,
int min,
int pref,
int max)

Adds the specified Component. Min, pref and max can be absolute values, or they can
be one of DEFAULT_SIZE or PREFERRED_SIZE. For example, the following:
add(component, PREFERRED_SIZE, PREFERRED_SIZE, 1000);

Forces a max of 1000, with the min and preferred equalling that of the preferred size
of component.
Parameters:

Methods inherited from class java.lang.Object

1158

Overview (Codename One API)


component - the Component
min - the minimum size
pref - the preferred size
max - the maximum size

to add

Returns:
this SequentialGroup
Throws:
- if min, pref or max are not positive and not one
of PREFERRED_SIZE or DEFAULT_SIZE
IllegalArgumentException

add
public GroupLayout.SequentialGroup add(boolean useAsBaseline,
Component component,
int min,
int pref,
int max)

Adds a Component to this Group with the specified size.


Parameters:
useAsBaseline - whether the specified Component should be used to calculate
the baseline for this Group
component - the Component to add
min - the minimum size or one of DEFAULT_SIZE or PREFERRED_SIZE
pref - the preferred size or one of DEFAULT_SIZE or PREFERRED_SIZE
max - the maximum size or one of DEFAULT_SIZE or PREFERRED_SIZE
Returns:
this Group
add
public GroupLayout.SequentialGroup add(int pref)

Adds a rigid gap.


Parameters:
pref - the size of the gap
Returns:
this SequentialGroup
Throws:
- if min < 0 or pref < 0 or max < 0 or the following
is not meant min <= pref <= max
IllegalArgumentException

add
public GroupLayout.SequentialGroup add(int min,
int pref,
int max)

Adds a gap with the specified size.


Parameters:
min - the minimum size of the gap, or PREFERRED_SIZE
pref - the preferred size of the gap
max - the maximum size of the gap, or PREFERRED_SIZE
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if min < 0 or pref < 0 or max < 0 or the following
is not meant min <= pref <= max
addPreferredGap
public GroupLayout.SequentialGroup addPreferredGap(Component comp1,
Component comp2,
int type)

Adds an element representing the preferred gap between the two components.
Parameters:
comp1 - the first component
comp2 - the second component
type - the type of gap; one of the constants defined by LayoutStyle
Returns:
this SequentialGroup

Method Detail

1159

Overview (Codename One API)


Throws:
IllegalArgumentException

- if type is not a valid LayoutStyle constant

See Also:
LayoutStyle

addPreferredGap
public GroupLayout.SequentialGroup addPreferredGap(Component comp1,
Component comp2,
int type,
boolean canGrow)

Adds an element representing the preferred gap between the two components.
Parameters:
comp1 - the first component
comp2 - the second component
type - the type of gap; one of the constants defined by LayoutStyle
canGrow - true if the gap can grow if more space is available
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if type is not a valid LayoutStyle constant
See Also:
LayoutStyle

addPreferredGap
public GroupLayout.SequentialGroup addPreferredGap(int type)

Adds an element representing the preferred gap between the nearest components.
That is, during layout the neighboring components are found, and the min, pref and
max of this element is set based on the preferred gap between the components. If no
neighboring components are found the min, pref and max are set to 0.
Parameters:
type - the type of gap; one of the LayoutStyle constants
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if type is not one of LayoutStyle.RELATED or
LayoutStyle.UNRELATED

See Also:
LayoutStyle

addPreferredGap
public GroupLayout.SequentialGroup addPreferredGap(int type,
int pref,
int max)

Adds an element for the preferred gap between the nearest components. That is,
during layout the neighboring components are found, and the min of this element is
set based on the preferred gap between the components. If no neighboring
components are found the min is set to 0. This method allows you to specify the
preferred and maximum size by way of the pref and max arguments. These can either
be a value >= 0, in which case the preferred or max is the max of the argument and
the preferred gap, of DEFAULT_VALUE in which case the value is the same as the
preferred gap.
Parameters:
type - the type of gap; one of LayoutStyle.RELATED or
LayoutStyle.UNRELATED
pref - the preferred size; one of DEFAULT_SIZE or a value > 0
max - the maximum size; one of DEFAULT_SIZE, PREFERRED_SIZE or a
value > 0
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if type is not one of LayoutStyle.RELATED or
LayoutStyle.UNRELATED or pref/max is != DEFAULT_SIZE and < 0, or pref >
max
See Also:
LayoutStyle

Method Detail

1160

Overview (Codename One API)


addContainerGap
public GroupLayout.SequentialGroup addContainerGap()

Adds an element representing the preferred gap between one edge of the container
and the next/previous Component. This will have no effect if the next/previous
element is not a Component and does not touch one edge of the parent container.
Returns:
this SequentialGroup.
addContainerGap
public GroupLayout.SequentialGroup addContainerGap(int pref,
int max)

Adds an element representing the preferred gap between one edge of the container
and the next/previous Component. This will have no effect if the next/previous
element is not a Component and does not touch one edge of the parent container.
Parameters:
pref - the preferred size; one of DEFAULT_SIZE or a value > 0
max - the maximum size; one of DEFAULT_SIZE, PREFERRED_SIZE or a
value > 0.
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if pref/max is != DEFAULT_SIZE and < 0, or
pref > max

Method Detail

1161

Overview (Codename One API)


com.codename1.ui.layouts

Class GroupLayout.ParallelGroup
java.lang.Object

com.codename1.ui.layouts.GroupLayout.Group

com.codename1.ui.layouts.GroupLayout.ParallelGroup
Enclosing class:
GroupLayout

public class
extends GroupLayout.Group

A Group that lays out its elements on top of each other. If a child element is smaller than the provided
space it is aligned based on the alignment of the child (if specified) or on the alignment of the
ParallelGroup.
See Also:
GroupLayout.createParallelGroup()

Method Summary
Modifier and Type
GroupLayout.ParallelGroup

Method and Description


add(Component component)

Adds the specified Component.

GroupLayout.ParallelGroup

add(Component component, int min, int pref, int max)


Adds the specified Component.

GroupLayout.ParallelGroup

add(GroupLayout.Group group)
Adds the specified Group.

GroupLayout.ParallelGroup
GroupLayout.ParallelGroup

add(int pref)

Adds a rigid gap.


add(int alignment, Component component)

Adds the specified Component.

add(int alignment, Component component, int min,


GroupLayout.ParallelGroup int pref, int max)
Adds the specified Component.
GroupLayout.ParallelGroup
GroupLayout.ParallelGroup

add(int alignment, GroupLayout.Group group)


Adds the specified Group as a child of this group.
add(int min, int pref, int max)

Adds a gap with the specified size.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
add
public GroupLayout.ParallelGroup add(GroupLayout.Group group)

Adds the specified Group.


Parameters:
group - the Group to add
Returns:
this Group

Class GroupLayout.ParallelGroup

1162

Overview (Codename One API)


add
public GroupLayout.ParallelGroup add(Component component)

Adds the specified Component. If the Component's min/max are different from its pref
than the component will be resizable.
Parameters:
component - the Component to add
Returns:
this ParallelGroup
add
public GroupLayout.ParallelGroup add(Component component,
int min,
int pref,
int max)

Adds the specified Component. Min, pref and max can be absolute values, or they can
be one of DEFAULT_SIZE or PREFERRED_SIZE. For example, the following:
add(component, PREFERRED_SIZE, PREFERRED_SIZE, 1000);

Forces a max of 1000, with the min and preferred equalling that of the preferred size
of component.
Parameters:
component - the Component to add
min - the minimum size
pref - the preferred size
max - the maximum size
Returns:
this SequentialGroup
Throws:
IllegalArgumentException - if min, pref or max are not positive and not one
of PREFERRED_SIZE or DEFAULT_SIZE.
add
public GroupLayout.ParallelGroup add(int pref)

Adds a rigid gap.


Parameters:
pref - the size of the gap
Returns:
this ParallelGroup
Throws:
- if min < 0 or pref < 0 or max < 0 or the following
is not meant min <= pref <= max.
IllegalArgumentException

add
public GroupLayout.ParallelGroup add(int min,
int pref,
int max)

Adds a gap with the specified size.


Parameters:
min - the minimum size of the gap
pref - the preferred size of the gap
max - the maximum size of the gap
Returns:
this ParallelGroup
Throws:
IllegalArgumentException - if min < 0 or pref < 0 or max < 0 or the following
is not meant min <= pref <= max.

Method Detail

1163

Overview (Codename One API)


add
public GroupLayout.ParallelGroup add(int alignment,
GroupLayout.Group group)

Adds the specified Group as a child of this group.


Parameters:
alignment - the alignment of the Group.
group - the Group to add
Returns:
this ParallelGroup
Throws:
IllegalArgumentException - if alignment is not one of LEADING, TRAILING or
CENTER

add
public GroupLayout.ParallelGroup add(int alignment,
Component component)

Adds the specified Component. If the Component's min/max are different from its pref
than the component will be resizable.
Parameters:
alignment - the alignment for the component
component - the Component to add
Returns:
this Group
Throws:
IllegalArgumentException - if alignment is not one of LEADING, TRAILING or
CENTER

add
public GroupLayout.ParallelGroup add(int alignment,
Component component,
int min,
int pref,
int max)

Adds the specified Component. Min, pref and max can be absolute values, or they can
be one of DEFAULT_SIZE or PREFERRED_SIZE. For example, the following:
add(component, PREFERRED_SIZE, PREFERRED_SIZE, 1000);

Forces a max of 1000, with the min and preferred equalling that of the preferred size
of component.
Parameters:
alignment - the alignment for the component.
component - the Component to add
min - the minimum size
pref - the preferred size
max - the maximum size
Returns:
this Group
Throws:
IllegalArgumentException - if min, pref or max are not positive and not one
of PREFERRED_SIZE or DEFAULT_SIZE.

Method Detail

1164

Overview (Codename One API)


com.codename1.ui.layouts

Class GroupLayout.Group
java.lang.Object

com.codename1.ui.layouts.GroupLayout.Group
Direct Known Subclasses:
GroupLayout.ParallelGroup, GroupLayout.SequentialGroup
Enclosing class:
GroupLayout

public abstract class


extends Object

Group provides for commonality between the two types of operations supported by GroupLayout:
laying out components one after another (SequentialGroup) or layout on top of each other
(ParallelGroup). Use one of createSequentialGroup or createParallelGroup to create one.

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class GroupLayout.Group

1165

Overview (Codename One API)


com.codename1.ui.layouts

Class GridLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.GridLayout

public class
extends Layout

The components are arranged in a grid based on available space, all cells in the grid are given
exactly the same size which matches the largest preferred size or available space. The main use
case for this layout is a grid of icons e.g. like one would see in the iPhone home screen.
If the number of rows * columns is smaller than the number of components added a new row is
implicitly added to the grid. However, if the number of components is smaller than available cells
(won't fill the last row) blank spaces will be left in place.
In this example we can see that a 2x2 grid is used to add 5 elements, this results in an additional row
that's implicitly added turning the grid to a 3x2 grid implicitly and leaving one blank cell.
Form hi = new Form("Grid Layout 2x2", new GridLayout(2, 2));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));

When we use a 2x4 size ratio we would see elements getting cropped as we do here. The grid layout
uses the grid size first and doesn't pay too much attention to the preferred size of the components it
holds.

Methods inherited from class java.lang.Object

1166

Overview (Codename One API)

Grid also has an autoFit attribute that can be used to automatically calculate the column count based
on available space and preferred width. This is really useful for working with UI's where the device
orientation might change.
There is also a terse syntax for working with a grid that has two versions, one that uses the "auto fit"
option and another that accepts the column names. Heres a sample of the terse syntax coupled with
the auto fit screenshots of the same code in two orientations:
GridLayout.encloseIn(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));

Class GridLayout

1167

Overview (Codename One API)

Constructor Summary
Constructor and Description
GridLayout(int columns)

Creates a new instance of GridLayout with the given columns, rows is set to 1 but will
implicitly grow if more components are added
GridLayout(int rows, int columns)

Creates a new instance of GridLayout with the given rows and columns

Method Summary
Modifier and
Type
static
GridLayout
static
Container
static
Container
boolean
int
Dimension
int
boolean

Method and Description


autoFit()

Returns a grid layout that implicitly auto-fits to width in term of number of


columns
encloseIn(Component... cmp)

Creates a new container with an auto fit grid layout and the components
added to it
encloseIn(int columns, Component... cmp)

Creates a new container with the grid layout and the components added to it
equals(Object o)

Indicates whether some other object is "equal to" this one.


getColumns()
getPreferredSize(Container parent)

Returns the container preferred size


getRows()
isAutoFit()

Auto fits columns/rows to available screen space


isFillLastRow()

boolean

void

When set to true makes the grid layout fill the last row of the layout entirely if
the number of elements in that row is bigger.
layoutContainer(Container parent)

Layout the given parent container children


obscuresPotential(Container parent)

boolean

void

Constructor Summary

Some layout managers can obscure their child components in some cases
this returns true if the basic underpinnings are in place for that.
setAutoFit(boolean autoFit)

Auto fits columns/rows to available screen space

1168

Overview (Codename One API)


setFillLastRow(boolean fillLastRow)

When set to true makes the grid layout fill the last row of the layout entirely if
the number of elements in that row is bigger.

void

toString()

String

Returns a string representation of the object.

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, getComponentConstraint, hashCode, isConstraintTracking,
isOverlapSupported, removeLayoutComponent

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
GridLayout
public GridLayout(int rows,
int columns)

Creates a new instance of GridLayout with the given rows and columns
Parameters:
rows - - number of rows.
columns - - number of columns.
Throws:
IllegalArgumentException - if rows < 1 or columns < 1
GridLayout
public GridLayout(int columns)

Creates a new instance of GridLayout with the given columns, rows is set to 1 but will
implicitly grow if more components are added
Parameters:
columns - - number of columns.
Throws:
IllegalArgumentException - if rows < 1 or columns < 1

Method Detail
autoFit
public static GridLayout autoFit()

Returns a grid layout that implicitly auto-fits to width in term of number of columns
Returns:
a grid layout that automatically adapts its size
encloseIn
public static Container encloseIn(Component... cmp)

Creates a new container with an auto fit grid layout and the components added to it
Parameters:
cmp - the components
Returns:
a new container
encloseIn
public static Container encloseIn(int columns,
Component... cmp)

Creates a new container with the grid layout and the components added to it

Method Summary

1169

Overview (Codename One API)


Parameters:
columns - the number of
cmp - the components

columns for the grid

Returns:
a new container
layoutContainer
public void layoutContainer(Container parent)

Layout the given parent container children


Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
getRows
public int getRows()

Returns:
the rows
getColumns
public int getColumns()

Returns:
the columns
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).

Method Detail

1170

Overview (Codename One API)


Overrides:
equals

in class Layout

isFillLastRow
public boolean isFillLastRow()

When set to true makes the grid layout fill the last row of the layout entirely if the
number of elements in that row is bigger.
Returns:
the fillLastRow
setFillLastRow
public void setFillLastRow(boolean fillLastRow)

When set to true makes the grid layout fill the last row of the layout entirely if the
number of elements in that row is bigger.
Parameters:
fillLastRow - the fillLastRow to set
isAutoFit
public boolean isAutoFit()

Auto fits columns/rows to available screen space


Returns:
the autoFit
setAutoFit
public void setAutoFit(boolean autoFit)

Auto fits columns/rows to available screen space


Parameters:
autoFit - the autoFit to set
obscuresPotential
public boolean obscuresPotential(Container parent)

Some layout managers can obscure their child components in some cases this
returns true if the basic underpinnings are in place for that. This method doesn't take
padding/margin etc. into account since that is checked by the caller
Overrides:
obscuresPotential in class Layout
Parameters:
parent - parent container
Returns:
true if there is a chance that this layout manager can fully obscure the
background, when in doubt return false...

Method Detail

1171

Overview (Codename One API)


com.codename1.ui.layouts

Class GridBagLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.GridBagLayout

public class
extends Layout

Codename One port of the infamous GridBagLayout based on the Apache Harmony code. For new
applications we generally recommend a "native" Codename One layout such as TableLayout and
recommend avoiding this layout. Its here for developers who are accustomed to it and need to port
existing code.
Button button;
hi.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
//natural height, maximum width
c.fill = GridBagConstraints.HORIZONTAL;

button = new Button("Button 1");


c.weightx = 0.5;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
hi.addComponent(c, button);
button = new Button("Button 2");
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.5;
c.gridx = 1;
c.gridy = 0;
hi.addComponent(c, button);
button = new Button("Button 3");
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.5;
c.gridx = 2;
c.gridy = 0;
hi.addComponent(c, button);
button = new Button("Long-Named Button 4");
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 40;
//make this component tall
c.weightx = 0.0;
c.gridwidth = 3;
c.gridx = 0;
c.gridy = 1;
hi.addComponent(c, button);
button = new Button("5");
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady = 0;
//reset to default
c.weighty = 1.0;
//request any extra vertical space
c.anchor = GridBagConstraints.PAGE_END; //bottom of space
c.insets = new Insets(10,0,0,0); //top padding
c.gridx = 1;
//aligned with button 2
c.gridwidth = 2;
//2 columns wide
c.gridy = 2;
//third row
hi.addComponent(c, button);

Class GridBagLayout

1172

Overview (Codename One API)

Field Summary
Field and
Description

Modifier and Type


double[]

columnWeights

int[]

columnWidths

protected Hashtable<Component,GridBagConstraints>

comptable

protected GridBagConstraints

defaultConstraints

protected com.codename1.ui.layouts.GridBagLayoutInfo

layoutInfo

protected static int

MAXGRIDSIZE

protected static int

MINSIZE

protected static int

PREFERREDSIZE

int[]

rowHeights

double[]

rowWeights

Constructor Summary
Constructor and Description
GridBagLayout()

Method Summary
Modifier and Type
void

Some layouts can optionally track the addition of elements with


meta-data that allows the user to "hint" on object positioning.

protected void

adjustForGravity(GridBagConstraints constraints,
Rectangle r)

protected void

AdjustForGravity(GridBagConstraints constraints,
Rectangle r)

protected void

arrangeGrid(Container parent)

protected void

ArrangeGrid(Container parent)

Object

Field Summary

Method and Description


addLayoutComponent(Object constraints, Component comp,
Container c)

getComponentConstraint(Component comp)

Returns the optional component constraint

1173

Overview (Codename One API)


int[][]

getLayoutDimensions()

double[][]

getLayoutWeights()

Dimension
void

getPreferredSize(Container parent)

Returns the container preferred size


invalidateLayout(Container target)
layoutContainer(Container parent)

void

Layout the given parent container children

protected
GridBagConstraints

lookupConstraints(Component comp)
removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only


useful if the layout maintains references to components within it

void

setConstraints(Component comp,
GridBagConstraints constraints)

void

Methods inherited from class com.codename1.ui.layouts.Layout


equals, hashCode, isConstraintTracking, isOverlapSupported,
obscuresPotential

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
MAXGRIDSIZE
protected static final int MAXGRIDSIZE

See Also:
Constant Field Values
MINSIZE
protected static final int MINSIZE

See Also:
Constant Field Values
PREFERREDSIZE
protected static final int PREFERREDSIZE

See Also:
Constant Field Values
comptable
protected volatile Hashtable<Component,GridBagConstraints> comptable

defaultConstraints
protected volatile GridBagConstraints defaultConstraints

layoutInfo
protected volatile com.codename1.ui.layouts.GridBagLayoutInfo layoutInfo

columnWeights
public volatile double[] columnWeights

rowWeights
public volatile double[] rowWeights

Method Summary

1174

Overview (Codename One API)


columnWidths
public volatile int[] columnWidths

rowHeights
public volatile int[] rowHeights

Constructor Detail
GridBagLayout
public GridBagLayout()

Method Detail
addLayoutComponent
public void addLayoutComponent(Object constraints,
Component comp,
Container c)

Description copied from class: Layout


Some layouts can optionally track the addition of elements with meta-data that allows
the user to "hint" on object positioning.
Overrides:
addLayoutComponent in class Layout
Parameters:
constraints - optional meta data information, like alignment orientation
comp - the added component to the layout
c - the parent container
removeLayoutComponent
public void removeLayoutComponent(Component comp)

Description copied from class: Layout


Removes the component from the layout this operation is only useful if the layout
maintains references to components within it
Overrides:
removeLayoutComponent in class Layout
Parameters:
comp - the removed component from layout
getComponentConstraint
public Object getComponentConstraint(Component comp)

Description copied from class: Layout


Returns the optional component constraint
Overrides:
getComponentConstraint in class Layout
Parameters:
comp - the component whose constraint should be returned
Returns:
the optional component constraint
setConstraints
public void setConstraints(Component comp,
GridBagConstraints constraints)

invalidateLayout
public void invalidateLayout(Container target)

getPreferredSize
public Dimension getPreferredSize(Container parent)

Description copied from class: Layout

Field Detail

1175

Overview (Codename One API)


Returns the container preferred size
Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
layoutContainer
public void layoutContainer(Container parent)

Description copied from class: Layout


Layout the given parent container children
Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
getLayoutDimensions
public int[][] getLayoutDimensions()

getLayoutWeights
public double[][] getLayoutWeights()

ArrangeGrid
protected void ArrangeGrid(Container parent)

lookupConstraints
protected GridBagConstraints lookupConstraints(Component comp)

adjustForGravity
protected void adjustForGravity(GridBagConstraints constraints,
Rectangle r)

arrangeGrid
protected void arrangeGrid(Container parent)

AdjustForGravity
protected void AdjustForGravity(GridBagConstraints constraints,
Rectangle r)

Method Detail

1176

Overview (Codename One API)


com.codename1.ui.layouts

Class GridBagConstraints
java.lang.Object

com.codename1.ui.layouts.GridBagConstraints

public class
extends Object

Port of the GridBag code from Apache's Harmony

Field Summary
Modifier and Type Field and Description
int

anchor

static int

BOTH

static int

CENTER

static int

EAST

int

fill

static int

FIRST_LINE_END

static int

FIRST_LINE_START

int

gridheight

int

gridwidth

int

gridx

int

gridy

static int

HORIZONTAL

Insets

insets

int

ipadx

int

ipady

static int

LAST_LINE_END

static int

LAST_LINE_START

static int

LINE_END

static int

LINE_START

static int

NONE

static int

NORTH

static int

NORTHEAST

static int

NORTHWEST

static int

PAGE_END

static int

PAGE_START

static int

RELATIVE

static int

REMAINDER

static int

SOUTH

static int

SOUTHEAST

static int

SOUTHWEST

static int

VERTICAL

double

weightx

Class GridBagConstraints

1177

Overview (Codename One API)


double

weighty

static int

WEST

Constructor Summary
Constructor and Description
GridBagConstraints()
GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight,
double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx,
int ipady)

Method Summary
Modifier and Type Method and Description
Object

clone()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RELATIVE
public static final int RELATIVE

See Also:
Constant Field Values
REMAINDER
public static final int REMAINDER

See Also:
Constant Field Values
NONE
public static final int NONE

See Also:
Constant Field Values
BOTH
public static final int BOTH

See Also:
Constant Field Values
HORIZONTAL
public static final int HORIZONTAL

See Also:
Constant Field Values
VERTICAL
public static final int VERTICAL

See Also:
Constant Field Values

Field Summary

1178

Overview (Codename One API)


CENTER
public static final int CENTER

See Also:
Constant Field Values
NORTH
public static final int NORTH

See Also:
Constant Field Values
NORTHEAST
public static final int NORTHEAST

See Also:
Constant Field Values
EAST
public static final int EAST

See Also:
Constant Field Values
SOUTHEAST
public static final int SOUTHEAST

See Also:
Constant Field Values
SOUTH
public static final int SOUTH

See Also:
Constant Field Values
SOUTHWEST
public static final int SOUTHWEST

See Also:
Constant Field Values
WEST
public static final int WEST

See Also:
Constant Field Values
NORTHWEST
public static final int NORTHWEST

See Also:
Constant Field Values
PAGE_START
public static final int PAGE_START

See Also:
Constant Field Values
PAGE_END
public static final int PAGE_END

See Also:
Constant Field Values

Field Detail

1179

Overview (Codename One API)


LINE_START
public static final int LINE_START

See Also:
Constant Field Values
LINE_END
public static final int LINE_END

See Also:
Constant Field Values
FIRST_LINE_START
public static final int FIRST_LINE_START

See Also:
Constant Field Values
FIRST_LINE_END
public static final int FIRST_LINE_END

See Also:
Constant Field Values
LAST_LINE_START
public static final int LAST_LINE_START

See Also:
Constant Field Values
LAST_LINE_END
public static final int LAST_LINE_END

See Also:
Constant Field Values
gridx
public int gridx

gridy
public int gridy

gridwidth
public int gridwidth

gridheight
public int gridheight

weightx
public double weightx

weighty
public double weighty

anchor
public int anchor

fill
public int fill

insets
public Insets insets

ipadx
public int ipadx

Field Detail

1180

Overview (Codename One API)


ipady
public int ipady

Constructor Detail
GridBagConstraints
public GridBagConstraints(int gridx,
int gridy,
int gridwidth,
int gridheight,
double weightx,
double weighty,
int anchor,
int fill,
Insets insets,
int ipadx,
int ipady)

GridBagConstraints
public GridBagConstraints()

Method Detail
clone
public Object clone()

Field Detail

1181

Overview (Codename One API)


com.codename1.ui.layouts

Class FlowLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.FlowLayout

public class
extends Layout

FlowLayout is the default layout manager for Codename One Containers and Forms. It places
components in a row one after another based on their preferred size. When it reaches the edge of the
container it will break a line and start a new row.
Form hi = new Form("Flow Layout", new FlowLayout());
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));
hi.show();

Since flow layout isn't a constraint based layout it has a bunch of very useful enclose methods that
can significantly reduce the code required to create the same UI e.g.:
Container flowLayout = FlowLayout.encloseIn(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth"));

This class works nicely for simple elements, however since Codename One doesn't reflow recursively
(for performance) it can't accurately handle complex layouts. As a result when an element of varying
size is placed in a flow layout this confuses the line breaking logic and fails in odd ways. That is why
this layout should only be used for relatively simple use cases.
Flow layout supports aligning the component horizontally and vertically, it defaults to the top left
alignment for LTR languages. E.g. the following alignments are supported thru the usage of setAlign
& setValign.

Method Detail

1182

Overview (Codename One API)


E.g. you can align to the center

You can align to the right

You can align to the center and the middle horizontally

Class FlowLayout

1183

Overview (Codename One API)

There are quite a few additional combinations that are possible with these API's.
See Also:
see the box layout X which is often a better choice than flow layout.

Constructor Summary
Constructor and Description
FlowLayout()

Creates a new instance of FlowLayout with left alignment


FlowLayout(int orientation)

Creates a new instance of FlowLayout with the given orientation one of LEFT, RIGHT or
CENTER
FlowLayout(int orientation, int valign)

Creates a new instance of FlowLayout with the given orientation one of LEFT, RIGHT or
CENTER and the vertical orientation

Method Summary
Modifier
and Type
static
Container
static
Container
static
Container
static
Container

Constructor Summary

Method and Description


encloseBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.LEFT,


Component.BOTTOM), cmps);
encloseCenter(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER),


cmps);
encloseCenterBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER,


Component.BOTTOM), cmps);
encloseCenterMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER,


Component.CENTER), cmps);

1184

Overview (Codename One API)


static
Container
static
Container
static
Container
static
Container
static
Container
boolean
protected
void

encloseIn(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(), cmps); see:


encloseMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.LEFT,


Component.CENTER), cmps);
encloseRight(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT),


cmps);
encloseRightBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT,


Component.BOTTOM), cmps);
encloseRightMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT,


Component.CENTER), cmps);
equals(Object o)

Indicates whether some other object is "equal to" this one.


fillRow(Container target, int width, int start, int end)

This method tries to fill up the available space in a row.


getAlign()

int

Alignment of the flow layout, defaults to LEFT

Dimension

getPreferredSize(Container parent)

Returns the container preferred size


getValign()

int

Indicates vertical alignment within the flow layout


isFillRows()

boolean

boolean

Indicates whether the layout manager should try to fill up the available space
in the row
isValignByRow()

Returns whether vertical alignment is done internally or externally


layoutContainer(Container parent)

void

Layout the given parent container children


setAlign(int orientation)

void

Alignment of the flow layout, defaults to LEFT


setFillRows(boolean fillRows)

Indicates whether the layout manager should try to fill up the available space
in the row

void

setValign(int valign)

void

Indicates vertical alignment within the flow layout


setValignByRow(boolean internal)

When set to true vertical alignment will be performed by row (components


within the container will be aligned vertically to each other in the same row)
When set to false (which is default) vertical alignment relates to the alignment
of this container in regards to external components

void

String

toString()

Returns a string representation of the object.

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, getComponentConstraint, hashCode, isConstraintTracking,
isOverlapSupported, obscuresPotential, removeLayoutComponent

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Method Summary

1185

Overview (Codename One API)


FlowLayout
public FlowLayout()

Creates a new instance of FlowLayout with left alignment


FlowLayout
public FlowLayout(int orientation)

Creates a new instance of FlowLayout with the given orientation one of LEFT, RIGHT
or CENTER
Parameters:
orientation - the orientation value
FlowLayout
public FlowLayout(int orientation,
int valign)

Creates a new instance of FlowLayout with the given orientation one of LEFT, RIGHT
or CENTER and the vertical orientation
Parameters:
orientation - the orientation value
valign - the vertical orientation one of Component.TOP/BOTTOM/CENTER

Method Detail
layoutContainer
public void layoutContainer(Container parent)

Layout the given parent container children


Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
fillRow
protected void fillRow(Container target,
int width,
int start,
int end)

This method tries to fill up the available space in a row. This method is called if
isFillRows() returns true.
Parameters:
target - the parent container
width - the width of the row to fill
start - the index of the first component in this row
end - the index of the last component in this row
getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but

Constructor Detail

1186

Overview (Codename One API)


informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
isFillRows
public boolean isFillRows()

Indicates whether the layout manager should try to fill up the available space in the
row
Returns:
the fillRows
setFillRows
public void setFillRows(boolean fillRows)

Indicates whether the layout manager should try to fill up the available space in the
row
Parameters:
fillRows - the fillRows to set
getValign
public int getValign()

Indicates vertical alignment within the flow layout


Returns:
Component.TOP/BOTTOM/CENTER
setValign
public void setValign(int valign)

Indicates vertical alignment within the flow layout


Parameters:
valign - one of Component.TOP/BOTTOM/CENTER
setValignByRow
public void setValignByRow(boolean internal)

When set to true vertical alignment will be performed by row (components within the
container will be aligned vertically to each other in the same row) When set to false
(which is default) vertical alignment relates to the alignment of this container in
regards to external components
Parameters:
internal - true for internal, false otherwise
isValignByRow
public boolean isValignByRow()

Returns whether vertical alignment is done internally or externally


Returns:
whether vertical alignment is done internally or externally
getAlign
public int getAlign()

Alignment of the flow layout, defaults to LEFT


Returns:
the orientation
setAlign
public void setAlign(int orientation)

Alignment of the flow layout, defaults to LEFT

Method Detail

1187

Overview (Codename One API)


Parameters:
orientation

- the orientation to set

equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Layout
encloseIn
public static Container encloseIn(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(), cmps); see:


Container flowLayout = FlowLayout.encloseIn(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth"));

Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseCenter
public static Container encloseCenter(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER), cmps);


Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseRight
public static Container encloseRight(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT), cmps);


Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseMiddle
public static Container encloseMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.LEFT,


Component.CENTER), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container

Method Detail

1188

Overview (Codename One API)


encloseCenterMiddle
public static Container encloseCenterMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER,


Component.CENTER), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseRightMiddle
public static Container encloseRightMiddle(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT,


Component.CENTER), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseBottom
public static Container encloseBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.LEFT,


Component.BOTTOM), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseCenterBottom
public static Container encloseCenterBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.CENTER,


Component.BOTTOM), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container
encloseRightBottom
public static Container encloseRightBottom(Component... cmps)

Shorthand for Container.encloseIn(new FlowLayout(Component.RIGHT,


Component.BOTTOM), cmps);
Parameters:
cmps - the components to enclose in a new container
Returns:
the new container

Method Detail

1189

Overview (Codename One API)


com.codename1.ui.layouts

Class CoordinateLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.CoordinateLayout

Deprecated.
the usage of this layout is strongly discouraged as elements will not adapt to the right position/size
public class
extends Layout

Allows laying out components based on absolute positions/sizes that are adapted based on available
space for the layout. The layout

Constructor Summary
Constructor and Description
CoordinateLayout()

Deprecated.
Allows creating a coordinate layouts that disables the scaling feature
CoordinateLayout(Dimension d)

Deprecated.
This constructor accepts the relative width and height used to define the aspect ratio of the
Container
CoordinateLayout(int width, int height)

Deprecated.
This constructor accepts the relative width and height used to define the aspect ratio of the
Container

Method Summary
Modifier and Type

Method and Description


getPreferredSize(Container parent)

Dimension

Deprecated.
Returns the container preferred size
isOverlapSupported()

boolean

Deprecated.
This method returns true if the Layout allows Components to Overlap.
layoutContainer(Container parent)

Deprecated.
Layout the given parent container children

void

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, equals, getComponentConstraint, hashCode,
isConstraintTracking, obscuresPotential, removeLayoutComponent

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Class CoordinateLayout

1190

Overview (Codename One API)

Constructor

Detail

CoordinateLayout
public CoordinateLayout()

Deprecated.
Allows creating a coordinate layouts that disables the scaling feature
CoordinateLayout
public CoordinateLayout(int width,
int height)

Deprecated.
This constructor accepts the relative width and height used to define the aspect ratio
of the Container
Parameters:
width height CoordinateLayout
public CoordinateLayout(Dimension d)

Deprecated.
This constructor accepts the relative width and height used to define the aspect ratio
of the Container
Parameters:
d - the width/height

Method Detail
layoutContainer
public void layoutContainer(Container parent)

Deprecated.
Layout the given parent container children
Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container
getPreferredSize
public Dimension getPreferredSize(Container parent)

Deprecated.
Returns the container preferred size
Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
isOverlapSupported
public boolean isOverlapSupported()

Deprecated.
This method returns true if the Layout allows Components to Overlap.
Overrides:
isOverlapSupported in class Layout
Returns:
true if Components may intersect in this layout

Constructor Detail

1191

Overview (Codename One API)


com.codename1.ui.layouts

Class BoxLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.BoxLayout

public class
extends Layout

Layout manager that places elements in a row (X_AXIS) or column (Y_AXIS) according to box
orientation. Box is a very simple and predictable layout that serves as the "workhorse" of component
lists in Codename One
You can create a box layout Y UI using syntax such as this
Form hi = new Form("Box Y Layout", new BoxLayout(BoxLayout.Y_AXIS));
hi.add(new Label("First")).
add(new Label("Second")).
add(new Label("Third")).
add(new Label("Fourth")).
add(new Label("Fifth"));

This can also be expressed with more terse syntax e.g. an X axis layout like this:
Container box = BoxLayout.encloseX(new Label("First"),
new Label("Second"),
new Label("Third"),
new Label("Fourth"),
new Label("Fifth")));

Method Detail

1192

Overview (Codename One API)

The BoxLayout keeps the preferred size of its destination orientation and scales elements on the other
axis. Specifically X_AXIS will keep the preferred width of the component while growing all the
components vertically to match in size. Its Y_AXIS counterpart keeps the preferred height while
growing the components horizontally.
This behavior is very useful since it allows elements to align as they would all have the same size.
In some cases the growing behavior in the X axis is undesired, for these cases we can use the
X_AXIS_NO_GROW variant.

Class BoxLayout

1193

Overview (Codename One API)


FlowLayout vs. BoxLayout.X_AXIS/X_AXIS_NO_GROW
There are quite a few differences between FlowLayout and BoxLayout. When it doesn't matter to you
we tend to recommend BoxLayout as it acts more consistently in all situations since its far simpler.
Another advantage of BoxLayout is the fact that it grows and thus aligns nicely.

Field Summary
Modifier and
Type
static int

Field and Description


X_AXIS

Horizontal layout where components are arranged from left to right


X_AXIS_NO_GROW

static int

static int

Horizontal layout where components are arranged from left to right but don't
grow vertically beyond their preferred size
Y_AXIS

Vertical layout where components are arranged from top to bottom

Constructor Summary
Constructor and Description
BoxLayout(int axis)

Creates a new instance of BoxLayout

Method Summary
Modifier and Type

Method and Description


encloseX(Component... cmps)

The equivalent of Container.enclose() with a box layout X

static Container

Class BoxLayout

1194

Overview (Codename One API)


encloseXNoGrow(Component... cmps)

The equivalent of Container.enclose() with a box layout X


no grow option

static Container

encloseY(Component... cmps)

The equivalent of Container.enclose() with a box layout Y

static Container

boolean
int
Dimension
void

Method Summary

equals(Object o)

Indicates whether some other object is "equal to" this one.


getAxis()

Returns the layout axis x/y


getPreferredSize(Container parent)

Returns the container preferred size


layoutContainer(Container parent)

1195

Overview (Codename One API)


Layout the given parent container children
toString()

String

Returns a string representation of the object.

Methods inherited from class com.codename1.ui.layouts.Layout


addLayoutComponent, getComponentConstraint, hashCode, isConstraintTracking,
isOverlapSupported, obscuresPotential, removeLayoutComponent

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
X_AXIS
public static final int X_AXIS

Horizontal layout where components are arranged from left to right


See Also:
Constant Field Values
Y_AXIS
public static final int Y_AXIS

Vertical layout where components are arranged from top to bottom


See Also:
Constant Field Values
X_AXIS_NO_GROW
public static final int X_AXIS_NO_GROW

Horizontal layout where components are arranged from left to right but don't grow
vertically beyond their preferred size
See Also:
Constant Field Values

Constructor Detail
BoxLayout
public BoxLayout(int axis)

Creates a new instance of BoxLayout


Parameters:
axis - the axis to lay out components along. Can be: BoxLayout.X_AXIS or
BoxLayout.Y_AXIS

Method Detail
layoutContainer
public void layoutContainer(Container parent)

Layout the given parent container children


Specified by:
layoutContainer in class Layout
Parameters:
parent - the given parent container

Methods inherited from class com.codename1.ui.layouts.Layout

1196

Overview (Codename One API)


getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
getAxis
public int getAxis()

Returns the layout axis x/y


Returns:
the layout axis
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Layout
encloseY
public static Container encloseY(Component... cmps)

The equivalent of Container.enclose() with a box layout Y

Method Detail

1197

Overview (Codename One API)

Parameters:
cmps - the set of components
Returns:
the newly created container
encloseX
public static Container encloseX(Component... cmps)

The equivalent of Container.enclose() with a box layout X

Parameters:
cmps - the set of components
Returns:
the newly created container

Method Detail

1198

Overview (Codename One API)


encloseXNoGrow
public static Container encloseXNoGrow(Component... cmps)

The equivalent of Container.enclose() with a box layout X no grow option

Parameters:
cmps - the set of components
Returns:
the newly created container

Method Detail

1199

Overview (Codename One API)


com.codename1.ui.layouts

Class BorderLayout
java.lang.Object

com.codename1.ui.layouts.Layout

com.codename1.ui.layouts.BorderLayout

public class
extends Layout

A border layout lays out a container, arranging and resizing its components to fit in five regions: north,
south, east, west, and center. Each region may contain no more than one component, and is
identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER. When adding
a component to a container with a border layout, use one of these five constants.
The border layout scales all of the components within it to match the available constraints. The
NORTH & SOUTH components use their preferred height but are stretched to take up the full width
available. The EAST & WEST do the same for the reverse axis however they leave room for the
NORTH/SOUTH entries if they are defined.
The CENTER constraint will take up the rest of the available space regardless of its preferred size.
This is normally very useful, however in some cases we would prefer that the center component will
actually position itself in the middle of the available space. For this we have the setCenterBehavior
method.
Because of its scaling behavior scrolling a border layout makes no sense. However it is a common
mistake to apply a border layout to a scrollable container or trying to make a border layout scrollable.
That is why the Container class explicitly blocks scrolling on a BorderLayout.
Typical usage of this class:
Form hi = new Form("Border Layout", new BorderLayout());
hi.add(BorderLayout.CENTER, new Label("Center")).
add(BorderLayout.SOUTH, new Label("South")).
add(BorderLayout.NORTH, new Label("North")).
add(BorderLayout.EAST, new Label("East")).
add(BorderLayout.WEST, new Label("West"));
hi.show();

When defining the center behavior we can get very different results:
Form hi = new Form("Border Layout", new BorderLayout());
((BorderLayout)hi.getLayout()).setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER);
hi.add(BorderLayout.CENTER, new Label("Center")).
add(BorderLayout.SOUTH, new Label("South")).
add(BorderLayout.NORTH, new Label("North")).
add(BorderLayout.EAST, new Label("East")).
add(BorderLayout.WEST, new Label("West"));
hi.show();

Class BorderLayout

1200

Overview (Codename One API)

Notice that in the case of RTL (right to left language also known as bidi) the EAST and WEST values
are implicitly reversed as shown in this image:

You can read further in the BorderLayout section in the developer guide.

Field Summary
Modifier
and Type
static
String

Field and Description


CENTER

The center layout constraint (middle of container)


CENTER_BEHAVIOR_CENTER

static int

Defines 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.
CENTER_BEHAVIOR_CENTER_ABSOLUTE

static int

Defines the behavior of the component placed in the center position of the
layout, places the component in the center of the surrounding container
CENTER_BEHAVIOR_SCALE

static int

Defines the behavior of the component placed in the center position of the
layout, by default it is scaled to the available space
CENTER_BEHAVIOR_TOTAL_BELLOW

static int

Field Summary

Deprecated.
Deprecated due to spelling mistake, use
CENTER_BEHAVIOR_TOTAL_BELOW

1201

Overview (Codename One API)


CENTER_BEHAVIOR_TOTAL_BELOW
static int

The center component takes up the entire screens and the sides are
automatically placed on top of it thus creating a layered effect

static
String

EAST

static
String

NORTH

static
String

SOUTH

static
String

WEST

The east layout constraint (right of container).


The north layout constraint (top of container).
The south layout constraint (bottom of container).
The west layout constraint (left of container).

Constructor Summary
Constructor and Description
BorderLayout()

Creates a new instance of BorderLayout


BorderLayout(int behavior)

Creates a new instance of BorderLayout with absolute behavior

Method Summary
Modifier and
Type

Method and Description


addLayoutComponent(Object name, Component comp, Container c)

void

static
Container

Some layouts can optionally track the addition of elements with meta-data
that allows the user to "hint" on object positioning.
center(Component center)

Convenience method that creates a border layout container and places the
given component in the center
defineLandscapeSwap(String portraitPosition,
String landscapePosition)

void

static
Container
boolean
Component

This method allows swapping positions within the border layout when the
layout orientation changes to landscape or if the layout starts off as
landscape.
east(Component east)

Convenience method that creates a border layout container and places the
given component in the east
equals(Object o)

Indicates whether some other object is "equal to" this one.


getCenter()

Returns the component in the center location


getCenterBehavior()

int

Object
Component

Defines the behavior of the center component to one of the constants defined
in this class
getComponentConstraint(Component comp)

Returns the component constraint


getEast()

Returns the component in the east location


getLandscapeSwap(String portraitPosition)

String

Component
Dimension
Component

Constructor Summary

Returns the landscape swap destination for the given border layout element if
such a destination is defined.
getNorth()

Returns the component in the north location


getPreferredSize(Container parent)

Returns the container preferred size


getSouth()

1202

Overview (Codename One API)


Returns the component in the south location
Component

getWest()

Returns the component in the west location


isAbsoluteCenter()

boolean

Deprecated.
use center behavior instead
isConstraintTracking()

boolean

boolean
boolean

If this method returns true, the addLayoutComponent method will be called


when replacing a layout for every component within the container
isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


isScaleEdges()

Stretches the edge components (NORTH/EAST/WEST/SOUTH)


layoutContainer(Container target)

void

Layout the given parent container children

static
Container

north(Component north)

Convenience method that creates a border layout container and places the
given component in the north
obscuresPotential(Container parent)

boolean

Some layout managers can obscure their child components in some cases
this returns true if the basic underpinnings are in place for that.
removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only useful if the
layout maintains references to components within it

void

setAbsoluteCenter(boolean absoluteCenter)

Deprecated.
use center behavior instead

void

setCenterBehavior(int centerBehavior)

Defines the behavior of the center component to one of the constants defined
in this class

void

setScaleEdges(boolean scaleEdges)

void

Stretches the edge components (NORTH/EAST/WEST/SOUTH)

static
Container

south(Component south)

Convenience method that creates a border layout container and places the
given component in the south
toString()

String

Returns a string representation of the object.

static
Container

west(Component west)

Convenience method that creates a border layout container and places the
given component in the west

Methods inherited from class com.codename1.ui.layouts.Layout


hashCode

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
CENTER_BEHAVIOR_SCALE
public static final int CENTER_BEHAVIOR_SCALE

Defines the behavior of the component placed in the center position of the layout, by
default it is scaled to the available space
See Also:
Constant Field Values

Method Summary

1203

Overview (Codename One API)


CENTER_BEHAVIOR_CENTER
public static final int CENTER_BEHAVIOR_CENTER

Defines 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:
Constant Field Values
CENTER_BEHAVIOR_CENTER_ABSOLUTE
public static final int CENTER_BEHAVIOR_CENTER_ABSOLUTE

Defines 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:
Constant Field Values
CENTER_BEHAVIOR_TOTAL_BELLOW
public static final int CENTER_BEHAVIOR_TOTAL_BELLOW

Deprecated. Deprecated due to spelling mistake, use


CENTER_BEHAVIOR_TOTAL_BELOW
Deprecated due to spelling mistake, use CENTER_BEHAVIOR_TOTAL_BELOW The
center component takes up the entire screens and the sides are automatically placed
on top of it thus creating a layered effect
See Also:
Constant Field Values
CENTER_BEHAVIOR_TOTAL_BELOW
public static final int CENTER_BEHAVIOR_TOTAL_BELOW

The center component takes up the entire screens and the sides are automatically
placed on top of it thus creating a layered effect
See Also:
Constant Field Values
NORTH
public static final String NORTH

The north layout constraint (top of container).


See Also:
Constant Field Values
SOUTH
public static final String SOUTH

The south layout constraint (bottom of container).


See Also:
Constant Field Values
CENTER
public static final String CENTER

The center layout constraint (middle of container)


See Also:
Constant Field Values
WEST
public static final String WEST

The west layout constraint (left of container).


See Also:
Constant Field Values

Field Detail

1204

Overview (Codename One API)


EAST
public static final String EAST

The east layout constraint (right of container).


See Also:
Constant Field Values

Constructor Detail
BorderLayout
public BorderLayout()

Creates a new instance of BorderLayout


BorderLayout
public BorderLayout(int behavior)

Creates a new instance of BorderLayout with absolute behavior


Parameters:
behavior - identical value as the setCenterBehavior method

Method Detail
addLayoutComponent
public void addLayoutComponent(Object name,
Component comp,
Container c)

Some layouts can optionally track the addition of elements with meta-data that allows
the user to "hint" on object positioning.
Overrides:
addLayoutComponent in class Layout
Parameters:
name - optional meta data information, like alignment orientation
comp - the added component to the layout
c - the parent container
removeLayoutComponent
public void removeLayoutComponent(Component comp)

Removes the component from the layout this operation is only useful if the layout
maintains references to components within it
Overrides:
removeLayoutComponent in class Layout
Parameters:
comp - the removed component from layout
getComponentConstraint
public Object getComponentConstraint(Component comp)

Returns the component constraint


Overrides:
getComponentConstraint in class Layout
Parameters:
comp - the component whose constraint is queried
Returns:
one of the constraints defined in this class

Field Detail

1205

Overview (Codename One API)


layoutContainer
public void layoutContainer(Container target)

Layout the given parent container children


Specified by:
layoutContainer in class Layout
Parameters:
target - the given parent container
getPreferredSize
public Dimension getPreferredSize(Container parent)

Returns the container preferred size


Specified by:
getPreferredSize in class Layout
Parameters:
parent - the parent container
Returns:
the container preferred size
getSouth
public Component getSouth()

Returns the component in the south location


Returns:
the component in the constraint
getCenter
public Component getCenter()

Returns the component in the center location


Returns:
the component in the constraint
getNorth
public Component getNorth()

Returns the component in the north location


Returns:
the component in the constraint
getEast
public Component getEast()

Returns the component in the east location


Returns:
the component in the constraint
getWest
public Component getWest()

Returns the component in the west location


Returns:
the component in the constraint
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())

Method Detail

1206

Overview (Codename One API)


Overrides:
toString in class Object
defineLandscapeSwap
public void defineLandscapeSwap(String portraitPosition,
String landscapePosition)

This method allows swapping positions within the border layout when the layout
orientation changes to landscape or if the layout starts off as landscape.
Parameters:
portraitPosition - the position for the component when in portrait (this
position should always be used when adding a component to the layout).
One of NORTH/SOUTH/EAST/WEST/CENTER.
landscapePosition - the destination position to use in landscape
getLandscapeSwap
public String getLandscapeSwap(String portraitPosition)

Returns the landscape swap destination for the given border layout element if such a
destination is defined.
Parameters:
portraitPosition - the constraint used when placing the component
Returns:
the constraint to use when in landscape or null if undefined
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Layout
isAbsoluteCenter
public boolean isAbsoluteCenter()

Deprecated. use center behavior instead


Indicates that the center shouldn't grow and should be placed exactly in the center of
the layout
Returns:
the absoluteCenter
setAbsoluteCenter
public void setAbsoluteCenter(boolean absoluteCenter)

Deprecated. use center behavior instead


Indicates that the center shouldn't grow and should be placed exactly in the center of
the layout
Parameters:
absoluteCenter - the absoluteCenter to set
getCenterBehavior
public int getCenterBehavior()

Defines the behavior of the center component to one of the constants defined in this
class
Returns:

Method Detail

1207

Overview (Codename One API)


the centerBehavior
setCenterBehavior
public void setCenterBehavior(int centerBehavior)

Defines the behavior of the center component to one of the constants defined in this
class
Parameters:
centerBehavior - the centerBehavior to set
isOverlapSupported
public boolean isOverlapSupported()

This method returns true if the Layout allows Components to Overlap.


Overrides:
isOverlapSupported in class Layout
Returns:
true if Components may intersect in this layout
isScaleEdges
public boolean isScaleEdges()

Stretches the edge components (NORTH/EAST/WEST/SOUTH)


Returns:
the scaleEdges
setScaleEdges
public void setScaleEdges(boolean scaleEdges)

Stretches the edge components (NORTH/EAST/WEST/SOUTH)


Parameters:
scaleEdges - the scaleEdges to set
isConstraintTracking
public boolean isConstraintTracking()

If this method returns true, the addLayoutComponent method will be called when
replacing a layout for every component within the container
Overrides:
isConstraintTracking in class Layout
Returns:
false by default
obscuresPotential
public boolean obscuresPotential(Container parent)

Some layout managers can obscure their child components in some cases this
returns true if the basic underpinnings are in place for that. This method doesn't take
padding/margin etc. into account since that is checked by the caller
Overrides:
obscuresPotential in class Layout
Parameters:
parent - parent container
Returns:
true if there is a chance that this layout manager can fully obscure the
background, when in doubt return false...
center
public static Container center(Component center)

Convenience method that creates a border layout container and places the given
component in the center
Parameters:
center - the center component
Returns:
the created component

Method Detail

1208

Overview (Codename One API)


north
public static Container north(Component north)

Convenience method that creates a border layout container and places the given
component in the north
Parameters:
north - the north component
Returns:
the created component
south
public static Container south(Component south)

Convenience method that creates a border layout container and places the given
component in the south
Parameters:
south - the south component
Returns:
the created component
east
public static Container east(Component east)

Convenience method that creates a border layout container and places the given
component in the east
Parameters:
east - the east component
Returns:
the created component
west
public static Container west(Component west)

Convenience method that creates a border layout container and places the given
component in the west
Parameters:
west - the west component
Returns:
the created component

Method Detail

1209

Overview (Codename One API)


com.codename1.ui.html

Interface IOCallback
All Known Implementing Classes:
HTMLComponent

public interface

This interface is implemented by HTMLComponent and ResourceThread (The two classes using the
AsyncDocumentRequestHandler)

Method Summary
Modifier and Type
void

Method and Description


streamReady(InputStream is, DocumentInfo docInfo)

Called when the stream of the document is ready

Method Detail
streamReady
void streamReady(InputStream is,
DocumentInfo docInfo)

Called when the stream of the document is ready


Parameters:
is - The ready InputStream
docInfo - A DocumentInfo object representing the fetched InputStream

Interface IOCallback

1210

Overview (Codename One API)


com.codename1.ui.html

Class HTMLUtils
java.lang.Object

com.codename1.ui.html.HTMLUtils

public class
extends Object

This class contains several useful static methods for HTML

Method Summary
Modifier and
Type
static
String

Method and Description


convertCharEntity(String charEntity, boolean lookupHTMLentities,
Hashtable userDefinedCharEntities)

Converts a char entity to the matching character or string.

static
String

convertHTMLCharEntity(String charEntity)

static
String

convertXMLCharEntity(String charEntity)

static
String

encodeString(String str)

Converts an HTML char entity to the matching character or string.


Converts an XML char entity to the matching character or string.
Encodes the specified string to "percent-encoding" or URL encoding.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
convertXMLCharEntity
public static String convertXMLCharEntity(String charEntity)

Converts an XML char entity to the matching character or string. This is a


convenience method that uses convertCharEntity with false for lookupHTMLentities
and a null userDefinedCharEntities
Parameters:
charEntity - The char entity to convert (Not including the & and ;)
Returns:
A string containing a single char, or the original char entity string (with & and
;) if the char entity couldn't be resolved
convertHTMLCharEntity
public static String convertHTMLCharEntity(String charEntity)

Converts an HTML char entity to the matching character or string. This is a


convenience method that uses convertCharEntity with true for lookupHTMLentities
and a null userDefinedCharEntities
Parameters:
charEntity - The char entity to convert (Not including the & and ;)
Returns:
A string containing a single char, or the original char entity string (with & and
;) if the char entity couldn't be resolved

Method Detail

1211

Overview (Codename One API)


convertCharEntity
public static String convertCharEntity(String charEntity,
boolean lookupHTMLentities,
Hashtable userDefinedCharEntities)

Converts a char entity to the matching character or string. This handles both
numbered and symbol char entities (The latter is done via getCharEntityCode)
Parameters:
charEntity - The char entity to convert (Not including the & and ;)
lookupHTMLentities - true to include the basic HTML named char entities
(unicode 160-255), false otherwise
userDefinedCharEntities - A hashtable containing (String,int) dentoing the
char entity name and its unicode
Returns:
A string containing a single char, or the original char entity string (with & and
;) if the char entity couldn't be resolved
encodeString
public static String encodeString(String str)

Encodes the specified string to "percent-encoding" or URL encoding. This encodes


reserved, unsafe and unicode characters
Parameters:
str - The string to be encoded
Returns:
A percent-encoding of the string (safe characters remain the same)

Method Detail

1212

Overview (Codename One API)


com.codename1.ui.html

Class HTMLParser
java.lang.Object

com.codename1.xml.XMLParser

com.codename1.ui.html.HTMLParser

public class
extends XMLParser

The HTMLParser class is used to parse an XHTML-MP 1.0 document into a DOM object (Element).
Unsupported tags and attributes as well as comments are dropped in the parsing process. The parser
is also makes use of CSSParser for external CSS files, embedded CSS segments and CSS within the
'style' attribute.

Constructor Summary
Constructor and Description
HTMLParser()

Constructs a new instance of HTMLParser

Method Summary
Modifier and
Type
protected
String
protected
Element
protected
Element
protected
String
protected
boolean
protected
boolean

Method and Description


convertCharEntity(String charEntity)

Overrides XMLParser.convertCharEntity to add in HTML char entities


createNewElement(String name)

Overrides XMLParser.createNewElement to return an HTMLElement


instance
createNewTextElement(String text)

Overrides XMLParser.createNewTextElement to return an HTMLElement


instance
getSupportedStandardName()

{Returns a string identifying the document type this parser supports.}


isEmptyTag(String tagName)

Checks whether the specified tag is an empty tag as defined in


EMPTY_TAGS
isSupported(Element element)

Overrides the Element.isSupported to let the parser know which tags are
supported in XHTML-MP 1.0
parseHTML(InputStreamReader isr)

HTMLElement

A convenience method that casts the returned type of the parse method to
HTMLElement.
parseTagContent(Element element, Reader is)

protected void

protected
boolean

Overrides XMLParser.parseTagContent to enable embedded CSS


segments (Style tags)
shouldEvaluate(Element element)

Overrides the Element.shouldEvaluate method to return false on the script


tag.

Methods inherited from class com.codename1.xml.XMLParser


addCharEntitiesRange, addCharEntity, attribute, endTag, eventParser,
isCaseSensitive, isWhiteSpace, notifyError, parse,
parseCommentOrXMLDeclaration, parseTag, setCaseSensitive,

Class HTMLParser

1213

Overview (Codename One API)


setIncludeWhitespacesBetweenTags, setParserCallback, startTag, textElement

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
HTMLParser
public HTMLParser()

Constructs a new instance of HTMLParser

Method Detail
parseTagContent
protected void parseTagContent(Element element,
Reader is)
throws IOException

Overrides XMLParser.parseTagContent to enable embedded CSS segments (Style


tags)
Overrides:
parseTagContent in class XMLParser
Parameters:
element - The current parent element
is - The reader containing the XML
Throws:
IOException - if an I/O error in the stream is encountered
createNewElement
protected Element createNewElement(String name)

Overrides XMLParser.createNewElement to return an HTMLElement instance


Overrides:
createNewElement in class XMLParser
Parameters:
name - The HTMLElement's name
Returns:
a new instance of the names HTMLElement
createNewTextElement
protected Element createNewTextElement(String text)

Overrides XMLParser.createNewTextElement to return an HTMLElement instance


Overrides:
createNewTextElement in class XMLParser
Parameters:
text - The HTMLElement's text
Returns:
a new instance of the HTMLElement
convertCharEntity
protected String convertCharEntity(String charEntity)

Overrides XMLParser.convertCharEntity to add in HTML char entities


Overrides:
convertCharEntity in class XMLParser
Parameters:
charEntity - The char entity to convert
Returns:

Methods inherited from class com.codename1.xml.XMLParser

1214

Overview (Codename One API)


A string containing a single char, or the original char entity string (with & and
;) if the char entity couldn't be resolved
isEmptyTag
protected boolean isEmptyTag(String tagName)

Checks whether the specified tag is an empty tag as defined in EMPTY_TAGS


Overrides:
isEmptyTag in class XMLParser
Parameters:
tagName - The tag name to check
Returns:
true if that tag is defined as an empty tag, false otherwise
parseHTML
public HTMLElement parseHTML(InputStreamReader isr)

A convenience method that casts the returned type of the parse method to
HTMLElement. Basically calling this method is simlar to calling parse and casting to
HTMLElement.
Parameters:
isr - The input stream containing the HTML
Returns:
The HTML document
getSupportedStandardName
protected String getSupportedStandardName()

{Returns a string identifying the document type this parser supports. This should be
overriden by subclassing parsers.}
Overrides:
getSupportedStandardName in class XMLParser
Returns:
a string identifying the document type this parser supports.
isSupported
protected boolean isSupported(Element element)

Overrides the Element.isSupported to let the parser know which tags are supported
in XHTML-MP 1.0
Overrides:
isSupported in class XMLParser
Parameters:
element - The element to check
Returns:
true if the tag is a supported XHTML Mobile Profile 1.0 tag, false otherwise
shouldEvaluate
protected boolean shouldEvaluate(Element element)

Overrides the Element.shouldEvaluate method to return false on the script tag. The
script tag should be skipped entirely, since it may contain characters like greater-than
and lesser-than which may break the HTML All other tags are evaluated (i.e. added
including all their children to the tree), even if not supported (But of course their
functionality is ignored by HTMLComponent)
Overrides:
shouldEvaluate in class XMLParser
Parameters:
element - The element to check
Returns:
false if this is the SCRIPT tag, true otherwise

Method Detail

1215

Overview (Codename One API)


com.codename1.ui.html

Class HTMLElement
java.lang.Object

com.codename1.xml.Element

com.codename1.ui.html.HTMLElement
All Implemented Interfaces:
Iterable<Element>

public class
extends Element

The HTMLElement class defines a single HTML element with its attributes and children. Due to its
hierarchial nature, this class can be used for a single "leaf" Element, for more complex elements (with
child elements), and up to describing the entire document.

Field Summary
Modifier and Type

Field and Description

static int

ATTR_ABBR

static int

ATTR_ACCESSKEY

static int

ATTR_ACTION

static int

ATTR_ALIGN

static int

ATTR_ALT

static int

ATTR_AXIS

static int

ATTR_BGCOLOR

static int

ATTR_BORDER

static int

ATTR_CELLPADDING

static int

ATTR_CELLSPACING

static int

ATTR_CHARSET

static int

ATTR_CHECKED

static int

ATTR_CITE

static int

ATTR_CLASS

static int

ATTR_COLOR

static int

ATTR_COLS

static int

ATTR_COLSPAN

static int

ATTR_CONTENT

static int

ATTR_COORDS

static int

ATTR_DIR

static int

ATTR_DISABLED

static int

ATTR_EMPTYOK

static int

ATTR_ENCTYPE

static int

ATTR_FACE

static int

ATTR_FOR

static int

ATTR_FORMAT

static int

ATTR_FRAME

static int

ATTR_HEADERS

Class HTMLElement

1216

Overview (Codename One API)

Field Summary

static int

ATTR_HEIGHT

static int

ATTR_HREF

static int

ATTR_HREFLANG

static int

ATTR_HSPACE

static int

ATTR_HTTPEQUIV

static int

ATTR_ID

static int

ATTR_ISMAP

static int

ATTR_ISTYLE

static int

ATTR_LABEL

static int

ATTR_LANG

static int

ATTR_LINK

static int

ATTR_LOCALSRC

static int

ATTR_LONGDESC

static int

ATTR_MAXLENGTH

static int

ATTR_MEDIA

static int

ATTR_METHOD

static int

ATTR_MULTIPLE

static int

ATTR_NAME

static int

ATTR_READONLY

static int

ATTR_REL

static int

ATTR_REV

static int

ATTR_ROWS

static int

ATTR_ROWSPAN

static int

ATTR_RULES

static int

ATTR_SCHEME

static int

ATTR_SCOPE

static int

ATTR_SELECTED

static int

ATTR_SHAPE

static int

ATTR_SIZE

static int

ATTR_SRC

static int

ATTR_START

static int

ATTR_STYLE

static int

ATTR_SUMMARY

static int

ATTR_TABINDEX

static int

ATTR_TEXT

static int

ATTR_TITLE

static int

ATTR_TYPE

static int

ATTR_USEMAP

static int

ATTR_VALIGN

static int

ATTR_VALUE

static int

ATTR_VERSION

static int

ATTR_VSPACE

static int

ATTR_WIDTH

static int

ATTR_XMLLANG

static int

ATTR_XMLNS

static int

ATTR_XMLSPACE

1217

Overview (Codename One API)

Field Summary

static int

COLOR_AQUA

static int

COLOR_BLACK

static int

COLOR_BLUE

static int

COLOR_FUCHSIA

static int

COLOR_GRAY

static int

COLOR_GREEN

static int

COLOR_LIME

static int

COLOR_MAROON

static int

COLOR_NAVY

static int

COLOR_OLIVE

static int

COLOR_ORANGE

static int

COLOR_PURPLE

static int

COLOR_RED

static int

COLOR_SILVER

static int

COLOR_TEAL

static int

COLOR_WHITE

static int

COLOR_YELLOW

static int

TAG_A

static int

TAG_ABBR

static int

TAG_ACRONYM

static int

TAG_ADDRESS

static int

TAG_AREA

static int

TAG_B

static int

TAG_BASE

static int

TAG_BASEFONT

static int

TAG_BIG

static int

TAG_BLOCKQUOTE

static int

TAG_BODY

static int

TAG_BR

static int

TAG_BUTTON

static int

TAG_CAPTION

static int

TAG_CENTER

static int

TAG_CITE

static int

TAG_CODE

static int

TAG_CSS_ILLEGAL_SELECTOR

static int

TAG_CSS_SELECTOR

static int

TAG_DD

static int

TAG_DEL

static int

TAG_DFN

static int

TAG_DIR

static int

TAG_DIV

static int

TAG_DL

static int

TAG_DT

static int

TAG_EM

static int

TAG_FIELDSET

static int

TAG_FONT

1218

Overview (Codename One API)

Field Summary

static int

TAG_FORM

static int

TAG_H1

static int

TAG_H2

static int

TAG_H3

static int

TAG_H4

static int

TAG_H5

static int

TAG_H6

static int

TAG_HEAD

static int

TAG_HR

static int

TAG_HTML

static int

TAG_I

static int

TAG_IMG

static int

TAG_INPUT

static int

TAG_INS

static int

TAG_KBD

static int

TAG_LABEL

static int

TAG_LEGEND

static int

TAG_LI

static int

TAG_LINK

static int

TAG_MAP

static int

TAG_MENU

static int

TAG_META

static int

TAG_NOFRAMES

static int

TAG_NOSCRIPT

static int

TAG_OBJECT

static int

TAG_OL

static int

TAG_OPTGROUP

static int

TAG_OPTION

static int

TAG_P

static int

TAG_PARAM

static int

TAG_PRE

static int

TAG_Q

static int

TAG_S

static int

TAG_SAMP

static int

TAG_SELECT

static int

TAG_SMALL

static int

TAG_SPAN

static int

TAG_STRIKE

static int

TAG_STRONG

static int

TAG_STYLE

static int

TAG_SUB

static int

TAG_SUP

static int

TAG_TABLE

static int

TAG_TBODY

static int

TAG_TD

static int

TAG_TEXT

1219

Overview (Codename One API)


static int

TAG_TEXTAREA

static int

TAG_TFOOT

static int

TAG_TH

static int

TAG_THEAD

static int

TAG_TITLE

static int

TAG_TR

static int

TAG_TT

static int

TAG_U

static int

TAG_UL

static int

TAG_UNSUPPORTED

static int

TAG_VAR

Fields inherited from class com.codename1.xml.Element


DEPTH_INFINITE

Constructor Summary
Modifier
protected

Constructor and Description


HTMLElement()

Constructs and HTMLElement without specifying a name.


HTMLElement(String tagName)

Constructor for HTMLElement.


HTMLElement(String tagName, boolean isTextElement)

Constructor for HTMLElement.

Method Summary
Modifier and
Type
void

Method and Description


addChild(Element childElement)

Adds the specified Element as a child to this element.


getAttribute(String name)

String

Returns the attribute value by its name (or null if it wasn't defined for this
element)
getAttributeById(int id)

String

String
Vector
Vector
HTMLElement
String
int
String
void

Returns an HTMLElement's attribute by the attribute's ID (One of the


ATTR_* constants)
getAttributeName(Integer attrKey)

Returns the attribute name of the requested attribute


getDescendantsByTagId(int tagId)

Returns all descendants with the specified tag id


getDescendantsByTagId(int tagId, int depth)

Returns all descendants with the specified tag id


getFirstChildByTagId(int tagId)

Returns an HTMLElement's child by a tag ID (One of the TAG_* constants)


getSupportedAttributesList()

Returns a list of supported attributes for this tag.


getTagId()

Returns this HTMLElement's ID


getTagName()

Returns this HTMLElement's tag name


removeAttributeById(int attrId)

Removes the specified attribute

Fields inherited from class com.codename1.xml.Element

1220

Overview (Codename One API)


removeChildAt(int index)

void

{Removes the child at the given index}


setAttribute(String attribute, String value)

Adds the specified attribute and value to this Element if it is supported for
the Element and has a valid value.

int

setAttributeById(int attrId, String value)

void

Allows setting an attribute with an attribute id

protected void

setTagId(int tagId)

Sets this HTMLElement's ID


toString()

String

{Returns a printable string representing this element}

Methods inherited from class com.codename1.xml.Element


contains, getAttributeAsInt, getAttributes, getChildAt, getChildIndex,
getChildren, getChildrenByTagName, getDescendantsByTagName,
getDescendantsByTagName, getDescendantsByTagNameAndAttribute,
getElementById, getFirstChildByTagName, getNumChildren, getParent, getText,
getTextChildren, getTextDescendants, getTextDescendants, hasTextChild,
insertChildAt, isEmpty, isTextElement, iterator, removeAttribute,
removeAttribute, replaceChild, setAttribute, setChildren, setParent,
setTagName, setText, setTextElement

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
TAG_CSS_ILLEGAL_SELECTOR
public static final int TAG_CSS_ILLEGAL_SELECTOR

See Also:
Constant Field Values
TAG_CSS_SELECTOR
public static final int TAG_CSS_SELECTOR

See Also:
Constant Field Values
TAG_UNSUPPORTED
public static final int TAG_UNSUPPORTED

See Also:
Constant Field Values
TAG_BODY
public static final int TAG_BODY

See Also:
Constant Field Values
TAG_HEAD
public static final int TAG_HEAD

See Also:
Constant Field Values
TAG_HTML
public static final int TAG_HTML

See Also:

Method Summary

1221

Overview (Codename One API)


Constant Field Values
TAG_TITLE
public static final int TAG_TITLE

See Also:
Constant Field Values
TAG_ABBR
public static final int TAG_ABBR

See Also:
Constant Field Values
TAG_ACRONYM
public static final int TAG_ACRONYM

See Also:
Constant Field Values
TAG_ADDRESS
public static final int TAG_ADDRESS

See Also:
Constant Field Values
TAG_BLOCKQUOTE
public static final int TAG_BLOCKQUOTE

See Also:
Constant Field Values
TAG_BR
public static final int TAG_BR

See Also:
Constant Field Values
TAG_CITE
public static final int TAG_CITE

See Also:
Constant Field Values
TAG_CODE
public static final int TAG_CODE

See Also:
Constant Field Values
TAG_DFN
public static final int TAG_DFN

See Also:
Constant Field Values
TAG_DIV
public static final int TAG_DIV

See Also:
Constant Field Values
TAG_EM
public static final int TAG_EM

See Also:
Constant Field Values

Field Detail

1222

Overview (Codename One API)


TAG_H1
public static final int TAG_H1

See Also:
Constant Field Values
TAG_H2
public static final int TAG_H2

See Also:
Constant Field Values
TAG_H3
public static final int TAG_H3

See Also:
Constant Field Values
TAG_H4
public static final int TAG_H4

See Also:
Constant Field Values
TAG_H5
public static final int TAG_H5

See Also:
Constant Field Values
TAG_H6
public static final int TAG_H6

See Also:
Constant Field Values
TAG_KBD
public static final int TAG_KBD

See Also:
Constant Field Values
TAG_P
public static final int TAG_P

See Also:
Constant Field Values
TAG_PRE
public static final int TAG_PRE

See Also:
Constant Field Values
TAG_Q
public static final int TAG_Q

See Also:
Constant Field Values
TAG_SAMP
public static final int TAG_SAMP

See Also:
Constant Field Values

Field Detail

1223

Overview (Codename One API)


TAG_SPAN
public static final int TAG_SPAN

See Also:
Constant Field Values
TAG_STRONG
public static final int TAG_STRONG

See Also:
Constant Field Values
TAG_VAR
public static final int TAG_VAR

See Also:
Constant Field Values
TAG_A
public static final int TAG_A

See Also:
Constant Field Values
TAG_DL
public static final int TAG_DL

See Also:
Constant Field Values
TAG_DT
public static final int TAG_DT

See Also:
Constant Field Values
TAG_DD
public static final int TAG_DD

See Also:
Constant Field Values
TAG_OL
public static final int TAG_OL

See Also:
Constant Field Values
TAG_UL
public static final int TAG_UL

See Also:
Constant Field Values
TAG_LI
public static final int TAG_LI

See Also:
Constant Field Values
TAG_FORM
public static final int TAG_FORM

See Also:
Constant Field Values

Field Detail

1224

Overview (Codename One API)


TAG_INPUT
public static final int TAG_INPUT

See Also:
Constant Field Values
TAG_LABEL
public static final int TAG_LABEL

See Also:
Constant Field Values
TAG_SELECT
public static final int TAG_SELECT

See Also:
Constant Field Values
TAG_OPTION
public static final int TAG_OPTION

See Also:
Constant Field Values
TAG_TEXTAREA
public static final int TAG_TEXTAREA

See Also:
Constant Field Values
TAG_CAPTION
public static final int TAG_CAPTION

See Also:
Constant Field Values
TAG_TABLE
public static final int TAG_TABLE

See Also:
Constant Field Values
TAG_TD
public static final int TAG_TD

See Also:
Constant Field Values
TAG_TH
public static final int TAG_TH

See Also:
Constant Field Values
TAG_TR
public static final int TAG_TR

See Also:
Constant Field Values
TAG_IMG
public static final int TAG_IMG

See Also:
Constant Field Values

Field Detail

1225

Overview (Codename One API)


TAG_OBJECT
public static final int TAG_OBJECT

See Also:
Constant Field Values
TAG_PARAM
public static final int TAG_PARAM

See Also:
Constant Field Values
TAG_META
public static final int TAG_META

See Also:
Constant Field Values
TAG_LINK
public static final int TAG_LINK

See Also:
Constant Field Values
TAG_BASE
public static final int TAG_BASE

See Also:
Constant Field Values
TAG_HR
public static final int TAG_HR

See Also:
Constant Field Values
TAG_OPTGROUP
public static final int TAG_OPTGROUP

See Also:
Constant Field Values
TAG_STYLE
public static final int TAG_STYLE

See Also:
Constant Field Values
TAG_B
public static final int TAG_B

See Also:
Constant Field Values
TAG_I
public static final int TAG_I

See Also:
Constant Field Values
TAG_BIG
public static final int TAG_BIG

See Also:
Constant Field Values

Field Detail

1226

Overview (Codename One API)


TAG_SMALL
public static final int TAG_SMALL

See Also:
Constant Field Values
TAG_FIELDSET
public static final int TAG_FIELDSET

See Also:
Constant Field Values
TAG_U
public static final int TAG_U

See Also:
Constant Field Values
TAG_FONT
public static final int TAG_FONT

See Also:
Constant Field Values
TAG_DEL
public static final int TAG_DEL

See Also:
Constant Field Values
TAG_INS
public static final int TAG_INS

See Also:
Constant Field Values
TAG_TT
public static final int TAG_TT

See Also:
Constant Field Values
TAG_BASEFONT
public static final int TAG_BASEFONT

See Also:
Constant Field Values
TAG_MENU
public static final int TAG_MENU

See Also:
Constant Field Values
TAG_S
public static final int TAG_S

See Also:
Constant Field Values
TAG_STRIKE
public static final int TAG_STRIKE

See Also:
Constant Field Values

Field Detail

1227

Overview (Codename One API)


TAG_CENTER
public static final int TAG_CENTER

See Also:
Constant Field Values
TAG_DIR
public static final int TAG_DIR

See Also:
Constant Field Values
TAG_MAP
public static final int TAG_MAP

See Also:
Constant Field Values
TAG_AREA
public static final int TAG_AREA

See Also:
Constant Field Values
TAG_LEGEND
public static final int TAG_LEGEND

See Also:
Constant Field Values
TAG_SUB
public static final int TAG_SUB

See Also:
Constant Field Values
TAG_SUP
public static final int TAG_SUP

See Also:
Constant Field Values
TAG_NOSCRIPT
public static final int TAG_NOSCRIPT

See Also:
Constant Field Values
TAG_NOFRAMES
public static final int TAG_NOFRAMES

See Also:
Constant Field Values
TAG_THEAD
public static final int TAG_THEAD

See Also:
Constant Field Values
TAG_TBODY
public static final int TAG_TBODY

See Also:
Constant Field Values

Field Detail

1228

Overview (Codename One API)


TAG_TFOOT
public static final int TAG_TFOOT

See Also:
Constant Field Values
TAG_BUTTON
public static final int TAG_BUTTON

See Also:
Constant Field Values
TAG_TEXT
public static final int TAG_TEXT

See Also:
Constant Field Values
ATTR_CLASS
public static final int ATTR_CLASS

See Also:
Constant Field Values
ATTR_ID
public static final int ATTR_ID

See Also:
Constant Field Values
ATTR_STYLE
public static final int ATTR_STYLE

See Also:
Constant Field Values
ATTR_TITLE
public static final int ATTR_TITLE

See Also:
Constant Field Values
ATTR_XMLNS
public static final int ATTR_XMLNS

See Also:
Constant Field Values
ATTR_XMLLANG
public static final int ATTR_XMLLANG

See Also:
Constant Field Values
ATTR_ALIGN
public static final int ATTR_ALIGN

See Also:
Constant Field Values
ATTR_BGCOLOR
public static final int ATTR_BGCOLOR

See Also:
Constant Field Values

Field Detail

1229

Overview (Codename One API)


ATTR_LINK
public static final int ATTR_LINK

See Also:
Constant Field Values
ATTR_TEXT
public static final int ATTR_TEXT

See Also:
Constant Field Values
ATTR_VERSION
public static final int ATTR_VERSION

See Also:
Constant Field Values
ATTR_CITE
public static final int ATTR_CITE

See Also:
Constant Field Values
ATTR_ACCESSKEY
public static final int ATTR_ACCESSKEY

See Also:
Constant Field Values
ATTR_CHARSET
public static final int ATTR_CHARSET

See Also:
Constant Field Values
ATTR_HREF
public static final int ATTR_HREF

See Also:
Constant Field Values
ATTR_HREFLANG
public static final int ATTR_HREFLANG

See Also:
Constant Field Values
ATTR_REL
public static final int ATTR_REL

See Also:
Constant Field Values
ATTR_REV
public static final int ATTR_REV

See Also:
Constant Field Values
ATTR_TABINDEX
public static final int ATTR_TABINDEX

See Also:
Constant Field Values

Field Detail

1230

Overview (Codename One API)


ATTR_TYPE
public static final int ATTR_TYPE

See Also:
Constant Field Values
ATTR_ACTION
public static final int ATTR_ACTION

See Also:
Constant Field Values
ATTR_ENCTYPE
public static final int ATTR_ENCTYPE

See Also:
Constant Field Values
ATTR_METHOD
public static final int ATTR_METHOD

See Also:
Constant Field Values
ATTR_WIDTH
public static final int ATTR_WIDTH

See Also:
Constant Field Values
ATTR_HEIGHT
public static final int ATTR_HEIGHT

See Also:
Constant Field Values
ATTR_ALT
public static final int ATTR_ALT

See Also:
Constant Field Values
ATTR_HSPACE
public static final int ATTR_HSPACE

See Also:
Constant Field Values
ATTR_VSPACE
public static final int ATTR_VSPACE

See Also:
Constant Field Values
ATTR_LONGDESC
public static final int ATTR_LONGDESC

See Also:
Constant Field Values
ATTR_LOCALSRC
public static final int ATTR_LOCALSRC

See Also:
Constant Field Values

Field Detail

1231

Overview (Codename One API)


ATTR_SRC
public static final int ATTR_SRC

See Also:
Constant Field Values
ATTR_SIZE
public static final int ATTR_SIZE

See Also:
Constant Field Values
ATTR_CHECKED
public static final int ATTR_CHECKED

See Also:
Constant Field Values
ATTR_EMPTYOK
public static final int ATTR_EMPTYOK

See Also:
Constant Field Values
ATTR_FORMAT
public static final int ATTR_FORMAT

See Also:
Constant Field Values
ATTR_ISTYLE
public static final int ATTR_ISTYLE

See Also:
Constant Field Values
ATTR_MAXLENGTH
public static final int ATTR_MAXLENGTH

See Also:
Constant Field Values
ATTR_NAME
public static final int ATTR_NAME

See Also:
Constant Field Values
ATTR_VALUE
public static final int ATTR_VALUE

See Also:
Constant Field Values
ATTR_FOR
public static final int ATTR_FOR

See Also:
Constant Field Values
ATTR_XMLSPACE
public static final int ATTR_XMLSPACE

See Also:
Constant Field Values

Field Detail

1232

Overview (Codename One API)


ATTR_MULTIPLE
public static final int ATTR_MULTIPLE

See Also:
Constant Field Values
ATTR_SELECTED
public static final int ATTR_SELECTED

See Also:
Constant Field Values
ATTR_ABBR
public static final int ATTR_ABBR

See Also:
Constant Field Values
ATTR_AXIS
public static final int ATTR_AXIS

See Also:
Constant Field Values
ATTR_COLSPAN
public static final int ATTR_COLSPAN

See Also:
Constant Field Values
ATTR_HEADERS
public static final int ATTR_HEADERS

See Also:
Constant Field Values
ATTR_ROWSPAN
public static final int ATTR_ROWSPAN

See Also:
Constant Field Values
ATTR_SCOPE
public static final int ATTR_SCOPE

See Also:
Constant Field Values
ATTR_VALIGN
public static final int ATTR_VALIGN

See Also:
Constant Field Values
ATTR_START
public static final int ATTR_START

See Also:
Constant Field Values
ATTR_MEDIA
public static final int ATTR_MEDIA

See Also:
Constant Field Values

Field Detail

1233

Overview (Codename One API)


ATTR_LABEL
public static final int ATTR_LABEL

See Also:
Constant Field Values
ATTR_SUMMARY
public static final int ATTR_SUMMARY

See Also:
Constant Field Values
ATTR_CONTENT
public static final int ATTR_CONTENT

See Also:
Constant Field Values
ATTR_HTTPEQUIV
public static final int ATTR_HTTPEQUIV

See Also:
Constant Field Values
ATTR_SCHEME
public static final int ATTR_SCHEME

See Also:
Constant Field Values
ATTR_COLS
public static final int ATTR_COLS

See Also:
Constant Field Values
ATTR_ROWS
public static final int ATTR_ROWS

See Also:
Constant Field Values
ATTR_DIR
public static final int ATTR_DIR

See Also:
Constant Field Values
ATTR_BORDER
public static final int ATTR_BORDER

See Also:
Constant Field Values
ATTR_COLOR
public static final int ATTR_COLOR

See Also:
Constant Field Values
ATTR_FACE
public static final int ATTR_FACE

See Also:
Constant Field Values

Field Detail

1234

Overview (Codename One API)


ATTR_SHAPE
public static final int ATTR_SHAPE

See Also:
Constant Field Values
ATTR_COORDS
public static final int ATTR_COORDS

See Also:
Constant Field Values
ATTR_USEMAP
public static final int ATTR_USEMAP

See Also:
Constant Field Values
ATTR_LANG
public static final int ATTR_LANG

See Also:
Constant Field Values
ATTR_CELLSPACING
public static final int ATTR_CELLSPACING

See Also:
Constant Field Values
ATTR_CELLPADDING
public static final int ATTR_CELLPADDING

See Also:
Constant Field Values
ATTR_FRAME
public static final int ATTR_FRAME

See Also:
Constant Field Values
ATTR_RULES
public static final int ATTR_RULES

See Also:
Constant Field Values
ATTR_DISABLED
public static final int ATTR_DISABLED

See Also:
Constant Field Values
ATTR_READONLY
public static final int ATTR_READONLY

See Also:
Constant Field Values
ATTR_ISMAP
public static final int ATTR_ISMAP

See Also:
Constant Field Values

Field Detail

1235

Overview (Codename One API)


COLOR_AQUA
public static final int COLOR_AQUA

See Also:
Constant Field Values
COLOR_BLACK
public static final int COLOR_BLACK

See Also:
Constant Field Values
COLOR_BLUE
public static final int COLOR_BLUE

See Also:
Constant Field Values
COLOR_FUCHSIA
public static final int COLOR_FUCHSIA

See Also:
Constant Field Values
COLOR_GRAY
public static final int COLOR_GRAY

See Also:
Constant Field Values
COLOR_GREEN
public static final int COLOR_GREEN

See Also:
Constant Field Values
COLOR_LIME
public static final int COLOR_LIME

See Also:
Constant Field Values
COLOR_MAROON
public static final int COLOR_MAROON

See Also:
Constant Field Values
COLOR_NAVY
public static final int COLOR_NAVY

See Also:
Constant Field Values
COLOR_OLIVE
public static final int COLOR_OLIVE

See Also:
Constant Field Values
COLOR_PURPLE
public static final int COLOR_PURPLE

See Also:
Constant Field Values

Field Detail

1236

Overview (Codename One API)


COLOR_RED
public static final int COLOR_RED

See Also:
Constant Field Values
COLOR_SILVER
public static final int COLOR_SILVER

See Also:
Constant Field Values
COLOR_TEAL
public static final int COLOR_TEAL

See Also:
Constant Field Values
COLOR_WHITE
public static final int COLOR_WHITE

See Also:
Constant Field Values
COLOR_YELLOW
public static final int COLOR_YELLOW

See Also:
Constant Field Values
COLOR_ORANGE
public static final int COLOR_ORANGE

See Also:
Constant Field Values

Constructor Detail
HTMLElement
protected HTMLElement()

Constructs and HTMLElement without specifying a name. This can be used by


subclasses that do not require name assigments.
HTMLElement
public HTMLElement(String tagName)

Constructor for HTMLElement. This mostly sets up the element's ID.


Parameters:
tagName - The HTMLElement's name
HTMLElement
public HTMLElement(String tagName,
boolean isTextElement)

Constructor for HTMLElement. This mostly sets up the element's ID.


Parameters:
tagName - The HTMLElement's name, or the text for text elements
isTextElement - true for a text element, false otherwise

Method Detail

Field Detail

1237

Overview (Codename One API)


addChild
public void addChild(Element childElement)

Description copied from class: Element


Adds the specified Element as a child to this element. If the specified element was
found to be unsupported (i.e. it's ID is TAG_UNSUPPORTED, it is not added.
Overrides:
addChild in class Element
Parameters:
childElement - The child element
setAttribute
public int setAttribute(String attribute,
String value)

Adds the specified attribute and value to this Element if it is supported for the
Element and has a valid value.
Overrides:
setAttribute in class Element
Parameters:
attribute - The attribute's name
value - The attribute's value
Returns:
a positive error code or -1 if attribute is supported and valid
setAttributeById
public void setAttributeById(int attrId,
String value)

Allows setting an attribute with an attribute id


Parameters:
attrId - The attribute Id (One of the ATTR_ constants)
value - The value to set to the attribute
removeAttributeById
public void removeAttributeById(int attrId)

Removes the specified attribute


Parameters:
attrId - The attribute Id (One of the ATTR_ constants)
getSupportedAttributesList
public String getSupportedAttributesList()

Returns a list of supported attributes for this tag. Note that the list does not include
the core attributes that are supported on almost all tags
Returns:
a list of supported attributes for this tag
getTagName
public String getTagName()

Returns this HTMLElement's tag name


Overrides:
getTagName in class Element
Returns:
the HTMLElement's tag name
getTagId
public int getTagId()

Returns this HTMLElement's ID


Returns:
the HTMLELement's ID

Method Detail

1238

Overview (Codename One API)


setTagId
protected void setTagId(int tagId)

Sets this HTMLElement's ID


Parameters:
tagId - The tag ID to set, one of the TAG_* constants (Not to be confused
with the id attribute)
getFirstChildByTagId
public HTMLElement getFirstChildByTagId(int tagId)

Returns an HTMLElement's child by a tag ID (One of the TAG_* constants)


Parameters:
tagId - The child's tag ID, one of the TAG_* constants (Not to be confused
with the id attribute)
Returns:
the first child with the specified ID, or null if not found
getAttributeById
public String getAttributeById(int id)

Returns an HTMLElement's attribute by the attribute's ID (One of the ATTR_*


constants)
Parameters:
id - The attribute's ID
Returns:
the attribute with the specified ID, or null if not found
toString
public String toString()

{Returns a printable string representing this element}


Overrides:
toString in class Element
Returns:
a printable string representing this element
getAttributeName
public String getAttributeName(Integer attrKey)

Returns the attribute name of the requested attribute


Parameters:
attrKey - The attribute key, which is typically an Integer object made of its int
attrId
Returns:
the attribute name of the requested attribute
getAttribute
public String getAttribute(String name)

Description copied from class: Element


Returns the attribute value by its name (or null if it wasn't defined for this element)
Overrides:
getAttribute in class Element
Parameters:
name - The attribute id
Returns:
the attribute value by its name (or null if it wasn't defined for this element)
removeChildAt
public void removeChildAt(int index)

{Removes the child at the given index}


Overrides:
removeChildAt in class Element
Parameters:

Method Detail

1239

Overview (Codename One API)


index - The child's index
getDescendantsByTagId
public Vector getDescendantsByTagId(int tagId,
int depth)

Returns all descendants with the specified tag id


Parameters:
tagId - The tag ID to look for, one of the TAG_* constants (Not to be
confused with the id attribute)
depth - The search depth (1 - children, 2 - grandchildren ....
DEPTH_INFINITE - for all descendants)
Returns:
A vector containing descendants with the specified tag id
getDescendantsByTagId
public Vector getDescendantsByTagId(int tagId)

Returns all descendants with the specified tag id


Parameters:
tagId - The tag ID to look for, one of the TAG_* constants (Not to be
confused with the id attribute)
Returns:
A vector containing descendants with the specified tag id

Method Detail

1240

Overview (Codename One API)


com.codename1.ui.html

Class HTMLComponent
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.html.HTMLComponent
All Implemented Interfaces:
Animation, ActionListener, StyleListener, IOCallback, Iterable<Component>
Deprecated.
this component includes some customizability advantages but its probably better for 99% of the use
cases to use the WebBrowser Component from the Components package. That component works
with the native browser when applicable which is a far superior approach.
public class
extends Container
implements ActionListener, IOCallback

HTMLComponent is a Codename One Component that renders HTML documents that conform to the
XHTML Mobile Profile 1.0

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
HTMLComponent()

Deprecated.
Constructs HTMLComponent
HTMLComponent(DocumentRequestHandler handler)

Deprecated.
Constructs HTMLComponent

Method Summary
Modifier and Type

Method and Description


actionPerformed(ActionEvent evt)

void

Deprecated.
{Invoked when an action occurred on a component}
addCharEntitiesRange(String[] symbols, int startcode)

void

Deprecated.
Adds the given symbols array to the user defined char entities
table with the startcode provided as the code of the first string,
startcode+1 for the second etc.
addCharEntity(String symbol, int code)

void

Class HTMLComponent

Deprecated.
Adds the given symbol and code to the user defined char entities
table.

1241

Overview (Codename One API)


addFont(String fontKey, Font font)
static void

Deprecated.
Sets the given Codename One font for use with
HTMLComponents.
addSpecialKey(String specialKeyName, int specialKeyCode)

static void

Deprecated.
Adds support for a special key to be used as an accesskey.
animate()

boolean

Deprecated.
Allows the animation to reduce "repaint" calls when it returns false.
cancel()

void

Deprecated.
Cancels the loading of the current page
deinitialize()

protected void

Deprecated.
If the component is taken off for any reason, makes sure access
keys are not active
getDocumentInfo()

DocumentInfo

Deprecated.
Returns the DocumentInfo that currently represents the document
loaded/shown
getDOM()

HTMLElement

Deprecated.
Returns the DOM representing this document
getHTMLCallback()

HTMLCallback

Deprecated.
Returns the HTMLCallback that is set on this HTMLComponent
getPageStatus()

int

Deprecated.
Returns the page status
getPageURL()

String

Deprecated.
Returns the page's URL
getPropertyNames()

String[]

Deprecated.
A component may expose mutable property names for a UI
designer to manipulate, this API is designed for usage internally
by the GUI builder code
getPropertyTypes()

Class[]

Deprecated.
Matches the property names method (see that method for further
details).
getPropertyValue(String name)

Object

Deprecated.
Returns the current value of the property name, this method is
used by the GUI builder
getRequestHandler()

DocumentRequestHandler

Deprecated.
Returns the document request handler
getTitle()

String

Deprecated.
Returns the HTML page's title as described in its TITLE tag
initComponent()

protected void

Deprecated.
Overrides initComponent to add the key listeners to the access
keys when the component is first added to the form/displayed This
is useful when the component is added only after the page was
read
isEventsEnabled()

boolean

Method Summary

Deprecated.
Returns the current status of the events enabled flag

1242

Overview (Codename One API)


isSupressExceptions()
boolean

Deprecated.
layoutContainer()

void

Deprecated.
{Performs the layout of the container if a layout is necessary}
refreshDOM()

void

Deprecated.
Refreshes the current DOM so it any changes done after loading
will be rendered.
scrollPages(int pages, boolean animate)

void

Deprecated.
Scrolls the HTMLComponent several pages forward/backward.
scrollPixels(int pixels, boolean animate)

void

Deprecated.
Scrolls the HTMLComponent several pixels forward/backward.
scrollToElement(HTMLElement element, boolean animate)

void

Deprecated.
Scrolls the HTMLComponent to the specified element
setAutoFocusOnFirstLink(boolean autoFocus)

void

Deprecated.
Determines whether to auto-focus on the first link after page load
Note that focusing will happen only if the link is within a visible
range (no scrolling is performed since this is rarely a wanted
behaviour in this case)
setBodyText(String htmlText)

void

Deprecated.
Sets the given string containing HTML code as this
HTMLComponent's body
setBodyText(String htmlText, String encoding)

boolean

Deprecated.
Sets the given string containing HTML code as this
HTMLComponent's body.
setCSSSupportedMediaTypes(String[] supportedMediaTypes)

static void

Deprecated.
Sets the supported CSS media types to the given strings.
setDefaultFont(String fontKey, Font font)

void

Deprecated.
Sets the default font for this HTMLComponent
setDOM(HTMLElement dom)

void

Deprecated.
Sets this HTMLComponent to render the document in the
specified DOM.
setDOM(HTMLElement dom, String baseURL)

void

Deprecated.
Sets this HTMLComponent to render the document in the
specified DOM
setEventsEnabled(boolean enabled)

void

Deprecated.
Sets whether the active controls in the HTML will trigger events,
and whether the DOM will change dynamically due to user input.
setHTML(String htmlText, String encoding, String title,
boolean isFullHTML)

boolean

Deprecated.
Sets the given string containing HTML code either as this
HTMLComponent's body or as the full HTML.
setHTMLCallback(HTMLCallback callback)

void

Deprecated.
Sets an HTMLCallback to listen to this HTMLCOmponent

void

setIgnoreCSS(boolean ignore)

Deprecated.

Method Summary

1243

Overview (Codename One API)


Sets whether this HTMLComponent will ignore all CSS.directives.
setMaxThreads(int threadsNum)
static void

Deprecated.
Sets the maximum number of threads to use for image download
setPage(String pageURL)

Deprecated.
Sets this HTMLComponent to render the document in the
specified URL

void

setPageStyle(Style pageStyle)

Deprecated.
Sets the style of the page, allowing for example to set
transparency to the main page.

void

setPageUIID(String pageUIID)

Deprecated.
Sets the UIID of the page (the internal container) This applies not
only to the current page, but rather to all pages created with this
HTMLComponent instance.

void

setParser(HTMLParser parser)

Deprecated.
Sets a custom HTMLParser for this HTMLComponent By default,
a new HTMLParser instance is created for each
HTMLComponent, use this method if you have a custom parser.

void

setPropertyValue(String name, Object value)


String

Deprecated.
Sets a new value to the given property, returns an error message
if failed and null if successful.
setRequestHandler(DocumentRequestHandler handler)

Deprecated.
Changes the document request handler

void

setShowImages(boolean show)

Deprecated.
Sets whether this HTMLComponent will download and show
linked images or not

void

setSupressExceptions(boolean supressExceptions)

Deprecated.

void

streamReady(InputStream is, DocumentInfo docInfo)

Deprecated.
This method should be called only by
AsyncDocumentRequestHandler implementations after an async
fetch of a document

void

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased, morph,
morphAndWait, paint, paintComponentBackground, paintGlass, paramString,
pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Container

1244

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
HTMLComponent
public HTMLComponent()

Deprecated.
Constructs HTMLComponent
HTMLComponent
public HTMLComponent(DocumentRequestHandler handler)

Deprecated.
Constructs HTMLComponent
Parameters:

Methods inherited from class com.codename1.ui.Component

1245

Overview (Codename One API)


handler

- The HttpRequestHandler to which all requests for links will be sent

Method Detail
addFont
public static void addFont(String fontKey,
Font font)

Deprecated.
Sets the given Codename One font for use with HTMLComponents. The font key can
contain information about the following attributes: * The font family - i.e. Arial, Times
New Roman etc. * The font size - in pixels (i.e. 12, 14 etc.) * The font style - bold,
italic or both (no need to specify plain) * The font tag assignments - if this font should
be used for any HTML specific tags they should be specified - i.e. h1, kbd etc. The
key is just a concatenation of all attributes seperated with a dot. Examples for valid
keys: arial.12 - Describes a plain font from the arial family in size 12 arial.16.bold - A
bold arial font in size 16 courier.italic.bold.20 - A bold and italic courier font in size 20
arial.20.h1 - A plain arial font, size 20, that should be used for contents of the H1 tag
code.kbd.samp - A font that should be used for the CODE, KBD and SAMP tags Note
that the order of the attributes is not important and also that the case is ignored. This
means that arial.12.bold.italic.h3 is equivalent to itALIc.H3.arial.BOLD.12 Also note
that while you do not have to provide all the info for the font, but the info helps the
rendering engine to reuse fonts when suitable. For example, if you have a 16px arial
bold font which you want to use for H2, you can simply add it as "h2", but if you add it
as "arial.16.bold.h2" then if the current font is arial.16 and the renderer encounters a
B tag, it will know it can use the font you added as the bold counterpart of the current
font. When adding system fonts there is no need to describe the font, the usage of
setFont with system fonts is usually just to assign them for tags. The rendering
engine knows to derive bold/italic/bigger/smaller fonts from other system fonts
(default or tag fonts) even if not added.
Parameters:
fontKey - The font key in the format described above
font - The actual Codename One font object
setParser
public void setParser(HTMLParser parser)

Deprecated.
Sets a custom HTMLParser for this HTMLComponent By default, a new HTMLParser
instance is created for each HTMLComponent, use this method if you have a custom
parser.
Parameters:
parser - The HTMLParser to use
addCharEntity
public void addCharEntity(String symbol,
int code)

Deprecated.
Adds the given symbol and code to the user defined char entities table. Symbols do
not need to include leading & and trailing ; - these will be trimmed if given as the
symbol
Parameters:
symbol - The symbol to add
code - The symbol's code
addSpecialKey
public static void addSpecialKey(String specialKeyName,
int specialKeyCode)

Deprecated.
Adds support for a special key to be used as an accesskey. The CSS property
-wap-accesskey supports special keys, for example "phone-send" that may have
different key codes per device. This method allows pairing between such keys to their

Constructor Detail

1246

Overview (Codename One API)


respective key codes. Note that these keys are valid only for -wap-aceesskey in CSS
files, and not for the XHTML accesskey attribute.
Parameters:
specialKeyName - The name of the special key as denoted in CSS files
specialKeyCode - The special key code
addCharEntitiesRange
public void addCharEntitiesRange(String[] symbols,
int startcode)

Deprecated.
Adds the given symbols array to the user defined char entities table with the
startcode provided as the code of the first string, startcode+1 for the second etc.
Some strings in the symbols array may be null thus skipping code numbers.
Parameters:
symbols - The symbols to add
startcode - The symbol's code
setMaxThreads
public static void setMaxThreads(int threadsNum)

Deprecated.
Sets the maximum number of threads to use for image download
Parameters:
threadsNum - the maximum number of threads to use for image download
setCSSSupportedMediaTypes
public static void setCSSSupportedMediaTypes(String[] supportedMediaTypes)

Deprecated.
Sets the supported CSS media types to the given strings. Usually the default media
types ("all","handheld") should be suitable, but in case this runs on a device that
matches another profile, the developer can specify it here.
Parameters:
supportedMediaTypes - A string array containing the media types that should
be supported
getRequestHandler
public DocumentRequestHandler getRequestHandler()

Deprecated.
Returns the document request handler
Returns:
the document request handler
setRequestHandler
public void setRequestHandler(DocumentRequestHandler handler)

Deprecated.
Changes the document request handler
Parameters:
handler - the new document request handler
getDocumentInfo
public DocumentInfo getDocumentInfo()

Deprecated.
Returns the DocumentInfo that currently represents the document loaded/shown
Returns:
the DocumentInfo that currently represents the document loaded/shown
setHTMLCallback
public void setHTMLCallback(HTMLCallback callback)

Deprecated.
Sets an HTMLCallback to listen to this HTMLCOmponent
Parameters:

Method Detail

1247

Overview (Codename One API)


callback - The HTMLCallback that will receive events
getHTMLCallback
public HTMLCallback getHTMLCallback()

Deprecated.
Returns the HTMLCallback that is set on this HTMLComponent
Returns:
the HTMLCallback that is set on this HTMLComponent or null if none
setDefaultFont
public void setDefaultFont(String fontKey,
Font font)

Deprecated.
Sets the default font for this HTMLComponent
Parameters:
fontKey - The font key in the format described in setFont (Can be null for
default font, but it is recommended to add a descriptive key if this is a bitmap
font to enable the font engine to use it in other cases as well)
font - The actual Codename One font object
setShowImages
public void setShowImages(boolean show)

Deprecated.
Sets whether this HTMLComponent will download and show linked images or not
Parameters:
show - true to show images, false otherwise
setIgnoreCSS
public void setIgnoreCSS(boolean ignore)

Deprecated.
Sets whether this HTMLComponent will ignore all CSS.directives. This includes
external CSS files (which won't be downloaded), embedded CSS segmentsand style
tags and attributes. By default this is false.
Parameters:
ignore - true to ignore CSS directives, false otherwise
scrollPixels
public void scrollPixels(int pixels,
boolean animate)

Deprecated.
Scrolls the HTMLComponent several pixels forward/backward.
Parameters:
pixels - The number of pixels to scroll (positive for forward and negative for
backward)
animate - true to animate the scrolling, false otherwise
scrollPages
public void scrollPages(int pages,
boolean animate)

Deprecated.
Scrolls the HTMLComponent several pages forward/backward. TO scroll to the start
or end of the document, one can provide a very big number.
Parameters:
pages - The number of pages to scroll (positive for forward and negative for
backward)
animate - true to animate the scrolling, false otherwise
scrollToElement
public void scrollToElement(HTMLElement element,
boolean animate)

Method Detail

1248

Overview (Codename One API)


Deprecated.
Scrolls the HTMLComponent to the specified element
Parameters:
element - The element to scroll to (must be contained in the document)
animate - true to animate the scrolling, false otherwise
Throws:
IllegalArgumentException - if the element is not contained in the current
document.
setBodyText
public void setBodyText(String htmlText)

Deprecated.
Sets the given string containing HTML code as this HTMLComponent's body
Parameters:
htmlText - The HTML body to set
setBodyText
public boolean setBodyText(String htmlText,
String encoding)

Deprecated.
Sets the given string containing HTML code as this HTMLComponent's body. The
string is read using the specified encoding. If the encoding is not supported it will be
read without encoding
Parameters:
htmlText - The HTML body to set
encoding - The encoding to use when reading the HTML i.e. UTF8,
ISO-8859-1 etc.
Returns:
true if the encoding succeeded, false otherwise
setHTML
public boolean setHTML(String htmlText,
String encoding,
String title,
boolean isFullHTML)

Deprecated.
Sets the given string containing HTML code either as this HTMLComponent's body or
as the full HTML. The string is read using the specified encoding. If the encoding is
not supported it will be read without encoding
Parameters:
htmlText - The HTML to set
encoding - The encoding to use when reading the HTML i.e. UTF8,
ISO-8859-1 etc.
title - The HTML title, or null if none (Used only when isFullHTML is false)
isFullHTML - true if this is a full HTML document (with html/body tags), false if
this HTML should be used as the HTMLComponent's body
Returns:
true if the encoding succeeded, false otherwise
cancel
public void cancel()

Deprecated.
Cancels the loading of the current page
setPage
public void setPage(String pageURL)

Deprecated.
Sets this HTMLComponent to render the document in the specified URL
Parameters:
pageURL - The URL containing the HTML document

Method Detail

1249

Overview (Codename One API)


setPageStyle
public void setPageStyle(Style pageStyle)

Deprecated.
Sets the style of the page, allowing for example to set transparency to the main page.
This applies not only to the current page, but rather to all pages created with this
HTMLComponent instance. If both a UIID and a pageStyle were set, the style
overrides the UIID.
Parameters:
pageStyle - The style to set to the page
setPageUIID
public void setPageUIID(String pageUIID)

Deprecated.
Sets the UIID of the page (the internal container) This applies not only to the current
page, but rather to all pages created with this HTMLComponent instance. If both a
UIID and a pageStyle were set, the style overrides the UIID.
Parameters:
pageUIID - The UIID that should be applied to the page
streamReady
public void streamReady(InputStream is,
DocumentInfo docInfo)

Deprecated.
This method should be called only by AsyncDocumentRequestHandler
implementations after an async fetch of a document
Specified by:
streamReady in interface IOCallback
Parameters:
is - The InputStream of the document
docInfo - The document info
setDOM
public void setDOM(HTMLElement dom)

Deprecated.
Sets this HTMLComponent to render the document in the specified DOM. Note that
relative links if any will be disabled. To allow relative links with DOM use
setDOM(HTMLElement dom,String baseURL)
Parameters:
dom - An HTMLElement representing the root of the HTML document
Throws:
IllegalArgumentException - if the HTMLElement supplied is not an 'html' tag
setDOM
public void setDOM(HTMLElement dom,
String baseURL)

Deprecated.
Sets this HTMLComponent to render the document in the specified DOM
Parameters:
dom - An HTMLElement representing the root of the HTML document
baseURL - The base URL for this DOM (Necessary if document references
relative links)
Throws:
IllegalArgumentException - if the HTMLElement supplied is not an 'html' tag
getDOM
public HTMLElement getDOM()

Deprecated.
Returns the DOM representing this document
Returns:
An HTMLElement representing the entire current HTML document

Method Detail

1250

Overview (Codename One API)


Throws:
IllegalStateException

- if the page is still loading

refreshDOM
public void refreshDOM()

Deprecated.
Refreshes the current DOM so it any changes done after loading will be rendered.
setEventsEnabled
public void setEventsEnabled(boolean enabled)

Deprecated.
Sets whether the active controls in the HTML will trigger events, and whether the
DOM will change dynamically due to user input. If so the events are dispatched via
HTMLCallback methods actionPerformed, focusGained/Lost, selectionChanged and
dataChanged The default is false in order not to add more overhead if these are not
needed.
Parameters:
enabled - true to enable event dispatching, false otherwise
isEventsEnabled
public boolean isEventsEnabled()

Deprecated.
Returns the current status of the events enabled flag
Returns:
true if events are enabled, false if not
setAutoFocusOnFirstLink
public void setAutoFocusOnFirstLink(boolean autoFocus)

Deprecated.
Determines whether to auto-focus on the first link after page load Note that focusing
will happen only if the link is within a visible range (no scrolling is performed since this
is rarely a wanted behaviour in this case)
Parameters:
autoFocus - true to auto-focus, false otherwise
animate
public boolean animate()

Deprecated.
Description copied from class: Component
Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
getTitle
public String getTitle()

Deprecated.
Returns the HTML page's title as described in its TITLE tag
Returns:
the HTML page's title as described in its TITLE tag
getPageURL
public String getPageURL()

Deprecated.
Returns the page's URL
Returns:

Method Detail

1251

Overview (Codename One API)


the current page's URL
getPageStatus
public int getPageStatus()

Deprecated.
Returns the page status
Returns:
the page status (One of the STATUS_* constants in HTMLCallback)
initComponent
protected void initComponent()

Deprecated.
Overrides initComponent to add the key listeners to the access keys when the
component is first added to the form/displayed This is useful when the component is
added only after the page was read
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Deprecated.
If the component is taken off for any reason, makes sure access keys are not active
Overrides:
deinitialize in class Component
layoutContainer
public void layoutContainer()

Deprecated.
{Performs the layout of the container if a layout is necessary}
Overrides:
layoutContainer in class Container
actionPerformed
public void actionPerformed(ActionEvent evt)

Deprecated.
{Invoked when an action occurred on a component}
Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - event object describing the source of the action as well as its trigger
getPropertyNames
public String[] getPropertyNames()

Deprecated.
A component may expose mutable property names for a UI designer to manipulate,
this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Deprecated.
Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties

Method Detail

1252

Overview (Codename One API)


getPropertyValue
public Object getPropertyValue(String name)

Deprecated.
Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Deprecated.
Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
isSupressExceptions
public boolean isSupressExceptions()

Deprecated.
Returns:
the supressExceptions
setSupressExceptions
public void setSupressExceptions(boolean supressExceptions)

Deprecated.
Parameters:
supressExceptions

Method Detail

- the supressExceptions to set

1253

Overview (Codename One API)


com.codename1.ui.html

Interface HTMLCallback
All Superinterfaces:
ParserCallback
All Known Implementing Classes:
Ads, DefaultHTMLCallback

public interface
extends ParserCallback

HTMLCallback is used to dispatch document lifecycle events. Most methods are called on the EDT
thread, except parsingError, getAutoComplete and getLinkProperties

Field Summary
Modifier
and Type
static
int
static
int
static
int

Field and Description


ERROR_CONNECTING

Error code denoting that a connection to the resource provider/server could not
be made
ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
ERROR_CSS_NO_BASE_URL

static
int

static
int
static
int
static
int
static
int

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not
via setPage) In this case the return value of parsingError is not considered parsing continues and the resource at the URL (CSS file/image) is ignored
ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found
ERROR_IMAGE_BAD_FORMAT

Error code denoting that an image referenced from the HTML could not be
loaded
ERROR_IMAGE_NOT_FOUND

Error code denoting that an image referenced from the HTML was not found
ERROR_INVALID_TAG_HIERARCHY

Error code denoting that a tag contains tags it shouldn't, or that a tag doesn't
have the parent tag it should have
ERROR_NO_BASE_URL

static
int

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not
via setPage) In this case the return value of parsingError is not considered parsing continues and the resource at the URL (CSS file/image) is ignored

static
int

FIELD_PASSWORD

static
int

FIELD_TEXT

static
int

LINK_FORBIDDEN

static
int

LINK_REGULAR

static
int

LINK_VISTED

Interface HTMLCallback

A password field
A text field
A forbidden link (not to be rendered as a link but as a regular label)
A regular link
A link that was visited before

1254

Overview (Codename One API)


static
int

STATUS_CANCELLED

static
int

STATUS_COMPLETED

static
int

STATUS_CONNECTED

The page loading was cancelled before it could be completed


The page and all of its referenced images and CSS files were loaded completely
The stream was received
STATUS_DISPLAYED

static
int

The page was displayed on screen - but at this stage some images and CSS
files may still be loading in the background
STATUS_ERROR

static
int

The page couldn't load completely because of parsing errors


STATUS_NONE

static
int

This is returned in the page status if no page has been set to the
HTMLComponent

static
int

STATUS_PARSED

static
int

STATUS_REDIRECTED

static
int

STATUS_REQUESTED

The page was parsed


The page was redirected to another URL
The page was requested from the request handler

Fields inherited from


interface com.codename1.xml.ParserCallback
ERROR_ATTIBUTE_VALUE_INVALID, ERROR_ATTRIBUTE_NOT_SUPPORTED,
ERROR_ENCODING, ERROR_MULTIPLE_ROOTS, ERROR_NO_CLOSE_TAG, ERROR_NO_ROOTS,
ERROR_TAG_NOT_SUPPORTED, ERROR_UNEXPECTED_CHARACTER,
ERROR_UNEXPECTED_TAG_CLOSING, ERROR_UNRECOGNIZED_CHAR_ENTITY

Method Summary
Modifier
and Type
void

void

String

Method and Description


actionPerformed(ActionEvent evt, HTMLComponent htmlC,
HTMLElement element)

Called whenever an ActionEvent is triggered in one of the controls in the


HTMLComponent For example, button press, checkbox/radiobutton check etc.
dataChanged(int type, int index, HTMLComponent htmlC,
TextField textField, HTMLElement element)

Called when the user types in a TextField inside the HTMLComponent This
method will be called only if HTMLComponent.isEventsEnabled() is true
fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL,
String id, String value, int type, String errorMsg)

Called whenever a field is submitted to a form.


focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)
void

Called when one of the controls in the HTMLComponent obtained focus This
method will be called only if HTMLComponent.isEventsEnabled() is true
focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)

void

Called when one of the controls in the HTMLComponent lost focus This method
will be called only if HTMLComponent.isEventsEnabled() is true
getAutoComplete(HTMLComponent htmlC, String actionURL, String id)

String

Called on form creation and enabled implementations of this method to return a


value to preset in a form field.
getLinkProperties(HTMLComponent htmlC, String url)

int

boolean
void

Field Summary

Returns properties about the given link to indicate to HTMLComponent how to


render it Note that this method is always called NOT on the EDT thread.
linkClicked(HTMLComponent htmlC, String url)

Called when a link is clicked.


pageStatusChanged(HTMLComponent htmlC, int status, String url)

Called when the page status has been changed

1255

Overview (Codename One API)


boolean

parsingError(int errorId, String tag, String attribute, String value,


String description)

Called when encountering an error while parsing the HTML document.


selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC,
List list, HTMLElement element)

Called when the user selects an item in a List inside the HTMLComponent Note:
Selection is traversing through the items - once the user has actually decided, an
ActionEvent will be sent as well This method will be called only if
HTMLComponent.isEventsEnabled() is true

void

titleUpdated(HTMLComponent htmlC, String title)

void

Called when the page's title is updated

Methods inherited from


interface com.codename1.xml.ParserCallback
parsingError

Field Detail
ERROR_CONNECTING
static final int ERROR_CONNECTING

Error code denoting that a connection to the resource provider/server could not be
made
See Also:
Constant Field Values
ERROR_IMAGE_NOT_FOUND
static final int ERROR_IMAGE_NOT_FOUND

Error code denoting that an image referenced from the HTML was not found
See Also:
Constant Field Values
ERROR_IMAGE_BAD_FORMAT
static final int ERROR_IMAGE_BAD_FORMAT

Error code denoting that an image referenced from the HTML could not be loaded
See Also:
Constant Field Values
ERROR_NO_BASE_URL
static final int ERROR_NO_BASE_URL

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not via
setPage) In this case the return value of parsingError is not considered - parsing
continues and the resource at the URL (CSS file/image) is ignored
See Also:
Constant Field Values
ERROR_INVALID_TAG_HIERARCHY
static final int ERROR_INVALID_TAG_HIERARCHY

Error code denoting that a tag contains tags it shouldn't, or that a tag doesn't have
the parent tag it should have
See Also:
Constant Field Values

Method Summary

1256

Overview (Codename One API)


STATUS_NONE
static final int STATUS_NONE

This is returned in the page status if no page has been set to the HTMLComponent
See Also:
Constant Field Values
STATUS_ERROR
static final int STATUS_ERROR

The page couldn't load completely because of parsing errors


See Also:
Constant Field Values
STATUS_CANCELLED
static final int STATUS_CANCELLED

The page loading was cancelled before it could be completed


See Also:
Constant Field Values
STATUS_REQUESTED
static final int STATUS_REQUESTED

The page was requested from the request handler


See Also:
Constant Field Values
STATUS_CONNECTED
static final int STATUS_CONNECTED

The stream was received


See Also:
Constant Field Values
STATUS_PARSED
static final int STATUS_PARSED

The page was parsed


See Also:
Constant Field Values
STATUS_DISPLAYED
static final int STATUS_DISPLAYED

The page was displayed on screen - but at this stage some images and CSS files
may still be loading in the background
See Also:
Constant Field Values
STATUS_COMPLETED
static final int STATUS_COMPLETED

The page and all of its referenced images and CSS files were loaded completely
See Also:
Constant Field Values
STATUS_REDIRECTED
static final int STATUS_REDIRECTED

The page was redirected to another URL


See Also:
Constant Field Values

Field Detail

1257

Overview (Codename One API)


FIELD_TEXT
static final int FIELD_TEXT

A text field
See Also:
Constant Field Values
FIELD_PASSWORD
static final int FIELD_PASSWORD

A password field
See Also:
Constant Field Values
LINK_REGULAR
static final int LINK_REGULAR

A regular link
See Also:
Constant Field Values
LINK_VISTED
static final int LINK_VISTED

A link that was visited before


See Also:
Constant Field Values
LINK_FORBIDDEN
static final int LINK_FORBIDDEN

A forbidden link (not to be rendered as a link but as a regular label)


See Also:
Constant Field Values
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED
static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
See Also:
Constant Field Values
ERROR_CSS_ATTIBUTE_VALUE_INVALID
static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
See Also:
Constant Field Values
ERROR_CSS_NOT_FOUND
static final int ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found
See Also:
Constant Field Values
ERROR_CSS_NO_BASE_URL
static final int ERROR_CSS_NO_BASE_URL

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not via
setPage) In this case the return value of parsingError is not considered - parsing
continues and the resource at the URL (CSS file/image) is ignored
See Also:

Field Detail

1258

Overview (Codename One API)


Constant Field Values

Method Detail
titleUpdated
void titleUpdated(HTMLComponent htmlC,
String title)

Called when the page's title is updated


Parameters:
htmlC - The HTMLComponent that triggered the event
title - The new title
pageStatusChanged
void pageStatusChanged(HTMLComponent htmlC,
int status,
String url)

Called when the page status has been changed


Parameters:
htmlC - The HTMLComponent in which the status change occured
status - The new status, one of the STATUS_* constants
url - The URL of the page
fieldSubmitted
String fieldSubmitted(HTMLComponent htmlC,
TextArea ta,
String actionURL,
String id,
String value,
int type,
String errorMsg)

Called whenever a field is submitted to a form. This can be used to perform sanity
checks and/or to store values for auto complete.
Parameters:
htmlC - The HTMLComponent in which this event occured
ta - The TextArea/TextField of this field
actionURL - The action URL of the form
id - The ID of the field
value - The value entered
type - The type of the field, one of the FIELD_* constants
errorMsg - The error message if any error occured (i.e. input validation error)
or null if no error occured
Returns:
The string to submit to the form (Should return value if nothing changed)
getAutoComplete
String getAutoComplete(HTMLComponent htmlC,
String actionURL,
String id)

Called on form creation and enabled implementations of this method to return a value
to preset in a form field. This can be used to auto complete previously entered value
Note that this method is always called NOT on the EDT thread.
Parameters:
htmlC - The HTMLComponent in which this event occured
actionURL - The action URL of the form
id - The ID of the field
Returns:
The string to place in the indicated field
getLinkProperties
int getLinkProperties(HTMLComponent htmlC,
String url)

Method Detail

1259

Overview (Codename One API)


Returns properties about the given link to indicate to HTMLComponent how to render
it Note that this method is always called NOT on the EDT thread.
Parameters:
htmlC - The HTMLComponent
url - The Link URL
Returns:
LINK_REGULAR or LINK_VISITED or LINK_FORBIDDEN or a mask of
those
linkClicked
boolean linkClicked(HTMLComponent htmlC,
String url)

Called when a link is clicked. This can be used to process links that needs
additional/alternate handling than fetching an HTML.
Parameters:
htmlC - The HTMLComponent
url - The Link URL
Returns:
true if regular link processing should continue, false otherwise
actionPerformed
void actionPerformed(ActionEvent evt,
HTMLComponent htmlC,
HTMLElement element)

Called whenever an ActionEvent is triggered in one of the controls in the


HTMLComponent For example, button press, checkbox/radiobutton check etc. This
method will be called only if HTMLComponent.isEventsEnabled() is true
Parameters:
evt - The event triggered, the component can be extracted using getSource
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
focusGained
void focusGained(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

Called when one of the controls in the HTMLComponent obtained focus This method
will be called only if HTMLComponent.isEventsEnabled() is true
Parameters:
cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
focusLost
void focusLost(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

Called when one of the controls in the HTMLComponent lost focus This method will
be called only if HTMLComponent.isEventsEnabled() is true
Parameters:
cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
selectionChanged
void selectionChanged(int oldSelected,
int newSelected,
HTMLComponent htmlC,
List list,
HTMLElement element)

Method Detail

1260

Overview (Codename One API)


Called when the user selects an item in a List inside the HTMLComponent Note:
Selection is traversing through the items - once the user has actually decided, an
ActionEvent will be sent as well This method will be called only if
HTMLComponent.isEventsEnabled() is true
Parameters:
oldSelected - old selected index in list model
newSelected - new selected index in list model
htmlC - The HTMLComponent
list - The list that triggered the event (Usually a ComboBox but not always)
element - The element associated with the component that triggered the
event (Should be TAG_SELECT)
dataChanged
void dataChanged(int type,
int index,
HTMLComponent htmlC,
TextField textField,
HTMLElement element)

Called when the user types in a TextField inside the HTMLComponent This method
will be called only if HTMLComponent.isEventsEnabled() is true
Parameters:
type - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model
htmlC - The HTMLComponent
textField - The TextField that triggerd the event
element - The element associated with the component that triggered the
event (Should be TAG_INPUT with type text/password)
parsingError
boolean parsingError(int errorId,
String tag,
String attribute,
String value,
String description)

Called when encountering an error while parsing the HTML document. When
implementing this, the developer should return true if the error should be ignored and
the document needs to be further parsed, or false to stop parsing and issue an error
to the user Note that this method is always called NOT on the EDT thread.
Parameters:
errorId - The error ID, one of the ERROR_* constants
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)
value - The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Returns:
true to continue parsing, false to stop

Method Detail

1261

Overview (Codename One API)


com.codename1.ui.html

Interface DocumentRequestHandler
All Known Subinterfaces:
AsyncDocumentRequestHandler
All Known Implementing Classes:
AsyncDocumentRequestHandlerImpl, DefaultDocumentRequestHandler

public interface

The DocumentRequestHandler interface should be implemented so it returns documents in requested


URLs.
Concrete classes should handle in its single method all necessary networking and IO issues.
Implementations of this interface are used by HTMLComponent to obtain links and form results

Method Summary
Modifier and
Type

Method and Description


resourceRequested(DocumentInfo docInfo)

InputStream

Implementations should return the document in the requested url as an


InputStream This is triggered only for the main document requested and not
for its resources.

Method Detail
resourceRequested
InputStream resourceRequested(DocumentInfo docInfo)

Implementations should return the document in the requested url as an InputStream


This is triggered only for the main document requested and not for its resources.
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
Returns:
the document at the URL as an InputStream

Interface DocumentRequestHandler

1262

Overview (Codename One API)


com.codename1.ui.html

Class DocumentInfo
java.lang.Object

com.codename1.ui.html.DocumentInfo

public class
extends Object

DocumentInfo holds important information about a document that is loading. This class is constructed
internally by HTMLComponent and HTMLForm and is sent to the RequestHandler. It is intended for
the RequestHandler to use and update (For example update encoding according to the HTTP
response, update URL in case of a redirect etc.)

Field Summary
Modifier and Type
static String
static String
static int
static int
static int

Field and Description


ENCODING_ISO

ISO-8859-1 encoding, the default one


ENCODING_UTF8

UTF8 encoding, very common


TYPE_CSS

Indicates that the request is for a CSS file


TYPE_HTML

Indicates that the request is for a page


TYPE_IMAGE

Indicates that the request is for an image

Method Summary
Modifier
and Type
String
String

Method and Description


getBaseURL()

Returns the base URL for this document


getEncoding()

Returns a string describing the document's encoding


getExpectedContentType()

int

String
String
String
boolean
void
static
void

Returns the expected content type, one of TYPE_HTML, TYPE_IMAGE or


TYPE_CSS
getFullUrl()

Returns the full url string including parameters in GET request


getParams()

Returns the request paramter as an percentage-encoded string


getUrl()

Returns the absolute URL associated with this DocumentInfo object


isPostRequest()

Returns whether this document request is a POST request or not


setBaseURL(String baseURL)

Sets the base URL for this document.


setDefaultEncoding(String encoding)

Sets the default encoding for the document e.g.


setEncoding(String encoding)

void

Method Detail

Sets the document encoding (This can be determined via the charset attribute in
the response)

1263

Overview (Codename One API)


setExpectedContentType(int requestType)

Sets this expected content type to be either TYPE_HTML, TYPE_IMAGE or


TYPE_CSS When the document itself is requested the type will be TYPE_HTML
and when images in the document are requested the type will be TYPE_IMAGE
The differentiation is important to handle cases in which the HTMLComponent
expects one type but the URL is has a resource of another type

void

setParams(String params)

void

Sets the request paramters of this request


setPostRequest(boolean postRequest)

void

Sets this DocumentInfo as using a POST request or not


setUrl(String url)

void

Sets the URL to the specified URL

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ENCODING_ISO
public static final String ENCODING_ISO

ISO-8859-1 encoding, the default one


See Also:
Constant Field Values
ENCODING_UTF8
public static final String ENCODING_UTF8

UTF8 encoding, very common


See Also:
Constant Field Values
TYPE_HTML
public static int TYPE_HTML

Indicates that the request is for a page


TYPE_IMAGE
public static int TYPE_IMAGE

Indicates that the request is for an image


TYPE_CSS
public static int TYPE_CSS

Indicates that the request is for a CSS file

Method Detail
setDefaultEncoding
public static void setDefaultEncoding(String encoding)

Sets the default encoding for the document e.g. ENCODING_UTF8


Parameters:
encoding - the encoding string matching ISO standards

Method Summary

1264

Overview (Codename One API)


getUrl
public String getUrl()

Returns the absolute URL associated with this DocumentInfo object


Returns:
the absolute URL associated with this DocumentInfo object
getFullUrl
public String getFullUrl()

Returns the full url string including parameters in GET request


Returns:
the full url string including parameters in GET request
setUrl
public void setUrl(String url)

Sets the URL to the specified URL


Parameters:
url - the URL to set as the URL of the document
getExpectedContentType
public int getExpectedContentType()

Returns the expected content type, one of TYPE_HTML, TYPE_IMAGE or


TYPE_CSS
Returns:
the expected content type, one of TYPE_HTML, TYPE_IMAGE or
TYPE_CSS
setExpectedContentType
public void setExpectedContentType(int requestType)

Sets this expected content type to be either TYPE_HTML, TYPE_IMAGE or


TYPE_CSS When the document itself is requested the type will be TYPE_HTML and
when images in the document are requested the type will be TYPE_IMAGE The
differentiation is important to handle cases in which the HTMLComponent expects
one type but the URL is has a resource of another type
Parameters:
requestType - the requestType to set, one of TYPE_HTML, TYPE_IMAGE or
TYPE_CSS
isPostRequest
public boolean isPostRequest()

Returns whether this document request is a POST request or not


Returns:
true if the document was requested via POST, false otherwise
setPostRequest
public void setPostRequest(boolean postRequest)

Sets this DocumentInfo as using a POST request or not


Parameters:
postRequest - true if this is a POST request, false otherwise
getParams
public String getParams()

Returns the request paramter as an percentage-encoded string


Returns:
the request paramter as an encoded string

Method Detail

1265

Overview (Codename One API)


setParams
public void setParams(String params)

Sets the request paramters of this request


Parameters:
params - The request paramters to set, should be as a percentage encoded
string
getEncoding
public String getEncoding()

Returns a string describing the document's encoding


Returns:
the document's encoding
setEncoding
public void setEncoding(String encoding)

Sets the document encoding (This can be determined via the charset attribute in the
response)
Parameters:
encoding - the encoding to set. It is recommended to use the ENCODING_*
constants when possible to avoid typos
getBaseURL
public String getBaseURL()

Returns the base URL for this document


Returns:
the baseURL
setBaseURL
public void setBaseURL(String baseURL)

Sets the base URL for this document. Usually this is deduced automatically from the
page URL, but in some cases this is different, for example when an HREF attribute is
provided in the BASE tag
Parameters:
baseURL - the baseURL to set

Method Detail

1266

Overview (Codename One API)


com.codename1.ui.html

Class DefaultHTMLCallback
java.lang.Object

com.codename1.ui.html.DefaultHTMLCallback
All Implemented Interfaces:
HTMLCallback, ParserCallback

public class
extends Object
implements HTMLCallback

This is a default implementation of HTMLCallback that basically doesn't do much but does keep the
HTMLComponent work intact. This class was created so developers will avoid pitfalls of
HTMLCallback, as using the wrong return values. Note that in any case an HTMLComponent doesn't
have to use an HTMLCallback.

Field Summary
Modifier
and Type
static
int
static
int

Field and Description


ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
ERROR_CSS_NO_BASE_URL

static
int

static
int

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not
via setPage) In this case the return value of parsingError is not considered parsing continues and the resource at the URL (CSS file/image) is ignored
ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found

Fields inherited from


interface com.codename1.ui.html.HTMLCallback
ERROR_CONNECTING, ERROR_IMAGE_BAD_FORMAT, ERROR_IMAGE_NOT_FOUND,
ERROR_INVALID_TAG_HIERARCHY, ERROR_NO_BASE_URL, FIELD_PASSWORD, FIELD_TEXT,
LINK_FORBIDDEN, LINK_REGULAR, LINK_VISTED, STATUS_CANCELLED,
STATUS_COMPLETED, STATUS_CONNECTED, STATUS_DISPLAYED, STATUS_ERROR,
STATUS_NONE, STATUS_PARSED, STATUS_REDIRECTED, STATUS_REQUESTED

Fields inherited from


interface com.codename1.xml.ParserCallback
ERROR_ATTIBUTE_VALUE_INVALID, ERROR_ATTRIBUTE_NOT_SUPPORTED,
ERROR_ENCODING, ERROR_MULTIPLE_ROOTS, ERROR_NO_CLOSE_TAG, ERROR_NO_ROOTS,
ERROR_TAG_NOT_SUPPORTED, ERROR_UNEXPECTED_CHARACTER,
ERROR_UNEXPECTED_TAG_CLOSING, ERROR_UNRECOGNIZED_CHAR_ENTITY

Constructor Summary
Constructor and Description
DefaultHTMLCallback()

Class DefaultHTMLCallback

1267

Overview (Codename One API)


Method

Summary

Modifier
and Type

Method and Description


actionPerformed(ActionEvent evt, HTMLComponent htmlC,
HTMLElement element)

void

{Called whenever an ActionEvent is triggered in one of the controls in the


HTMLComponent For example, button press, checkbox/radiobutton check etc.}
dataChanged(int type, int index, HTMLComponent htmlC,
TextField textField, HTMLElement element)

void

{Called when the user types in a TextField inside the HTMLComponent This
method will be called only if HTMLComponent.isEventsEnabled() is true}
fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL,
String id, String value, int type, String errorMsg)

String

{Called whenever a field is submitted to a form.}


focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)

{Called when one of the controls in the HTMLComponent obtained focus This
method will be called only if HTMLComponent.isEventsEnabled() is true}

void

focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)

{Called when one of the controls in the HTMLComponent lost focus This method
will be called only if HTMLComponent.isEventsEnabled() is true}

void

getAutoComplete(HTMLComponent htmlC, String actionURL, String id)

{Called on form creation and enabled implementations of this method to return a


value to preset in a form field.}

String

getLinkProperties(HTMLComponent htmlC, String url)

{Returns properties about the given link to indicate to HTMLComponent how to


render it Note that this method is always called NOT on the EDT thread.}

int

boolean

linkClicked(HTMLComponent htmlC, String url)

{Called when a link is clicked.}


pageStatusChanged(HTMLComponent htmlC, int status, String url)

void

{Called when the page status has been changed}

boolean

parsingError(int errorId, String tag, String attribute, String value,


String description)

{Called when encountering an error while parsing the XML document.}


selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC,
List list, HTMLElement element)

{Called when the user selects an item in a List inside the HTMLComponent
Note: Selection is traversing through the items - once the user has actually
decided, an ActionEvent will be sent as well This method will be called only if
HTMLComponent.isEventsEnabled() is true}

void

titleUpdated(HTMLComponent htmlC, String title)

void

{Called when the page's title is updated}

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED
public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
See Also:
Constant Field Values

Method Summary

1268

Overview (Codename One API)


ERROR_CSS_ATTIBUTE_VALUE_INVALID
public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
See Also:
Constant Field Values
ERROR_CSS_NOT_FOUND
public static final int ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found
See Also:
Constant Field Values
ERROR_CSS_NO_BASE_URL
public static final int ERROR_CSS_NO_BASE_URL

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not via
setPage) In this case the return value of parsingError is not considered - parsing
continues and the resource at the URL (CSS file/image) is ignored
See Also:
Constant Field Values

Constructor Detail
DefaultHTMLCallback
public DefaultHTMLCallback()

Method Detail
titleUpdated
public void titleUpdated(HTMLComponent htmlC,
String title)

{Called when the page's title is updated}


Specified by:
titleUpdated in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent that triggered the event
title - The new title
parsingError
public boolean parsingError(int errorId,
String tag,
String attribute,
String value,
String description)

{Called when encountering an error while parsing the XML document. When
implementing this, the developer should return true if the error should be ignored and
the document needs to be further parsed, or false to stop parsing and issue an error
to the user Note that this method is always called NOT on the EDT thread.}
Specified by:
parsingError in interface ParserCallback
Parameters:
errorId - The error ID, one of the ERROR_* constants
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)

Field Detail

1269

Overview (Codename One API)


- The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Returns:
true to continue parsing, false to stop
pageStatusChanged
value

public void pageStatusChanged(HTMLComponent htmlC,


int status,
String url)

{Called when the page status has been changed}


Specified by:
pageStatusChanged in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which the status change occured
status - The new status, one of the STATUS_* constants
url - The URL of the page
fieldSubmitted
public String fieldSubmitted(HTMLComponent htmlC,
TextArea ta,
String actionURL,
String id,
String value,
int type,
String errorMsg)

{Called whenever a field is submitted to a form. This can be used to perform sanity
checks and/or to store values for auto complete.}
Specified by:
fieldSubmitted in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which this event occured
ta - The TextArea/TextField of this field
actionURL - The action URL of the form
id - The ID of the field
value - The value entered
type - The type of the field, one of the FIELD_* constants
errorMsg - The error message if any error occured (i.e. input validation error)
or null if no error occured
Returns:
The string to submit to the form (Should return value if nothing changed)
getAutoComplete
public String getAutoComplete(HTMLComponent htmlC,
String actionURL,
String id)

{Called on form creation and enabled implementations of this method to return a


value to preset in a form field. This can be used to auto complete previously entered
value Note that this method is always called NOT on the EDT thread.}
Specified by:
getAutoComplete in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which this event occured
actionURL - The action URL of the form
id - The ID of the field
Returns:
The string to place in the indicated field
getLinkProperties
public int getLinkProperties(HTMLComponent htmlC,
String url)

{Returns properties about the given link to indicate to HTMLComponent how to


render it Note that this method is always called NOT on the EDT thread.}
Specified by:

Method Detail

1270

Overview (Codename One API)


getLinkProperties

in interface HTMLCallback

Parameters:
htmlC - The HTMLComponent
url - The Link URL

Returns:
LINK_REGULAR or LINK_VISITED or LINK_FORBIDDEN or a mask of
those
linkClicked
public boolean linkClicked(HTMLComponent htmlC,
String url)

{Called when a link is clicked. This can be used to process links that needs
additional/alternate handling than fetching an HTML.}
Specified by:
linkClicked in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent
url - The Link URL
Returns:
true if regular link processing should continue, false otherwise
actionPerformed
public void actionPerformed(ActionEvent evt,
HTMLComponent htmlC,
HTMLElement element)

{Called whenever an ActionEvent is triggered in one of the controls in the


HTMLComponent For example, button press, checkbox/radiobutton check etc. This
method will be called only if HTMLComponent.isEventsEnabled() is true}
Specified by:
actionPerformed in interface HTMLCallback
Parameters:
evt - The event triggered, the component can be extracted using getSource
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
focusGained
public void focusGained(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

{Called when one of the controls in the HTMLComponent obtained focus This method
will be called only if HTMLComponent.isEventsEnabled() is true}
Specified by:
focusGained in interface HTMLCallback
Parameters:
cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
focusLost
public void focusLost(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

{Called when one of the controls in the HTMLComponent lost focus This method will
be called only if HTMLComponent.isEventsEnabled() is true}
Specified by:
focusLost in interface HTMLCallback
Parameters:
cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event

Method Detail

1271

Overview (Codename One API)


selectionChanged
public void selectionChanged(int oldSelected,
int newSelected,
HTMLComponent htmlC,
List list,
HTMLElement element)

{Called when the user selects an item in a List inside the HTMLComponent Note:
Selection is traversing through the items - once the user has actually decided, an
ActionEvent will be sent as well This method will be called only if
HTMLComponent.isEventsEnabled() is true}
Specified by:
selectionChanged in interface HTMLCallback
Parameters:
oldSelected - old selected index in list model
newSelected - new selected index in list model
htmlC - The HTMLComponent
list - The list that triggered the event (Usually a ComboBox but not always)
element - The element associated with the component that triggered the
event (Should be TAG_SELECT)
dataChanged
public void dataChanged(int type,
int index,
HTMLComponent htmlC,
TextField textField,
HTMLElement element)

{Called when the user types in a TextField inside the HTMLComponent This method
will be called only if HTMLComponent.isEventsEnabled() is true}
Specified by:
dataChanged in interface HTMLCallback
Parameters:
type - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model
htmlC - The HTMLComponent
textField - The TextField that triggerd the event
element - The element associated with the component that triggered the
event (Should be TAG_INPUT with type text/password)

Method Detail

1272

Overview (Codename One API)


com.codename1.ui.html

Class DefaultDocumentRequestHandler
java.lang.Object

com.codename1.ui.html.DefaultDocumentRequestHandler
All Implemented Interfaces:
AsyncDocumentRequestHandler, DocumentRequestHandler
Direct Known Subclasses:
AsyncDocumentRequestHandlerImpl

public class
extends Object
implements AsyncDocumentRequestHandler

Default implementation of the HTML components document request handler to allow simple HTML
support in Codename One. This version includes only the basics supported by MIDP e.g. resources
and jar file URL's such as jar:// and res://

Constructor Summary
Constructor and Description
DefaultDocumentRequestHandler()

Method Summary
Modifier and
Type
static
Resources
boolean

Method and Description


getResFile()

Allows URL's referring to a res:// local resource to default to this file


isTrackVisitedURLs()

Allows tracking whether a URL was visited or not


resourceRequested(DocumentInfo docInfo)

InputStream

Implementations should return the document in the requested url as an


InputStream This is triggered only for the main document requested and not
for its resources.
resourceRequestedAsync(DocumentInfo docInfo, IOCallback callback)

This method is called by HTMLComponent when a resource is requested


asynchronously.

void

static void

setResFile(Resources res)

Allows URL's referring to a local:// local resource to default to this file


setTrackVisitedURLs(boolean trackVisitedURLs)

void

Allows tracking whether a URL was visited or not

protected
void
boolean

visitingURL(String url)

This method can be invoked to indicate a URL was visited fro tracking
wasURLVisited(String url)

Returns true if the URL was visited, requires trackVisitedURLs to be true

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class DefaultDocumentRequestHandler

1273

Overview (Codename One API)


DefaultDocumentRequestHandler
public DefaultDocumentRequestHandler()

Method Detail
resourceRequestedAsync
public void resourceRequestedAsync(DocumentInfo docInfo,
IOCallback callback)

This method is called by HTMLComponent when a resource is requested


asynchronously. This method should return immediately and start a process of
fetching the requested resource on another thread. When the resource was fetched,
the HTMLComponent.streamReady should be called.
Specified by:
resourceRequestedAsync in interface AsyncDocumentRequestHandler
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
callback - The HTMLComponent that should be called back when the stream
was fetched.
resourceRequested
public InputStream resourceRequested(DocumentInfo docInfo)

Implementations should return the document in the requested url as an InputStream


This is triggered only for the main document requested and not for its resources.
Specified by:
resourceRequested in interface DocumentRequestHandler
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
Returns:
the document at the URL as an InputStream
visitingURL
protected void visitingURL(String url)

This method can be invoked to indicate a URL was visited fro tracking
Parameters:
url - the url
wasURLVisited
public boolean wasURLVisited(String url)

Returns true if the URL was visited, requires trackVisitedURLs to be true


Parameters:
url - the url
Returns:
true if it was visited
getResFile
public static Resources getResFile()

Allows URL's referring to a res:// local resource to default to this file


Returns:
the resFile
setResFile
public static void setResFile(Resources res)

Allows URL's referring to a local:// local resource to default to this file


Parameters:
res - the resource

Constructor Detail

1274

Overview (Codename One API)


isTrackVisitedURLs
public boolean isTrackVisitedURLs()

Allows tracking whether a URL was visited or not


Returns:
the trackVisitedURLs
setTrackVisitedURLs
public void setTrackVisitedURLs(boolean trackVisitedURLs)

Allows tracking whether a URL was visited or not


Parameters:
trackVisitedURLs - the trackVisitedURLs to set

Method Detail

1275

Overview (Codename One API)


com.codename1.ui.html

Class AsyncDocumentRequestHandlerImpl
java.lang.Object

com.codename1.ui.html.DefaultDocumentRequestHandler

com.codename1.ui.html.AsyncDocumentRequestHandlerImpl
All Implemented Interfaces:
AsyncDocumentRequestHandler, DocumentRequestHandler

public class
extends DefaultDocumentRequestHandler

Implementation of the HTML components document request handler to allow simple HTML support in
CodenameOne.

Field Summary
Modifier and Type

Field and Description

protected static Object

LOCK

Constructor Summary
Constructor and Description
AsyncDocumentRequestHandlerImpl()

Method Summary
Modifier and Type
protected
ConnectionRequest

Method and Description


createConnectionRequest(DocumentInfo docInfo,
IOCallback callback, Object[] response)
resourceRequested(DocumentInfo docInfo)

InputStream

Implementations should return the document in the requested url as


an InputStream This is triggered only for the main document
requested and not for its resources.
resourceRequestedAsync(DocumentInfo docInfo,
IOCallback callback)

void

This method is called by HTMLComponent when a resource is


requested asynchronously.

Methods inherited from


class com.codename1.ui.html.DefaultDocumentRequestHandler
getResFile, isTrackVisitedURLs, setResFile, setTrackVisitedURLs,
visitingURL, wasURLVisited

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Class AsyncDocumentRequestHandlerImpl

1276

Overview (Codename One API)


LOCK
protected static final Object LOCK

Constructor Detail
AsyncDocumentRequestHandlerImpl
public AsyncDocumentRequestHandlerImpl()

Method Detail
resourceRequestedAsync
public void resourceRequestedAsync(DocumentInfo docInfo,
IOCallback callback)

This method is called by HTMLComponent when a resource is requested


asynchronously. This method should return immediately and start a process of
fetching the requested resource on another thread. When the resource was fetched,
the HTMLComponent.streamReady should be called.
Specified by:
resourceRequestedAsync in interface AsyncDocumentRequestHandler
Overrides:
resourceRequestedAsync in class DefaultDocumentRequestHandler
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
callback - The HTMLComponent that should be called back when the stream
was fetched.
resourceRequested
public InputStream resourceRequested(DocumentInfo docInfo)

Implementations should return the document in the requested url as an InputStream


This is triggered only for the main document requested and not for its resources.
Specified by:
resourceRequested in interface DocumentRequestHandler
Overrides:
resourceRequested in class DefaultDocumentRequestHandler
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
Returns:
the document at the URL as an InputStream
createConnectionRequest
protected ConnectionRequest createConnectionRequest(DocumentInfo docInfo,
IOCallback callback,
Object[] response)

Field Detail

1277

Overview (Codename One API)


com.codename1.ui.html

Interface AsyncDocumentRequestHandler
All Superinterfaces:
DocumentRequestHandler
All Known Implementing Classes:
AsyncDocumentRequestHandlerImpl, DefaultDocumentRequestHandler

public interface
extends DocumentRequestHandler

Provides an interface for Asynchronous request handling. The resourceRequestedAsync will be called
without creating a new thread, but it has to return immediately. This can be useful when an external
threading mechanism is to be utilized instead of the internal threading which is done by
HTMLComponent. Note that the resourceRequested method should be implemented as well, since
HTMLComponent has situations in which a resource needs to be fetched immediately (And block all
the rest).

Method Summary
Modifier and
Type

Method and Description


resourceRequestedAsync(DocumentInfo docInfo, IOCallback callback)

This method is called by HTMLComponent when a resource is requested


asynchronously.

void

Methods inherited from


interface com.codename1.ui.html.DocumentRequestHandler
resourceRequested

Method Detail
resourceRequestedAsync
void resourceRequestedAsync(DocumentInfo docInfo,
IOCallback callback)

This method is called by HTMLComponent when a resource is requested


asynchronously. This method should return immediately and start a process of
fetching the requested resource on another thread. When the resource was fetched,
the HTMLComponent.streamReady should be called.
Parameters:
docInfo - A DocumentInfo object representing the requested URL and its
attributes
callback - The HTMLComponent that should be called back when the stream
was fetched.

Method Detail

1278

Overview (Codename One API)


com.codename1.ui.geom

Interface Shape
All Known Implementing Classes:
GeneralPath, Rectangle, Rectangle2D

public interface

An interface that can be implemented by any class that wants to be drawable as a shape.
See Also:
for a concrete implementation of Shape.,
Graphics.drawShape(com.codename1.ui.geom.Shape, com.codename1.ui.Stroke),
Graphics.fillShape(com.codename1.ui.geom.Shape)

Method Summary
Modifier and
Type

Method and Description


contains(int x, int y)

boolean

Checks if the shape contains the given point.


getBounds()

Rectangle

Returns the bounding rectangle for the shape.


getBounds2D()

Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.

float[]

getPathIterator()

PathIterator

Gets an iterator to walk all of the path segments of the shape.


getPathIterator(Transform transform)

Gets an iterator where all points are transformed by the provided


transform.

PathIterator

intersection(Rectangle rect)

Returns the shape formed by the intersection of this shape and the
provided rectangle.

Shape

isRectangle()

boolean

Checks if this shape is a rectangle.

Method Detail
getPathIterator
PathIterator getPathIterator()

Gets an iterator to walk all of the path segments of the shape.


Returns:
A PathIterator that can iterate over the path segments of the shape.
getPathIterator
PathIterator getPathIterator(Transform transform)

Gets an iterator where all points are transformed by the provided transform.
Note: If Transform.isSupported() is false, then using this iterator will throw a
Runtime Exception.
Parameters:
transform

Returns:

Method Detail

1279

Overview (Codename One API)


A PathIterator where points are transformed by the provided transform.
getBounds
Rectangle getBounds()

Returns the bounding rectangle for the shape. This should be the smallest rectangle
such that the all path segments in the shape are contained within it.
Returns:
A Rectangle that comprises the bounds of the shape.
getBounds2D
float[] getBounds2D()

Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.
Returns:
[x, y, width, height] bounds of this shape.
isRectangle
boolean isRectangle()

Checks if this shape is a rectangle. A Shape is a rectangle if it is a closed


quadrilateral composed of two vertical lines and two horizontal lines. If all points have
integer coordinates, and this returns true, then getBounds() should return an
equivalent rectangle to the shape itself.
Returns:
True if shape is a rectangle.
contains
boolean contains(int x,
int y)

Checks if the shape contains the given point.


Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if (x, y) is inside the shape.
intersection
Shape intersection(Rectangle rect)

Returns the shape formed by the intersection of this shape and the provided
rectangle.
Parameters:
rect - A rectangle with which to form an intersection.
Returns:
The shape formed by intersecting the current shape with the provided
rectangle.

Method Detail

1280

Overview (Codename One API)


com.codename1.ui.geom

Class Rectangle2D
java.lang.Object

com.codename1.ui.geom.Rectangle2D
All Implemented Interfaces:
Shape

public class
extends Object
implements Shape

Represents a Rectangle position (x, y) and Dimension (width, height), this is useful for measuring
coordinates within the application.

Constructor Summary
Constructor and Description
Rectangle2D()

Creates a new instance of Rectangle


Rectangle2D(double x, double y, Dimension2D size)

Creates a new instance of Rectangle at position (x, y) and with predefine dimension
Rectangle2D(double x, double y, double w, double h)

Creates a new instance of Rectangle at position (x, y) and with predefine width and height
Rectangle2D(Rectangle2D rect)

A copy Constructor

Method Summary
Modifier and
Type

Method and Description


contains(double rX, double rY)

boolean

Checks whether or not this Rectangle contains the point at the specified
location (rX, rY).
contains(double rX, double rY, double rWidth, double rHeight)

boolean

Checks whether this Rectangle entirely contains the Rectangle at the


specified location (rX, rY) with the specified dimensions (rWidth, rHeight).

contains(double x1, double y1, double w1, double h1, double x2,
static boolean double y2, double w2, double h2)

Checks wheather the 2nd rectangle is contained in the first rectangle


boolean

contains(int x, int y)

Checks if the shape contains the given point.


contains(Rectangle2D rect)

boolean

Rectangle

Checks whether or not this Rectangle entirely contains the specified


Rectangle.
getBounds()

{Returns the bounding rectangle for the shape.}


getBounds2D()

float[]

double
PathIterator

Class Rectangle2D

{Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.}
getHeight()

Convenience method for getSize().getHeight();


getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}

1281

Overview (Codename One API)


getPathIterator(Transform m)
PathIterator

Dimension2D

{Gets an iterator where all points are transformed by the provided


transform.}
getSize()

Return the dimension of the rectangle


getWidth()

double

Convenience method for getSize().getWidth();


getX()

double

Return the x coordinate of the rectangle


getY()

double

Return the y coordinate of the rectangle

Rectangle2D

static void

intersection(double rX, double rY, double rW, double rH)

Returns a rectangle that intersects the given rectangle with this rectangle
intersection(double rrX, double rrY, double rrW, double rrH,
double rtx1, double rty1, double rtw2, double rth2,
Rectangle2D dest)

Returns a rectangle that intersects the given rectangle with this rectangle
intersection(Rectangle rect)

Returns the shape formed by the intersection of this shape and the
provided rectangle.

Shape

Rectangle2D

intersection(Rectangle2D r)

Returns a rectangle that intersects the given rectangle with this rectangle
intersects(double x, double y, double width, double height)

boolean

Determines whether or not this Rectangle and the specified Rectangle


location (x, y) with the specified dimensions (width, height), intersect.

intersects(double tx, double ty, double tw, double th, double x,


static boolean double y, double width, double height)

Helper method allowing us to determine if two coordinate sets intersect.


intersects(Rectangle2D rect)
boolean

boolean

Determines whether or not this Rectangle and the specified Rectangle


location (x, y) with the specified dimensions (width, height), intersect.
isRectangle()

{Checks if this shape is a rectangle.}


setBounds(double x, double y, double w, double h)

void

Helper method to set coordinates


setHeight(double h)

void

Convenience method for getSize().setHeight();


setWidth(double w)

void

Convenience method for getSize().setWidth();


setX(int x)

void

Sets the x position of the rectangle


setY(int y)

void

Sets the y position of the rectangle

String
void

toString()

Returns a string representation of the object.


translate(double x, double y)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Rectangle2D
public Rectangle2D()

Creates a new instance of Rectangle

Method Summary

1282

Overview (Codename One API)


Rectangle2D
public Rectangle2D(double x,
double y,
Dimension2D size)

Creates a new instance of Rectangle at position (x, y) and with predefine dimension
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
size - the Dimension of the rectangle
Rectangle2D
public Rectangle2D(double
double
double
double

x,
y,
w,
h)

Creates a new instance of Rectangle at position (x, y) and with predefine width and
height
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
Rectangle2D
public Rectangle2D(Rectangle2D rect)

A copy Constructor
Parameters:
rect - the Rectangle to copy

Method Detail
setBounds
public void setBounds(double
double
double
double

x,
y,
w,
h)

Helper method to set coordinates


getWidth
public double getWidth()

Convenience method for getSize().getWidth();


Returns:
width
setWidth
public void setWidth(double w)

Convenience method for getSize().setWidth();


Parameters:
w - the width
setHeight
public void setHeight(double h)

Convenience method for getSize().setHeight();


Parameters:
h - the height

Constructor Detail

1283

Overview (Codename One API)


getHeight
public double getHeight()

Convenience method for getSize().getHeight();


Returns:
height
getSize
public Dimension2D getSize()

Return the dimension of the rectangle


Returns:
the size of the rectangle
getX
public double getX()

Return the x coordinate of the rectangle


Returns:
the x coordinate of the rectangle
getY
public double getY()

Return the y coordinate of the rectangle


Returns:
the y coordinate of the rectangle
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
setX
public void setX(int x)

Sets the x position of the rectangle


Parameters:
x - the x coordinate of the rectangle
setY
public void setY(int y)

Sets the y position of the rectangle


Parameters:
y - the y coordinate of the rectangle
contains
public boolean contains(Rectangle2D rect)

Checks whether or not this Rectangle entirely contains the specified Rectangle.
Parameters:
rect - the specified Rectangle
Returns:
true if the Rectangle is contained entirely inside this Rectangle; false
otherwise

Method Detail

1284

Overview (Codename One API)


contains
public boolean contains(double
double
double
double

rX,
rY,
rWidth,
rHeight)

Checks whether this Rectangle entirely contains the Rectangle at the specified
location (rX, rY) with the specified dimensions (rWidth, rHeight).
Parameters:
rX - the specified x coordinate
rY - the specified y coordinate
rWidth - the width of the Rectangle
rHeight - the height of the Rectangle
Returns:
true if the Rectangle specified by (rX, rY, rWidth, rHeight) is entirely enclosed
inside this Rectangle; false otherwise.
contains
public static boolean contains(double
double
double
double
double
double
double
double

x1,
y1,
w1,
h1,
x2,
y2,
w2,
h2)

Checks wheather the 2nd rectangle is contained in the first rectangle


Parameters:
x1 - first rect x
y1 - first rect y
w1 - first rect w
h1 - first rect h
x2 - second rect x
y2 - second rect y
w2 - second rect w
h2 - second rect h
Returns:
true if x2, y2, w2, h2 is contained in x1, y1, w1, h1
contains
public boolean contains(double rX,
double rY)

Checks whether or not this Rectangle contains the point at the specified location (rX,
rY).
Parameters:
rX - the specified x coordinate
rY - the specified y coordinate
Returns:
true if the point (rX, rY) is inside this Rectangle; false otherwise.
intersection
public Rectangle2D intersection(double
double
double
double

rX,
rY,
rW,
rH)

Returns a rectangle that intersects the given rectangle with this rectangle
Parameters:
rX - rectangle to intersect with this rectangle
rY - rectangle to intersect with this rectangle
rW - rectangle to intersect with this rectangle
rH - rectangle to intersect with this rectangle
Returns:
the intersection

Method Detail

1285

Overview (Codename One API)


intersection
public static void intersection(double rrX,
double rrY,
double rrW,
double rrH,
double rtx1,
double rty1,
double rtw2,
double rth2,
Rectangle2D dest)

Returns a rectangle that intersects the given rectangle with this rectangle
Parameters:
rrX - rectangle to intersect with this rectangle
rrY - rectangle to intersect with this rectangle
rrW - rectangle to intersect with this rectangle
rrH - rectangle to intersect with this rectangle
rtx1 - rectangle to intersect with this rectangle
rty1 - rectangle to intersect with this rectangle
rtw2 - rectangle to intersect with this rectangle
rth2 - rectangle to intersect with this rectangle
dest - result of the intersection are stored here
intersection
public Rectangle2D intersection(Rectangle2D r)

Returns a rectangle that intersects the given rectangle with this rectangle
Parameters:
r - rectangle to intersect with this rectangle
Returns:
the intersection
intersects
public boolean intersects(double
double
double
double

x,
y,
width,
height)

Determines whether or not this Rectangle and the specified Rectangle location (x, y)
with the specified dimensions (width, height), intersect. Two rectangles intersect if
their intersection is nonempty.
Parameters:
x - the specified x coordinate
y - the specified y coordinate
width - the width of the Rectangle
height - the height of the Rectangle
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.
intersects
public boolean intersects(Rectangle2D rect)

Determines whether or not this Rectangle and the specified Rectangle location (x, y)
with the specified dimensions (width, height), intersect. Two rectangles intersect if
their intersection is nonempty.
Parameters:
rect - the Rectangle to check intersection with
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.
intersects
public static boolean intersects(double
double
double
double
double
double
double

Method Detail

tx,
ty,
tw,
th,
x,
y,
width,

1286

Overview (Codename One API)


double height)

Helper method allowing us to determine if two coordinate sets intersect. This saves
us the need of creating a rectangle object for a quick calculation
Parameters:
tx - x of first rectangle
ty - y of first rectangle
tw - width of first rectangle
th - height of first rectangle
x - x of second rectangle
y - y of second rectangle
width - width of second rectangle
height - height of second rectangle
Returns:
true if the rectangles intersect
getPathIterator
public PathIterator getPathIterator(Transform m)

{Gets an iterator where all points are transformed by the provided transform.
Note: If Transform.isSupported() is false, then using this iterator will throw a
Runtime Exception.
}
Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator where points are transformed by the provided transform.
getPathIterator
public PathIterator getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}


Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator that can iterate over the path segments of the shape.
getBounds
public Rectangle getBounds()

{Returns the bounding rectangle for the shape. This should be the smallest rectangle
such that the all path segments in the shape are contained within it.}
Specified by:
getBounds in interface Shape
Returns:
A Rectangle that comprises the bounds of the shape.
getBounds2D
public float[] getBounds2D()

{Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.}
Specified by:
getBounds2D in interface Shape
Returns:
[x, y, width, height] bounds of this shape.
isRectangle
public boolean isRectangle()

{Checks if this shape is a rectangle. A Shape is a rectangle if it is a closed


quadrilateral composed of two vertical lines and two horizontal lines. If all points have
integer coordinates, and this returns true, then getBounds() should return an
equivalent rectangle to the shape itself.}
Specified by:

Method Detail

1287

Overview (Codename One API)


isRectangle in interface Shape
Returns:
True if shape is a rectangle.
contains
public boolean contains(int x,
int y)

Description copied from interface: Shape


Checks if the shape contains the given point.
Specified by:
contains in interface Shape
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if (x, y) is inside the shape.
intersection
public Shape intersection(Rectangle rect)

Description copied from interface: Shape


Returns the shape formed by the intersection of this shape and the provided
rectangle.
Specified by:
intersection in interface Shape
Parameters:
rect - A rectangle with which to form an intersection.
Returns:
The shape formed by intersecting the current shape with the provided
rectangle.
translate
public void translate(double x,
double y)

Method Detail

1288

Overview (Codename One API)


com.codename1.ui.geom

Class Rectangle
java.lang.Object

com.codename1.ui.geom.Rectangle
All Implemented Interfaces:
Shape

public class
extends Object
implements Shape

Represents a Rectangle position (x, y) and Dimension (width, height), this is useful for measuring
coordinates within the application.

Constructor Summary
Constructor and Description
Rectangle()

Creates a new instance of Rectangle


Rectangle(int x, int y, Dimension size)

Creates a new instance of Rectangle at position (x, y) and with predefine dimension
Rectangle(int x, int y, int w, int h)

Creates a new instance of Rectangle at position (x, y) and with predefine width and height
Rectangle(Rectangle rect)

A copy Constructor

Method Summary
Modifier and
Type

Method and Description


contains(int rX, int rY)

boolean

Checks whether or not this Rectangle contains the point at the specified
location (rX, rY).
contains(int rX, int rY, int rWidth, int rHeight)

boolean

Checks whether this Rectangle entirely contains the Rectangle at the


specified location (rX, rY) with the specified dimensions (rWidth, rHeight).

contains(int x1, int y1, int w1, int h1, int x2, int y2, int w2,
static boolean int h2)

Checks wheather the 2nd rectangle is contained in the first rectangle


contains(Rectangle rect)
boolean

Rectangle

Checks whether or not this Rectangle entirely contains the specified


Rectangle.
getBounds()

{Returns the bounding rectangle for the shape.}


getBounds2D()

float[]

int
PathIterator

{Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.}
getHeight()

Convenience method for getSize().getHeight();


getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}


getPathIterator(Transform m)

PathIterator

Class Rectangle

{Gets an iterator where all points are transformed by the provided


transform.}

1289

Overview (Codename One API)


Dimension

getSize()

Return the dimension of the rectangle


getWidth()

int

Convenience method for getSize().getWidth();


getX()

int

Return the x coordinate of the rectangle


getY()

int

Return the y coordinate of the rectangle

Rectangle

static void

intersection(int rX, int rY, int rW, int rH)

Returns a rectangle that intersects the given rectangle with this rectangle
intersection(int rrX, int rrY, int rrW, int rrH, int rtx1,
int rty1, int rtw2, int rth2, Rectangle dest)

Returns a rectangle that intersects the given rectangle with this rectangle
Rectangle
void

intersection(Rectangle r)

Returns a rectangle that intersects the given rectangle with this rectangle
intersection(Rectangle input, Rectangle output)
intersects(int x, int y, int width, int height)

boolean

Determines whether or not this Rectangle and the specified Rectangle


location (x, y) with the specified dimensions (width, height), intersect.

intersects(int tx, int ty, int tw, int th, int x, int y,
static boolean int width, int height)

Helper method allowing us to determine if two coordinate sets intersect.


intersects(Rectangle rect)
boolean

boolean

Determines whether or not this Rectangle and the specified Rectangle


location (x, y) with the specified dimensions (width, height), intersect.
isRectangle()

{Checks if this shape is a rectangle.}


setBounds(int x, int y, int w, int h)

void

Helper method to set coordinates


setHeight(int h)

void

Convenience method for getSize().setHeight();


setWidth(int w)

void

Convenience method for getSize().setWidth();


setX(int x)

void

Sets the x position of the rectangle


setY(int y)

void

Sets the y position of the rectangle

String

toString()

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Rectangle
public Rectangle()

Creates a new instance of Rectangle


Rectangle
public Rectangle(int x,
int y,
Dimension size)

Creates a new instance of Rectangle at position (x, y) and with predefine dimension
Parameters:

Method Summary

1290

Overview (Codename One API)


x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
size - the Dimension of the rectangle

Rectangle
public Rectangle(int
int
int
int

x,
y,
w,
h)

Creates a new instance of Rectangle at position (x, y) and with predefine width and
height
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
Rectangle
public Rectangle(Rectangle rect)

A copy Constructor
Parameters:
rect - the Rectangle to copy

Method Detail
setBounds
public void setBounds(int
int
int
int

x,
y,
w,
h)

Helper method to set coordinates


getWidth
public int getWidth()

Convenience method for getSize().getWidth();


Returns:
width
setWidth
public void setWidth(int w)

Convenience method for getSize().setWidth();


Parameters:
w - the width
setHeight
public void setHeight(int h)

Convenience method for getSize().setHeight();


Parameters:
h - the height
getHeight
public int getHeight()

Convenience method for getSize().getHeight();


Returns:
height

Constructor Detail

1291

Overview (Codename One API)


getSize
public Dimension getSize()

Return the dimension of the rectangle


Returns:
the size of the rectangle
getX
public int getX()

Return the x coordinate of the rectangle


Returns:
the x coordinate of the rectangle
getY
public int getY()

Return the y coordinate of the rectangle


Returns:
the y coordinate of the rectangle
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
setX
public void setX(int x)

Sets the x position of the rectangle


Parameters:
x - the x coordinate of the rectangle
setY
public void setY(int y)

Sets the y position of the rectangle


Parameters:
y - the y coordinate of the rectangle
contains
public boolean contains(Rectangle rect)

Checks whether or not this Rectangle entirely contains the specified Rectangle.
Parameters:
rect - the specified Rectangle
Returns:
true if the Rectangle is contained entirely inside this Rectangle; false
otherwise
contains
public boolean contains(int
int
int
int

Method Detail

rX,
rY,
rWidth,
rHeight)

1292

Overview (Codename One API)


Checks whether this Rectangle entirely contains the Rectangle at the specified
location (rX, rY) with the specified dimensions (rWidth, rHeight).
Parameters:
rX - the specified x coordinate
rY - the specified y coordinate
rWidth - the width of the Rectangle
rHeight - the height of the Rectangle
Returns:
true if the Rectangle specified by (rX, rY, rWidth, rHeight) is entirely enclosed
inside this Rectangle; false otherwise.
contains
public static boolean contains(int
int
int
int
int
int
int
int

x1,
y1,
w1,
h1,
x2,
y2,
w2,
h2)

Checks wheather the 2nd rectangle is contained in the first rectangle


Parameters:
x1 - first rect x
y1 - first rect y
w1 - first rect w
h1 - first rect h
x2 - second rect x
y2 - second rect y
w2 - second rect w
h2 - second rect h
Returns:
true if x2, y2, w2, h2 is contained in x1, y1, w1, h1
contains
public boolean contains(int rX,
int rY)

Checks whether or not this Rectangle contains the point at the specified location (rX,
rY).
Specified by:
contains in interface Shape
Parameters:
rX - the specified x coordinate
rY - the specified y coordinate
Returns:
true if the point (rX, rY) is inside this Rectangle; false otherwise.
intersection
public Rectangle intersection(int
int
int
int

rX,
rY,
rW,
rH)

Returns a rectangle that intersects the given rectangle with this rectangle
Parameters:
rX - rectangle to intersect with this rectangle
rY - rectangle to intersect with this rectangle
rW - rectangle to intersect with this rectangle
rH - rectangle to intersect with this rectangle
Returns:
the intersection
intersection
public void intersection(Rectangle input,
Rectangle output)

Method Detail

1293

Overview (Codename One API)


intersection
public static void intersection(int rrX,
int rrY,
int rrW,
int rrH,
int rtx1,
int rty1,
int rtw2,
int rth2,
Rectangle dest)

Returns a rectangle that intersects the given rectangle with this rectangle
Parameters:
rrX - rectangle to intersect with this rectangle
rrY - rectangle to intersect with this rectangle
rrW - rectangle to intersect with this rectangle
rrH - rectangle to intersect with this rectangle
rtx1 - rectangle to intersect with this rectangle
rty1 - rectangle to intersect with this rectangle
rtw2 - rectangle to intersect with this rectangle
rth2 - rectangle to intersect with this rectangle
dest - result of the intersection are stored here
intersection
public Rectangle intersection(Rectangle r)

Returns a rectangle that intersects the given rectangle with this rectangle
Specified by:
intersection in interface Shape
Parameters:
r - rectangle to intersect with this rectangle
Returns:
the intersection
intersects
public boolean intersects(int
int
int
int

x,
y,
width,
height)

Determines whether or not this Rectangle and the specified Rectangle location (x, y)
with the specified dimensions (width, height), intersect. Two rectangles intersect if
their intersection is nonempty.
Parameters:
x - the specified x coordinate
y - the specified y coordinate
width - the width of the Rectangle
height - the height of the Rectangle
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.
intersects
public boolean intersects(Rectangle rect)

Determines whether or not this Rectangle and the specified Rectangle location (x, y)
with the specified dimensions (width, height), intersect. Two rectangles intersect if
their intersection is nonempty.
Parameters:
rect - the Rectangle to check intersection with
Returns:
true if the specified Rectangle and this Rectangle intersect; false otherwise.
intersects
public static boolean intersects(int
int
int
int
int

Method Detail

tx,
ty,
tw,
th,
x,

1294

Overview (Codename One API)


int y,
int width,
int height)

Helper method allowing us to determine if two coordinate sets intersect. This saves
us the need of creating a rectangle object for a quick calculation
Parameters:
tx - x of first rectangle
ty - y of first rectangle
tw - width of first rectangle
th - height of first rectangle
x - x of second rectangle
y - y of second rectangle
width - width of second rectangle
height - height of second rectangle
Returns:
true if the rectangles intersect
getPathIterator
public PathIterator getPathIterator(Transform m)

{Gets an iterator where all points are transformed by the provided transform.
Note: If Transform.isSupported() is false, then using this iterator will throw a
Runtime Exception.
}
Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator where points are transformed by the provided transform.
getPathIterator
public PathIterator getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}


Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator that can iterate over the path segments of the shape.
getBounds
public Rectangle getBounds()

{Returns the bounding rectangle for the shape. This should be the smallest rectangle
such that the all path segments in the shape are contained within it.}
Specified by:
getBounds in interface Shape
Returns:
A Rectangle that comprises the bounds of the shape.
getBounds2D
public float[] getBounds2D()

{Gets the bounds of the shape as a 4-element array representing the


(x,y,width,height) tuple.}
Specified by:
getBounds2D in interface Shape
Returns:
[x, y, width, height] bounds of this shape.
isRectangle
public boolean isRectangle()

{Checks if this shape is a rectangle. A Shape is a rectangle if it is a closed


quadrilateral composed of two vertical lines and two horizontal lines. If all points have
integer coordinates, and this returns true, then getBounds() should return an

Method Detail

1295

Overview (Codename One API)


equivalent rectangle to the shape itself.}
Specified by:
isRectangle in interface Shape
Returns:
True if shape is a rectangle.

Method Detail

1296

Overview (Codename One API)


com.codename1.ui.geom

Class Point2D
java.lang.Object

com.codename1.ui.geom.Point2D

public class
extends Object

Utility class that holds x,y

Constructor Summary
Constructor and Description
Point2D(double x, double y)

Constructor with x and y

Method Summary
Modifier and Type

Method and Description


getX()

double

Gets the x value of this Point


getY()

double

Gets the y value of this Point


setX(double x)

void

Sets the x value of this Point


setY(double y)

void

Sets the y value of this Point


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Point2D
public Point2D(double x,
double y)

Constructor with x and y


Parameters:
xy

Method Detail

Class Point2D

1297

Overview (Codename One API)


getX
public double getX()

Gets the x value of this Point


Returns:
getY
public double getY()

Gets the y value of this Point


Returns:
setX
public void setX(double x)

Sets the x value of this Point


Parameters:
x setY
public void setY(double y)

Sets the y value of this Point


Parameters:
y toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

1298

Overview (Codename One API)


com.codename1.ui.geom

Class Point
java.lang.Object

com.codename1.ui.geom.Point

public class
extends Object

Utility class that holds x,y

Constructor Summary
Constructor and Description
Point(int x, int y)

Constructor with x and y

Method Summary
Modifier and Type

Method and Description


getX()

int

Gets the x value of this Point


getY()

int

Gets the y value of this Point


setX(int x)

void

Sets the x value of this Point


setY(int y)

void

Sets the y value of this Point


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Point
public Point(int x,
int y)

Constructor with x and y


Parameters:
xy

Method Detail

Class Point

1299

Overview (Codename One API)


getX
public int getX()

Gets the x value of this Point


Returns:
getY
public int getY()

Gets the y value of this Point


Returns:
setX
public void setX(int x)

Sets the x value of this Point


Parameters:
x setY
public void setY(int y)

Sets the y value of this Point


Parameters:
y toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

1300

Overview (Codename One API)


com.codename1.ui.geom

Interface PathIterator

public interface

This interface provides a directed path over the boundary of a shape. The path can contain 1st
through 3rd order Bezier curves (lines, and quadratic and cubic splines). A shape can have multiple
disjoint paths via the SEG_MOVETO directive, and can close a circular path back to the previous
SEG_MOVETO via the SEG_CLOSE directive.
See Also:
GeneralPath, Shape, Graphics.drawShape(com.codename1.ui.geom.Shape,
com.codename1.ui.Stroke), Graphics.fillShape(com.codename1.ui.geom.Shape)

Field Summary
Modifier
and Type

Field and Description


SEG_CLOSE

static int

The current segment closes a loop by an implicit line to the previous


SEG_MOVETO coordinate.
SEG_CUBICTO

static int

static int
static int
static int

The current segment is a cubic parametric curve (more commonly known as a


Bezier curve).
SEG_LINETO

The current segment is a line.


SEG_MOVETO

Starts a new subpath.


SEG_QUADTO

The current segment is a quadratic parametric curve.


WIND_EVEN_ODD

static int

The even-odd winding mode: a point is internal to the shape if a ray from the
point to infinity (in any direction) crosses an odd number of segments.
WIND_NON_ZERO

static int

The non-zero winding mode: a point is internal to the shape if a ray from the
point to infinity (in any direction) crosses a different number of segments
headed clockwise than those headed counterclockwise.

Method Summary
Modifier and
Type

Method and Description


currentSegment(double[] coords)

int

Returns the coordinates of the next point(s), as well as the type of line
segment.
currentSegment(float[] coords)

int

int
boolean
void

Interface PathIterator

Returns the coordinates of the next point(s), as well as the type of line
segment.
getWindingRule()

Returns the winding rule to determine which points are inside this path.
isDone()

Tests if the iterator is exhausted.


next()

Advance to the next segment in the iteration.

1301

Overview (Codename One API)

Field Detail
WIND_EVEN_ODD
static final int WIND_EVEN_ODD

The even-odd winding mode: a point is internal to the shape if a ray from the point to
infinity (in any direction) crosses an odd number of segments.
See Also:
Constant Field Values
WIND_NON_ZERO
static final int WIND_NON_ZERO

The non-zero winding mode: a point is internal to the shape if a ray from the point to
infinity (in any direction) crosses a different number of segments headed clockwise
than those headed counterclockwise.
See Also:
Constant Field Values
SEG_MOVETO
static final int SEG_MOVETO

Starts a new subpath. There is no segment from the previous vertex.


See Also:
Constant Field Values
SEG_LINETO
static final int SEG_LINETO

The current segment is a line.


See Also:
Constant Field Values
SEG_QUADTO
static final int SEG_QUADTO

The current segment is a quadratic parametric curve. It is interpolated as t varies


from 0 to 1 over the current point (CP), first control point (P1), and final interpolated
control point (P2):
P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2
0 <= t <= 1
B(n,m) = mth coefficient of nth degree Bernstein polynomial
= C(n,m) * t^(m) * (1 - t)^(n-m)
C(n,m) = Combinations of n things, taken m at a time
= n! / (m! * (n-m)!)

See Also:
Constant Field Values
SEG_CUBICTO
static final int SEG_CUBICTO

The current segment is a cubic parametric curve (more commonly known as a Bezier
curve). It is interpolated as t varies from 0 to 1 over the current point (CP), first control
point (P1), the second control point (P2), and final interpolated control point (P3):
P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3
0 <= t <= 1
B(n,m) = mth coefficient of nth degree Bernstein polynomial
= C(n,m) * t^(m) * (1 - t)^(n-m)
C(n,m) = Combinations of n things, taken m at a time
= n! / (m! * (n-m)!)

See Also:
Constant Field Values

Field Detail

1302

Overview (Codename One API)

SEG_CLOSE
static final int SEG_CLOSE

The current segment closes a loop by an implicit line to the previous SEG_MOVETO
coordinate.
See Also:
Constant Field Values

Method Detail
getWindingRule
int getWindingRule()

Returns the winding rule to determine which points are inside this path.
Returns:
the winding rule. (WIND_EVEN_ODD or WIND_NON_ZERO).
isDone
boolean isDone()

Tests if the iterator is exhausted. If this returns true, currentSegment and next may
throw a RuntimeException (although this is not required).
Returns:
true if the iteration is complete
next
void next()

Advance to the next segment in the iteration. It is not specified what this does if called
when isDone() returns true.
currentSegment
int currentSegment(float[] coords)

Returns the coordinates of the next point(s), as well as the type of line segment. The
input array must be at least a float[6], to accommodate up to three (x,y) point pairs
(although if you know the iterator is flat, you can probably get by with a float[2]). If
the returned type is SEG_MOVETO or SEG_LINETO, the first point in the array is modified;
if the returned type is SEG_QUADTO, the first two points are modified; if the returned
type is SEG_CUBICTO, all three points are modified; and if the returned type is
SEG_CLOSE, the array is untouched.
Parameters:
coords - the array to place the point coordinates in
Returns:
the segment type. One of (SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO,
SEG_CLOSE).
currentSegment
int currentSegment(double[] coords)

Returns the coordinates of the next point(s), as well as the type of line segment. The
input array must be at least a double[6], to accommodate up to three (x,y) point
pairs (although if you know the iterator is flat, you can probably get by with a
double[2]). If the returned type is SEG_MOVETO or SEG_LINETO, the first point in the
array is modified; if the returned type is SEG_QUADTO, the first two points are modified;
if the returned type is SEG_CUBICTO, all three points are modified; and if the returned
type is SEG_CLOSE, the array is untouched.
Parameters:
coords - the array to place the point coordinates in
Returns:
the segment type. One of (SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO,
SEG_CLOSE).

Field Detail

1303

Overview (Codename One API)


com.codename1.ui.geom

Class GeneralPath
java.lang.Object

com.codename1.ui.geom.GeneralPath
All Implemented Interfaces:
Shape

public final class


extends Object
implements Shape

A general geometric path, consisting of any number of subpaths constructed out of straight lines and
cubic or quadratic Bezier curves. The inside of the curve is defined for drawing purposes by a winding
rule. Either the WIND_EVEN_ODD or WIND_NON_ZERO winding rule can be chosen.
A drawing of a GeneralPath

The WIND_EVEN_ODD winding rule defines a point as inside a path if: A ray from the point towards
infinity in an arbitrary direction intersects the path an odd number of times. Points A and C in the
image are considered to be outside the path. (both intersect twice) Point B intersects once, and is
inside.
The WIND_NON_ZERO winding rule defines a point as inside a path if: The path intersects the ray in an
equal number of opposite directions. Point A in the image is outside (one intersection in the 'up'
direction, one in the 'down' direction) Point B in the image is inside (one intersection 'down') Point C in
the image is inside (two intersections in the 'down' direction)
See Also:
Graphics.drawShape(com.codename1.ui.geom.Shape, com.codename1.ui.Stroke),
Graphics.fillShape(com.codename1.ui.geom.Shape)

Field Summary
Modifier and Type
static int
static int

Field and Description


WIND_EVEN_ODD

Same constant as PathIterator.WIND_EVEN_ODD


WIND_NON_ZERO

Same constant as PathIterator.WIND_NON_ZERO

Constructor Summary
Constructor and Description
GeneralPath()

Method Detail

1304

Overview (Codename One API)


Constructs a GeneralPath with the default (WIND_NON_ZERO) winding rule and initial capacity
(10).
GeneralPath(int rule)

Constructs a GeneralPath with a specific winding rule and the default initial capacity (10).
GeneralPath(int rule, int initialCapacity)

Constructs a GeneralPath with a specific winding rule and the initial capacity.
GeneralPath(Shape shape)

Constructs a GeneralPath from an arbitrary shape object.

Method Summary
Modifier and
Type
void
void

void

Method and Description


append(PathIterator path, boolean connect)

Appends the segments of a PathIterator to this GeneralPath.


append(Shape shape, boolean connect)

Appends the segments of a Shape to the path.


arc(double x, double y, double w, double h, double startAngle,
double sweepAngle)

Draws an elliptical arc on the path given the provided bounds.


void

arc(double x, double y, double w, double h, double startAngle,


double sweepAngle, boolean joinPath)

Draws an elliptical arc on the path given the provided bounds.


void

arc(float x, float y, float w, float h, float startAngle,


float sweepAngle)

Draws an elliptical arc on the path given the provided bounds.


void

arc(float x, float y, float w, float h, float startAngle,


float sweepAngle, boolean joinPath)

Draws an elliptical arc on the path given the provided bounds.


void
void

arcTo(double cX, double cY, double endX, double endY)

Adds an arc to the path.


arcTo(float cX, float cY, float endX, float endY)

Adds an arc to the path.


closePath()

void

boolean
boolean

Closes the current subpath by drawing a line back to the point of the last
moveTo, unless the path is already closed.
contains(float x, float y)

Checks if the given point is contained in the current shape.


contains(int x, int y)

{Checks if the shape contains the given point.}


createTransformedShape(Transform m)

Shape

void

void

Returns a shape formed by transforming the current shape with the


provided transform.
curveTo(double x1, double y1, double x2, double y2, double x3,
double y3)
curveTo(float x1, float y1, float x2, float y2, float x3,
float y3)

Appends a cubic Bezier curve to the current path.


Rectangle
float[]
float[]
PathIterator
PathIterator

getBounds()

Returns the path's bounding box.


getBounds2D()

Returns the path's bounding box, in float precision.


getCurrentPoint()

Returns the current appending point of the path.


getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}


getPathIterator(Transform m)

{Gets an iterator where all points are transformed by the provided

Constructor Summary

1305

Overview (Codename One API)


transform.}
getPoints(float[] out)

void

Returns a copy of the points in this path.


getPointsSize()

int

Returns the number of points in this path.


getTypes(byte[] out)

void

Returns a copy of the types (aka path commands) in this path.


getTypesSize()

int

Returns the number of path commands in this path.


getWindingRule()

int

Returns the path's current winding rule.


intersect(Shape shape)

void

Resets this path to be the intersection of itself with the given shape.
intersection(Rectangle rect)

{Returns the shape formed by the intersection of this shape and the
provided rectangle.}

Shape

boolean
void

isRectangle()

Checks if this shape is a rectangle.


lineTo(double x, double y)
lineTo(float x, float y)

void

Appends a straight line to the current path.

void

moveTo(double x, double y)
moveTo(float x, float y)

void

Adds a new point to a path.

void

quadTo(double x1, double y1, double x2, double y2)


quadTo(float x1, float y1, float x2, float y2)

void

Appends a quadratic Bezier curve to the current path.


reset()

void

Resets the path.


setWindingRule(int rule)

Sets the path's winding rule, which controls which areas are considered
'inside' or 'outside' the path on drawing.

void

toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
WIND_EVEN_ODD
public static final int WIND_EVEN_ODD

Same constant as PathIterator.WIND_EVEN_ODD


See Also:
Constant Field Values
WIND_NON_ZERO
public static final int WIND_NON_ZERO

Same constant as PathIterator.WIND_NON_ZERO


See Also:
Constant Field Values

Method Summary

1306

Overview (Codename One API)


Constructor

Detail

GeneralPath
public GeneralPath()

Constructs a GeneralPath with the default (WIND_NON_ZERO) winding rule and initial
capacity (10).
GeneralPath
public GeneralPath(int rule)

Constructs a GeneralPath with a specific winding rule and the default initial capacity
(10).
Parameters:
rule - The winding rule. One of WIND_NON_ZERO and WIND_EVEN_ODD
See Also:
WIND_NON_ZERO, WIND_EVEN_ODD
GeneralPath
public GeneralPath(int rule,
int initialCapacity)

Constructs a GeneralPath with a specific winding rule and the initial capacity. The
initial capacity should be the approximate number of path segments to be used.
Parameters:
rule - The winding rule. (WIND_NON_ZERO or WIND_EVEN_ODD).
initialCapacity - the inital capacity, in path segments
GeneralPath
public GeneralPath(Shape shape)

Constructs a GeneralPath from an arbitrary shape object. The Shapes PathIterator


path and winding rule will be used.
Parameters:
shape

Method Detail
getTypesSize
public int getTypesSize()

Returns the number of path commands in this path.


Returns:
The number of path commands in this path.
getPointsSize
public int getPointsSize()

Returns the number of points in this path.


Returns:
The number of points in this path.
getTypes
public void getTypes(byte[] out)

Returns a copy of the types (aka path commands) in this path.


Parameters:
out - An array to copy the path commands into.

Constructor Detail

1307

Overview (Codename One API)


getPoints
public void getPoints(float[] out)

Returns a copy of the points in this path.


Parameters:
out - An array to copy the points into.
toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
setWindingRule
public void setWindingRule(int rule)

Sets the path's winding rule, which controls which areas are considered 'inside' or
'outside' the path on drawing. Valid rules are WIND_EVEN_ODD for an even-odd winding
rule, or WIND_NON_ZERO for a non-zero winding rule.
Parameters:
rule - the rule. (WIND_NON_ZERO or WIND_EVEN_ODD).
getWindingRule
public int getWindingRule()

Returns the path's current winding rule.


Returns:
WIND_NON_ZERO or WIND_EVEN_ODD
moveTo
public void moveTo(double x,
double y)

moveTo
public void moveTo(float x,
float y)

Adds a new point to a path.


Parameters:
x - the x-coordinate.
y - the y-coordinate.
lineTo
public void lineTo(double x,
double y)

lineTo
public void lineTo(float x,
float y)

Appends a straight line to the current path.


Parameters:
x - x coordinate of the line endpoint.
y - y coordinate of the line endpoint.

Method Detail

1308

Overview (Codename One API)


quadTo
public void quadTo(double
double
double
double

x1,
y1,
x2,
y2)

quadTo
public void quadTo(float
float
float
float

x1,
y1,
x2,
y2)

Appends a quadratic Bezier curve to the current path.


Parameters:
x1 - x coordinate of the control point
y1 - y coordinate of the control point
x2 - x coordinate of the curve endpoint.
y2 - y coordinate of the curve endpoint.
curveTo
public void curveTo(double
double
double
double
double
double

x1,
y1,
x2,
y2,
x3,
y3)

curveTo
public void curveTo(float
float
float
float
float
float

x1,
y1,
x2,
y2,
x3,
y3)

Appends a cubic Bezier curve to the current path.


Parameters:
x1 - x coordinate of the first control point
y1 - y coordinate of the first control point
x2 - x coordinate of the second control point
y2 - y coordinate of the second control point
x3 - x coordinate of the curve endpoint.
y3 - y coordinate of the curve endpoint.
arc
public void arc(float
float
float
float
float
float

x,
y,
w,
h,
startAngle,
sweepAngle)

Draws an elliptical arc on the path given the provided bounds.


Parameters:
x - Left x coord of bounding rect.
y - Top y coordof bounding rect.
w - Width of bounding rect.
h - Height of bounding rect.
startAngle - Start angle on ellipse in radians. Counter-clockwise from
3-o'clock.
sweepAngle - Sweep angle in radians. Counter-clockwise.
arc
public void arc(float x,
float y,
float w,
float h,
float startAngle,
float sweepAngle,
boolean joinPath)

Method Detail

1309

Overview (Codename One API)


Draws an elliptical arc on the path given the provided bounds.
Parameters:
x - Left x coord of bounding rect.
y - Top y coordof bounding rect.
w - Width of bounding rect.
h - Height of bounding rect.
startAngle - Start angle on ellipse in radians. Counter-clockwise from
3-o'clock.
sweepAngle - Sweep angle in radians. Counter-clockwise.
joinPath - If true, then this will join the arc to the existing path with a line.
arc
public void arc(double
double
double
double
double
double

x,
y,
w,
h,
startAngle,
sweepAngle)

Draws an elliptical arc on the path given the provided bounds.


Parameters:
x - Left x coord of bounding rect.
y - Top y coordof bounding rect.
w - Width of bounding rect.
h - Height of bounding rect.
startAngle - Start angle on ellipse in radians. Counter-clockwise from
3-o'clock.
sweepAngle - Sweep angle in radians. Counter-clockwise.
arc
public void arc(double x,
double y,
double w,
double h,
double startAngle,
double sweepAngle,
boolean joinPath)

Draws an elliptical arc on the path given the provided bounds.


Parameters:
x - Left x coord of bounding rect.
y - Top y coordof bounding rect.
w - Width of bounding rect.
h - Height of bounding rect.
startAngle - Start angle on ellipse in radians. Counter-clockwise from
3-o'clock.
sweepAngle - Sweep angle in radians. Counter-clockwise.
joinPath - If true then this will join the arc to the existing path with a line.
arcTo
public void arcTo(float
float
float
float

cX,
cY,
endX,
endY)

Adds an arc to the path. This method uses an approximation of an arc using a cubic
path. It is not a precise arc.
Parameters:
cX - The x-coordinate of the oval center.
cY - The y-coordinate of the oval center.
endX - The end X coordinate.
endY - The end Y coordinate.
arcTo
public void arcTo(double
double
double
double

Method Detail

cX,
cY,
endX,
endY)

1310

Overview (Codename One API)


Adds an arc to the path. This method uses an approximation of an arc using a cubic
path. It is not a precise arc.
Parameters:
cX - The x-coordinate of the oval center.
cY - The y-coordinate of the oval center.
endX - The end X coordinate.
endY - The end Y coordinate.
closePath
public void closePath()

Closes the current subpath by drawing a line back to the point of the last moveTo,
unless the path is already closed.
append
public void append(Shape shape,
boolean connect)

Appends the segments of a Shape to the path. If connect is true, the new path
segments are connected to the existing one with a line. The winding rule of the
Shape is ignored.
Parameters:
shape - the shape (null not permitted).
connect - whether to connect the new shape to the existing path.
append
public void append(PathIterator path,
boolean connect)

Appends the segments of a PathIterator to this GeneralPath. Optionally, the initial


PathIterator.SEG_MOVETO segment of the appended path is changed into a
PathIterator.SEG_LINETO segment.
Parameters:
path - the PathIterator specifying which segments shall be appended (null not
permitted).
connect - true for substituting the initial PathIterator.SEG_MOVETO segment
by a PathIterator.SEG_LINETO, or false for not performing any substitution. If
this GeneralPath is currently empty, connect is assumed to be false, thus
leaving the initial PathIterator.SEG_MOVETO unchanged.
getCurrentPoint
public float[] getCurrentPoint()

Returns the current appending point of the path.


Returns:
2-element array of the form [x,y] representing x and y coordinate of the
current appending point of the path..
reset
public void reset()

Resets the path. All points and segments are destroyed.


getBounds2D
public float[] getBounds2D()

Returns the path's bounding box, in float precision.


Specified by:
getBounds2D in interface Shape
Returns:
4-element array of the form [x, y, width, height].
getBounds
public Rectangle getBounds()

Returns the path's bounding box.


Specified by:

Method Detail

1311

Overview (Codename One API)


getBounds in interface Shape
Returns:
The bounding box of the path.
isRectangle
public boolean isRectangle()

Description copied from interface: Shape


Checks if this shape is a rectangle. A Shape is a rectangle if it is a closed
quadrilateral composed of two vertical lines and two horizontal lines. If all points have
integer coordinates, and this returns true, then getBounds() should return an
equivalent rectangle to the shape itself.
Specified by:
isRectangle in interface Shape
Returns:
True if shape is a rectangle.
getPathIterator
public PathIterator getPathIterator()

{Gets an iterator to walk all of the path segments of the shape.}


Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator that can iterate over the path segments of the shape.
getPathIterator
public PathIterator getPathIterator(Transform m)

{Gets an iterator where all points are transformed by the provided transform.
Note: If Transform.isSupported() is false, then using this iterator will throw a
Runtime Exception.
}
Specified by:
getPathIterator in interface Shape
Returns:
A PathIterator where points are transformed by the provided transform.
createTransformedShape
public Shape createTransformedShape(Transform m)

Returns a shape formed by transforming the current shape with the provided
transform.
Note: If Transform.isSupported() is false, this may throw a RuntimeException.
Parameters:
m - The transform to be used to transform the shape.
Returns:
The transformed shape.
intersect
public void intersect(Shape shape)

Resets this path to be the intersection of itself with the given shape. Note that only
Rectangles are current supported. If you pass any other shape, it will throw a
RuntimeException.
Note: If com.codename1.ui.TransformisSupported is false, this will throw a Runtime
Exception
Parameters:
shape

Method Detail

- The shape to intersect with the current shape.

1312

Overview (Codename One API)


intersection
public Shape intersection(Rectangle rect)

{Returns the shape formed by the intersection of this shape and the provided
rectangle.}
Specified by:
intersection in interface Shape
Parameters:
rect - A rectangle with which to form an intersection.
Returns:
The shape formed by intersecting the current shape with the provided
rectangle.
contains
public boolean contains(float x,
float y)

Checks if the given point is contained in the current shape.


contains
public boolean contains(int x,
int y)

{Checks if the shape contains the given point.}


Specified by:
contains in interface Shape
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if (x, y) is inside the shape.

Method Detail

1313

Overview (Codename One API)


com.codename1.ui.geom

Class Dimension2D
java.lang.Object

com.codename1.ui.geom.Dimension2D

public class
extends Object

Utility class that holds a width and height that represents a dimension of a component or element

Constructor Summary
Constructor and Description
Dimension2D()

Creates a new instance of Dimension


Dimension2D(Dimension2D d)

Creates a new instance of Dimension with a predefine dimension


Dimension2D(double width, double height)

CCreates a new instance of Dimension with width and height

Method Summary
Modifier and Type
double
double

Method and Description


getHeight()

Return the height of the dimension


getWidth()

Returns the width of the dimension


setHeight(double height)

void

Set the height of the dimension


setWidth(double width)

void

Set the width of the dimension

String

toString()

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Dimension2D
public Dimension2D()

Creates a new instance of Dimension


Dimension2D
public Dimension2D(Dimension2D d)

Creates a new instance of Dimension with a predefine dimension


Parameters:
d - Dimension to copy

Class Dimension2D

1314

Overview (Codename One API)


Dimension2D
public Dimension2D(double width,
double height)

CCreates a new instance of Dimension with width and height


Parameters:
width - the dimention width
height - the dimention height

Method Detail
setWidth
public void setWidth(double width)

Set the width of the dimension


Parameters:
width - the dimention width
setHeight
public void setHeight(double height)

Set the height of the dimension


Parameters:
height - the dimention height
getWidth
public double getWidth()

Returns the width of the dimension


Returns:
width of the dimension
getHeight
public double getHeight()

Return the height of the dimension


Returns:
height of the dimension
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Constructor Detail

1315

Overview (Codename One API)


com.codename1.ui.geom

Class Dimension
java.lang.Object

com.codename1.ui.geom.Dimension

public class
extends Object

Utility class that holds a width and height that represents a dimension of a component or element

Constructor Summary
Constructor and Description
Dimension()

Creates a new instance of Dimension


Dimension(Dimension d)

Creates a new instance of Dimension with a predefine dimension


Dimension(int width, int height)

CCreates a new instance of Dimension with width and height

Method Summary
Modifier and Type
boolean

Method and Description


equals(Object arg0)

Indicates whether some other object is "equal to" this one.


getHeight()

int

Return the height of the dimension


getWidth()

int

Returns the width of the dimension


hashCode()

int

Returns a hash code value for the object.


setHeight(int height)

void

Set the height of the dimension


setWidth(int width)

void

Set the width of the dimension


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
Dimension
public Dimension()

Creates a new instance of Dimension

Method Detail

1316

Overview (Codename One API)


Dimension
public Dimension(Dimension d)

Creates a new instance of Dimension with a predefine dimension


Parameters:
d - Dimension to copy
Dimension
public Dimension(int width,
int height)

CCreates a new instance of Dimension with width and height


Parameters:
width - the dimention width
height - the dimention height

Method Detail
setWidth
public void setWidth(int width)

Set the width of the dimension


Parameters:
width - the dimention width
setHeight
public void setHeight(int height)

Set the height of the dimension


Parameters:
height - the dimention height
getWidth
public int getWidth()

Returns the width of the dimension


Returns:
width of the dimension
getHeight
public int getHeight()

Return the height of the dimension


Returns:
height of the dimension
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
hashCode
public int hashCode()

Constructor Detail

1317

Overview (Codename One API)


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
equals
public boolean equals(Object arg0)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object

Method Detail

1318

Overview (Codename One API)


com.codename1.ui.events

Interface StyleListener
All Known Implementing Classes:
Ads, AutoCompleteTextField, BaseSpinner, BrowserComponent, Button, Calendar,
ChartComponent, CheckBox, ComboBox, Component, ComponentGroup, Container,
ContainerList, DateSpinner, DateTimeSpinner, DefaultListCellRenderer, Dialog,
EmbeddedContainer, FileTree, FloatingHint, Form, GenericSpinner, HTMLComponent,
ImageViewer, InfiniteContainer, InfiniteProgress, InteractionDialog, Label, LikeButton, List,
MapComponent, MediaPlayer, MenuBar, MultiButton, MultiList, NumericSpinner,
OnOffSwitch, PeerComponent, Picker, Progress, RadioButton, RSSReader,
ScaleImageButton, ScaleImageLabel, ShareButton, SideMenuBar, Slider, SliderBridge,
SpanButton, SpanLabel, SwipeableContainer, Table, Tabs, TextArea, TextField,
TimeSpinner, Toolbar, Tree, VirtualKeyboard, WebBrowser

public interface

Invoked to indicate a change in a Style property

Method Summary
Modifier and Type
void

Method and Description


styleChanged(String propertyName, Style source)

Invoked to indicate a change in a propertyName of a Style

Method Detail
styleChanged
void styleChanged(String propertyName,
Style source)

Invoked to indicate a change in a propertyName of a Style


Parameters:
propertyName - the property name that was changed
source - The changed Style object

Interface StyleListener

1319

Overview (Codename One API)


com.codename1.ui.events

Interface SelectionListener

public interface

Invoked to indicate a selection change in the list model

Method Summary
Modifier and Type

selectionChanged(int oldSelected, int newSelected)

void

Method and Description


Indicates the selection changed in the underlying list model

Method Detail
selectionChanged
void selectionChanged(int oldSelected,
int newSelected)

Indicates the selection changed in the underlying list model


Parameters:
oldSelected - old selected index in list model
newSelected - new selected index in list model

Method Detail

1320

Overview (Codename One API)


com.codename1.ui.events

Interface ScrollListener

public interface

Invoked to indicate a scroll change events

Method Summary
Modifier and
Type

Method and Description


scrollChanged(int scrollX, int scrollY, int oldscrollX,
int oldscrollY)

void

Indicates the scroll changed events

Method Detail
scrollChanged
void scrollChanged(int
int
int
int

scrollX,
scrollY,
oldscrollX,
oldscrollY)

Indicates the scroll changed events


Parameters:
scrollX - the current scroll x value
scrollY - the current scroll y value
oldscrollX - the previous scroll x value
oldscrollY - the previous scroll y value

Method Detail

1321

Overview (Codename One API)


com.codename1.ui.events

Interface FocusListener
All Known Implementing Classes:
DefaultLookAndFeel

public interface

Observes focus change events for a given form and invokes the callbacks to enable us to assign
functionality based on current focused component.

Method Summary
Modifier and Type
void

Invoked when component gains focus


focusLost(Component cmp)

void

Method and Description


focusGained(Component cmp)

Invoked when component loses focus

Method Detail
focusGained
void focusGained(Component cmp)

Invoked when component gains focus


Parameters:
cmp - the component that gains focus
focusLost
void focusLost(Component cmp)

Invoked when component loses focus


Parameters:
cmp - the component that lost focus

Method Detail

1322

Overview (Codename One API)


com.codename1.ui.events

Interface DataChangedListener
All Known Implementing Classes:
FilterProxyListModel

public interface

Event callback interface invoked when a ListModel changes its state thus indicating to the view that it
should refresh.

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


ADDED

Type value for added data in ListModel


CHANGED

Type value for changed data in ListModel


REMOVED

Type value for removed data in ListModel

Method Summary
Modifier and Type
void

Method and Description


dataChanged(int type, int index)

Invoked when there was a change in the underlying model

Field Detail
REMOVED
static final int REMOVED

Type value for removed data in ListModel


See Also:
Constant Field Values
ADDED
static final int ADDED

Type value for added data in ListModel


See Also:
Constant Field Values
CHANGED
static final int CHANGED

Type value for changed data in ListModel


See Also:
Constant Field Values

Method Detail

Method Detail

1323

Overview (Codename One API)


dataChanged
void dataChanged(int type,
int index)

Invoked when there was a change in the underlying model


Parameters:
type - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model

Method Detail

1324

Overview (Codename One API)


com.codename1.ui.events

Interface BrowserNavigationCallback

public interface

Important: Calls to this interface are always performed on a separate thread from the EDT!
They are performed on the native webkit rendering thread or native event dispatch thread, this
interface MUST NEVER block or synchronize against the EDT which WILL lead to deadlocks.
This interface can be used to bind functionality to URL navigation which is a very portable way to
invoke Java functionality from the JavaScript side of things.
This interface should be applied to the BrowserComponent or WebBrowser class.

Method Summary
Modifier
and Type

Method and Description


shouldNavigate(String url)

boolean

Important: Calls to this interface are always performed on a separate


thread from the EDT! They are performed on the native webkit rendering
thread or native event dispatch thread, this interface MUST NEVER block
or synchronize against the EDT which WILL lead to deadlocks.

Method Detail
shouldNavigate
boolean shouldNavigate(String url)

Important: Calls to this interface are always performed on a separate thread


from the EDT! They are performed on the native webkit rendering thread or
native event dispatch thread, this interface MUST NEVER block or synchronize
against the EDT which WILL lead to deadlocks.
This method can be used to bind functionality to URL navigation which is a very
portable way to invoke Java functionality from the JavaScript side of things. The
method should return true if navigation should occur otherwise it can return false and
do any processing it desires with the requested URL.
Parameters:
url - the URL requested
Returns:
true to navigate to the given URL, false to ignore it.

Interface BrowserNavigationCallback

1325

Overview (Codename One API)


com.codename1.ui.events

Interface ActionListener
All Known Implementing Classes:
Command, EmailShare, FacebookShare, HTMLComponent, LikeButton, MenuBar,
NavigationCommand, Progress, ShareButton, ShareService, SideMenuBar, SMSShare

public interface

Event callback interface invoked when a component action occurs

Method Summary
Modifier and Type
void

Method and Description


actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component

Method Detail
actionPerformed
void actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component


Parameters:
evt - event object describing the source of the action as well as its trigger

Method Detail

1326

Overview (Codename One API)


com.codename1.ui.events

Class ActionEvent
java.lang.Object

com.codename1.ui.events.ActionEvent
Direct Known Subclasses:
NetworkEvent

public class
extends Object

Event object delivered when an ActionListener callback is invoked

Nested Class Summary


Modifier and Type
static class

Class and Description


ActionEvent.Type

The event type, as declared when the event is created.

Constructor Summary
Constructor and Description
ActionEvent(Command source, ActionEvent.Type type, Component sourceComponent,
int x, int y)

Creates a new instance of ActionEvent for a command


ActionEvent(Command source, Component sourceComponent, int x, int y)

Creates a new instance of ActionEvent for a command


ActionEvent(Component dragged, ActionEvent.Type type, Component drop, int x,
int y)

Creates a new instance of ActionEvent for a drop operation


ActionEvent(Component dragged, Component drop, int x, int y)

Creates a new instance of ActionEvent for a drop operation


ActionEvent(Object source)

Creates a new instance of ActionEvent.


ActionEvent(Object source, ActionEvent.Type type)

Creates a new instance of ActionEvent


ActionEvent(Object source, ActionEvent.Type type, int keyEvent)

Creates a new instance of ActionEvent.


ActionEvent(Object source, ActionEvent.Type type, int x, int y)

Creates a new instance of ActionEvent as a pointer event


ActionEvent(Object source, int keyEvent)

Creates a new instance of ActionEvent


ActionEvent(Object source, int keyEvent, boolean longClick)

Creates a new instance of ActionEvent


ActionEvent(Object source, int x, int y)

Creates a new instance of ActionEvent as a generic pointer event.


ActionEvent(Object source, int x, int y, boolean longPointer)

Creates a new instance of ActionEvent as a pointer event

Method Summary
Modifier and
Type

Method Detail

Method and Description

1327

Overview (Codename One API)


consume()

Consume the event indicating that it was handled thus preventing other
action listeners from handling/receiving the event

void

Component

getActualComponent()
Identical to getComponent()

except for the fact that a lead component


will be returned if such a lead component is available.
getCommand()

Command

Component
Component

If this event was sent as a result of a command action this method


returns that command
getComponent()

Returns the component that generated the event.


getDraggedComponent()

Set in the case of a drop listener, returns the component being dragged
getDropTarget()

Component

Set in the case of a drop listener, returns the component on which the
drop occurs
getEventType()

ActionEvent.Type

Returns the type of the given event allowing us to have more generic
event handling code and useful for debugging
getKeyEvent()

If this event was triggered by a key press this method will return the
appropriate keycode

int

getSource()

The element that triggered the action event, useful for decoupling event
handling code

Object

getX()

int

The X position if this is a pointer event otherwise undefined


getY()

int

The Y position if this is a pointer event otherwise undefined


isConsumed()

boolean

boolean

Returns true if the event was consumed thus indicating that it was
handled.
isLongEvent()

Returns true for long click or long pointer event

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ActionEvent
public ActionEvent(Object source)

Creates a new instance of ActionEvent. This is unused locally, but provided so


existing customer code with still work.
Parameters:
source - element for the action event
ActionEvent
public ActionEvent(Object source,
ActionEvent.Type type)

Creates a new instance of ActionEvent


Parameters:
source - element for the action event
type - the ActionEvent.Type of the event

Method Summary

1328

Overview (Codename One API)


ActionEvent
public ActionEvent(Object source,
ActionEvent.Type type,
int x,
int y)

Creates a new instance of ActionEvent as a pointer event


Parameters:
source - element for the pointer event
type - the ActionEvent.Type of the event
x - (or sometimes width) associated with the event
y - (or sometimes height)associated with the event
ActionEvent
public ActionEvent(Command source,
ActionEvent.Type type,
Component sourceComponent,
int x,
int y)

Creates a new instance of ActionEvent for a command


Parameters:
source - element command
type - the ActionEvent.Type of the event
sourceComponent - the triggering component
x - the x position of the pointer event
y - the y position of the pointer event
ActionEvent
public ActionEvent(Component dragged,
ActionEvent.Type type,
Component drop,
int x,
int y)

Creates a new instance of ActionEvent for a drop operation


Parameters:
dragged - the dragged component
type - the ActionEvent.Type of the event
drop - the drop target component
x - the x position of the pointer event
y - the y position of the pointer event
ActionEvent
public ActionEvent(Object source,
ActionEvent.Type type,
int keyEvent)

Creates a new instance of ActionEvent. The key event is really just a numeric code,
not indicative of a key press
Parameters:
source - element for the action event
type - the ActionEvent.Type of the event
keyEvent - the key that triggered the event
ActionEvent
public ActionEvent(Object source,
int keyEvent)

Creates a new instance of ActionEvent


Parameters:
source - element for the action event
keyEvent - the key that triggered the event
ActionEvent
public ActionEvent(Object source,
int keyEvent,
boolean longClick)

Constructor Detail

1329

Overview (Codename One API)


Creates a new instance of ActionEvent
Parameters:
source - element for the action event
keyEvent - the key that triggered the event
longClick - true if the event is triggered from long pressed
ActionEvent
public ActionEvent(Object source,
int x,
int y,
boolean longPointer)

Creates a new instance of ActionEvent as a pointer event


Parameters:
source - element for the pointer event
x - the x position of the pointer event
y - the y position of the pointer event
longPointer - true if the event is triggered from long pressed
ActionEvent
public ActionEvent(Object source,
int x,
int y)

Creates a new instance of ActionEvent as a generic pointer event.


Parameters:
source - element for the pointer event
x - the x position of the pointer event
y - the y position of the pointer event
ActionEvent
public ActionEvent(Command source,
Component sourceComponent,
int x,
int y)

Creates a new instance of ActionEvent for a command


Parameters:
source - element command
sourceComponent - the triggering component
x - the x position of the pointer event
y - the y position of the pointer event
ActionEvent
public ActionEvent(Component dragged,
Component drop,
int x,
int y)

Creates a new instance of ActionEvent for a drop operation


Parameters:
dragged - the dragged component
drop - the drop target component
x - the x position of the pointer event
y - the y position of the pointer event

Method Detail
getEventType
public ActionEvent.Type getEventType()

Returns the type of the given event allowing us to have more generic event handling
code and useful for debugging
Returns:
the Type enum

Constructor Detail

1330

Overview (Codename One API)


getSource
public Object getSource()

The element that triggered the action event, useful for decoupling event handling
code
Returns:
the element that triggered the action event
getKeyEvent
public int getKeyEvent()

If this event was triggered by a key press this method will return the appropriate
keycode
Returns:
the key that triggered the event
getCommand
public Command getCommand()

If this event was sent as a result of a command action this method returns that
command
Returns:
the command action that triggered the action event
getActualComponent
public Component getActualComponent()

Identical to getComponent() except for the fact that a lead component will be returned
if such a lead component is available. This is important for components such as
MultiButton which will return the underlying button instead.
Returns:
the component that sent the event
getComponent
public Component getComponent()

Returns the component that generated the event. important this might not be the
actual component. In case of a lead component such as MultiButton the underlying
Button will be returned and not the MultiButton itself. To get the component that you
would logically think of as the source component use the getActualComponent
method.
If you are in doubt use the getActualComponent method.
Returns:
a component
See Also:
- you should probably use {@code getActualComponent} instead of this
method

consume
public void consume()

Consume the event indicating that it was handled thus preventing other action
listeners from handling/receiving the event
isConsumed
public boolean isConsumed()

Returns true if the event was consumed thus indicating that it was handled. This
prevents other action listeners from handling/receiving the event
Returns:
true if the event was consumed

Method Detail

1331

Overview (Codename One API)


getX
public int getX()

The X position if this is a pointer event otherwise undefined


Returns:
x position
getY
public int getY()

The Y position if this is a pointer event otherwise undefined


Returns:
y position
isLongEvent
public boolean isLongEvent()

Returns true for long click or long pointer event


getDraggedComponent
public Component getDraggedComponent()

Set in the case of a drop listener, returns the component being dragged
Returns:
the component being dragged
getDropTarget
public Component getDropTarget()

Set in the case of a drop listener, returns the component on which the drop occurs
Returns:
the component on which the drop occurs

Method Detail

1332

Overview (Codename One API)


com.codename1.ui.events

Enum ActionEvent.Type
java.lang.Object

java.lang.Enum<ActionEvent.Type>

com.codename1.ui.events.ActionEvent.Type
All Implemented Interfaces:
Comparable<ActionEvent.Type>
Enclosing class:
ActionEvent

public static enum


extends Enum<ActionEvent.Type>

The event type, as declared when the event is created.

Enum Constant Summary


Enum Constant and Description
Calendar
Command
Data
Done
Edit
Exception
File
JavaScript
KeyPress
KeyRelease
Log
OrientationChange
Other
Pointer
PointerDrag
PointerPressed
PointerReleased
Progress
Response
Show
SizeChange
Swipe
Theme

Method Summary
Modifier and Type
static ActionEvent.Type

Enum ActionEvent.Type

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.

1333

Overview (Codename One API)


static
ActionEvent.Type[]

values()

Returns an array containing the constants of this enum type, in


the order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


Other
public static final ActionEvent.Type Other

Command
public static final ActionEvent.Type Command

Pointer
public static final ActionEvent.Type Pointer

PointerPressed
public static final ActionEvent.Type PointerPressed

PointerReleased
public static final ActionEvent.Type PointerReleased

PointerDrag
public static final ActionEvent.Type PointerDrag

Swipe
public static final ActionEvent.Type Swipe

KeyPress
public static final ActionEvent.Type KeyPress

KeyRelease
public static final ActionEvent.Type KeyRelease

Exception
public static final ActionEvent.Type Exception

Response
public static final ActionEvent.Type Response

Progress
public static final ActionEvent.Type Progress

Data
public static final ActionEvent.Type Data

Calendar
public static final ActionEvent.Type Calendar

Edit
public static final ActionEvent.Type Edit

Done
public static final ActionEvent.Type Done

Method Summary

1334

Overview (Codename One API)


File
public static final ActionEvent.Type File

JavaScript
public static final ActionEvent.Type JavaScript

Log
public static final ActionEvent.Type Log

Theme
public static final ActionEvent.Type Theme

Show
public static final ActionEvent.Type Show

SizeChange
public static final ActionEvent.Type SizeChange

OrientationChange
public static final ActionEvent.Type OrientationChange

Method Detail
values
public static ActionEvent.Type[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (ActionEvent.Type c : ActionEvent.Type.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static ActionEvent.Type valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Enum Constant Detail

1335

Overview (Codename One API)


com.codename1.ui.animations

Class Transition
java.lang.Object

com.codename1.ui.animations.Transition
All Implemented Interfaces:
Animation
Direct Known Subclasses:
CommonTransitions, FlipTransition, MorphTransition

public abstract class


extends Object
implements Animation

Represents a transition animation between two forms this class is used internally by Display to play
an animation when moving from one form to the next. A transition can be installed on a Form object
using the in/out transitions, for ease of use LookAndFeel has support for default transitions.

Constructor Summary
Constructor and Description
Transition()

Method Summary
Modifier and
Type
abstract
boolean
protected
void

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


cleanSource()

Allows setting the source form to null to save memory if the transition
doesn't need it in memory.
cleanup()

void

Optional operation to cleanup the garbage left over by a running transition

Transition

copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.


getDestination()

Component

Returns the destination form that should be set once animation is


completed
getSource()

Component

Returns the source form which is the form from which the animation is
starting.
init(Component source, Component destination)
Invoked by Display to set the source and destination

void

forms.

initTransition()

Callback thats invoked before a transition begins, the source form may be
null for the first form in the application.

void

paint(Graphics g)
abstract void

Draws the animation, within a component the standard paint method would
be invoked since it bares the exact same signature.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

1336

Overview (Codename One API)


Constructor

Detail

Transition
public Transition()

Method Detail
init
public final void init(Component source,
Component destination)

Invoked by Display to set the source and destination forms. This method should not
be invoked by developers.
Parameters:
source - the source form from which the transition originates
destination - the destination form to which the transition will lead
initTransition
public void initTransition()

Callback thats invoked before a transition begins, the source form may be null for the
first form in the application.
getDestination
public final Component getDestination()

Returns the destination form that should be set once animation is completed
Returns:
the destination component
getSource
public final Component getSource()

Returns the source form which is the form from which the animation is starting. This
may be null for the first form in the application
Returns:
the source component
cleanup
public void cleanup()

Optional operation to cleanup the garbage left over by a running transition


copy
public Transition copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.


Parameters:
reverse - creates a new transition instance with "reverse" behavior useful for
signifying "back" operations
Returns:
new transition instance
cleanSource
protected final void cleanSource()

Allows setting the source form to null to save memory if the transition doesn't need it
in memory.
animate
public abstract boolean animate()

Constructor Detail

1337

Overview (Codename One API)

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public abstract void paint(Graphics g)

Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation
Parameters:
g - graphics context

Method Detail

1338

Overview (Codename One API)


com.codename1.ui.animations

Class Timeline
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.animations.Timeline
All Implemented Interfaces:
Animation, Painter

public final class


extends Image
implements Animation, Painter

A timeline represents the motions of animation objects

Method Summary
Modifier and
Type
void

Method and Description


addAnimation(AnimationObject o)

Adds an animation object to show using this timeline

boolean

animate()

static Timeline

createTimeline(int duration, AnimationObject[] animations,


Dimension size)

Create a new timeline animation


drawImage(Graphics g, Object nativeGraphics, int x, int y)
protected void

AnimationObject

Callback invoked internally by Codename One to draw the image/frame


onto the display.
getAnimation(int i)

Returns the animation object in the given offset


getAnimationAt(int x, int y)

AnimationObject

int

Returns the animation object at the given X/Y coordinate in the timeline
for the current frame.
getAnimationCount()

Returns the number of animation objects in this timeline


getAnimationDelay()

int

int
int
int[]

Inidicates the minimal delay between animation frames allowing the CPU
to rest.
getDuration()

Returns the duration of the entire timeline in milliseconds


getHeight()

Returns the height of the image


getRGB()

Returns the content of this image as a newly created ARGB array.


getRGBCached()

int[]

Dimension
int
int
boolean

Class Timeline

Returns the content of this image as a newly created ARGB array or a


cached instance if possible.
getSize()

Returns the pixel based unscaled dimentions of this timeline


getTime()

Returns the time of the timeline


getWidth()

Returns the width of the image


isAnimation()

Returns true if this is an animated image

1339

Overview (Codename One API)


boolean
boolean

isLoop()

Indicates if the image should loop


isPause()

Returns true when the timeline is paused


lock()

This callback indicates that a component pointing at this image is


initialized, this allows an image to make performance sensitive
considerations e.g.

void

paint(Graphics g)

Draws the animation, within a component the standard paint method


would be invoked since it bares the exact same signature.

void

paint(Graphics g, Rectangle rect)

void

Draws inside the given rectangle clipping area.


requiresDrawImage()

boolean

New label optimizations don't invoke drawImage and instead just pass
the native image directly to the underlying renderer.
scaled(int width, int height)

Returns a scaled version of this image image using the given width and
height, this is a fast algorithm that preserves translucent information.

Image

setAnimationDelay(int animationDelay)

Inidicates the minimal delay between animation frames allowing the CPU
to rest.

void

setLoop(boolean loop)

void

Indicates if the image should loop


setPause(boolean pause)

void

Indicate that the application is paused


setTime(int time)

void

Set the time of the timeline


unlock()

This callback indicates that a component pointing at this image is now


deinitilized This method may be invoked multiple times.

void

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, asyncLock, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, dispose, drawImage,
flipHorizontally, flipVertically, getGraphics, getImage, getImageName,
getSVGDocument, isAlphaMutableImageSupported, isLocked, isOpaque, isSVG,
isSVGSupported, mirror, modifyAlpha, modifyAlpha,
modifyAlphaWithTranslucency, rotate, rotate180Degrees, rotate270Degrees,
rotate90Degrees, scale, scaledHeight, scaledLargerRatio,
scaledSmallerRatio, scaledWidth, setImageName, subImage, toRGB

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
lock
public void lock()

This callback indicates that a component pointing at this image is initialized, this
allows an image to make performance sensitive considerations e.g. an encoded
image might choose to cache itself in RAM. This method may be invoked multiple
times.
Overrides:
lock in class Image

Method Summary

1340

Overview (Codename One API)


unlock
public void unlock()

This callback indicates that a component pointing at this image is now deinitilized
This method may be invoked multiple times.
Overrides:
unlock in class Image
getRGB
public int[] getRGB()

Returns the content of this image as a newly created ARGB array.


Overrides:
getRGB in class Image
Returns:
new array instance containing the ARGB data within this image
getRGBCached
public int[] getRGBCached()

Returns the content of this image as a newly created ARGB array or a cached
instance if possible. Note that cached instances may be garbage collected.
Overrides:
getRGBCached in class Image
Returns:
array instance containing the ARGB data within this image
createTimeline
public static Timeline createTimeline(int duration,
AnimationObject[] animations,
Dimension size)

Create a new timeline animation


Parameters:
duration - the duration of the animation in milliseconds
animations - the animation objects that are part of this timeline
size - size of the animation in virtual pixels, if the size differs the animation
would be scaled on the fly
Returns:
the new timeline instance
addAnimation
public void addAnimation(AnimationObject o)

Adds an animation object to show using this timeline


Parameters:
o - animation object featured in this timeline
setTime
public void setTime(int time)

Set the time of the timeline


Parameters:
time - the time of the timeline in ms starting from 0
getTime
public int getTime()

Returns the time of the timeline


Returns:
the time of the timeline in ms starting from 0
isAnimation
public boolean isAnimation()

Returns true if this is an animated image

Method Detail

1341

Overview (Codename One API)


Overrides:
isAnimation in class Image
Returns:
true if this image represents an animation
animate
public boolean animate()

Specified by:
animate

in interface Animation

Overrides:
animate in class Image
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public void paint(Graphics g)

Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation
Parameters:
g - graphics context
paint
public void paint(Graphics g,
Rectangle rect)

Draws inside the given rectangle clipping area.


Specified by:
paint in interface Painter
Parameters:
g - the Graphics object
rect - the given rectangle cliping area
getAnimationDelay
public int getAnimationDelay()

Inidicates the minimal delay between animation frames allowing the CPU to rest.
Increase this number to increase general device performance, decrease it to speed
the animation.
Returns:
the animationDelay
setAnimationDelay
public void setAnimationDelay(int animationDelay)

Inidicates the minimal delay between animation frames allowing the CPU to rest.
Increase this number to increase general device performance, decrease it to speed
the animation.
Parameters:
animationDelay - the animationDelay to set
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object

Method Detail

1342

Overview (Codename One API)


- the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
getWidth
nativeGraphics

public int getWidth()

Returns the width of the image


Overrides:
getWidth in class Image
Returns:
the width of the image
getHeight
public int getHeight()

Returns the height of the image


Overrides:
getHeight in class Image
Returns:
the height of the image
scaled
public Image scaled(int width,
int height)

Returns a scaled version of this image image using the given width and height, this is
a fast algorithm that preserves translucent information. The method accepts -1 to
preserve aspect ratio in the given axis.
Overrides:
scaled in class Image
Parameters:
width - width for the scaling
height - height of the scaled image
Returns:
new image instance scaled to the given height and width
isPause
public boolean isPause()

Returns true when the timeline is paused


Returns:
the pause state
setPause
public void setPause(boolean pause)

Indicate that the application is paused


Parameters:
pause - true to pause the application
getDuration
public int getDuration()

Returns the duration of the entire timeline in milliseconds


Returns:
the duration
getSize
public Dimension getSize()

Returns the pixel based unscaled dimentions of this timeline


Returns:
the size

Method Detail

1343

Overview (Codename One API)


getAnimationCount
public int getAnimationCount()

Returns the number of animation objects in this timeline


Returns:
the number of animations
getAnimation
public AnimationObject getAnimation(int i)

Returns the animation object in the given offset


Parameters:
i - the offset of the animation
Returns:
the animation object
getAnimationAt
public AnimationObject getAnimationAt(int x,
int y)

Returns the animation object at the given X/Y coordinate in the timeline for the
current frame. This allows functionality such as responding to pointer events on the
resource editor. Notice that this method is not efficient since it tests the pixel opacity
which is a pretty expensive operation...
Parameters:
x - the x location in the timeline
y - the y location in the timeline
Returns:
an animation object or null if no animation object is at that position.
isLoop
public boolean isLoop()

Indicates if the image should loop


Returns:
the loop
setLoop
public void setLoop(boolean loop)

Indicates if the image should loop


Parameters:
loop - the loop to set
requiresDrawImage
public boolean requiresDrawImage()

New label optimizations don't invoke drawImage and instead just pass the native
image directly to the underlying renderer. This is problematic for some image types
specifically timeline & FontImage and this method allows these classes to indicate
that they need that legacy behavior of calling drawImage.
Overrides:
requiresDrawImage in class Image
Returns:
true if a drawImage call is a required

Method Detail

1344

Overview (Codename One API)


com.codename1.ui.animations

Class Motion
java.lang.Object

com.codename1.ui.animations.Motion

public class
extends Object

Abstracts the notion of physical motion over time from a numeric location to another. This class can
be subclassed to implement any motion equation for appropriate physics effects.
This class relies on the System.currentTimeMillis() method to provide transitions between
coordinates. The motion can be subclassed to provide every type of motion feel from parabolic motion
to spline and linear motion. The default implementation provides a simple algorithm giving the feel of
acceleration and deceleration.

Constructor Summary
Modifier

Constructor and Description

protected Motion(int sourceValue, double initVelocity, double friction)


protected
protected

Motion(int sourceValue, float initVelocity, float friction)

Construct a velocity motion


Motion(int sourceValue, int destinationValue, int duration)

Construct a point/destination motion

Method Summary
Modifier
and Type
static
Motion

static
Motion

static
Motion
static
Motion
static
Motion
static
Motion
static
Motion
static
Motion
static
Motion

Class Motion

Method and Description


createCubicBezierMotion(int sourceValue, int destinationValue,
int duration, float p0, float p1, float p2, float p3)

Creates a standard Cubic Bezier motion to implement functions such as


ease-in/out etc.
createDecelerationMotion(int sourceValue, int destinationValue,
int duration)

Creates a deceleration motion starting from source value all the way to
destination value
createEaseInMotion(int sourceValue, int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0f, 0.42f, 1f, 1f as arguments.


createEaseInOutMotion(int sourceValue, int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0, 0.42, 0.58, 1.0 as arguments.


createEaseMotion(int sourceValue, int destinationValue, int duration)

Equivalent to createCubicBezierMotion with 0f, 0.25f, 0.25f, 1 as arguments.


createEaseOutMotion(int sourceValue, int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0f, 0f, 0.58f, 1.0f as arguments.


createExponentialDecayMotion(int sourceValue, int maxValue,
double initVelocity, double timeConstant)
createFrictionMotion(int sourceValue, int maxValue,
float initVelocity, float friction)

Creates a friction motion starting from source with initial speed and the friction
createLinearColorMotion(int sourceValue, int destinationValue,
int duration)

1345

Overview (Codename One API)


Creates a linear motion starting from source value all the way to destination
value for a color value.
createLinearMotion(int sourceValue, int destinationValue,
int duration)

static
Motion

Creates a linear motion starting from source value all the way to destination
value
createSplineMotion(int sourceValue, int destinationValue,
int duration)

static
Motion

Creates a spline motion starting from source value all the way to destination
value
finish()

Sends the motion to the end time instantly which is useful for flushing an
animation

void

getCurrentMotionTime()

long

Returns the current time within the motion relative to start time
getDestinationValue()

int

The number to which we will reach when the motion is finished


getDuration()

int

Returns the animation duration


getSourceValue()

int

The number from which we are starting (usually indicating animation start
position)

protected
long

getStartTime()

The value of System.currentTimemillis() when motion was started


getValue()

int

Returns the value for the motion for the current clock time.
isFinished()

boolean

static
boolean

Returns true if the motion has run its course and has finished meaning the
current time is greater than startTime + duration.
isSlowMotion()

Allows debugging motion behavior by slowing motions down 50 fold, doesn't


apply to friction motion
setCurrentMotionTime(long currentMotionTime)

Allows overriding the getCurrentMotionTime method value with a manual


value to provide full developer control over animation speed/position.

void

setSlowMotion(boolean aSlowMotion)
static void

Allows debugging motion behavior by slowing motions down 50 fold, doesn't


apply to friction motion
setSourceValue(int sourceValue)

The number from which we are starting (usually indicating animation start
position)

void

setStartTime(long startTime)

void

Sets the start time of the motion


start()

void

Sets the start time to the current time

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Motion
protected Motion(int sourceValue,
int destinationValue,
int duration)

Construct a point/destination motion

Method Summary

1346

Overview (Codename One API)


Parameters:
sourceValue - starting value
destinationValue - destination
duration - motion duration

value

Motion
protected Motion(int sourceValue,
float initVelocity,
float friction)

Construct a velocity motion


Parameters:
sourceValue - starting value
initVelocity - initial velocity
friction - degree of friction
Motion
protected Motion(int sourceValue,
double initVelocity,
double friction)

Method Detail
isSlowMotion
public static boolean isSlowMotion()

Allows debugging motion behavior by slowing motions down 50 fold, doesn't apply to
friction motion
Returns:
the slowMotion
setSlowMotion
public static void setSlowMotion(boolean aSlowMotion)

Allows debugging motion behavior by slowing motions down 50 fold, doesn't apply to
friction motion
Parameters:
aSlowMotion - the slowMotion to set
finish
public void finish()

Sends the motion to the end time instantly which is useful for flushing an animation
createCubicBezierMotion
public static Motion createCubicBezierMotion(int sourceValue,
int destinationValue,
int duration,
float p0,
float p1,
float p2,
float p3)

Creates a standard Cubic Bezier motion to implement functions such as ease-in/out


etc.
Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration
p0 - argument to the bezier function
p1 - argument to the bezier function
p2 - argument to the bezier function
p3 - argument to the bezier function
Returns:
Motion instance

Constructor Detail

1347

Overview (Codename One API)


createEaseInOutMotion
public static Motion createEaseInOutMotion(int sourceValue,
int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0, 0.42, 0.58, 1.0 as arguments.


Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration
Returns:
Motion instance
createEaseMotion
public static Motion createEaseMotion(int sourceValue,
int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0f, 0.25f, 0.25f, 1 as arguments.


Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration
Returns:
Motion instance
createEaseInMotion
public static Motion createEaseInMotion(int sourceValue,
int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0f, 0.42f, 1f, 1f as arguments.


Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration
Returns:
Motion instance
createEaseOutMotion
public static Motion createEaseOutMotion(int sourceValue,
int destinationValue,
int duration)

Equivalent to createCubicBezierMotion with 0f, 0f, 0.58f, 1.0f as arguments.


Parameters:
sourceValue - starting value
destinationValue - destination value
duration - motion duration
Returns:
Motion instance
createLinearMotion
public static Motion createLinearMotion(int sourceValue,
int destinationValue,
int duration)

Creates a linear motion starting from source value all the way to destination value
Parameters:
sourceValue - the number from which we are starting (usually indicating
animation start position)
destinationValue - the number to which we are heading (usually indicating
animation destination)
duration - the length in milliseconds of the motion (time it takes to get from
sourceValue to destinationValue)
Returns:
new motion object

Method Detail

1348

Overview (Codename One API)


createLinearColorMotion
public static Motion createLinearColorMotion(int sourceValue,
int destinationValue,
int duration)

Creates a linear motion starting from source value all the way to destination value for
a color value. Unlike a regular linear motion a color linear motion is shifted based on
channels where red, green & blue get shifted separately.
Parameters:
sourceValue - the color from which we are starting
destinationValue - the destination color
duration - the length in milliseconds of the motion (time it takes to get from
sourceValue to destinationValue)
Returns:
new motion object
createSplineMotion
public static Motion createSplineMotion(int sourceValue,
int destinationValue,
int duration)

Creates a spline motion starting from source value all the way to destination value
Parameters:
sourceValue - the number from which we are starting (usually indicating
animation start position)
destinationValue - the number to which we are heading (usually indicating
animation destination)
duration - the length in milliseconds of the motion (time it takes to get from
sourceValue to destinationValue)
Returns:
new motion object
createDecelerationMotion
public static Motion createDecelerationMotion(int sourceValue,
int destinationValue,
int duration)

Creates a deceleration motion starting from source value all the way to destination
value
Parameters:
sourceValue - the number from which we are starting (usually indicating
animation start position)
destinationValue - the number to which we are heading (usually indicating
animation destination)
duration - the length in milliseconds of the motion (time it takes to get from
sourceValue to destinationValue)
Returns:
new motion object
createFrictionMotion
public static Motion createFrictionMotion(int sourceValue,
int maxValue,
float initVelocity,
float friction)

Creates a friction motion starting from source with initial speed and the friction
Parameters:
sourceValue - the number from which we are starting (usually indicating
animation start position)
maxValue - the maximum value for the friction
initVelocity - the starting velocity
friction - the motion friction
Returns:
new motion object

Method Detail

1349

Overview (Codename One API)


createExponentialDecayMotion
public static Motion createExponentialDecayMotion(int sourceValue,
int maxValue,
double initVelocity,
double timeConstant)

start
public void start()

Sets the start time to the current time


getCurrentMotionTime
public long getCurrentMotionTime()

Returns the current time within the motion relative to start time
Returns:
long value representing System.currentTimeMillis() - startTime
setCurrentMotionTime
public void setCurrentMotionTime(long currentMotionTime)

Allows overriding the getCurrentMotionTime method value with a manual value to


provide full developer control over animation speed/position.
Parameters:
currentMotionTime - the time in milliseconds for the motion.
setStartTime
public void setStartTime(long startTime)

Sets the start time of the motion


Parameters:
startTime - the starting time
isFinished
public boolean isFinished()

Returns true if the motion has run its course and has finished meaning the current
time is greater than startTime + duration.
Returns:
true if System.currentTimeMillis() > duration + startTime or the last returned
value is the destination value
getValue
public int getValue()

Returns the value for the motion for the current clock time. The value is dependent on
the Motion type.
Returns:
a value that is relative to the source value
getSourceValue
public int getSourceValue()

The number from which we are starting (usually indicating animation start position)
Returns:
the source value
getDestinationValue
public int getDestinationValue()

The number to which we will reach when the motion is finished


Returns:
the source value

Method Detail

1350

Overview (Codename One API)


setSourceValue
public void setSourceValue(int sourceValue)

The number from which we are starting (usually indicating animation start position)
Parameters:
sourceValue - the source value
getStartTime
protected long getStartTime()

The value of System.currentTimemillis() when motion was started


Returns:
the start time
getDuration
public int getDuration()

Returns the animation duration


Returns:
animation duration in milliseconds

Method Detail

1351

Overview (Codename One API)


com.codename1.ui.animations

Class MorphTransition
java.lang.Object

com.codename1.ui.animations.Transition

com.codename1.ui.animations.MorphTransition
All Implemented Interfaces:
Animation

public class
extends Transition

A transition inspired by the Android L release morph activity effect allowing a set of components in
one form/container to morph into another in a different container/form.

Method Summary
Modifier and Type
boolean
Transition
static
MorphTransition

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.


create(int duration)

Creates a transition with the given duration, this transition should be


modified with the builder methods such as morph
initTransition()

Callback thats invoked before a transition begins, the source form may
be null for the first form in the application.

void

morph(String source, String to)


MorphTransition

Morphs the component with the given source name in the source
container hierarchy to the component with the given name in the
destination hierarchy
paint(Graphics g)

Draws the animation, within a component the standard paint method


would be invoked since it bares the exact same signature.

void

Methods inherited from


class com.codename1.ui.animations.Transition
cleanSource, cleanup, getDestination, getSource, init

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
copy
public Transition copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.


Overrides:
copy in class Transition
Parameters:

Class MorphTransition

1352

Overview (Codename One API)


- creates a new transition instance with "reverse" behavior useful for
signifying "back" operations
Returns:
new transition instance
create
reverse

public static MorphTransition create(int duration)

Creates a transition with the given duration, this transition should be modified with the
builder methods such as morph
Parameters:
duration - the duration of the transition
Returns:
a new Morph transition instance
morph
public MorphTransition morph(String source,
String to)

Morphs the component with the given source name in the source container hierarchy
to the component with the given name in the destination hierarchy
Parameters:
source to Returns:
this so morph operations can be chained as MorphTransition t =
MorphTransition.create(300).morph("a", "b").("c", "d");
initTransition
public final void initTransition()

Callback thats invoked before a transition begins, the source form may be null for the
first form in the application.
Overrides:
initTransition in class Transition
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Specified by:
animate in class Transition
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public void paint(Graphics g)

Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation
Specified by:
paint in class Transition
Parameters:
g - graphics context

Method Detail

1353

Overview (Codename One API)


com.codename1.ui.animations

Class FlipTransition
java.lang.Object

com.codename1.ui.animations.Transition

com.codename1.ui.animations.FlipTransition
All Implemented Interfaces:
Animation

public class
extends Transition

A Transitions that flips between 2 views

Constructor Summary
Constructor and Description
FlipTransition()

Creates a Flip Transition


FlipTransition(int bgColor)

Creates a Flip Transition


FlipTransition(int bgColor, int duration)

Creates a Flip Transition

Method Summary
Modifier and
Type
boolean

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


cleanup()

void

Optional operation to cleanup the garbage left over by a running transition


getBgColor()

The background color that is painted behind the flipping effect or -1 to use
the paintBackgrounds method instead

int

getDuration()

int

The duration for the flip transition


initTransition()

Callback thats invoked before a transition begins, the source form may be
null for the first form in the application.

void

paint(Graphics g)

Draws the animation, within a component the standard paint method would
be invoked since it bares the exact same signature.

void

setBgColor(int bgColor)

The background color that is painted behind the flipping effect or -1 to use
the paintBackgrounds method instead

void

setDuration(int duration)

void

The duration for the flip transition

Methods inherited from


class com.codename1.ui.animations.Transition
cleanSource, copy, getDestination, getSource, init

Class FlipTransition

1354

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FlipTransition
public FlipTransition()

Creates a Flip Transition


FlipTransition
public FlipTransition(int bgColor)

Creates a Flip Transition


Parameters:
bgColor - the color to paint in the background when the transition paints, use
-1 to not paint a background color
FlipTransition
public FlipTransition(int bgColor,
int duration)

Creates a Flip Transition


Parameters:
bgColor - the color to paint in the background when the transition paints, use
-1 to not paint a background color
duration - the duration of the transition

Method Detail
initTransition
public void initTransition()

Description copied from class: Transition


Callback thats invoked before a transition begins, the source form may be null for the
first form in the application.
Overrides:
initTransition in class Transition
animate
public boolean animate()

Description copied from class: Transition


Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Specified by:
animate in class Transition
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public void paint(Graphics g)

Description copied from class: Transition


Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation

Methods inherited from class java.lang.Object

1355

Overview (Codename One API)


Specified by:
paint in class Transition
Parameters:
g - graphics context
cleanup
public void cleanup()

Description copied from class: Transition


Optional operation to cleanup the garbage left over by a running transition
Overrides:
cleanup in class Transition
getDuration
public int getDuration()

The duration for the flip transition


Returns:
the duration
setDuration
public void setDuration(int duration)

The duration for the flip transition


Parameters:
duration - the duration to set
getBgColor
public int getBgColor()

The background color that is painted behind the flipping effect or -1 to use the
paintBackgrounds method instead
Returns:
the bgColor
setBgColor
public void setBgColor(int bgColor)

The background color that is painted behind the flipping effect or -1 to use the
paintBackgrounds method instead
Parameters:
bgColor - the bgColor to set

Method Detail

1356

Overview (Codename One API)


com.codename1.ui.animations

Class ComponentAnimation
java.lang.Object

com.codename1.ui.animations.ComponentAnimation

public abstract class


extends Object

Parent class representing an animation object within the AnimationManager queue.

Constructor Summary
Constructor and Description
ComponentAnimation()

Method Summary
Modifier and Type

Method and Description


compoundAnimation(ComponentAnimation... anims)

static
ComponentAnimation

Allows us to create an animation that compounds several separate


animations so they appear as a single animation to the system and
process in parallel
flush()

Flushes the animation immediately, this will be called if the form is


de-initialized

void

getMaxSteps()

int

The total number of steps in this animation.

int

getStep()

abstract boolean

isInProgress()

Indicates if the animation is in progress


isStepModeSupported()

boolean

Step mode allows stepping thru an animation one frame at a time,


e.g.
setNotifyLock(Object l)

This method is used internally by the addAnimationAndBlock


method of AnimationManager and shouldn't be used outside of that.

void

setOnCompletion(Runnable r)

This method is used internally by the addAnimation method of


AnimationManager and shouldn't be used outside of that.

void

setStep(int step)

void

Sets the current animation step to a value between 0 and maxSteps


updateAnimationState()

void

Invoked by the animation manager internally

protected abstract
void

updateState()

Updates the animation state

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class ComponentAnimation

1357

Overview (Codename One API)


Constructor

Detail

ComponentAnimation
public ComponentAnimation()

Method Detail
isStepModeSupported
public boolean isStepModeSupported()

Step mode allows stepping thru an animation one frame at a time, e.g. when scrolling
down an animation might change title elements then change them back as we scroll
up.
Returns:
true if this animation can be stepped in which case the setStep etc. methods
should work.
setStep
public void setStep(int step)

Sets the current animation step to a value between 0 and maxSteps


Parameters:
step - the current step
getStep
public int getStep()

getMaxSteps
public int getMaxSteps()

The total number of steps in this animation.


Returns:
the number of steps
isInProgress
public abstract boolean isInProgress()

Indicates if the animation is in progress


Returns:
true if in progress
updateState
protected abstract void updateState()

Updates the animation state


updateAnimationState
public final void updateAnimationState()

Invoked by the animation manager internally


flush
public void flush()

Flushes the animation immediately, this will be called if the form is de-initialized
setNotifyLock
public final void setNotifyLock(Object l)

This method is used internally by the addAnimationAndBlock method of


AnimationManager and shouldn't be used outside of that.
Parameters:
l - the lock object

Constructor Detail

1358

Overview (Codename One API)

setOnCompletion
public final void setOnCompletion(Runnable r)

This method is used internally by the addAnimation method of AnimationManager


and shouldn't be used outside of that.
Parameters:
r - the callback
compoundAnimation
public static ComponentAnimation compoundAnimation(ComponentAnimation... anims)

Allows us to create an animation that compounds several separate animations so


they appear as a single animation to the system and process in parallel
Parameters:
anims - the animations
Returns:
the compounded animation

Method Detail

1359

Overview (Codename One API)


com.codename1.ui.animations

Class CommonTransitions
java.lang.Object

com.codename1.ui.animations.Transition

com.codename1.ui.animations.CommonTransitions
All Implemented Interfaces:
Animation

public final class


extends Transition

Contains common transition animations including the following:


1. Slide - the exiting form slides out of the screen while the new form slides in.
2. Fade - components fade into/out of the screen
3. Timeline - uses an animation image as an alpha mask between the source/destination
Instances of this class are created using factory methods.

Field Summary
Modifier and Type
static int
static int

Field and Description


SLIDE_HORIZONTAL

Slide the transition horizontally


SLIDE_VERTICAL

Slide the transition vertically

Method Summary
Modifier and Type
boolean

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


cleanup()

void

Transition

Optional operation to cleanup the garbage left over by a running


transition
copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.

static
CommonTransitions

createCover(int type, boolean forward, int duration)

static
CommonTransitions

createDialogPulsate()

static
CommonTransitions

createEmpty()

static
CommonTransitions

Creates a cover transition with the given duration and direction


Creates a dialog pulsate transition
Creates an empty transition that does nothing.
createFade(int duration)

Creates a transition for fading a form in while fading out the original
form
createFastSlide(int type, boolean forward, int duration)

static
CommonTransitions

Creates a slide transition with the given duration and direction, this
differs from the standard slide animation by focusing on speed rather
than on minimizing heap usage.

static
CommonTransitions

createFastSlide(int type, boolean forward, int duration,


boolean drawDialogMenu)

Creates a slide transition with the given duration and direction, this
differs from the standard slide animation by focusing on speed rather
than on minimizing heap usage This method works by creating two

Class CommonTransitions

1360

Overview (Codename One API)


images and sliding them which works much faster for all devices
however takes up more ram.
createMotion(int startOffset, int dest, int speed)
protected Motion

This method can be overriden by subclasses to create their own


motion object on the fly

static
CommonTransitions

createSlide(int type, boolean forward, int duration)

static
CommonTransitions
static
CommonTransitions

Creates a slide transition with the given duration and direction


createSlide(int type, boolean forward, int duration,
boolean drawDialogMenu)

Creates a slide transition with the given duration and direction


createSlideFadeTitle(boolean forward, int duration)

Creates a slide transition for the body of the form that fades the title in
while sliding

static
CommonTransitions

createTimeline(Image animation)

static
CommonTransitions

createUncover(int type, boolean forward, int duration)

Creates a transition using an animated image object (e.g.


Creates a uncover transition with the given duration and direction
getMotion()

Motion

int

Motion represents the physical movement within a transition, it can be


replaced by the user to provide a more appropriate physical feel
getTransitionSpeed()

Returns the speed of the transition in milliseconds


initTransition()

void

Callback thats invoked before a transition begins, the source form may
be null for the first form in the application.
isDefaultLinearMotion()

static boolean

boolean
boolean
boolean

Indicates whether the motion associated with these transitions by


default is linear or spline motion
isForwardSlide()

Indicates the slide/cover transition direction


isHorizontalCover()

Returns true if this is a horizontal cover transition


isHorizontalSlide()

Returns true if this is a horizontal slide transition


isLinearMotion()

boolean

boolean
boolean

Indicates whether the motion associated with this transition is linear or


spline motion
isVerticalCover()

Returns true if this is a vertical cover transition


isVerticalSlide()

Returns true if this is a vertical slide transition


paint(Graphics g)

void

Draws the animation, within a component the standard paint method


would be invoked since it bares the exact same signature.
setDefaultLinearMotion(boolean aDefaultLinearMotion)

static void

Indicates whether the motion associated with these transitions by


default is linear or spline motion
setLinearMotion(boolean linearMotion)

void

Indicates whether the motion associated with this transition is linear or


spline motion
setMotion(LazyValue<Motion> motion)

void

Motion represents the physical movement within a transition, it can be


replaced by the user to provide a more appropriate physical feel
setMotion(Motion motion)

void

Method Summary

Motion represents the physical movement within a transition, it can be


replaced by the user to provide a more appropriate physical feel

1361

Overview (Codename One API)


Methods

inherited from
class com.codename1.ui.animations.Transition
cleanSource, getDestination, getSource, init

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
SLIDE_HORIZONTAL
public static final int SLIDE_HORIZONTAL

Slide the transition horizontally


See Also:
createSlide(int, boolean, int),

Constant Field Values

SLIDE_VERTICAL
public static final int SLIDE_VERTICAL

Slide the transition vertically


See Also:
createSlide(int, boolean, int),

Constant Field Values

Method Detail
isHorizontalSlide
public boolean isHorizontalSlide()

Returns true if this is a horizontal slide transition


Returns:
true if this is a horizontal slide transition
isVerticalSlide
public boolean isVerticalSlide()

Returns true if this is a vertical slide transition


Returns:
true if this is a vertical slide transition
isHorizontalCover
public boolean isHorizontalCover()

Returns true if this is a horizontal cover transition


Returns:
true if this is a horizontal cover transition
isVerticalCover
public boolean isVerticalCover()

Returns true if this is a vertical cover transition


Returns:
true if this is a vertical cover transition
isForwardSlide
public boolean isForwardSlide()

Indicates the slide/cover transition direction


Returns:
true for forward

Methods inherited from class com.codename1.ui.animations.Transition

1362

Overview (Codename One API)


getTransitionSpeed
public int getTransitionSpeed()

Returns the speed of the transition in milliseconds


Returns:
The speed of the transition in milliseconds
createEmpty
public static CommonTransitions createEmpty()

Creates an empty transition that does nothing. This has the same effect as setting a
transition to null.
Returns:
empty transition
createSlideFadeTitle
public static CommonTransitions createSlideFadeTitle(boolean forward,
int duration)

Creates a slide transition for the body of the form that fades the title in while sliding
Parameters:
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
createDialogPulsate
public static CommonTransitions createDialogPulsate()

Creates a dialog pulsate transition


createFastSlide
public static CommonTransitions createFastSlide(int type,
boolean forward,
int duration)

Creates a slide transition with the given duration and direction, this differs from the
standard slide animation by focusing on speed rather than on minimizing heap usage.
This method works by creating two images and sliding them which works much faster
for all devices however takes up more ram. Notice that this method of painting
doesn't support various basic CodenameOne abilities such as translucent
menus/dialogs etc.
Parameters:
type - type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
Returns:
a transition object
createSlide
public static CommonTransitions createSlide(int type,
boolean forward,
int duration)

Creates a slide transition with the given duration and direction


Parameters:
type - type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
Returns:

Method Detail

1363

Overview (Codename One API)


a transition object
createSlide
public static CommonTransitions createSlide(int type,
boolean forward,
int duration,
boolean drawDialogMenu)

Creates a slide transition with the given duration and direction


Parameters:
type - type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
drawDialogMenu - indicates that the menu (softkey area) of the dialog should
be kept during a slide transition. This is only relevant for dialog in/out
transitions.
Returns:
a transition object
createCover
public static CommonTransitions createCover(int type,
boolean forward,
int duration)

Creates a cover transition with the given duration and direction


Parameters:
type - type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
Returns:
a transition object
createUncover
public static CommonTransitions createUncover(int type,
boolean forward,
int duration)

Creates a uncover transition with the given duration and direction


Parameters:
type - type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
Returns:
a transition object
createFastSlide
public static CommonTransitions createFastSlide(int type,
boolean forward,
int duration,
boolean drawDialogMenu)

Creates a slide transition with the given duration and direction, this differs from the
standard slide animation by focusing on speed rather than on minimizing heap usage
This method works by creating two images and sliding them which works much faster
for all devices however takes up more ram. Notice that this method of painting
doesn't support various basic CodenameOne abilities such as translucent
menus/dialogs etc.
Parameters:

Method Detail

1364

Overview (Codename One API)


- type can be either vertically or horizontally, which means the
movement direction of the transition
forward - forward is a boolean value, represent the directions of switching
forms, for example for a horizontally type, true means horizontally movement
to right.
duration - represent the time the transition should take in millisecond
drawDialogMenu - indicates that the menu (softkey area) of the dialog should
be kept during a slide transition. This is only relevant for dialog in/out
transitions.
Returns:
a transition object
createFade
type

public static CommonTransitions createFade(int duration)

Creates a transition for fading a form in while fading out the original form
Parameters:
duration - represent the time the transition should take in millisecond
Returns:
a transition object
createTimeline
public static CommonTransitions createTimeline(Image animation)

Creates a transition using an animated image object (e.g. timeline object) as an alpha
mask between the source/target
Parameters:
animation - the image object to execute
Returns:
a transition object
initTransition
public void initTransition()

Callback thats invoked before a transition begins, the source form may be null for the
first form in the application.
Overrides:
initTransition in class Transition
createMotion
protected Motion createMotion(int startOffset,
int dest,
int speed)

This method can be overriden by subclasses to create their own motion object on the
fly
Parameters:
startOffset - the start offset for the menu
dest - the destination of the motion
speed - the speed of the motion
Returns:
a motion instance
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Specified by:
animate in class Transition
Returns:
true if a repaint is desired or false if no repaint is necessary

Method Detail

1365

Overview (Codename One API)


paint
public void paint(Graphics g)

Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation
Specified by:
paint in class Transition
Parameters:
g - graphics context
cleanup
public void cleanup()

Optional operation to cleanup the garbage left over by a running transition


Overrides:
cleanup in class Transition
getMotion
public Motion getMotion()

Motion represents the physical movement within a transition, it can be replaced by


the user to provide a more appropriate physical feel
Returns:
the instanceo of the motion class used by this transition
setMotion
public void setMotion(Motion motion)

Motion represents the physical movement within a transition, it can be replaced by


the user to provide a more appropriate physical feel
Parameters:
motion - new instance of the motion class that will be used by the transition
setMotion
public void setMotion(LazyValue<Motion> motion)

Motion represents the physical movement within a transition, it can be replaced by


the user to provide a more appropriate physical feel
Parameters:
motion - new instance of the motion class that will be used by the transition
copy
public Transition copy(boolean reverse)

Create a copy of the transition, usually the transition used is a copy.


Overrides:
copy in class Transition
Parameters:
reverse - creates a new transition instance with "reverse" behavior useful for
signifying "back" operations
Returns:
new transition instance
isLinearMotion
public boolean isLinearMotion()

Indicates whether the motion associated with this transition is linear or spline motion
Returns:
the linearMotion
setLinearMotion
public void setLinearMotion(boolean linearMotion)

Indicates whether the motion associated with this transition is linear or spline motion

Method Detail

1366

Overview (Codename One API)


Parameters:
linearMotion - the linearMotion to set
isDefaultLinearMotion
public static boolean isDefaultLinearMotion()

Indicates whether the motion associated with these transitions by default is linear or
spline motion
Returns:
the defaultLinearMotion
setDefaultLinearMotion
public static void setDefaultLinearMotion(boolean aDefaultLinearMotion)

Indicates whether the motion associated with these transitions by default is linear or
spline motion
Parameters:
aDefaultLinearMotion - the defaultLinearMotion to set

Method Detail

1367

Overview (Codename One API)


com.codename1.ui.animations

Class AnimationObject
java.lang.Object

com.codename1.ui.animations.AnimationObject

public final class


extends Object

An animation object is an element within the timeline that has a visibility state for rendering at a given
point in time. E.g. the object can be queried of its position and render itself for any time.

Field Summary
Modifier and
Type

Field and Description


MOTION_TYPE_LINEAR

static int

Used to define the motion type used when manipulating an animation


property
MOTION_TYPE_SPLINE

static int

Used to define the motion type used when manipulating an animation


property

Method Summary
Modifier and Type
AnimationObject
static
AnimationObject

static
AnimationObject

Method and Description


copy()

Creates a copy of the given animation object


createAnimationImage(Image img, int x, int y)

Creates an animation object instance that can define the animation


properties for an image
createAnimationImage(String imageName, Resources res, int x,
int y)

Creates an animation object instance that can define the animation


properties for an image.
defineFrames(int frameWidth, int frameHeight, int frameDelay)

void

void

void

void

void

void

Class AnimationObject

Defines the frames of the animation if this is a frame changing


animation (e.g.
defineHeight(int motionType, int startTime, int duration,
int start, int end)

Defines the height of the object starting at the given time/value and
ending at the given position
defineMotionX(int motionType, int startTime, int duration,
int start, int end)

Defines a motion on the x axis starting at the given time/value and


ending at the given position
defineMotionY(int motionType, int startTime, int duration,
int start, int end)

Defines a motion on the y axis starting at the given time/value and


ending at the given position
defineOpacity(int motionType, int startTime, int duration,
int start, int end)

Defines opacity (translucency) starting at the given time/value and


ending at the given position.
defineOrientation(int motionType, int startTime,
int duration, int start, int end)

1368

Overview (Codename One API)


Defines a rotation animation starting at the given time/value and
ending at the given position
defineWidth(int motionType, int startTime, int duration,
int start, int end)

void

Defines the width of the object starting at the given time/value and
ending at the given position
getEndTime()

The end time of the animation determines when we finish actually


drawing the animation object.

int

getStartTime()

The start time of the animation determines when we start actually


drawing the animation object.

int

setEndTime(int endTime)

The end time of the animation determines when we finish actually


drawing the animation object.

void

setStartTime(int startTime)

The start time of the animation determines when we start actually


drawing the animation object.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
MOTION_TYPE_SPLINE
public static final int MOTION_TYPE_SPLINE

Used to define the motion type used when manipulating an animation property
See Also:
Constant Field Values
MOTION_TYPE_LINEAR
public static final int MOTION_TYPE_LINEAR

Used to define the motion type used when manipulating an animation property
See Also:
Constant Field Values

Method Detail
copy
public AnimationObject copy()

Creates a copy of the given animation object


Returns:
a new instance of the Animation object with the same state
createAnimationImage
public static AnimationObject createAnimationImage(Image img,
int x,
int y)

Creates an animation object instance that can define the animation properties for an
image
Parameters:
img - the image to animate within the timeline
x - position of the animation
y - position of the animation

Method Summary

1369

Overview (Codename One API)


Returns:
new animation object
defineFrames
public void defineFrames(int frameWidth,
int frameHeight,
int frameDelay)

Defines the frames of the animation if this is a frame changing animation (e.g. a sprite
of a walking person). Notice that this method must not be invoked more than once or
after the image was initilized
Parameters:
frameWidth - the width of the frame within the image object
frameHeight - the height of the frame within the image object
frameDelay - the delay of the frame
createAnimationImage
public static AnimationObject createAnimationImage(String imageName,
Resources res,
int x,
int y)

Creates an animation object instance that can define the animation properties for an
image. This version of the method is useful while a resource file is in the process of
being loaded and not all images are in place. Loading will finish implicitly when the
image is first used.
Parameters:
imageName - the image to animate within the timeline
res - the resources file from which the image should be fetched.
x - position of the animation
y - position of the animation
Returns:
new animation object
defineMotionX
public void defineMotionX(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines a motion on the x axis starting at the given time/value and ending at the
given position
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)
defineMotionY
public void defineMotionY(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines a motion on the y axis starting at the given time/value and ending at the
given position
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)

Method Detail

1370

Overview (Codename One API)


defineOrientation
public void defineOrientation(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines a rotation animation starting at the given time/value and ending at the given
position
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)
defineOpacity
public void defineOpacity(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines opacity (translucency) starting at the given time/value and ending at the
given position. Values should rance from 0 (transparent) to 255 (opaque).
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)
defineWidth
public void defineWidth(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines the width of the object starting at the given time/value and ending at the
given position
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)
defineHeight
public void defineHeight(int
int
int
int
int

motionType,
startTime,
duration,
start,
end)

Defines the height of the object starting at the given time/value and ending at the
given position
Parameters:
motionType - the type of the motion (spline/linear)
startTime - the start time for the motion within the timeline timeframe
duration - the duration of the motion
start - the starting position (the value before startTime)
end - the ending position for the property (the value after endTime)
getStartTime
public int getStartTime()

Method Detail

1371

Overview (Codename One API)


The start time of the animation determines when we start actually drawing the
animation object. -1 means the duration of the entire animation.
Returns:
the startTime in timeline time
setStartTime
public void setStartTime(int startTime)

The start time of the animation determines when we start actually drawing the
animation object. -1 means the duration of the entire animation.
Parameters:
startTime - the startTime to set
getEndTime
public int getEndTime()

The end time of the animation determines when we finish actually drawing the
animation object. -1 means the duration of the entire animation.
Returns:
the endTime in timeline time
setEndTime
public void setEndTime(int endTime)

The end time of the animation determines when we finish actually drawing the
animation object. -1 means the duration of the entire animation.
Parameters:
endTime - the endTime to set

Method Detail

1372

Overview (Codename One API)


com.codename1.ui.animations

Interface Animation
All Known Implementing Classes:
Ads, AutoCompleteTextField, BaseSpinner, BrowserComponent, Button, Calendar,
ChartComponent, CheckBox, ComboBox, CommonTransitions, Component,
ComponentGroup, Container, ContainerList, DateSpinner, DateTimeSpinner,
DefaultListCellRenderer, Dialog, EmbeddedContainer, FileTree, FlipTransition, FloatingHint,
Form, GenericSpinner, HTMLComponent, ImageViewer, InfiniteContainer, InfiniteProgress,
InteractionDialog, Label, LikeButton, List, MapComponent, MediaPlayer, MenuBar,
MorphTransition, MultiButton, MultiList, NumericSpinner, OnOffSwitch, PeerComponent,
Picker, Progress, RadioButton, RSSReader, ScaleImageButton, ScaleImageLabel,
SeriesTransition, ShareButton, SideMenuBar, Slider, SliderBridge, SpanButton, SpanLabel,
SwipeableContainer, Table, Tabs, TextArea, TextField, Timeline, TimeSpinner, Toolbar,
Transition, Tree, VirtualKeyboard, WebBrowser, XYMultiSeriesTransition,
XYSeriesTransition, XYValueSeriesTransition

public interface

Allows any object to react to events and draw an animation at a fixed interval. All animation methods
are executed on the EDT. For simplicities sake all components are animatable, however no animation
will appear unless it is explicitly registered into the parent form. In order to stop animation callbacks
the animation must be explicitly removed from the form (notice that this differs from removing the
component from the form!).

Method Summary
Modifier and
Type
boolean

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


paint(Graphics g)

void

Draws the animation, within a component the standard paint method would
be invoked since it bares the exact same signature.

Method Detail
animate
boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
void paint(Graphics g)

Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Parameters:
g - graphics context

Interface Animation

1373

Overview (Codename One API)


com.codename1.ui

Class VirtualKeyboard
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Form

com.codename1.ui.Dialog

com.codename1.ui.VirtualKeyboard
All Implemented Interfaces:
com.codename1.impl.VirtualKeyboardInterface, Animation, StyleListener,
Iterable<Component>

public class
extends Dialog
implements com.codename1.impl.VirtualKeyboardInterface

This class represent the Codename One Light Weight Virtual Keyboard

Field Summary
Modifier and Type
static int
static String[][]
static String[][]
static String[][]
static String[][]

Field and Description


CHANGE_MODE
DEFAULT_NUMBERS

This keymap represents numbers keyboard


DEFAULT_NUMBERS_SYMBOLS

This keymap represents numbers and symbols keyboard


DEFAULT_QWERTY

This keymap represents qwerty keyboard


DEFAULT_SYMBOLS

This keymap represents symbols keyboard

static int

DELETE_CHAR

static int

INSERT_CHAR

static String

NAME

static String
static String
static int
static String

NUMBERS_MODE

The String that represent the numbers mode.


NUMBERS_SYMBOLS_MODE

The String that represent the numbers sybols mode.


OK
QWERTY_MODE

The String that represent the qwerty mode.

static int

SHIFT

static int

SPACE

static String
static int

SYMBOLS_MODE

The String that represent the symbols mode.


T9

Fields inherited from class com.codename1.ui.Dialog


TYPE_ALARM, TYPE_CONFIRMATION, TYPE_ERROR, TYPE_INFO, TYPE_NONE,
TYPE_WARNING

Method Detail

1374

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.Form

focusScrolling

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
VirtualKeyboard()

Creates a new instance of VirtualKeyboard

Method Summary
Modifier and
Type

Method and Description


actionCommand(Command cmd)

protected void

static void
void
void
void
protected void

Invoked to allow subclasses of form to handle a command from one


point rather than implementing many command instances
addDefaultInputMode(String mode, String[][] inputChars)

Add an input mode to the virtual keyboard


addInputMode(String mode, String[][] inputChars)

Add an input mode to the virtual keyboard


addSpecialButton(String key, Command cmd)

This method adds a special button to the virtual keyboard


addSpecialButton(String key, Command cmd, int space)

This method adds a special button to the virtual keyboard


autoAdjust(int w, int h)

Auto adjust size of the dialog.


bindVirtualKeyboard(TextArea t, VirtualKeyboard vkb)

static void

This method is used to bind a specific instance of a virtual keyboard to a


specific TextField.
dispose()

void

protected String
static String[]
protected
TextField
String[]
static Transition
static Transition
static
VirtualKeyboard
String

Closes the current form and returns to the previous form, releasing the
EDT in the process
getCurrentMode()

Gets the current mode.


getDefaultInputModeOrder()

Returns the order in which input modes are toggled by default


getInputField()

This method returns the Virtual Keyboard TextField.


getInputModeOrder()

Returns the order in which input modes are toggled


getTransitionIn()

The transition in for the VKB


getTransitionOut()

The transition out for the VKB


getVirtualKeyboard(TextArea t)

This method returns the Textfield associated VirtualKeyboard, see


bindVirtualKeyboard(TextField tf, VirtualKeyboard vkb) method.
getVirtualKeyboardName()

Returns the Virtual Keyboard name.

Fields inherited from class com.codename1.ui.Form

1375

Overview (Codename One API)


getVKBTint(TextArea tf)
static int

The tint color for the virtual keyboard when shown on top of this text
field see the form tint methods for more information
initModes()

protected void

protected void
static boolean

init all virtual keyboard modes, such as QWERTY_MODE,


NUMBERS_SYMBOLS_MODE...
initSpecialButtons()

This method initialize all the virtual keyboard special buttons.


isCommitOnDispose(TextArea tf)

Indicates whether the given text field should commit on dispose


isShowTooltips()

static boolean

boolean

Indicates whether tooltips should be shown when the keys in the VKB
are pressed
isVirtualKeyboardShowing()

Indicates if the Virtual Keyboard is currently showing.


onShow()

protected void

Allows subclasses to bind functionality that occurs when a specific form


or dialog appears on the screen
pointerDragged(int x, int y)

void

If this Component is focused, the pointer dragged event will call this
method
pointerPressed(int x, int y)

void

If this Component is focused, the pointer pressed event will call this
method
pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this
method
setCommitOnDispose(TextField tf, boolean b)

static void

protected void

Indicates whether the VKB should commit changes to the text field
when the VKB is closed not via the OK button.
setCurrentMode(String mode)

Sets the current virtual keyboard mode.


setDefaultInputModeOrder(String[] order)

static void

Sets the order in which input modes are toggled by default and allows
disabling/hiding an input mode
setDefaultVirtualKeyboardClass(Class vkbClazz)

static void

Sets the default virtual keyboard class for the


com.codename1.ui.VirtualKeyboard type This class is used as the
default virtual keyboard class if the current platform VirtualKeyboard is
com.codename1.ui.VirtualKeyboard.
setInputModeOrder(String[] order)

void

Sets the order in which input modes are toggled and allows
disabling/hiding an input mode
setInputType(int inputType)

void

This can be used to indicate to the VirtualKeyboard what type of input to


display.
setShowTooltips(boolean aShowTooltips)

static void

Indicates whether tooltips should be shown when the keys in the VKB
are pressed
setTextField(TextArea field)

void

static void
static void

Invoked internally by the implementation to indicate the text field that will
be edited by the virtual keyboard
setTransitionIn(Transition aTransitionIn)

The transition in for the VKB


setTransitionOut(Transition aTransitionOut)

The transition out for the VKB


setVKBTint(TextField tf, int tint)

static void

Method Summary

Sets the tint color for the virtual keyboard when shown on top of this text
field see the form tint methods for more information

1376

Overview (Codename One API)


show()

The default version of show modal shows the dialog occupying the
center portion of the screen.

void

showKeyboard(boolean show)

Shows the virtual keyboard that is assoiciated with the displayed


TextField or displays the default virtual keyboard.

void

Methods inherited from class com.codename1.ui.Dialog


addComponent, addComponent, addComponent, addComponent, animate,
getBlurBackgroundRadius, getContentPane, getDefaultBlurBackgroundRadius,
getDefaultDialogPosition, getDefaultDialogType, getDialogComponent,
getDialogPosition, getDialogPreferredSize, getDialogStyle, getDialogType,
getDialogUIID, getLayout, getPopupDirectionBiasPortrait, getTitle,
getTitleComponent, getTitleStyle, growOrShrink, initLaf,
isAutoAdjustDialogSize, isAutoDispose, isCommandsAsButtons,
isDisableStaticDialogScrolling, isDisposeWhenPointerOutOfBounds,
keyReleased, placeButtonCommands, removeAll, removeComponent,
setAutoAdjustDialogSize, setAutoDispose, setBlurBackgroundRadius,
setCommandsAsButtons, setDefaultBlurBackgroundRadius,
setDefaultDialogPosition, setDefaultDialogType, setDialogPosition,
setDialogStyle, setDialogType, setDialogUIID,
setDisableStaticDialogScrolling, setDisposeWhenPointerOutOfBounds,
setLayout, setPopupDirectionBiasPortrait, setScrollable, setTimeout,
setTitle, setTitleComponent, setTitleComponent, show, show, show, show,
show, show, show, show, show, show, show, show, show, show, show,
showAtPosition, showBack, showDialog, showModeless, showPacked,
showPopupDialog, showPopupDialog, showStetched, showStretched,
wasDisposedDueToOutOfBoundsTouch, wasDisposedDueToRotation

Methods inherited from class com.codename1.ui.Form


addCommand, addCommand, addCommandListener, addGameKeyListener,
addKeyListener, addOrientationListener, addShowListener,
addSizeChangedListener, deregisterAnimated, dispatchCommand,
findNextFocusHorizontal, findNextFocusVertical, getAnimationManager,
getBackCommand, getClearCommand, getCommand, getCommandCount,
getComponentForm, getComponentIndex, getDefaultCommand,
getDragRegionStatus, getEditOnShow, getFocused, getGlassPane,
getLayeredPane, getLayeredPane, getMenuBar, getMenuStyle, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getScrollAnimationSpeed, getSoftButton, getSoftButtonCount, getTintColor,
getTitleArea, getToolbar, getTransitionInAnimator,
getTransitionOutAnimator, getUIManager, grabAnimationLock, hasMedia,
hideNotify, isAlwaysTensile, isCyclicFocus, isDragRegion, isFocusScrolling,
isFormBottomPaddingEditingMode, isMinimizeOnBack, isScrollable,
isSingleFocusMode, isSmoothScrolling, keyPressed, keyRepeated,
longKeyPress, longPointerPress, onShowCompleted, paint, paintBackground,
paramString, pointerDragged, pointerHover, pointerHoverPressed,
pointerHoverReleased, refreshTheme, registerAnimated, releaseAnimationLock,
removeAllCommands, removeAllShowListeners, removeCommand,
removeCommandListener, removeGameKeyListener, removeKeyListener,
removeOrientationListener, removeShowListener, removeSizeChangedListener,
replace, replaceAndWait, scrollComponentToVisible, setAlwaysTensile,
setBackCommand, setBgImage, setClearCommand, setCyclicFocus,
setDefaultCommand, setEditOnShow, setFocused, setFocusScrolling,
setFormBottomPaddingEditingMode, setGlassPane, setMenuBar,
setMenuCellRenderer, setMenuTransitions, setMinimizeOnBack,
setPropertyValue, setRTL, setScrollableX, setScrollableY,
setScrollAnimationSpeed, setSmoothScrolling, setTintColor, setTitleStyle,
setToolbar, setToolBar, setTransitionInAnimator, setTransitionOutAnimator,
setUIManager, setVisible, shouldSendPointerReleaseToOtherForm, showNotify,
sizeChanged

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getGridPosX,

Methods inherited from class com.codename1.ui.Dialog

1377

Overview (Codename One API)


getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled,
isScrollableX, isScrollableY, isSelectableInteraction, iterator,
layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass,
replace, replaceAndWait, replaceAndWait, revalidate, setCellRenderer,
setEnabled, setLeadComponent, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentState, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed,
getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollVisible, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
onScrollX, onScrollY, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerPressed,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setSameHeight, setSameWidth, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString,
unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
DEFAULT_QWERTY
public static final String[][] DEFAULT_QWERTY

This keymap represents qwerty keyboard


DEFAULT_NUMBERS
public static final String[][] DEFAULT_NUMBERS

This keymap represents numbers keyboard

Methods inherited from class com.codename1.ui.Container

1378

Overview (Codename One API)


DEFAULT_NUMBERS_SYMBOLS
public static final String[][] DEFAULT_NUMBERS_SYMBOLS

This keymap represents numbers and symbols keyboard


DEFAULT_SYMBOLS
public static final String[][] DEFAULT_SYMBOLS

This keymap represents symbols keyboard


QWERTY_MODE
public static final String QWERTY_MODE

The String that represent the qwerty mode.


See Also:
Constant Field Values
NUMBERS_MODE
public static final String NUMBERS_MODE

The String that represent the numbers mode.


See Also:
Constant Field Values
NUMBERS_SYMBOLS_MODE
public static final String NUMBERS_SYMBOLS_MODE

The String that represent the numbers sybols mode.


See Also:
Constant Field Values
SYMBOLS_MODE
public static final String SYMBOLS_MODE

The String that represent the symbols mode.


See Also:
Constant Field Values
INSERT_CHAR
public static final int INSERT_CHAR

See Also:
Constant Field Values
DELETE_CHAR
public static final int DELETE_CHAR

See Also:
Constant Field Values
CHANGE_MODE
public static final int CHANGE_MODE

See Also:
Constant Field Values
SHIFT
public static final int SHIFT

See Also:
Constant Field Values
OK
public static final int OK

See Also:

Field Detail

1379

Overview (Codename One API)


Constant Field Values
SPACE
public static final int SPACE

See Also:
Constant Field Values
T9
public static final int T9

See Also:
Constant Field Values
NAME
public static final String NAME

See Also:
Constant Field Values

Constructor Detail
VirtualKeyboard
public VirtualKeyboard()

Creates a new instance of VirtualKeyboard

Method Detail
setInputType
public void setInputType(int inputType)

Description copied from interface: com.codename1.impl.VirtualKeyboardInterface


This can be used to indicate to the VirtualKeyboard what type of input to display.
Specified by:
setInputType in interface com.codename1.impl.VirtualKeyboardInterface
setTextField
public void setTextField(TextArea field)

Invoked internally by the implementation to indicate the text field that will be edited by
the virtual keyboard
Parameters:
field - the text field instance
show
public void show()

The default version of show modal shows the dialog occupying the center portion of
the screen.
Overrides:
show in class Dialog
autoAdjust
protected void autoAdjust(int w,
int h)

Auto adjust size of the dialog. This method is triggered from a sizeChanged event.
Overrides:
autoAdjust in class Dialog
Parameters:
w - width of the screen
h - height of the screen

Field Detail

1380

Overview (Codename One API)


initModes
protected void initModes()

init all virtual keyboard modes, such as QWERTY_MODE,


NUMBERS_SYMBOLS_MODE... to add an addtitional mode a developer needs to
override this method and add a mode by calling addInputMode method
setCurrentMode
protected void setCurrentMode(String mode)

Sets the current virtual keyboard mode.


Parameters:
mode - the String that represents the mode(QWERTY_MODE,
SYMBOLS_MODE, ...)
getCurrentMode
protected String getCurrentMode()

Gets the current mode.


Returns:
the String that represents the current mode(QWERTY_MODE,
SYMBOLS_MODE, ...)
addDefaultInputMode
public static void addDefaultInputMode(String mode,
String[][] inputChars)

Add an input mode to the virtual keyboard


Parameters:
mode - a string that represents the identifier of the mode
inputChars - 2 dimensional String array that contains buttons String and
special buttons (a special button is identified with $...$ marks e.g: "$Space$")
addInputMode
public void addInputMode(String mode,
String[][] inputChars)

Add an input mode to the virtual keyboard


Parameters:
mode - a string that represents the identifier of the mode
inputChars - 2 dimentional String array that contains buttons String and
special buttons (a special button is identified with $...$ marks e.g: "$Space$")
addSpecialButton
public void addSpecialButton(String key,
Command cmd)

This method adds a special button to the virtual keyboard


Parameters:
key - the string identifier from within the relevant input mode
cmd - the Command to invoke when this button is invoked.
addSpecialButton
public void addSpecialButton(String key,
Command cmd,
int space)

This method adds a special button to the virtual keyboard


Parameters:
key - the string identifier from within the relevant input mode
cmd - the Command to invoke when this button is invoked.
space - how much space in percentage from the overall row the special
button should occupy

Method Detail

1381

Overview (Codename One API)


pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Dialog
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Form
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Dialog
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
initSpecialButtons
protected void initSpecialButtons()

This method initialize all the virtual keyboard special buttons.


getInputModeOrder
public String[] getInputModeOrder()

Returns the order in which input modes are toggled


Returns:
the order of the input modes
setInputModeOrder
public void setInputModeOrder(String[] order)

Sets the order in which input modes are toggled and allows disabling/hiding an input
mode
Parameters:
order - the order for the input modes in this field
getDefaultInputModeOrder
public static String[] getDefaultInputModeOrder()

Returns the order in which input modes are toggled by default


Returns:
the default order of the input mode
setDefaultInputModeOrder
public static void setDefaultInputModeOrder(String[] order)

Sets the order in which input modes are toggled by default and allows
disabling/hiding an input mode
Parameters:

Method Detail

1382

Overview (Codename One API)


order - the order for the input modes in all future created fields
actionCommand
protected void actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point rather than
implementing many command instances
Overrides:
actionCommand in class Dialog
Parameters:
cmd - the action command
dispose
public void dispose()

Closes the current form and returns to the previous form, releasing the EDT in the
process
Overrides:
dispose in class Dialog
onShow
protected void onShow()

Allows subclasses to bind functionality that occurs when a specific form or dialog
appears on the screen
Overrides:
onShow in class Dialog
getInputField
protected TextField getInputField()

This method returns the Virtual Keyboard TextField.


Returns:
the the Virtual Keyboard TextField.
setCommitOnDispose
public static void setCommitOnDispose(TextField tf,
boolean b)

Indicates whether the VKB should commit changes to the text field when the VKB is
closed not via the OK button. This might be useful for some situations such as
searches
Parameters:
tf - the text field to mark as commit on dispose
b - the value of commit on dispose, true to always commit changes
bindVirtualKeyboard
public static void bindVirtualKeyboard(TextArea t,
VirtualKeyboard vkb)

This method is used to bind a specific instance of a virtual keyboard to a specific


TextField. For example if a specific TextField requires only numeric input consider
using this method as follows: TextField tf = new TextField();
tf.setConstraint(TextField.NUMERIC); tf.setInputModeOrder(new String[]{"123"});
VirtualKeyboard vkb = new VirtualKeyboard(); vkb.setInputModeOrder(new
String[]{VirtualKeyboard.NUMBERS_MODE});
VirtualKeyboard.bindVirtualKeyboard(tf, vkb);
Parameters:
t - the TextField to bind a VirualKeyboard to.
vkb - the binded VirualKeyboard.
getVirtualKeyboard
public static VirtualKeyboard getVirtualKeyboard(TextArea t)

This method returns the Textfield associated VirtualKeyboard, see


bindVirtualKeyboard(TextField tf, VirtualKeyboard vkb) method.
Parameters:

Method Detail

1383

Overview (Codename One API)


t - a TextField.that might have an associated VirtualKeyboard instance
Returns:
a VirtualKeyboard instance or null if not exists.
isCommitOnDispose
public static boolean isCommitOnDispose(TextArea tf)

Indicates whether the given text field should commit on dispose


Parameters:
tf - the text field
Returns:
true if the text field should save the data despite the fact that it was disposed
in an irregular way
setVKBTint
public static void setVKBTint(TextField tf,
int tint)

Sets the tint color for the virtual keyboard when shown on top of this text field see the
form tint methods for more information
Parameters:
tf - the relevant text field
tint - the tint color with an alpha channel
getVKBTint
public static int getVKBTint(TextArea tf)

The tint color for the virtual keyboard when shown on top of this text field see the
form tint methods for more information
Parameters:
tf - the relevant text field
Returns:
the tint color with an alpha channel
isShowTooltips
public static boolean isShowTooltips()

Indicates whether tooltips should be shown when the keys in the VKB are pressed
Returns:
the showTooltips
setShowTooltips
public static void setShowTooltips(boolean aShowTooltips)

Indicates whether tooltips should be shown when the keys in the VKB are pressed
Parameters:
aShowTooltips - true to show tooltips
getTransitionIn
public static Transition getTransitionIn()

The transition in for the VKB


Returns:
the transitionIn
setTransitionIn
public static void setTransitionIn(Transition aTransitionIn)

The transition in for the VKB


Parameters:
aTransitionIn - the transitionIn to set
getTransitionOut
public static Transition getTransitionOut()

The transition out for the VKB


Returns:

Method Detail

1384

Overview (Codename One API)


the transitionOut
setTransitionOut
public static void setTransitionOut(Transition aTransitionOut)

The transition out for the VKB


Parameters:
aTransitionOut - the transitionOut to set
showKeyboard
public void showKeyboard(boolean show)

Shows the virtual keyboard that is assoiciated with the displayed TextField or
displays the default virtual keyboard.
Specified by:
showKeyboard in interface com.codename1.impl.VirtualKeyboardInterface
Parameters:
show - it show is true open the relevant keyboard, if close dispose the
displayed keyboard
setDefaultVirtualKeyboardClass
public static void setDefaultVirtualKeyboardClass(Class vkbClazz)

Sets the default virtual keyboard class for the com.codename1.ui.VirtualKeyboard


type This class is used as the default virtual keyboard class if the current platform
VirtualKeyboard is com.codename1.ui.VirtualKeyboard. Platform VirtualKeyboard is
defined here:
Display.getIntance().setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
Parameters:
vkbClazz - this class must extend VirtualKeyboard.
getVirtualKeyboardName
public String getVirtualKeyboardName()

Description copied from interface: com.codename1.impl.VirtualKeyboardInterface


Returns the Virtual Keyboard name. This is a unique indentifier for the Virtual
Keyboard implementation
Specified by:
getVirtualKeyboardName in
interface com.codename1.impl.VirtualKeyboardInterface
Returns:
a unique id that represents this virtual keyboard.
See Also:
VirtualKeyboardInterface

isVirtualKeyboardShowing
public boolean isVirtualKeyboardShowing()

Description copied from interface: com.codename1.impl.VirtualKeyboardInterface


Indicates if the Virtual Keyboard is currently showing.
Specified by:
isVirtualKeyboardShowing in
interface com.codename1.impl.VirtualKeyboardInterface
Returns:
true if the Virtual Keyboard is currently showing
See Also:
VirtualKeyboardInterface

Method Detail

1385

Overview (Codename One API)


com.codename1.ui

Class URLImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.ui.URLImage

public class
extends EncodedImage

allows us to create an image from a URL. If the image was downloaded already it is fetched
from cache; if not it is downloaded optionally scaled/adapted and placed in cache.
URLImage

By default an image is fetched lazily as it is asked for by the GUI unless the fetch() method is invoked
in which case the IO code is executed immediately.
This sample code show a URLImage that is fetched to the title area background and scaled/cropped to
fit device specific dimensions.
This sample code shows the usage of the nestoria API to fill out an infinitely scrolling list in it we use
URLImage to fetch the icon.

Nested Class Summary


Modifier and
Type
static
interface

Class URLImage

Class and Description


URLImage.ImageAdapter

Allows applying resize logic to downloaded images you can use constant
resize behaviors defined in this class.

1386

Overview (Codename One API)


Field

Summary

Modifier and Type


static
URLImage.ImageAdapter
static
URLImage.ImageAdapter
static
URLImage.ImageAdapter

Field and Description


RESIZE_FAIL

Will fail if the downloaded image has a different size from the
placeholder image
RESIZE_SCALE

Scales the image to match the size of the new image exactly
RESIZE_SCALE_TO_FILL

Scales the image to match to fill the area while preserving


aspect ratio

Method Summary
Modifier and Type
boolean

Method and Description


animate()
createMaskAdapter(Image imageMask)

static
URLImage.ImageAdapter

static URLImage

Creates an adapter that uses an image as a Mask, this is


roughly the same as SCALE_TO_FILL with the exception that a
mask will be applied later on.
createToFileSystem(EncodedImage placeholder, String file,
String url, URLImage.ImageAdapter adapter)

Creates an image the will be downloaded on the fly as


necessary
createToStorage(EncodedImage placeholder,
String storageFile, String url)

static URLImage

static URLImage

Creates an image the will be downloaded on the fly as


necessary with RESIZE_SCALE_TO_FILL as the default
behavior
createToStorage(EncodedImage placeholder,
String storageFile, String url,
URLImage.ImageAdapter adapter)

Creates an image the will be downloaded on the fly as


necessary
fetch()

Images are normally fetched from storage or network only as


needed, however if the download must start before the image is
drawn this method can be invoked.

void

getImageData()

Returns the byte array data backing the image allowing the
image to be stored and discarded completely from RAM.

byte[]

getInternal()
protected Image

boolean

Returns the actual image represented by the encoded image,


this image will be cached in a weak/soft reference internally.
isAnimation()

Returns true if this is an animated image

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getWidth, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha,
resetCache, rotate, scale, scaled, scaledEncoded, scaledHeight,
scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, createImage, createImage,
createImage, createImage, createImage, createImage, createImage,
createIndexed, createMask, createSVG, dispose, flipHorizontally,
flipVertically, getImageName, getRGB, getRGBCached, getSVGDocument,

Field Summary

1387

Overview (Codename One API)


isAlphaMutableImageSupported, isSVG, isSVGSupported, mirror,
modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RESIZE_FAIL
public static final URLImage.ImageAdapter RESIZE_FAIL

Will fail if the downloaded image has a different size from the placeholder image
RESIZE_SCALE
public static final URLImage.ImageAdapter RESIZE_SCALE

Scales the image to match the size of the new image exactly
RESIZE_SCALE_TO_FILL
public static final URLImage.ImageAdapter RESIZE_SCALE_TO_FILL

Scales the image to match to fill the area while preserving aspect ratio

Method Detail
createMaskAdapter
public static URLImage.ImageAdapter createMaskAdapter(Image imageMask)

Creates an adapter that uses an image as a Mask, this is roughly the same as
SCALE_TO_FILL with the exception that a mask will be applied later on. This adapter
requires that the resulting image be in the size of the imageMask!
Parameters:
imageMask - the mask image see the createMask() method of image for
details of what a mask is, it will be used as the reference size for the image
and resulting images must be of the same size!
Returns:
the adapter
fetch
public void fetch()

Images are normally fetched from storage or network only as needed, however if the
download must start before the image is drawn this method can be invoked.
getInternal
protected Image getInternal()

Returns the actual image represented by the encoded image, this image will be
cached in a weak/soft reference internally. This method is useful to detect when the
system actually created an image instance. You shouldn't invoke this method
manually!
Overrides:
getInternal in class EncodedImage
Returns:
drawable image instance
getImageData
public byte[] getImageData()

Methods inherited from class com.codename1.ui.Image

1388

Overview (Codename One API)


Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
animate
public boolean animate()

Overrides:
animate

in class Image

isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class EncodedImage
Returns:
true if this image represents an animation
createToStorage
public static URLImage createToStorage(EncodedImage placeholder,
String storageFile,
String url)

Creates an image the will be downloaded on the fly as necessary with


RESIZE_SCALE_TO_FILL as the default behavior
Parameters:
placeholder - the image placeholder is shown as the image is
loading/downloading and serves as the guideline to the size of the
downloaded image.
storageFile - the file in storage to which the image will be stored
url - the url from which the image is fetched
Returns:
a URLImage that will initialy just delegate to the placeholder
createToStorage
public static URLImage createToStorage(EncodedImage placeholder,
String storageFile,
String url,
URLImage.ImageAdapter adapter)

Creates an image the will be downloaded on the fly as necessary


Parameters:
placeholder - the image placeholder is shown as the image is
loading/downloading and serves as the guideline to the size of the
downloaded image.
storageFile - the file in storage to which the image will be stored
url - the url from which the image is fetched
adapter - the adapter used to adapt the image into place, it should scale the
image if necessary
Returns:
a URLImage that will initialy just delegate to the placeholder
createToFileSystem
public static URLImage createToFileSystem(EncodedImage placeholder,
String file,
String url,
URLImage.ImageAdapter adapter)

Creates an image the will be downloaded on the fly as necessary


Parameters:
placeholder - the image placeholder is shown as the image is
loading/downloading and serves as the guideline to the size of the
downloaded image.
file - the file in the file system to which the image will be stored

Method Detail

1389

Overview (Codename One API)


url - the url from which the image is fetched
adapter - the adapter used to adapt the image

into place, it should scale the


image if necessary
Returns:
a URLImage that will initialy just delegate to the placeholder

Method Detail

1390

Overview (Codename One API)


com.codename1.ui

Interface URLImage.ImageAdapter
Enclosing class:
URLImage

public static interface

Allows applying resize logic to downloaded images you can use constant resize behaviors defined in
this class. This class allows masking and various other effects to be applied to downloaded images.
Notice: adapters happen before the image is saved so they will only happen once and the image will
be saved as "adapted" which can be great for performance but is also permanent. E.g. If you mask an
image it will remain masked.

Method Summary
Modifier and
Type
EncodedImage

Method and Description


adaptImage(EncodedImage downloadedImage,
EncodedImage placeholderImage)

Allows the downloaded image to be adapted e.g if it isn't the same size of
the placeholder image.
isAsyncAdapter()

boolean

Return true if the adapter should work on a separate thread to avoid


blocking the EDT this is especially important for image masks and heavy
image manipulation

Method Detail
adaptImage
EncodedImage adaptImage(EncodedImage downloadedImage,
EncodedImage placeholderImage)

Allows the downloaded image to be adapted e.g if it isn't the same size of the
placeholder image.
Parameters:
downloadedImage - the downloaded image
placeholderImage - the placeholder image
Returns:
the adapted image or the same image
isAsyncAdapter
boolean isAsyncAdapter()

Return true if the adapter should work on a separate thread to avoid blocking the
EDT this is especially important for image masks and heavy image manipulation
Returns:
true to run off the EDT

Interface URLImage.ImageAdapter

1391

Overview (Codename One API)


com.codename1.ui

Class Transform
java.lang.Object

com.codename1.ui.Transform

public class
extends Object

Encapsulates a 3D transform that can be used in Graphics contexts or with Shapes to transform in
various ways. Use the isSupported() and isPerspectiveSupported() to check if transforms and
perspective transforms are supported on this platform. If they are not supported, this class will throw
RuntimeExceptions if you try to use it.

Field Summary
Modifier and Type
static int
static int
static int
static int

Field and Description


TYPE_IDENTITY

Constant for transform type.


TYPE_SCALE

Constant for transform type.


TYPE_TRANSLATION

Constant for transform type.


TYPE_UNKNOWN

Constant for transform type.

Method Summary
Modifier and
Type

Method and Description


concatenate(Transform t)

void

Transform
boolean
Transform
Object
float
float
float
float
float
float
static
Transform

Method Detail

Sets the current transform to be the concatenation of the current transform


and the provided transform.
copy()

Creates a copy of the current transform.


equals(Transform t2)
getInverse()

Gets the inverse transformation for this transform.


getNativeTransform()

Gets the native transform object.


getScaleX()

Gets the x scale factor of this transformation.


getScaleY()

Gets the y scale factor of this transformation.


getScaleZ()

Gets the z scale factor of this transformation.


getTranslateX()

Gets the x translation of this transformation.


getTranslateY()

Gets the y translation of this transformation.


getTranslateZ()

Gets the z translation of this transformation.


IDENTITY()

1392

Overview (Codename One API)


boolean
static
boolean
boolean
static
boolean
boolean
static
Transform
static
Transform
static
Transform
static
Transform
static
Transform
static
Transform
static
Transform
static
Transform
static
Transform

isIdentity()

Checks if this transform is the identity transform.


isPerspectiveSupported()

Checks if perspective transforms are supported on this platform.


isScale()

Checks if this transform is a scale transformation .


isSupported()

Checks if transforms are supported on this platform.


isTranslation()

Checks if this transform is a translation transform.


makeCamera(float eyeX, float eyeY, float eyeZ, float centerX,
float centerY, float centerZ, float upX, float upY, float upZ)

Makes a transform to simulate a camera's perspective at a given location.


makeIdentity()

Makes a new identity transform.


makeOrtho(float left, float right, float bottom, float top,
float near, float far)

Makes a new orthographic projection transform.


makePerspective(float fovy, float aspect, float zNear, float zFar)

Makes a new perspective transform.


makeRotation(float angle, float x, float y)
makeRotation(float angle, float x, float y, float z)

Makes a new rotation transformation.


makeScale(float x, float y)
makeScale(float x, float y, float z)

Makes a new scale transformation.


makeTranslation(float x, float y)

static
Transform

makeTranslation(float x, float y, float z)

void

rotate(float angle, float px, float py)

void
void
void

void

Makes a new translation transformation.


rotate(float angle, float x, float y, float z)

Rotates the current transform.


scale(float x, float y)
scale(float x, float y, float z)

Scales the current transform by the provide scale factors.


setCamera(float eyeX, float eyeY, float eyeZ, float centerX,
float centerY, float centerZ, float upX, float upY, float upZ)

Sets the transform to the specified camera's perspective.


void

void

setIdentity()

Sets the transform to the identity transform.


setOrtho(float left, float right, float bottom, float top,
float near, float far)

Sets the transform to be the specified orthogonal view.


void
void
void
void
void
void
String

Method Summary

setPerspective(float fovy, float aspect, float zNear, float zFar)

Sets the transform to be the specified perspective transformation.


setRotation(float angle, float px, float py)
setRotation(float angle, float x, float y, float z)

Sets the transform to be the provided rotation.


setTransform(Transform t)

Sets the current transform to be identical to the provided transform.


setTranslation(float x, float y)
setTranslation(float x, float y, float z)

Sets the current transform to be the specified translation.


toString()

Returns a string representation of the object.

1393

Overview (Codename One API)


float[]

transformPoint(float[] point)

Transforms a provided point.


transformPoint(float[] in, float[] out)

void

Transforms a provided point and places the result in the provided array.

void

translate(float x, float y)
translate(float x, float y, float z)

void

Translates the transform by the specified amounts.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN

Constant for transform type. Transform is not a special matrix.


See Also:
Constant Field Values
TYPE_IDENTITY
public static final int TYPE_IDENTITY

Constant for transform type. Transform is the identity transform.


See Also:
Constant Field Values
TYPE_TRANSLATION
public static final int TYPE_TRANSLATION

Constant for transform type. Transform is a translation transform only.


See Also:
Constant Field Values
TYPE_SCALE
public static final int TYPE_SCALE

Constant for transform type. Transform is a scale transform only.


See Also:
Constant Field Values

Method Detail
IDENTITY
public static Transform IDENTITY()

makeIdentity
public static Transform makeIdentity()

Makes a new identity transform.


Returns:
An identity transform.
isIdentity
public boolean isIdentity()

Checks if this transform is the identity transform.


Returns:
True if the transform is the identity.

Methods inherited from class java.lang.Object

1394

Overview (Codename One API)


isTranslation
public boolean isTranslation()

Checks if this transform is a translation transform.


Returns:
True if this transform performs translation only. Note that this will return false
if the transform is the identity (i.e. is actually a translation of (0,0,0).
getScaleX
public float getScaleX()

Gets the x scale factor of this transformation. This value is only reliable if the
transform is a scale transform.
Returns:
The x scale factor of this transformation.
See Also:
isScale(), #setScale()
getScaleY
public float getScaleY()

Gets the y scale factor of this transformation. This value is only reliable if the
transform is a scale transform.
Returns:
The y scale factor of this transformation.
See Also:
isScale(), #setScale()
getScaleZ
public float getScaleZ()

Gets the z scale factor of this transformation. This value is only reliable if the
transform is a scale transform.
Returns:
The z scale factor of this transformation.
See Also:
isScale(), #setScale()
getTranslateX
public float getTranslateX()

Gets the x translation of this transformation. This value is only reliable if the transform
is a translation transform.
Returns:
The x translation of this transform.
See Also:
isTranslation(), #setTranslation(), #translate()
getTranslateY
public float getTranslateY()

Gets the y translation of this transformation. This value is only reliable if the transform
is a translation transform.
Returns:
The y translation of this transform.
See Also:
isTranslation(), #setTranslation(), #translate()
getTranslateZ
public float getTranslateZ()

Gets the z translation of this transformation. This value is only reliable if the transform
is a translation transform.
Returns:
The z translation of this transform.
See Also:

Method Detail

1395

Overview (Codename One API)


isTranslation(), #setTranslation(), #translate()

isScale
public boolean isScale()

Checks if this transform is a scale transformation .


Returns:
Returns true if and only if this is a non-identity scale transformation.
makeRotation
public static Transform makeRotation(float
float
float
float

angle,
x,
y,
z)

Makes a new rotation transformation.


Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
angle x - The
y - The
z - The

The angle of the rotation in radians.


x component of the vector around which the rotation occurs.
y component of the vector around which the rotation occurs.
z component of the vector around which the rotation occurs.

Returns:
A transform that makes the appropriate rotation.
Throws:
RuntimeException - If isSupported() is false.
makeRotation
public static Transform makeRotation(float angle,
float x,
float y)

makeTranslation
public static Transform makeTranslation(float x,
float y,
float z)

Makes a new translation transformation.


Parameters:
x - The x component of the translation.
y - The y component of the translation.
z - The z component of the translation.
Returns:
A transform that makes the specified translation.
makeTranslation
public static Transform makeTranslation(float x,
float y)

makeScale
public static Transform makeScale(float x,
float y,
float z)

Makes a new scale transformation.


Parameters:
x - The x scale factor.
y - The y scale factor.
z - The z scale factor.
Returns:
A transform that scales values according to the provided scale factors.
makeScale
public static Transform makeScale(float x,
float y)

Method Detail

1396

Overview (Codename One API)


makePerspective
public static Transform makePerspective(float
float
float
float

fovy,
aspect,
zNear,
zFar)

Makes a new perspective transform.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
fovy - The y field of view angle.
aspect - The aspect ratio.
zNear - The nearest visible z coordinate.
zFar - The farthest z coordinate.

Returns:
A transform for the given perspective.
makeOrtho
public static Transform makeOrtho(float
float
float
float
float
float

left,
right,
bottom,
top,
near,
far)

Makes a new orthographic projection transform.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
left - x-coordinate that is the left edge of the view.
right - The x-coordinate that is the right edge of the view.
bottom - The y-coordinate that is the bottom edge of the view.
top - The y-coordinate that is the top edge of the view.
near - The nearest visible z-coordinate.
far - The farthest visible z-coordinate.

Returns:
A transform with the provided orthographic projection.
makeCamera
public static Transform makeCamera(float
float
float
float
float
float
float
float
float

eyeX,
eyeY,
eyeZ,
centerX,
centerY,
centerZ,
upX,
upY,
upZ)

Makes a transform to simulate a camera's perspective at a given location.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
eyeX - The x-coordinate of the camera's eye.
eyeY - The y-coordinate of the camera's eye.
eyeZ - The z-coordinate of the camera's eye.
centerX - The center x coordinate of the view.
centerY - The center y coordinate of the view.
centerZ - The center z coordinate of the view.
upX - The x-coordinate of the up vector for the camera.
upY - The y-coordinate of the up vector for the camera.
upZ - The z-coordinate of the up vector for the camera.

Returns:
A transform with the provided camera's view perspective.

Method Detail

1397

Overview (Codename One API)


rotate
public void rotate(float
float
float
float

angle,
x,
y,
z)

Rotates the current transform.


Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
angle x - The
y - The
z - The

The angle to rotate in radians.


x-coordinate of the vector around which to rotate.
y-coordinate of the vector around which to rotate.
z-coordinate of the vector around which to rotate.

See Also:
setRotation(float, float, float, float)

rotate
public void rotate(float angle,
float px,
float py)

setRotation
public void setRotation(float
float
float
float

angle,
x,
y,
z)

Sets the transform to be the provided rotation. This replaces the current transform
whereas #rotate() further rotates the current transform.
Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
angle x - The
y - The
z - The

The angle to rotate in radians.


x-coordinate of the vector around which to rotate.
y-coordinate of the vector around which to rotate.
z-coordinate of the vector around which to rotate.

See Also:
#rotate()

setRotation
public void setRotation(float angle,
float px,
float py)

setIdentity
public void setIdentity()

Sets the transform to the identity transform.


toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

1398

Overview (Codename One API)


translate
public void translate(float x,
float y,
float z)

Translates the transform by the specified amounts. This adds additional translations
to whereas #setTranslation() replaces the transform with the specified translation.
Note: If isSupported() is false, then this may throw a Runtime Exception.
Parameters:
x - The x translation.
y - The y translation.
z - The z translation.
See Also:
#setTranslation()

translate
public void translate(float x,
float y)

setTranslation
public void setTranslation(float x,
float y,
float z)

Sets the current transform to be the specified translation. This replaces the current
transform with the given translation whereas #translate() adds additional translation
to the existing translation.
Parameters:
x - The x translation.
y - The y translation.
z - The z translation.
See Also:
#translate()

setTranslation
public void setTranslation(float x,
float y)

scale
public void scale(float x,
float y,
float z)

Scales the current transform by the provide scale factors. Not to be confused with
#setScale() which replaces the transform.
Note: If isSupported() is false, then this may throw a Runtime Exception.
Parameters:
x - The x-scale factor
y - The y-scale factor
z - The z-scale factor
See Also:
#setScale()

scale
public void scale(float x,
float y)

getInverse
public Transform getInverse()

Gets the inverse transformation for this transform.


Note: If isSupported() is false, then this will throw a Runtime Exception.

Method Detail

1399

Overview (Codename One API)


Returns:
The inverse transform.
setTransform
public void setTransform(Transform t)

Sets the current transform to be identical to the provided transform.


Note: If isSupported() is false, then this will may throw a Runtime Exception.
Parameters:
t - A transform to copy into the current transform.
concatenate
public void concatenate(Transform t)

Sets the current transform to be the concatenation of the current transform and the
provided transform.
Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
t - The transform to concatenate to this one.
setPerspective
public void setPerspective(float
float
float
float

fovy,
aspect,
zNear,
zFar)

Sets the transform to be the specified perspective transformation.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
fovy - Y-field of view angle.
aspect - Apspect ratio of the view window.
zNear - Nearest visible z-coordinate.
zFar - Farthest visible z-coordinate.

See Also:
#makePerspective()

setOrtho
public void setOrtho(float
float
float
float
float
float

left,
right,
bottom,
top,
near,
far)

Sets the transform to be the specified orthogonal view.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
left - Left x-coord of view.
right - Right x-coord of view.
bottom - Bottom y-coord of view.
top - Top y-coord of view.
near - Nearest visible z-coordinate
far - Farthest visible z-coordinate

setCamera
public void setCamera(float
float
float
float
float
float

Method Detail

eyeX,
eyeY,
eyeZ,
centerX,
centerY,
centerZ,

1400

Overview (Codename One API)


float upX,
float upY,
float upZ)

Sets the transform to the specified camera's perspective.


Note: If isPerspectiveSupported() is false, then this will throw a Runtime Exception.
Parameters:
eyeX - The x-coordinate of the camera's eye.
eyeY - The y-coordinate of the camera's eye.
eyeZ - The z-coordinate of the camera's eye.
centerX - The center x coordinate of the view.
centerY - The center y coordinate of the view.
centerZ - The center z coordinate of the view.
upX - The x-coordinate of the up vector for the camera.
upY - The y-coordinate of the up vector for the camera.
upZ - The z-coordinate of the up vector for the camera.

transformPoint
public float[] transformPoint(float[] point)

Transforms a provided point.


Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
point - 2 or 3 element array representing either an (x,y) or (x,y,z) tuple.
Returns:
A 3-element array representing transformed (x,y,z) tuple.
transformPoint
public void transformPoint(float[] in,
float[] out)

Transforms a provided point and places the result in the provided array.
Note: If isSupported() is false, then this will throw a Runtime Exception.
Parameters:
in - A 2 or 3 element array representing either an (x,y) or (x,y,z) tuple.
out - A 2 or 3 element array in which the transformed point will be stored.
Should match the length of the in array.
getNativeTransform
public Object getNativeTransform()

Gets the native transform object. This object is implementation dependent so this
method should really only be used by the implementation.
Note: If isSupported() is false, then this will throw a Runtime Exception.
Returns:
The native transform object.
copy
public Transform copy()

Creates a copy of the current transform.


Note: If isSupported() is false, then this will throw a Runtime Exception.
Returns:
A copy of the current transform.

Method Detail

1401

Overview (Codename One API)


isSupported
public static boolean isSupported()

Checks if transforms are supported on this platform. If this returns false, you cannot
use this class.
Returns:
True if and only if this platform supports transforms.
isPerspectiveSupported
public static boolean isPerspectiveSupported()

Checks if perspective transforms are supported on this platform. If this returns false,
you cannot use this class.
Returns:
True if and only if this platform supports transforms.
equals
public boolean equals(Transform t2)

Method Detail

1402

Overview (Codename One API)


com.codename1.ui

Class Toolbar
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Toolbar
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

Toolbar replaces the default title area with a powerful abstraction that allows functionality ranging from
side menus (hamburger) to title animations and any arbitrary component type. Toolbar allows
customizing the Form title with different commands on the title area, within the side menu or the
overflow menu.
The Toolbar allows placing components in one of 4 positions as illustrated by the sample below:

The following code demonstrates a more advanced search widget where the data is narrowed as we
type directly into the title area search. Notice that the TextField and its hint are styled to look like the
title.

Class Toolbar

1403

Overview (Codename One API)

This sample code show off title animations that allow a title to change (and potentially shrink) as the
user scrolls down the UI. The 3 frames below show a step by step process in the change.

Class Toolbar

1404

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Toolbar()

Empty Constructor
Toolbar(boolean layered)

This constructor places the Toolbar on a different layer on top of the Content Pane.

Method Summary
Modifier and
Type
void
Command
void

Command

Method and Description


addCommandToLeftBar(Command cmd)

Adds a Command to the TitleArea on the left side.


addCommandToLeftBar(String name, Image icon, ActionListener ev)

Adds a Command to the TitleArea on the left side.


addCommandToOverflowMenu(Command cmd)

Adds a Command to the overflow menu


addCommandToOverflowMenu(String name, Image icon,
ActionListener ev)

Adds a Command to the overflow menu


void

Field Summary

addCommandToRightBar(Command cmd)

1405

Overview (Codename One API)


Adds a Command to the TitleArea on the right side.
Command
void
Command
void
void
protected
void
boolean
protected
Container
protected
List
protected
Container
Button
MenuBar
Component
void
protected
void
static
boolean
static
boolean
boolean
static void

addCommandToRightBar(String name, Image icon, ActionListener ev)

Adds a Command to the TitleArea on the right side.


addCommandToSideMenu(Command cmd)

Adds a Command to the side navigation menu


addCommandToSideMenu(String name, Image icon, ActionListener ev)

Adds a Command to the side navigation menu


addComponentToSideMenu(Component cmp)

Adds a Component to the side navigation menu.


addComponentToSideMenu(Component cmp, Command cmd)

Adds a Component to the side navigation menu.


addComponentToSideMenu(Container menu, Component cmp)

This method responsible to add a Component to the side navigation panel.


animate()

Allows the animation to reduce "repaint" calls when it returns false.


constructSideNavigationComponent()

Creates an empty side navigation panel.


createOverflowCommandList(Vector commands)

Creates the list component containing the commands within the given vector
used for showing the menu dialog
createSideNavigationComponent(Vector commands, String placement)

Creates the side navigation component with the Commands.


findCommandComponent(Command c)

Find the command component instance if such an instance exists


getMenuBar()

Returns the associated SideMenuBar object of this Toolbar.


getTitleComponent()

Returns the Toolbar title Component.


hideToolbar()

Hide the Toolbar if it is currently showing


initTitleBarStatus()

Adds a status bar space to the north of the Component, subclasses can
override this default behavior.
isGlobalToolbar()

Enables/disables the Toolbar for all the forms in the application.


isPermanentSideMenu()

Creates a static side menu that doesn't fold instead of the standard
sidemenu.
isTitleCentered()

Returns true if the title is centered via the layout


setGlobalToolbar(boolean gt)

Enables/disables the Toolbar for all the forms in the application.


setPermanentSideMenu(boolean p)

static void

void
void

Creates a static side menu that doesn't fold instead of the standard
sidemenu.
setScrollOffUponContentPane(boolean scrollOff)

Sets the Toolbar to scroll off the screen upon content scroll.
setTitle(String title)

Sets the title of the Toolbar.


setTitleCentered(boolean cent)

void

void
protected
Command
void

Method Summary

Makes the title align to the center accurately by doing it at the layout level
which also takes into account right/left commands
setTitleComponent(Component titleCmp)

Sets the Toolbar title component.


showOverflowMenu(Dialog menu)
showToolbar()

Show the Toolbar if it is currently not showing

1406

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Container

add, add, add, add, add, add, addComponent, addComponent, addComponent,


addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class com.codename1.ui.Container

1407

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Toolbar
public Toolbar()

Empty Constructor
Toolbar
public Toolbar(boolean layered)

This constructor places the Toolbar on a different layer on top of the Content Pane.
Parameters:
layered - if true places the Toolbar on top of the Content Pane

Method Detail
setGlobalToolbar
public static void setGlobalToolbar(boolean gt)

Enables/disables the Toolbar for all the forms in the application. This flag can be
flipped via the theme constant globalToobarBool.
Parameters:
gt - true to enable the toolbar globally
isGlobalToolbar
public static boolean isGlobalToolbar()

Enables/disables the Toolbar for all the forms in the application. This flag can be
flipped via the theme constant globalToobarBool.
Returns:
true if the toolbar API is turned on by default
setTitle
public void setTitle(String title)

Sets the title of the Toolbar.


Parameters:
title - the Toolbar title
setTitleCentered
public void setTitleCentered(boolean cent)

Makes the title align to the center accurately by doing it at the layout level which also
takes into account right/left commands
Parameters:
cent - whether the title should be centered
isTitleCentered
public boolean isTitleCentered()

Returns true if the title is centered via the layout


Returns:
true if the title is centered

Methods inherited from class java.lang.Object

1408

Overview (Codename One API)


setPermanentSideMenu
public static void setPermanentSideMenu(boolean p)

Creates a static side menu that doesn't fold instead of the standard sidemenu. This is
common for tablet UI's where folding the side menu doesn't make as much sense.
Parameters:
p - true to have a permanent side menu
isPermanentSideMenu
public static boolean isPermanentSideMenu()

Creates a static side menu that doesn't fold instead of the standard sidemenu. This is
common for tablet UI's where folding the side menu doesn't make as much sense.
Returns:
true if we will use a permanent sidemenu
setTitleComponent
public void setTitleComponent(Component titleCmp)

Sets the Toolbar title component. This method allow placing any component in the
Toolbar ceneter instead of the regular Label. Can be used to place a TextField to
preform search operations
Parameters:
titleCmp - Comoponent to place in the Toolbar center.
getTitleComponent
public Component getTitleComponent()

Returns the Toolbar title Component.


Returns:
the Toolbar title component
addCommandToOverflowMenu
public Command addCommandToOverflowMenu(String name,
Image icon,
ActionListener ev)

Adds a Command to the overflow menu


Parameters:
name - the name/title of the command
icon - the icon for the command
ev - the even handler
Returns:
a newly created Command instance
addCommandToOverflowMenu
public void addCommandToOverflowMenu(Command cmd)

Adds a Command to the overflow menu


Parameters:
cmd - a Command
addCommandToSideMenu
public Command addCommandToSideMenu(String name,
Image icon,
ActionListener ev)

Adds a Command to the side navigation menu


Parameters:
name - the name/title of the command
icon - the icon for the command
ev - the even handler
Returns:
a newly created Command instance

Method Detail

1409

Overview (Codename One API)


addCommandToSideMenu
public void addCommandToSideMenu(Command cmd)

Adds a Command to the side navigation menu


Parameters:
cmd - a Command
addComponentToSideMenu
public void addComponentToSideMenu(Component cmp,
Command cmd)

Adds a Component to the side navigation menu. The Component is added to the
navigation menu and the command gets the events once the Component is being
pressed.
Parameters:
cmp - c Component to be added to the menu
cmd - a Command to handle the events
addComponentToSideMenu
public void addComponentToSideMenu(Component cmp)

Adds a Component to the side navigation menu.


Parameters:
cmp - c Component to be added to the menu
findCommandComponent
public Button findCommandComponent(Command c)

Find the command component instance if such an instance exists


Parameters:
c - the command instance
Returns:
the button instance
addCommandToRightBar
public Command addCommandToRightBar(String name,
Image icon,
ActionListener ev)

Adds a Command to the TitleArea on the right side.


Parameters:
name - the name/title of the command
icon - the icon for the command
ev - the even handler
Returns:
a newly created Command instance
addCommandToRightBar
public void addCommandToRightBar(Command cmd)

Adds a Command to the TitleArea on the right side.


Parameters:
cmd - a Command
addCommandToLeftBar
public Command addCommandToLeftBar(String name,
Image icon,
ActionListener ev)

Adds a Command to the TitleArea on the left side.


Parameters:
name - the name/title of the command
icon - the icon for the command
ev - the even handler
Returns:
a newly created Command instance

Method Detail

1410

Overview (Codename One API)


addCommandToLeftBar
public void addCommandToLeftBar(Command cmd)

Adds a Command to the TitleArea on the left side.


Parameters:
cmd - a Command
getMenuBar
public MenuBar getMenuBar()

Returns the associated SideMenuBar object of this Toolbar.


Returns:
the associated SideMenuBar object
showOverflowMenu
protected Command showOverflowMenu(Dialog menu)

createOverflowCommandList
protected List createOverflowCommandList(Vector commands)

Creates the list component containing the commands within the given vector used for
showing the menu dialog
Parameters:
commands - list of command objects
Returns:
List object
initTitleBarStatus
protected void initTitleBarStatus()

Adds a status bar space to the north of the Component, subclasses can override this
default behavior.
setScrollOffUponContentPane
public void setScrollOffUponContentPane(boolean scrollOff)

Sets the Toolbar to scroll off the screen upon content scroll. This feature can only
work if the Form contentPane is scrollableY
Parameters:
scrollOff - if true the Toolbar needs to scroll off the screen when the Form
ContentPane is scrolled
hideToolbar
public void hideToolbar()

Hide the Toolbar if it is currently showing


showToolbar
public void showToolbar()

Show the Toolbar if it is currently not showing


animate
public boolean animate()

Description copied from class: Component


Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

Method Detail

1411

Overview (Codename One API)


createSideNavigationComponent
protected Container createSideNavigationComponent(Vector commands,
String placement)

Creates the side navigation component with the Commands.


Parameters:
commands - the Command objects
Returns:
the Component to display on the side navigation
constructSideNavigationComponent
protected Container constructSideNavigationComponent()

Creates an empty side navigation panel.


addComponentToSideMenu
protected void addComponentToSideMenu(Container menu,
Component cmp)

This method responsible to add a Component to the side navigation panel.


Parameters:
menu - the Menu Container that was created in the
constructSideNavigationComponent() method
cmp - the Component to add to the side menu

Method Detail

1412

Overview (Codename One API)


com.codename1.ui

Class TextField
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.TextArea

com.codename1.ui.TextField
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
AutoCompleteTextField

public class
extends TextArea

A specialized version of TextArea with some minor deviations from the original specifically:
Blinking cursor is rendered on TextField only
com.codename1.ui.events.DataChangeListener is only available in TextField. This is crucial
for character by character input event tracking
setDoneListener(com.codename1.ui.events.ActionListener) is only available in TextField
Different UIID's ("TextField" vs. "TextArea")
The demo code below shows simple input using text fields:
TableLayout tl;
int spanButton = 2;
if(Display.getInstance().isTablet()) {
tl = new TableLayout(7, 2);
} else {
tl = new TableLayout(14, 1);
spanButton = 1;
}
tl.setGrowHorizontally(true);
hi.setLayout(tl);
TextField
TextField
TextField
TextField
TextField

firstName = new TextField("", "First Name", 20, TextArea.ANY);


surname = new TextField("", "Surname", 20, TextArea.ANY);
email = new TextField("", "E-Mail", 20, TextArea.EMAILADDR);
url = new TextField("", "URL", 20, TextArea.URL);
phone = new TextField("", "Phone", 20, TextArea.PHONENUMBER);

TextField
TextField
TextField
TextField

num1
num2
num3
num4

=
=
=
=

new
new
new
new

TextField("",
TextField("",
TextField("",
TextField("",

"1234",
"1234",
"1234",
"1234",

4,
4,
4,
4,

TextArea.NUMERIC);
TextArea.NUMERIC);
TextArea.NUMERIC);
TextArea.NUMERIC);

Button submit = new Button("Submit");


TableLayout.Constraint cn = tl.createConstraint();
cn.setHorizontalSpan(spanButton);
cn.setHorizontalAlign(Component.RIGHT);
hi.add("First Name").add(firstName).
add("Surname").add(surname).
add("E-Mail").add(email).
add("URL").add(url).
add("Phone").add(phone).
add("Credit Card").
add(GridLayout.encloseIn(4, num1, num2, num3, num4)).
add(cn, submit);

Class TextField

1413

Overview (Codename One API)

The following code demonstrates a more advanced search widget where the data is narrowed as we
type directly into the title area search. Notice that the TextField and its hint are styled to look like the
title.
Toolbar.setGlobalToolbar(true);
Style s = UIManager.getInstance().getComponentStyle("Title");
Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS));
TextField searchField = new TextField("", "Toolbar Search"); <1>
searchField.getHintLabel().setUIID("Title");
searchField.setUIID("Title");
searchField.getAllStyles().setAlignment(Component.LEFT);
hi.getToolbar().setTitleComponent(searchField);
FontImage searchIcon = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
searchField.addDataChangeListener((i1, i2) -> { <2>
String t = searchField.getText();
if(t.length() < 1) {
for(Component cmp : hi.getContentPane()) {
cmp.setHidden(false);
cmp.setVisible(true);
}
} else {
t = t.toLowerCase();
for(Component cmp : hi.getContentPane()) {
String val = null;
if(cmp instanceof Label) {
val = ((Label)cmp).getText();
} else {
if(cmp instanceof TextArea) {
val = ((TextArea)cmp).getText();
} else {
val = (String)cmp.getPropertyValue("text");
}
}
boolean show = val != null && val.toLowerCase().indexOf(t) > -1;
cmp.setHidden(!show); <3>
cmp.setVisible(show);
}
}
hi.getContentPane().animateLayout(250);
});
hi.getToolbar().addCommandToRightBar("", searchIcon, (e) -> {
searchField.startEditingAsync(); <4>
});
hi.add("A Game of Thrones").
add("A Clash Of Kings").
add("A Storm Of Swords").
add("A Feast For Crows").
add("A Dance With Dragons").
add("The Winds of Winter").
add("A Dream of Spring");
hi.show();

Class TextField

1414

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.TextArea


ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD,
NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, URL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
TextField()

Default constructor
TextField(int columns)

Construct a text field with space reserved for columns


TextField(String text)

Construct text field


TextField(String text, int columns)

Construct text field


TextField(String text, String hint)

Construct text field with a hint


TextField(String text, String hint, int columns, int constraint)

Construct text field with a hint, columns and constraint values

Field Summary

1415

Overview (Codename One API)

Method Summary
Modifier and
Type

Method and Description


addDataChangeListener(DataChangedListener d)

void

Adds a listener for data change events it will be invoked for every change
made to the text field, notice most platforms will invoke only the
DataChangedListener.CHANGED event
addInputMode(String name, Hashtable values, boolean firstUpcase)

static void

boolean
protected
Dimension
void
protected void
static
TextArea
static
TextArea
static
TextArea
static
TextArea
protected
Container

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


clear()

Cleares the text from the TextField


commitChange()

Commit the changes made to the text field as a complete edit operation.
create()

Default factory method


create(int columns)

Construct text field/area depending on whether native in place editing is


supported
create(String text)

Construct text field/area depending on whether native in place editing is


supported
create(String text, int columns)

Construct text field/area depending on whether native in place editing is


supported
createSymbolTable()

Creates a symbol table container used by the showSymbolDialog method.


deinitialize()

protected void

void

Invoked to indicate that the component initialization is being reversed since


the component was detached from the container hierarchy.
deleteChar()

Performs a backspace operation


fireClicked()

protected void

void
void

When working in 3 softbutton mode "fire" key (center softbutton) is sent to


this method in order to allow 3 button devices to work properly.
fireDataChanged(int type, int index)

Alert the TextField listeners the text has been changed on the TextField
fireDoneEvent()

Fire the done event to done listener


getCharPerKeyCode(int pressCount, int keyCode, boolean longClick)

protected char

Returns the character matching the given key code after the given amount
of user presses
getCommitTimeout()

int

int
int
int
int

Method Summary

The amount of time in milliseconds it will take for a change to get


committed into the field.
getCursorBlinkTimeOff()

The amount of time in milliseconds in which the cursor is invisible


getCursorBlinkTimeOn()

The amount of time in milliseconds in which the cursor is visible


getCursorPosition()

Returns the position of the cursor char position


getCursorX()

1416

Overview (Codename One API)


Returns the position of the cursor char position in the current line.
int

getCursorY()

Returns the position of the cursor line position


getDefaultChangeInputModeKey()

static int

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
getDefaultInputModeOrder()

static
String[]

static int
ActionListener

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
getDefaultSymbolDialogKey()

The default key for poping open the symbol dialog


getDoneListener()

Gets the done listener of this TextField.


getInputMode()

String

String[]

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
getInputModeOrder()

Returns the order in which input modes are toggled


getLongClickDuration()

protected int

The amount of time considered as a "long click" causing the long click
method to be invoked.

protected
String

getLongClickInputMode()

static char[]

Returns the input mode for the ong click mode


getSymbolTable()

Returns the symbol table for the device


insertChars(String c)

void

protected
Command

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
installCommands(Command clear, Command t9)

Installs the clear and t9 commands onto the parent form, this method can
be overriden to provide device specific placement for these commands
isChangeInputMode(int keyCode)

protected
boolean

protected
boolean
protected
boolean
protected
boolean
protected
boolean

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
isClearKey(int keyCode)

Returns true if this is the clear key on the device, many devices don't
contain a clear key and even in those that contain it this might be an issue
isCursorPositionCycle()

Returns true if the cursor should cycle to the beginning of the text when the
user navigates beyond the edge of the text and visa versa.
isEditingEndTrigger(int keyCode)

Indicates whether the given key code should be ignored or should trigger
cause editing to end.
isEditingTrigger(int keyCode)

Indicates whether the given key code should be ignored or should trigger
editing, by default fire or any numeric key should trigger editing implicitly.
isEnableInputScroll()

boolean

Indicates whether text field input should scroll to the right side when no
more room for the input is present.
isImmediateInputMode(String mode)

protected
boolean

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else

boolean

isLeftAndRightEditingTrigger()

Method Summary

1417

Overview (Codename One API)


Indicates whether the left/right keys will trigger editing, this is true by
default.
boolean
boolean

isOverwriteMode()

Indicates that this is the overwrite mode


isPendingCommit()

Returns true if the text field is waiting for a commit on editing


isQwertyAutoDetect()

static boolean

Indicates whether the text field should try to auto detect qwerty and switch
the qwerty device flag implicitly
isQwertyDevice()

static boolean

boolean

The default value for the qwerty flag so it doesn't need setting for every text
field individually.
isQwertyInput()

True is this is a qwerty device or a device that is currently in qwerty mode.


isReplaceMenu()

boolean

Indicates whether the menu of the form should be replaced with the
T9/Clear commands for the duration of interactivity with the text field
isReplaceMenuDefault()

static boolean

Indicates whether the menu of the form should be replaced with the
T9/Clear commands for the duration of interactivity with the text field
isSelectableInteraction()

protected
boolean

This method allows a component to indicate that it is interested in an


"implicit" select command to appear in the "fire" button when 3 softbuttons
are defined in a device.

protected
boolean

isSymbolDialogKey(int keyCode)

Returns true if this keycode is the one mapping to the symbol dialog popup
isUseNativeTextInput()

static boolean

boolean
void
void
void

Indicates that native text input should be used in text field when in place
editing is supported by the platform
isUseSoftkeys()

When set to true softkeys are used to enable delete functionality


keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
longKeyPress(int keyCode)

protected void

If this Component is focused this method is invoked when the user presses
and holds the key
paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the
PLAF perform the rendering.
pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this
method
removeCommands(Command clear, Command t9, Command originalClear)

protected void

void
void
static void

Removes the clear and t9 commands from the parent form, this method
can be overriden to provide device specific placement for these commands
removeDataChangeListener(DataChangedListener d)

Removes the listener for data change events


setAlignment(int align)

Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHT
setClearText(String text)

Set the text that should appear on the clear softkey


setCommitTimeout(int commitTimeout)

void

Method Summary

The amount of time in milliseconds it will take for a change to get


committed into the field.

1418

Overview (Codename One API)


void
void
void

setCursorBlinkTimeOff(int time)

The amount of time in milliseconds in which the cursor is invisible


setCursorBlinkTimeOn(int time)

The amount of time in milliseconds in which the cursor is visible


setCursorPosition(int pos)

Sets the position of the cursor char position


setDefaultChangeInputModeKey(int k)

static void

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
setDefaultInputModeOrder(String[] order)

static void

static void

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
setDefaultSymbolDialogKey(int d)

The default key for poping open the symbol dialog


setDoneListener(ActionListener l)

void

void

Sets a Done listener on the TextField - notice this listener will be called only
on supported platforms that supports done action on the keyboard
setEditable(boolean b)

Sets this text area to be editable or readonly


setEnableInputScroll(boolean enableInputScroll)

void

Indicates whether text field input should scroll to the right side when no
more room for the input is present.
setInputMode(String inputMode)

void

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
setInputModeOrder(String[] order)

void

Deprecated.
this is a method for use only on old J2ME devices and is ignored
everywhere else
setLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger)

void

void

Indicates whether the left/right keys will trigger editing, this is true by
default.
setOverwriteMode(boolean overwriteMode)

Indicates that this is the overwrite mode


setQwertyAutoDetect(boolean v)

static void

Indicates whether the text field should try to auto detect qwerty and switch
the qwerty device flag implicitly
setQwertyDevice(boolean v)

static void

void

The default value for the qwerty flag so it doesn't need setting for every text
field individually.
setQwertyInput(boolean qwerty)

True is this is a qwerty device or a device that is currently in qwerty mode.


setReplaceMenu(boolean replaceMenu)

void

Indicates whether the menu of the form should be replaced with the
T9/Clear commands for the duration of interactivity with the text field
setReplaceMenuDefault(boolean replaceMenu)

static void

static void
static void
void

Indicates whether the menu of the form should be replaced with the
T9/Clear commands for the duration of interactivity with the text field
setSymbolTable(char[] table)

Sets the symbol table to show when the user clicks the symbol table key
setT9Text(String text)

Set the text that should appear on the T9 softkey


setText(String text)

Sets the text within this text area


setUseNativeTextInput(boolean aUseNativeTextInput)

static void

Method Summary

Indicates that native text input should be used in text field when in place
editing is supported by the platform

1419

Overview (Codename One API)


setUseSoftkeys(boolean useSoftkeys)

void

When set to true softkeys are used to enable delete functionality


showSymbolDialog()

protected void

boolean

Invoked to show the symbol dialog, this method can be overriden by


subclasses to manipulate the symbol table
validChar(String c)

Checks if the candidate input is valid for this TextField

Methods inherited from class com.codename1.ui.TextArea


addActionListener, autoDetectWidestChar, bindProperty, calcScrollSize,
getAbsoluteAlignment, getActualRows, getAlignment, getAsInt,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getColumns, getConstraint, getDefaultValign, getGrowLimit, getHint,
getHintIcon, getHintLabel, getLines, getLinesToScroll, getMaxSize, getRows,
getRowsGap, getStyle, getText, getTextAt, getUnsupportedChars,
getVerticalAlignment, getWidestChar, initLaf, isAutoDegradeMaxSize,
isEditable, isEditing, isEndsWith3Points, isEnterKey, isGrowByContent,
isScrollableY, isSingleLineTextArea, isUseStringWidth, pointerHover,
pointerHoverReleased, preprocess, removeActionListener,
setAutoDegradeMaxSize, setBoundPropertyValue, setColumns, setConstraint,
setDefaultMaxSize, setDefaultValign, setEndsWith3Points, setGrowByContent,
setGrowLimit, setHint, setHint, setHintIcon, setLinesToScroll, setMaxSize,
setRows, setRowsGap, setSingleLineTextArea, setUnsupportedChars,
setUseStringWidth, setVerticalAlignment, setWidestChar, setWidth,
startEditing, startEditingAsync, stopEditing, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
cancelRepaints, clearClientProperties, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
dragInitiated, drawDraggedImage, drop, focusGained, focusLost,
getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline,
getBaselineResizeBehavior, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled,
isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, paramString, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerPressed, pointerPressed, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight,
setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,

Methods inherited from class com.codename1.ui.TextArea

1420

Overview (Codename One API)

setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,


setScrollY, setSelectCommandText, setSelectedStyle,
setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe,
styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
TextField
public TextField()

Default constructor
TextField
public TextField(int columns)

Construct a text field with space reserved for columns


Parameters:
columns - - the number of columns
TextField
public TextField(String text)

Construct text field


Parameters:
text - the text of the field
TextField
public TextField(String text,
String hint)

Construct text field with a hint


Parameters:
text - the text of the field
hint - the hint string
TextField
public TextField(String text,
String hint,
int columns,
int constraint)

Construct text field with a hint, columns and constraint values


Parameters:
text - the text of the field
hint - the hint string
columns - columns value
constraint - the constraint value
TextField
public TextField(String text,
int columns)

Construct text field


Parameters:
text - the text of the field
columns - - the number of columns

Methods inherited from class com.codename1.ui.Component

1421

Overview (Codename One API)

Method Detail
isUseNativeTextInput
public static boolean isUseNativeTextInput()

Indicates that native text input should be used in text field when in place editing is
supported by the platform
Returns:
the useNativeTextInput
setUseNativeTextInput
public static void setUseNativeTextInput(boolean aUseNativeTextInput)

Indicates that native text input should be used in text field when in place editing is
supported by the platform
Parameters:
aUseNativeTextInput - the useNativeTextInput to set
setClearText
public static void setClearText(String text)

Set the text that should appear on the clear softkey


Parameters:
text - localized text for the clear softbutton
setT9Text
public static void setT9Text(String text)

Set the text that should appear on the T9 softkey


Parameters:
text - text for the T9 softbutton
isEnableInputScroll
public boolean isEnableInputScroll()

Indicates whether text field input should scroll to the right side when no more room for
the input is present.
Overrides:
isEnableInputScroll in class TextArea
Returns:
true if scrolling is enabled
setEnableInputScroll
public void setEnableInputScroll(boolean enableInputScroll)

Indicates whether text field input should scroll to the right side when no more room for
the input is present.
Parameters:
enableInputScroll - true to enable scrolling to the side
deleteChar
public void deleteChar()

Performs a backspace operation


create
public static TextArea create(String text,
int columns)

Construct text field/area depending on whether native in place editing is supported


Parameters:
text - the text of the field
columns - - the number of columns
Returns:
a text field if native in place editing is unsupported and a text area if it is

Method Detail

1422

Overview (Codename One API)


create
public static TextArea create()

Default factory method


Returns:
a text field if native in place editing is unsupported and a text area if it is
create
public static TextArea create(int columns)

Construct text field/area depending on whether native in place editing is supported


Parameters:
columns - - the number of columns
Returns:
a text field if native in place editing is unsupported and a text area if it is
create
public static TextArea create(String text)

Construct text field/area depending on whether native in place editing is supported


Parameters:
text - the text of the field
Returns:
a text field if native in place editing is unsupported and a text area if it is
commitChange
protected void commitChange()

Commit the changes made to the text field as a complete edit operation. This is used
in a numeric keypad to allow the user to repeatedly press a number to change
values.
isPendingCommit
public boolean isPendingCommit()

Returns true if the text field is waiting for a commit on editing


Overrides:
isPendingCommit in class TextArea
Returns:
true if a commit is pending
setCommitTimeout
public void setCommitTimeout(int commitTimeout)

The amount of time in milliseconds it will take for a change to get committed into the
field.
Parameters:
commitTimeout - indicates the amount of time that should elapse for a commit
to automatically occur
getCommitTimeout
public int getCommitTimeout()

The amount of time in milliseconds it will take for a change to get committed into the
field.
Returns:
the time for a commit timeout
setInputMode
public void setInputMode(String inputMode)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Sets the current selected input mode matching one of the existing input modes
Parameters:

Method Detail

1423

Overview (Codename One API)


- the display name of the input mode by default the following
modes are supported: Abc, ABC, abc, 123
getInputMode
inputMode

public String getInputMode()

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Returns the currently selected input mode
Overrides:
getInputMode in class TextArea
Returns:
the display name of the input mode by default the following modes are
supported: Abc, ABC, abc, 123
isChangeInputMode
protected boolean isChangeInputMode(int keyCode)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Indicates whether the key changes the current input mode
Parameters:
keyCode - the code
Returns:
true for the hash (#) key code
addInputMode
public static void addInputMode(String name,
Hashtable values,
boolean firstUpcase)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Adds a new inputmode hashtable with the given name and set of values
Parameters:
name - a unique display name for the input mode e.g. ABC, 123 etc...
values - The key for the hashtable is an Integer keyCode and the value is a
String containing the characters to toggle between for the given keycode
firstUpcase - indicates if this input mode in an input mode used for the
special case where the first letter is an upper case letter
getInputModeOrder
public String[] getInputModeOrder()

Returns the order in which input modes are toggled


Overrides:
getInputModeOrder in class TextArea
Returns:
the order of the input modes
setInputModeOrder
public void setInputModeOrder(String[] order)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Sets the order in which input modes are toggled and allows disabling/hiding an input
mode
Parameters:
order - the order for the input modes in this field
getDefaultInputModeOrder
public static String[] getDefaultInputModeOrder()

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Returns the order in which input modes are toggled by default
Returns:

Method Detail

1424

Overview (Codename One API)


the default order of the input mode
setDefaultInputModeOrder
public static void setDefaultInputModeOrder(String[] order)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Sets the order in which input modes are toggled by default and allows
disabling/hiding an input mode
Parameters:
order - the order for the input modes in all future created fields
getLongClickInputMode
protected String getLongClickInputMode()

Returns the input mode for the ong click mode


Returns:
returns 123 by default
getCharPerKeyCode
protected char getCharPerKeyCode(int pressCount,
int keyCode,
boolean longClick)

Returns the character matching the given key code after the given amount of user
presses
Parameters:
pressCount - number of times this keycode was pressed
keyCode - the actual keycode input by the user
longClick - does this click constitute a long click
Returns:
the char mapping to this key or 0 if no appropriate char was found
(navigation, input mode change etc...).
setCursorPosition
public void setCursorPosition(int pos)

Sets the position of the cursor char position


Parameters:
pos - the cursor position
getCursorPosition
public int getCursorPosition()

Returns the position of the cursor char position


Overrides:
getCursorPosition in class TextArea
Returns:
the cursor position
getCursorY
public int getCursorY()

Returns the position of the cursor line position


Overrides:
getCursorY in class TextArea
Returns:
the cursor line position
getCursorX
public int getCursorX()

Returns the position of the cursor char position in the current line.
Overrides:
getCursorX in class TextArea
Returns:
the cursor char position in the current line

Method Detail

1425

Overview (Codename One API)


setText
public void setText(String text)

Sets the text within this text area


Overrides:
setText in class TextArea
Parameters:
text - new value for the text area
clear
public void clear()

Cleares the text from the TextField


isClearKey
protected boolean isClearKey(int keyCode)

Returns true if this is the clear key on the device, many devices don't contain a clear
key and even in those that contain it this might be an issue
Parameters:
keyCode - the key code that might be the clear key
Returns:
true if this is the clear key.
longKeyPress
protected void longKeyPress(int keyCode)

If this Component is focused this method is invoked when the user presses and holds
the key
Overrides:
longKeyPress in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
isQwertyInput
public boolean isQwertyInput()

True is this is a qwerty device or a device that is currently in qwerty mode.


Overrides:
isQwertyInput in class TextArea
Returns:
currently defaults to false
setQwertyInput
public void setQwertyInput(boolean qwerty)

True is this is a qwerty device or a device that is currently in qwerty mode.


Parameters:
qwerty - the value of qwerty mode
isImmediateInputMode
protected boolean isImmediateInputMode(String mode)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Returns true if the given input mode should commit immediately or wait for the
commit timeout
Parameters:
mode - the input mode
Returns:
returns true for input mode 123 by default
insertChars
public void insertChars(String c)

Method Detail

1426

Overview (Codename One API)


Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
This method is responsible for adding a character into the field and is the focal point
for all input. It can be overriden to prevent a particular char from insertion or provide a
different behavior for char insertion. It is the responsibility of this method to shift the
cursor and invoke setText...
This method accepts a string for the more elaborate cases such as multi-char input
and paste.
Parameters:
c - character for insertion
validChar
public boolean validChar(String c)

Checks if the candidate input is valid for this TextField


Parameters:
c - the String to insert
Returns:
true if the String is valid
showSymbolDialog
protected void showSymbolDialog()

Invoked to show the symbol dialog, this method can be overriden by subclasses to
manipulate the symbol table
createSymbolTable
protected Container createSymbolTable()

Creates a symbol table container used by the showSymbolDialog method. This


method is designed for subclases to override and customize.
Returns:
container for the symbol table.
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class TextArea
Parameters:
keyCode - the key code value to indicate a physical key.
getLongClickDuration
protected int getLongClickDuration()

The amount of time considered as a "long click" causing the long click method to be
invoked.
Returns:
currently defaults to 800
getSymbolTable
public static char[] getSymbolTable()

Returns the symbol table for the device


Returns:
the symbol table of the device for the symbol table input
setSymbolTable
public static void setSymbolTable(char[] table)

Sets the symbol table to show when the user clicks the symbol table key
Parameters:
table - the symbol table of the device for the symbol table input

Method Detail

1427

Overview (Codename One API)


isCursorPositionCycle
protected boolean isCursorPositionCycle()

Returns true if the cursor should cycle to the beginning of the text when the user
navigates beyond the edge of the text and visa versa.
Returns:
true by default
isSymbolDialogKey
protected boolean isSymbolDialogKey(int keyCode)

Returns true if this keycode is the one mapping to the symbol dialog popup
Parameters:
keyCode - the keycode to check
Returns:
true if this is the star symbol *
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
setEditable
public void setEditable(boolean b)

Sets this text area to be editable or readonly


Overrides:
setEditable in class TextArea
Parameters:
b - true is text are is editable; otherwise false
keyRepeated
public void keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
Overrides:
keyRepeated in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class TextArea
Parameters:
keyCode - the key code value to indicate a physical key.
installCommands
protected Command installCommands(Command clear,
Command t9)

Installs the clear and t9 commands onto the parent form, this method can be
overriden to provide device specific placement for these commands
Parameters:
clear - the clear command
t9 - the t9 command
Returns:
clear command already installed in the form if applicable, none if no clear
command was installed before or not applicable.

Method Detail

1428

Overview (Codename One API)


isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class TextArea
Returns:
true if this is a selectable interaction
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class TextArea
removeCommands
protected void removeCommands(Command clear,
Command t9,
Command originalClear)

Removes the clear and t9 commands from the parent form, this method can be
overriden to provide device specific placement for these commands
Parameters:
clear - the clear command
t9 - the t9 command
originalClear - the command originally assigned as the clear command (or
null if no command was assigned before)
isEditingTrigger
protected boolean isEditingTrigger(int keyCode)

Indicates whether the given key code should be ignored or should trigger editing, by
default fire or any numeric key should trigger editing implicitly. This method is only
called when handles input is false.
Parameters:
keyCode - the keycode passed to the keyPressed method
Returns:
true if this key code should cause a switch to editing mode.
isEditingEndTrigger
protected boolean isEditingEndTrigger(int keyCode)

Indicates whether the given key code should be ignored or should trigger cause
editing to end. By default the fire key, up or down will trigger the end of editing.
Parameters:
keyCode - the keycode passed to the keyPressed method
Returns:
true if this key code should cause a switch to editing mode.
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class TextArea
Parameters:
g - the component graphics

Method Detail

1429

Overview (Codename One API)


calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class TextArea
Returns:
the calculated preferred size based on component content
setCursorBlinkTimeOn
public void setCursorBlinkTimeOn(int time)

The amount of time in milliseconds in which the cursor is visible


Parameters:
time - for the cursor to stay "on"
setCursorBlinkTimeOff
public void setCursorBlinkTimeOff(int time)

The amount of time in milliseconds in which the cursor is invisible


Parameters:
time - for the cursor to stay "off"
getCursorBlinkTimeOn
public int getCursorBlinkTimeOn()

The amount of time in milliseconds in which the cursor is visible


Returns:
time for the cursor to stay "on"
getCursorBlinkTimeOff
public int getCursorBlinkTimeOff()

The amount of time in milliseconds in which the cursor is invisible


Returns:
time for the cursor to stay "off"
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class TextArea
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
isUseSoftkeys
public boolean isUseSoftkeys()

When set to true softkeys are used to enable delete functionality


Returns:

Method Detail

1430

Overview (Codename One API)


true if softkeys should be used
setUseSoftkeys
public void setUseSoftkeys(boolean useSoftkeys)

When set to true softkeys are used to enable delete functionality


Parameters:
useSoftkeys - true if softkeys should be used
setDoneListener
public void setDoneListener(ActionListener l)

Sets a Done listener on the TextField - notice this listener will be called only on
supported platforms that supports done action on the keyboard
Parameters:
l - the listener
getDoneListener
public ActionListener getDoneListener()

Gets the done listener of this TextField.


Returns:
the done listener or null if not exists
fireDoneEvent
public void fireDoneEvent()

Fire the done event to done listener


addDataChangeListener
public void addDataChangeListener(DataChangedListener d)

Adds a listener for data change events it will be invoked for every change made to
the text field, notice most platforms will invoke only the
DataChangedListener.CHANGED event
Parameters:
d - the listener
removeDataChangeListener
public void removeDataChangeListener(DataChangedListener d)

Removes the listener for data change events


Parameters:
d - the listener
fireDataChanged
public void fireDataChanged(int type,
int index)

Alert the TextField listeners the text has been changed on the TextField
Parameters:
type - the event type: Added, Removed or Change
index - cursor location of the event
isReplaceMenu
public boolean isReplaceMenu()

Indicates whether the menu of the form should be replaced with the T9/Clear
commands for the duration of interactivity with the text field
Returns:
true if the menu should be replaced
setReplaceMenu
public void setReplaceMenu(boolean replaceMenu)

Indicates whether the menu of the form should be replaced with the T9/Clear
commands for the duration of interactivity with the text field

Method Detail

1431

Overview (Codename One API)


Parameters:
replaceMenu - true if the menu should be replaced
isReplaceMenuDefault
public static boolean isReplaceMenuDefault()

Indicates whether the menu of the form should be replaced with the T9/Clear
commands for the duration of interactivity with the text field
Returns:
true if the menu should be replaced
setReplaceMenuDefault
public static void setReplaceMenuDefault(boolean replaceMenu)

Indicates whether the menu of the form should be replaced with the T9/Clear
commands for the duration of interactivity with the text field
Parameters:
replaceMenu - true if the menu should be replaced
setQwertyAutoDetect
public static void setQwertyAutoDetect(boolean v)

Indicates whether the text field should try to auto detect qwerty and switch the qwerty
device flag implicitly
Parameters:
v - true for qwerty auto detection
setQwertyDevice
public static void setQwertyDevice(boolean v)

The default value for the qwerty flag so it doesn't need setting for every text field
individually.
Parameters:
v - true for qwerty device
isQwertyAutoDetect
public static boolean isQwertyAutoDetect()

Indicates whether the text field should try to auto detect qwerty and switch the qwerty
device flag implicitly
Returns:
true for qwerty auto detection
isQwertyDevice
public static boolean isQwertyDevice()

The default value for the qwerty flag so it doesn't need setting for every text field
individually.
Returns:
true for qwerty devices
setDefaultChangeInputModeKey
public static void setDefaultChangeInputModeKey(int k)

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Key to change the input mode on the device
Parameters:
k - key to change the input mode
getDefaultChangeInputModeKey
public static int getDefaultChangeInputModeKey()

Deprecated. this is a method for use only on old J2ME devices and is ignored
everywhere else
Key to change the input mode on the device
Returns:

Method Detail

1432

Overview (Codename One API)

key to change the input mode


setDefaultSymbolDialogKey
public static void setDefaultSymbolDialogKey(int d)

The default key for poping open the symbol dialog


Parameters:
d - new key value
getDefaultSymbolDialogKey
public static int getDefaultSymbolDialogKey()

The default key for poping open the symbol dialog


Returns:
the default key
setOverwriteMode
public void setOverwriteMode(boolean overwriteMode)

Indicates that this is the overwrite mode


Parameters:
overwriteMode - set to true if input with overwrite characters
isOverwriteMode
public boolean isOverwriteMode()

Indicates that this is the overwrite mode


Returns:
true if input with overwrite characters
setLeftAndRightEditingTrigger
public void setLeftAndRightEditingTrigger(boolean leftAndRightEditingTrigger)

Indicates whether the left/right keys will trigger editing, this is true by default. Left and
right key edit trigger might be disabled for cases such as text field positioned
horizontally one next to the other.
Parameters:
leftAndRightEditingTrigger - Indicates whether the left/right keys will
trigger editing
isLeftAndRightEditingTrigger
public boolean isLeftAndRightEditingTrigger()

Indicates whether the left/right keys will trigger editing, this is true by default. Left and
right key edit trigger might be disabled for cases such as text field positioned
horizontally one next to the other.
Returns:
leftAndRightEditingTrigger Indicates whether the left/right keys will trigger
editing
setAlignment
public void setAlignment(int align)

Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHT
Overrides:
setAlignment in class TextArea
Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

Method Detail

1433

Overview (Codename One API)


com.codename1.ui

Class TextArea
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.TextArea
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
TextField

public class
extends Component

An optionally multi-line editable region that can display text and allow a user to edit it. By default the
text area will grow based on its content.
TextArea is useful both for text input and for displaying multi-line data, it is used internally by
components such as SpanLabel & SpanButton.
& TextField are very similar, we discuss the main differences between the two here. In fact
they are so similar that our sample code below was written for TextField but should be
interchangeable with TextArea.
TextArea

TableLayout tl;
int spanButton = 2;
if(Display.getInstance().isTablet()) {
tl = new TableLayout(7, 2);
} else {
tl = new TableLayout(14, 1);
spanButton = 1;
}
tl.setGrowHorizontally(true);
hi.setLayout(tl);
TextField
TextField
TextField
TextField
TextField

firstName = new TextField("", "First Name", 20, TextArea.ANY);


surname = new TextField("", "Surname", 20, TextArea.ANY);
email = new TextField("", "E-Mail", 20, TextArea.EMAILADDR);
url = new TextField("", "URL", 20, TextArea.URL);
phone = new TextField("", "Phone", 20, TextArea.PHONENUMBER);

TextField
TextField
TextField
TextField

num1
num2
num3
num4

=
=
=
=

new
new
new
new

TextField("",
TextField("",
TextField("",
TextField("",

"1234",
"1234",
"1234",
"1234",

4,
4,
4,
4,

TextArea.NUMERIC);
TextArea.NUMERIC);
TextArea.NUMERIC);
TextArea.NUMERIC);

Button submit = new Button("Submit");


TableLayout.Constraint cn = tl.createConstraint();
cn.setHorizontalSpan(spanButton);
cn.setHorizontalAlign(Component.RIGHT);
hi.add("First Name").add(firstName).
add("Surname").add(surname).
add("E-Mail").add(email).
add("URL").add(url).
add("Phone").add(phone).
add("Credit Card").
add(GridLayout.encloseIn(4, num1, num2, num3, num4)).
add(cn, submit);

Class TextArea

1434

Overview (Codename One API)

Field Summary
Modifier
and Type

Field and Description


ANY

static int

Allows any type of input into a text field, if a constraint is not supported by an
underlying implementation this will be the default.
DECIMAL

static int

static int

The user is allowed to enter numeric values with optional decimal fractions, for
example "-123", "0.123", or ".5".
EMAILADDR

The user is allowed to enter an e-mail address.


INITIAL_CAPS_SENTENCE

static int

This flag is a hint to the implementation that during text editing, the initial letter
of each sentence should be capitalized.
INITIAL_CAPS_WORD

static int

This flag is a hint to the implementation that during text editing, the initial letter
of each word should be capitalized.
NON_PREDICTIVE

static int

static int

Indicates that the text entered does not consist of words that are likely to be
found in dictionaries typically used by predictive input schemes.
NUMERIC

The user is allowed to enter only an integer value.


PASSWORD

static int

static int

Indicates that the text entered is confidential data that should be obscured
whenever possible.
PHONENUMBER

The user is allowed to enter a phone number.


SENSITIVE

static int

static int

Field Summary

Indicates that the text entered is sensitive data that the implementation must
never store into a dictionary or table for use in predictive, auto-completing, or
other accelerated input schemes.
UNEDITABLE

1435

Overview (Codename One API)


Indicates that editing is currently disallowed.
static int

URL

The user is allowed to enter a URL.

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
TextArea()

Creates an empty text area, this constructor will create a single line text area similar to a text
field!
TextArea(int rows, int columns)

Creates an area with the given rows and columns


TextArea(int rows, int columns, int constraint)

Creates an area with the given rows, columns and constraint


TextArea(String text)

Creates an area with the given text, this constructor will create a single line text area similar
to a text field!
TextArea(String text, int maxSize)

Creates an area with the given text and maximum size, this constructor will create a single
line text area similar to a text field!
TextArea(String text, int rows, int columns)

Creates an area with the given text, rows and columns


TextArea(String text, int rows, int columns, int constraint)

Creates an area with the given text, rows, columns and constraint

Method Summary
Modifier
and Type

Method and Description


addActionListener(ActionListener a)

void

Add an action listener which is invoked when the text area was modified not
during modification.
autoDetectWidestChar(String s)

static void

void
protected
Dimension
protected
Dimension
protected
void

Searches the given string for the widest character using char width, this
operation should only be performed once and it solves cases where a devices
language might have a char bigger than 'W' that isn't consistently bigger.
bindProperty(String prop, BindTarget target)

Binds the given property name to the given bind target


calcPreferredSize()

Calculates the preferred size based on component content.


calcScrollSize()

Method that can be overriden to represent the actual size of the component
when it differs from the desireable size for the viewport
fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly.
getAbsoluteAlignment()

int

Deprecated.
this method is redundant and no longer used

int

getActualRows()

Fields inherited from class com.codename1.ui.Component

1436

Overview (Codename One API)


Returns the number of actual rows in the text area taking into consideration
growsByContent
getAlignment()
int

Deprecated.
use Style.getAlignment instead
getAsInt(int invalid)

int

Convenience method for numeric text fields, returns the value as a number or
invalid if the value in the text field isn't a number
getBindablePropertyNames()

String[]

Class[]
Object
int
int
int
int
int

Returns the names of the properties within this component that can be bound
for persistence, the order of these names mean that the first one will be the
first bound
getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


getColumns()

Returns the number of columns in the text area


getConstraint()

Returns the editing constraint value


getCursorPosition()

Returns the position of the cursor char position


getCursorX()

Returns the position of the cursor char position in the current line.
getCursorY()

Returns the position of the cursor line position


getDefaultValign()

static int

Indicates the default vertical alignment for a text field, only applies to single
line text fields
getGrowLimit()

int

String
Image
Label
String
String[]
int
int
int
int
int

Indicates the maximum number of rows in a text area after it has grown, -1
indicates no limit
getHint()

Returns the hint text


getHintIcon()

Returns the hint icon


getHintLabel()

Returns the hint label component that can be customized directly


getInputMode()

Returns the currently selected input mode


getInputModeOrder()

Returns the order in which input modes are toggled


getLines()

Returns the number of text lines in the TextArea


getLinesToScroll()

Indicates the number of lines to scroll with every scroll operation


getMaxSize()

Returns the maximum size for the text area


getRows()

Returns the number of rows in the text area


getRowsGap()

Gets the num of pixels gap between the rows


getStyle()

Style

String

Method Summary

Returns the current Component Style allowing code to draw the current
component, you should normally use getUnselected/Pressed/DisabledStyle()
and not this method since it will return different values based on component
state.
getText()

Returns the text in the text area

1437

Overview (Codename One API)


String

getTextAt(int line)

Returns the text in the given row of the text box


getUnsupportedChars()

String

Unsupported characters is a string that contains characters that cause issues


when rendering on some problematic fonts.
getVerticalAlignment()

int

Returns the vertical alignment of the text field, this only applies to single line
text field
getWidestChar()

static char

Indicates the widest character in the alphabet, this is useful for detecting
linebreaks internally.

protected
void

initLaf(UIManager uim)

static
boolean
boolean
boolean

This method initializes the Component defaults constants


isAutoDegradeMaxSize()

Indicates whether a high value for default maxSize will be reduced to a lower
value if the underlying platform throws an exception.
isEditable()

Returns true if this area is editable


isEditing()

Indicates whether we are currently editing this text area


isEnableInputScroll()

boolean

boolean
protected
boolean

Indicates whether text field input should scroll to the right side when no more
room for the input is present.
isEndsWith3Points()

Simple getter
isEnterKey(int keyCode)

Indicates the enter key to be used for editing the text area and by the text field
isGrowByContent()

boolean

boolean
boolean
boolean

Indicates that the text area should "grow" in height based on the content
beyond the limits indicate by the rows variable
isPendingCommit()

Returns true if the text field is waiting for a commit on editing


isQwertyInput()

True is this is a qwerty device or a device that is currently in qwerty mode.


isScrollableY()

Indicates whether the component should/could scroll on the Y axis


isSelectableInteraction()

protected
boolean

This method allows a component to indicate that it is interested in an "implicit"


select command to appear in the "fire" button when 3 softbuttons are defined
in a device.
isSingleLineTextArea()

boolean

static
boolean
void
void

Indicates whether this is a single line text area, in which case "growing" won't
work as expected.
isUseStringWidth()

By default text area uses charWidth since its much faster on some devices
than string width.
keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF
perform the rendering.
pointerHover(int[] x, int[] y)

void

Invoked for devices where the pointer can hover without actually clicking the
display.

void

pointerHoverReleased(int[] x, int[] y)

Method Summary

1438

Overview (Codename One API)


Invoked for devices where the pointer can hover without actually clicking the
display.
void

pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
preprocess(String text)

protected
char[]

void

Override this to modify the text for rendering in cases of invalid characters for
display, this method allows the developer to replace such characters e.g.:
replace "\\t" with 4 spaces
removeActionListener(ActionListener a)

Removes an action listener


setAlignment(int align)

void

Deprecated.
use Style.setAlignment instead
setAutoDegradeMaxSize(boolean value)

static void

Indicates whether a high value for default maxSize will be reduced to a lower
value if the underlying platform throws an exception.
setBoundPropertyValue(String prop, Object value)

void

void
void
static void

Sets the value of a bound property within this component, notice that this
method MUST NOT fire the property change event when invoked to prevent
recursion!
setColumns(int columns)

Sets the number of columns in the text area


setConstraint(int constraint)

Sets the constraint


setDefaultMaxSize(int value)

Sets the default limit for the native text box size
setDefaultValign(int aDefaultValign)

static void

void

Indicates the default vertical alignment for a text field, only applies to single
line text fields
setEditable(boolean b)

Sets this text area to be editable or readonly


setEndsWith3Points(boolean endsWith3Points)

void

If the TextArea text is too long to fit the text to the widget add "..." points at the
last displayable row.
setGrowByContent(boolean growByContent)

void

Indicates that the text area should "grow" in height based on the content
beyond the limits indicate by the rows variable
setGrowLimit(int growLimit)

void

Indicates the maximum number of rows in a text area after it has grown, -1
indicates no limit
setHint(String hint)

void

Sets the TextArea hint text, the hint text is displayed on the TextArea When
there is no text in the TextArea
setHint(String hint, Image icon)

void

Sets the TextArea hint text and Icon, the hint text and icon are displayed on
the TextArea when there is no text in the TextArea
setHintIcon(Image icon)

void

void
void
void
void
void

Method Summary

Sets the TextArea hint icon, the hint is displayed on the TextArea When there
is no text in the TextArea
setLinesToScroll(int linesToScroll)

Indicates the number of lines to scroll with every scroll operation


setMaxSize(int maxSize)

Sets the maximum size of the text area


setRows(int rows)

Sets the number of rows in the text area


setRowsGap(int rowsGap)

The gap in pixels between rows


setSingleLineTextArea(boolean singleLineTextArea)

1439

Overview (Codename One API)


Indicates whether this is a single line text area, in which case "growing" won't
work as expected.
setText(String t)

void

Sets the text within this text area


setUnsupportedChars(String unsupportedChars)

Unsupported characters is a string that contains characters that cause issues


when rendering on some problematic fonts.

void

setUseStringWidth(boolean aUseStringWidth)
static void

By default text area uses charWidth since its much faster on some devices
than string width.
setVerticalAlignment(int valign)

Sets the vertical alignment of the text field to one of: CENTER, TOP,
BOTTOM
only applies to single line text field

void

setWidestChar(char widestC)
static void

Indicates the widest character in the alphabet, this is useful for detecting
linebreaks internally.
setWidth(int width)

Sets the Component width, this method is exposed for the purpose of external
layout managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be
used.

void

startEditing()

Launches the text field editing, notice that calling this in a callSerially is
generally considered good practice

void

startEditingAsync()

void

Launches the text field editing in a callserially call


stopEditing()

void

Stops text editing of this field if it is being edited


unbindProperty(String prop, BindTarget target)

void

Removes a bind target from the given property name

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
cancelRepaints, clearClientProperties, contains, createStyleAnimation,
deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished,
draggingOver, dragInitiated, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled,
isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, paramString, pinch,
pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed,
pointerPressed, pointerReleased, putClientProperty, refreshTheme,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,

Methods inherited from class com.codename1.ui.Component

1440

Overview (Codename One API)


removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setX, setY, shouldBlockSideSwipe, styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
ANY
public static final int ANY

Allows any type of input into a text field, if a constraint is not supported by an
underlying implementation this will be the default.
See Also:
Constant Field Values
EMAILADDR
public static final int EMAILADDR

The user is allowed to enter an e-mail address.


See Also:
Constant Field Values
NUMERIC
public static final int NUMERIC

The user is allowed to enter only an integer value.


See Also:
Constant Field Values
PHONENUMBER
public static final int PHONENUMBER

The user is allowed to enter a phone number.


See Also:
Constant Field Values
URL
public static final int URL

The user is allowed to enter a URL.


See Also:
Constant Field Values
DECIMAL
public static final int DECIMAL

The user is allowed to enter numeric values with optional decimal fractions, for
example "-123", "0.123", or ".5".

Methods inherited from class java.lang.Object

1441

Overview (Codename One API)


See Also:
Constant Field Values
PASSWORD
public static final int PASSWORD

Indicates that the text entered is confidential data that should be obscured whenever
possible.
See Also:
Constant Field Values
UNEDITABLE
public static final int UNEDITABLE

Indicates that editing is currently disallowed.


See Also:
Constant Field Values
SENSITIVE
public static final int SENSITIVE

Indicates that the text entered is sensitive data that the implementation must never
store into a dictionary or table for use in predictive, auto-completing, or other
accelerated input schemes.
See Also:
Constant Field Values
NON_PREDICTIVE
public static final int NON_PREDICTIVE

Indicates that the text entered does not consist of words that are likely to be found in
dictionaries typically used by predictive input schemes.
See Also:
Constant Field Values
INITIAL_CAPS_WORD
public static final int INITIAL_CAPS_WORD

This flag is a hint to the implementation that during text editing, the initial letter of
each word should be capitalized.
See Also:
Constant Field Values
INITIAL_CAPS_SENTENCE
public static final int INITIAL_CAPS_SENTENCE

This flag is a hint to the implementation that during text editing, the initial letter of
each sentence should be capitalized.
See Also:
Constant Field Values

Constructor Detail
TextArea
public TextArea(int rows,
int columns)

Creates an area with the given rows and columns


Parameters:
rows - the number of rows
columns - - the number of columns
Throws:
IllegalArgumentException - if rows <= 0 or columns <= 1

Field Detail

1442

Overview (Codename One API)


TextArea
public TextArea(int rows,
int columns,
int constraint)

Creates an area with the given rows, columns and constraint


Parameters:
rows - the number of rows
columns - - the number of columns
constraint - one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL,
DECIMAL it can be bitwised or'd with one of PASSWORD, UNEDITABLE,
SENSITIVE, NON_PREDICTIVE, INITIAL_CAPS_SENTENCE,
INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.
Throws:
IllegalArgumentException - if rows <= 0 or columns <= 1
TextArea
public TextArea(String text,
int rows,
int columns)

Creates an area with the given text, rows and columns


Parameters:
text - the text to be displayed; if text is null, the empty string "" will be
displayed
rows - the number of rows
columns - - the number of columns
Throws:
IllegalArgumentException - if rows <= 0 or columns <= 1
TextArea
public TextArea(String text,
int rows,
int columns,
int constraint)

Creates an area with the given text, rows, columns and constraint
Parameters:
text - the text to be displayed; if text is null, the empty string "" will be
displayed
rows - the number of rows
columns - - the number of columns
constraint - one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL,
DECIMAL it can be bitwised or'd with one of PASSWORD, UNEDITABLE,
SENSITIVE, NON_PREDICTIVE, INITIAL_CAPS_SENTENCE,
INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.
Throws:
IllegalArgumentException - if rows <= 0 or columns <= 1
TextArea
public TextArea(String text,
int maxSize)

Creates an area with the given text and maximum size, this constructor will create a
single line text area similar to a text field!
Parameters:
text - the text to be displayed; if text is null, the empty string "" will be
displayed
maxSize - text area maximum size
TextArea
public TextArea(String text)

Creates an area with the given text, this constructor will create a single line text area
similar to a text field!
Parameters:

Constructor Detail

1443

Overview (Codename One API)


- the text to be displayed; if text is null, the empty string "" will be
displayed
TextArea
text

public TextArea()

Creates an empty text area, this constructor will create a single line text area similar
to a text field!

Method Detail
getDefaultValign
public static int getDefaultValign()

Indicates the default vertical alignment for a text field, only applies to single line text
fields
Returns:
the defaultValign
setDefaultValign
public static void setDefaultValign(int aDefaultValign)

Indicates the default vertical alignment for a text field, only applies to single line text
fields
Parameters:
aDefaultValign - the defaultValign to set
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Component
setConstraint
public void setConstraint(int constraint)

Sets the constraint


Parameters:
- one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL,
DECIMAL it can be bitwised or'd with one of PASSWORD, UNEDITABLE,
SENSITIVE, NON_PREDICTIVE, INITIAL_CAPS_SENTENCE,
INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.
getConstraint
constraint

public int getConstraint()

Returns the editing constraint value


Returns:
the editing constraint value
See Also:
setConstraint(int)

setWidth
public void setWidth(int width)

Sets the Component width, this method is exposed for the purpose of external layout
managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
Overrides:
setWidth in class Component
Parameters:
width - the width of the component
See Also:
Component.setPreferredSize(com.codename1.ui.geom.Dimension)

Constructor Detail

1444

Overview (Codename One API)


setText
public void setText(String t)

Sets the text within this text area


Parameters:
t - new value for the text area
getText
public String getText()

Returns the text in the text area


Returns:
the text in the text area
getAsInt
public int getAsInt(int invalid)

Convenience method for numeric text fields, returns the value as a number or invalid
if the value in the text field isn't a number
Parameters:
invalid - in case the text isn't an integer this number will be returned
Returns:
the int value of the text field
isEditable
public boolean isEditable()

Returns true if this area is editable


Returns:
true if this area is editable
setEditable
public void setEditable(boolean b)

Sets this text area to be editable or readonly


Parameters:
b - true is text are is editable; otherwise false
getMaxSize
public int getMaxSize()

Returns the maximum size for the text area


Returns:
the maximum size for the text area
setMaxSize
public void setMaxSize(int maxSize)

Sets the maximum size of the text area


Parameters:
maxSize - the maximum size of the text area
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this

Method Detail

1445

Overview (Codename One API)


method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component
isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
isScrollableY
public boolean isScrollableY()

Indicates whether the component should/could scroll on the Y axis


Overrides:
isScrollableY in class Component
Returns:
whether the component is scrollable on the X axis
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

Method Detail

1446

Overview (Codename One API)


getColumns
public int getColumns()

Returns the number of columns in the text area


Returns:
the number of columns in the text area
getActualRows
public int getActualRows()

Returns the number of actual rows in the text area taking into consideration
growsByContent
Returns:
the number of rows in the text area
getRows
public int getRows()

Returns the number of rows in the text area


Returns:
the number of rows in the text area
setColumns
public void setColumns(int columns)

Sets the number of columns in the text area


Parameters:
columns - number of columns
setRows
public void setRows(int rows)

Sets the number of rows in the text area


Parameters:
rows - number of rows
getLines
public int getLines()

Returns the number of text lines in the TextArea


Returns:
the number of text lines in the TextArea
getTextAt
public String getTextAt(int line)

Returns the text in the given row of the text box


Parameters:
line - the line number in the text box
Returns:
the text of the line
preprocess
protected char[] preprocess(String text)

Override this to modify the text for rendering in cases of invalid characters for display,
this method allows the developer to replace such characters e.g.: replace "\\t" with 4
spaces
Parameters:
text - the text to process
Returns:
the given string as a processed char array ready for rendering

Method Detail

1447

Overview (Codename One API)


getRowsGap
public int getRowsGap()

Gets the num of pixels gap between the rows


Returns:
the gap between rows in pixels
setRowsGap
public void setRowsGap(int rowsGap)

The gap in pixels between rows


Parameters:
rowsGap - num of pixels to gap between rows
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content
calcScrollSize
protected Dimension calcScrollSize()

Method that can be overriden to represent the actual size of the component when it
differs from the desireable size for the viewport
Overrides:
calcScrollSize in class Component
Returns:
scroll size, by default this is the same as the preferred size
addActionListener
public void addActionListener(ActionListener a)

Add an action listener which is invoked when the text area was modified not during
modification. A text field might never fire an action event if it is edited in place and
the user never leaves the text field!
Parameters:
a - actionListener
removeActionListener
public void removeActionListener(ActionListener a)

Removes an action listener


Parameters:
a - actionListener

Method Detail

1448

Overview (Codename One API)


setDefaultMaxSize
public static void setDefaultMaxSize(int value)

Sets the default limit for the native text box size
Parameters:
value - default value for the size of the native text box
isGrowByContent
public boolean isGrowByContent()

Indicates that the text area should "grow" in height based on the content beyond the
limits indicate by the rows variable
Returns:
true if the text component should grow and false otherwise
setGrowByContent
public void setGrowByContent(boolean growByContent)

Indicates that the text area should "grow" in height based on the content beyond the
limits indicate by the rows variable
Parameters:
growByContent - true if the text component should grow and false otherwise
setAutoDegradeMaxSize
public static void setAutoDegradeMaxSize(boolean value)

Indicates whether a high value for default maxSize will be reduced to a lower value if
the underlying platform throws an exception.
Parameters:
value - new value for autoDegradeMaxSize
isAutoDegradeMaxSize
public static boolean isAutoDegradeMaxSize()

Indicates whether a high value for default maxSize will be reduced to a lower value if
the underlying platform throws an exception.
Returns:
value for autoDegradeMaxSize
getUnsupportedChars
public String getUnsupportedChars()

Unsupported characters is a string that contains characters that cause issues when
rendering on some problematic fonts. The rendering engine can thus remove them
when drawing.
Returns:
unsupported characters string
setUnsupportedChars
public void setUnsupportedChars(String unsupportedChars)

Unsupported characters is a string that contains characters that cause issues when
rendering on some problematic fonts. The rendering engine can thus remove them
when drawing.
Parameters:
unsupportedChars - the unsupported character string
getLinesToScroll
public int getLinesToScroll()

Indicates the number of lines to scroll with every scroll operation


Returns:
number bigger or equal to 1

Method Detail

1449

Overview (Codename One API)


setLinesToScroll
public void setLinesToScroll(int linesToScroll)

Indicates the number of lines to scroll with every scroll operation


Parameters:
linesToScroll - number bigger or equal to 1
setWidestChar
public static void setWidestChar(char widestC)

Indicates the widest character in the alphabet, this is useful for detecting linebreaks
internally. In CJK languages the widest char is different than W hence this
functionality is exposed to developers.
Parameters:
widestC - the widest character
getWidestChar
public static char getWidestChar()

Indicates the widest character in the alphabet, this is useful for detecting linebreaks
internally. In CJK languages the widest char is different than W hence this
functionality is exposed to developers.
Returns:
the widest character
setSingleLineTextArea
public void setSingleLineTextArea(boolean singleLineTextArea)

Indicates whether this is a single line text area, in which case "growing" won't work as
expected.
Parameters:
singleLineTextArea - set to true to force a single line text
isSingleLineTextArea
public boolean isSingleLineTextArea()

Indicates whether this is a single line text area, in which case "growing" won't work as
expected.
Returns:
true if this is a single line text area
setAlignment
public void setAlignment(int align)

Deprecated. use Style.setAlignment instead


Sets the Alignment of the TextArea to one of: CENTER, LEFT, RIGHT
Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
getAlignment
public int getAlignment()

Deprecated. use Style.getAlignment instead


Returns the alignment of the TextArea
Returns:
the alignment of the TextArea one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
getAbsoluteAlignment
public int getAbsoluteAlignment()

Deprecated. this method is redundant and no longer used

Method Detail

1450

Overview (Codename One API)


Returns the absolute alignment of the TextArea In RTL LEFT alignment is actually
RIGHT, but this method returns the actual alignment
Returns:
the alignment of the TextArea one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
isPendingCommit
public boolean isPendingCommit()

Returns true if the text field is waiting for a commit on editing


Returns:
true if a commit is pending
getCursorPosition
public int getCursorPosition()

Returns the position of the cursor char position


Returns:
the cursor position
getCursorY
public int getCursorY()

Returns the position of the cursor line position


Returns:
the cursor line position
getCursorX
public int getCursorX()

Returns the position of the cursor char position in the current line.
Returns:
the cursor char position in the current line
isQwertyInput
public boolean isQwertyInput()

True is this is a qwerty device or a device that is currently in qwerty mode.


Returns:
currently defaults to false
getInputMode
public String getInputMode()

Returns the currently selected input mode


Returns:
the display name of the input mode by default the following modes are
supported: Abc, ABC, abc, 123
getInputModeOrder
public String[] getInputModeOrder()

Returns the order in which input modes are toggled


Returns:
the order of the input modes
isEnableInputScroll
public boolean isEnableInputScroll()

Indicates whether text field input should scroll to the right side when no more room for
the input is present.
Returns:
true if scrolling is enabled

Method Detail

1451

Overview (Codename One API)


isEnterKey
protected boolean isEnterKey(int keyCode)

Indicates the enter key to be used for editing the text area and by the text field
Parameters:
keyCode - the key tested
autoDetectWidestChar
public static void autoDetectWidestChar(String s)

Searches the given string for the widest character using char width, this operation
should only be performed once and it solves cases where a devices language might
have a char bigger than 'W' that isn't consistently bigger. Notice that this method will
use the TextArea style font which might differ when switching themes etc.
Parameters:
s - string to search using charWidth
isUseStringWidth
public static boolean isUseStringWidth()

By default text area uses charWidth since its much faster on some devices than
string width. However, with some fonts and especially some languages (such as
Arabic, Korean etc.) the width of the string drawn might not equal the summary of the
width of the chars. Hence for portability to those languages/fonts this flag must be set
to true.
Returns:
the value of useStringWidth
setUseStringWidth
public static void setUseStringWidth(boolean aUseStringWidth)

By default text area uses charWidth since its much faster on some devices than
string width. However, with some fonts and especially some languages (such as
Arabic, Korean etc.) the width of the string drawn might not equal the summary of the
width of the chars. Hence for portability to those languages/fonts this flag must be set
to true.
Parameters:
aUseStringWidth - the new value for useStringWidth
setHint
public void setHint(String hint)

Sets the TextArea hint text, the hint text is displayed on the TextArea When there is
no text in the TextArea
Parameters:
hint - the hint text to display
getHint
public String getHint()

Returns the hint text


Returns:
the hint text or null
setHintIcon
public void setHintIcon(Image icon)

Sets the TextArea hint icon, the hint is displayed on the TextArea When there is no
text in the TextArea
Parameters:
icon - the icon
getHintIcon
public Image getHintIcon()

Returns the hint icon

Method Detail

1452

Overview (Codename One API)


Returns:
the hint icon
setHint
public void setHint(String hint,
Image icon)

Sets the TextArea hint text and Icon, the hint text and icon are displayed on the
TextArea when there is no text in the TextArea
Parameters:
hint - the hint text to display
icon - the hint icon to display
getHintLabel
public Label getHintLabel()

Returns the hint label component that can be customized directly


Returns:
hint label component
setVerticalAlignment
public void setVerticalAlignment(int valign)

Sets the vertical alignment of the text field to one of: CENTER, TOP, BOTTOM
only applies to single line text field
Parameters:
valign - alignment value
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM
getVerticalAlignment
public int getVerticalAlignment()

Returns the vertical alignment of the text field, this only applies to single line text field
Returns:
the vertical alignment of the TextField one of: CENTER, TOP, BOTTOM
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM
getBindablePropertyNames
public String[] getBindablePropertyNames()

Returns the names of the properties within this component that can be bound for
persistence, the order of these names mean that the first one will be the first bound
Overrides:
getBindablePropertyNames in class Component
Returns:
a string array of property names or null
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
Overrides:
getBindablePropertyTypes in class Component
Returns:
the class for binding
bindProperty
public void bindProperty(String prop,
BindTarget target)

Binds the given property name to the given bind target


Overrides:
bindProperty in class Component
Parameters:
prop - the property name

Method Detail

1453

Overview (Codename One API)


target - the target binder
unbindProperty
public void unbindProperty(String prop,
BindTarget target)

Removes a bind target from the given property name


Overrides:
unbindProperty in class Component
Parameters:
prop - the property names
target - the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


Overrides:
getBoundPropertyValue in class Component
Parameters:
prop - the property
Returns:
the value for the property
setBoundPropertyValue
public void setBoundPropertyValue(String prop,
Object value)

Sets the value of a bound property within this component, notice that this method
MUST NOT fire the property change event when invoked to prevent recursion!
Overrides:
setBoundPropertyValue in class Component
Parameters:
prop - the property whose value should be set
value - the value
getGrowLimit
public int getGrowLimit()

Indicates the maximum number of rows in a text area after it has grown, -1 indicates
no limit
Returns:
the growLimit
setGrowLimit
public void setGrowLimit(int growLimit)

Indicates the maximum number of rows in a text area after it has grown, -1 indicates
no limit
Parameters:
growLimit - the growLimit to set
setEndsWith3Points
public void setEndsWith3Points(boolean endsWith3Points)

If the TextArea text is too long to fit the text to the widget add "..." points at the last
displayable row. By default this is set to false
Parameters:
endsWith3Points - true if text should add "..." at the end
isEndsWith3Points
public boolean isEndsWith3Points()

Simple getter
Returns:
true if this TextArea adds "..." when the text is too long

Method Detail

1454

Overview (Codename One API)


startEditing
public void startEditing()

Launches the text field editing, notice that calling this in a callSerially is generally
considered good practice
startEditingAsync
public void startEditingAsync()

Launches the text field editing in a callserially call


isEditing
public boolean isEditing()

Indicates whether we are currently editing this text area


Returns:
true if Display.getInstance().isTextEditing(this)
stopEditing
public void stopEditing()

Stops text editing of this field if it is being edited


getStyle
public Style getStyle()

Returns the current Component Style allowing code to draw the current component,
you should normally use getUnselected/Pressed/DisabledStyle() and not this method
since it will return different values based on component state. We override get style
here to return the selected style when editing
Overrides:
getStyle in class Component
Returns:
the selected style if editing, super.getStyle() otherwise

Method Detail

1455

Overview (Codename One API)


com.codename1.ui

Class Tabs
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Tabs
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A component that lets the user switch between a group of components by clicking on a tab with a
given title and/or icon.
Tabs/components are added to a Tabs object by using the addTab and insertTab methods. A tab is
represented by an index corresponding to the position it was added in, where the first tab has an
index equal to 0 and the last tab has an index equal to the tab count minus 1.
The Tabs uses a SingleSelectionModel to represent the set of tab indices and the currently selected
index. If the tab count is greater than 0, then there will always be a selected index, which by default
will be initialized to the first tab. If the tab count is 0, then the selected index will be -1.
A simple Tabs sample looks a bit like this:
Form hi = new Form("Tabs", new BorderLayout());
Tabs t = new Tabs();
Style s = UIManager.getInstance().getComponentStyle("Tab");
FontImage icon1 = FontImage.createMaterial(FontImage.MATERIAL_QUESTION_ANSWER, s);
Container container1 = BoxLayout.encloseY(new Label("Label1"), new Label("Label2"));
t.addTab("Tab1", icon1, container1);
t.addTab("Tab2", new SpanLabel("Some text directly in the tab"));
hi.add(BorderLayout.CENTER, t);

Class Tabs

1456

Overview (Codename One API)


A common use case for Tabs is the iOS carousel UI where dots are drawn at the bottom of the form
and swiping is used to move between pages:
Form hi = new Form("Swipe Tabs", new LayeredLayout());
Tabs t = new Tabs();
t.hideTabs();

Style s = UIManager.getInstance().getComponentStyle("Button");
FontImage radioEmptyImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, s);
FontImage radioFullImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, s);
((DefaultLookAndFeel)UIManager.getInstance().getLookAndFeel()).setRadioButtonImages(radioFullImage, radioEmptyImage, r
Container container1 = BoxLayout.encloseY(new Label("Swipe the tab to see more"),
new Label("You can put anything here"));
t.addTab("Tab1", container1);
t.addTab("Tab2", new SpanLabel("Some text directly in the tab"));
RadioButton firstTab = new RadioButton("");
RadioButton secondTab = new RadioButton("");
firstTab.setUIID("Container");
secondTab.setUIID("Container");
new ButtonGroup(firstTab, secondTab);
firstTab.setSelected(true);
Container tabsFlow = FlowLayout.encloseCenter(firstTab, secondTab);
hi.add(t);
hi.add(BorderLayout.south(tabsFlow));
t.addSelectionListener((i1, i2) -> {
switch(i2) {
case 0:
if(!firstTab.isSelected()) {
firstTab.setSelected(true);
}
break;
case 1:
if(!secondTab.isSelected()) {
secondTab.setSelected(true);
}
break;
}
});

Field Summary

Field Summary

1457

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.Component

BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,


BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Tabs()

Creates an empty TabbedPane with a default tab placement of Component.TOP.


Tabs(int tabP)

Creates an empty TabbedPane with the specified tab placement of either: Component.TOP,
Component.BOTTOM, Component.LEFT, or Component.RIGHT.

Method Summary
Modifier
and Type
void

Method and Description


addSelectionListener(SelectionListener listener)

Adds a selection listener to the tabs.


addTab(Button tab, Component component)

void

Deprecated.
should use radio button as an argument

void

addTab(String title, Component component)


Adds a component represented by a title and no icon.

void

addTab(String title, Image icon, Component component)


Adds a component represented by a title and/or icon, either

of which can be null.

addTabsFocusListener(FocusListener listener)
void

boolean

Deprecated.
use addSelectionListener instead
animate()

Allows the animation to reduce "repaint" calls when it returns false.

protected
void

bindTabActionListener(Component tab, ActionListener l)

protected
Component

createTab(String title, Image icon)

protected
Motion

createTabSlideMotion(int start, int end)

protected
void
Container

Binds an action listener to the tab component.

Creates a tab component by default this is a RadioButton but subclasses can use this to r

Allows developers to customize the motion object for the slide effect to provide a linear sl
deinitialize()

Invoked to indicate that the component initialization is being reversed since the componen
the container hierarchy.
getContentPane()

This method retrieves the Tabs content pane


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this A
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
Component

This method is here to workaround an XMLVM array type bug where property types aren'
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListM
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder
getSelectedComponent()

Fields inherited from class com.codename1.ui.Component

1458

Overview (Codename One API)


Returns the component associated with the tab at the given index
int
Component
int
protected
Image
Image
int
Container
protected
Image
Image
int
protected
String
String
String
void
int

getSelectedIndex()

Returns the currently selected index for this tabbedpane.


getTabComponentAt(int index)
Returns the tab at index.
getTabCount()

Returns the number of tabs in this tabbedpane.


getTabIcon(Component tab)

Returns the icon of the tab component.


getTabIcon(int index)

Returns the icon of the tab at the given index


getTabPlacement()

Returns the placement of the tabs for this tabbedpane.


getTabsContainer()

This method retrieves the Tabs buttons Container


getTabSelectedIcon(Component tab)

Returns the selected icon of the tab component.


getTabSelectedIcon(int index)

Returns the icon of the tab at the given index


getTabTextPosition()

Returns The position of the text relative to the icon


getTabTitle(Component tab)

Returns the title of the tab component.


getTabTitle(int index)

Returns the title of the tab at the given index


getTabUIID()

The UIID for a tab component which defaults to Tab


hideTabs()

Hide the tabs bar


indexOfComponent(Component component)

Returns the index of the tab for the specified component.

protected
void

initComponent()

protected
void

initLaf(UIManager manager)

Allows subclasses to bind functionality that relies on fully initialized and "ready for action"
This method initializes the Component defaults constants
insertTab(Component tab, Component component, int index)

void

void

Deprecated.
should use radio button as an argument
insertTab(String title, Image icon, Component component, int index)
Inserts a component, at index, represented by a title and/or icon, either of which

may be

isAnimateTabSelection()
boolean

Indicates whether clicking on a tab button should result in an animation to the selected ta
switch
isChangeTabContainerStyleOnFocus()

boolean

boolean

Indicates that the tabs container should have its style changed to the selected style when
focus this allows incorporating it into the theme of the application
isChangeTabOnFocus()

Indicates that a tab should change when the focus changes without the user physically pr
isEagerSwipeMode()

boolean

boolean

Allows marking tabs as swipe "eager" which instantly triggers swipe on movement rather
swipe.
isSwipeActivated()

Returns true if the swipe between tabs is activated, this is relevant for touch devices only
refreshTheme(boolean merge)

void

void

Method Summary

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS ME
CHANGED THE THEME!
removeSelectionListener(SelectionListener listener)

Removes a selection Listener from the tabs

1459

Overview (Codename One API)


removeTabAt(int index)
Removes the tab at index.

void

removeTabsFocusListener(FocusListener listener)
void

Deprecated.
use addSelectionListener instead

protected
void

selectTab(Component tab)

Invoked to select a specific tab, this method should be overriden for subclasses overriding
setAnimateTabSelection(boolean animateTabSelection)

Indicates whether clicking on a tab button should result in an animation to the selected ta
switch

void

setChangeTabContainerStyleOnFocus(boolean changeTabContainerStyleOnFocus)

Indicates that the tabs container should have its style changed to the selected style when
focus this allows incorporating it into the theme of the application

void

setChangeTabOnFocus(boolean changeTabOnFocus)

void

Indicates that a tab should change when the focus changes without the user physically pr
setEagerSwipeMode(boolean eagerSwipeMode)

Allows marking tabs as swipe "eager" which instantly triggers swipe on movement rather
swipe.

void

setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and null if succe
setSelectedIndex(int index)

void

Sets the selected index for this tabbedpane.


setSelectedIndex(int index, boolean slideToSelected)

void

Sets the currently selected index in the tabs component


setSwipeActivated(boolean swipeActivated)

void

Setter method for swipe mode


setTabPlacement(int tabPlacement)

void

Sets the tab placement for this tabbedpane.


setTabsContentGap(int tabsGap)

void

This method allows setting the Tabs content pane spacing (right and left), This can be us
where the selected tab is smaller and the right and left tabs are visible on the sides

protected
void

setTabSelectedIcon(Component tab, Image icon)

Sets the selected icon of the tab.


setTabSelectedIcon(int index, Image icon)

void

Sets the selected icon of the tab at the given index


setTabTextPosition(int textPosition)

void

Sets the position of the text relative to the icon if exists

protected
void

setTabTitle(Component tab, String title, Image icon)

Updates the tabs title .


setTabTitle(String title, Image icon, int index)

void

Updates the information about the tab details


setTabUIID(String tabUIID)

void

The UIID for a tab button which defaults to Tab.

protected
void

setTextPosition(Component tabComponent, int textPosition)

Invokes set text position on the given tab, the tab should be a toggle button radio by defa
showTabs()

void

Show the tabs bar if it was hidden

String

toString()

Overriden to return a useful value for debugging purposes

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,

Methods inherited from class com.codename1.ui.Container

1460

Overview (Codename One API)


getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, removeAll,
removeComponent, replace, replace, replaceAndWait, replaceAndWait,
replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer,
setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX,
setScrollableY, setScrollIncrement, setShouldCalcPreferredSize,
setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

Methods inherited from class com.codename1.ui.Component

1461

Overview (Codename One API)


Tabs
public Tabs()

Creates an empty TabbedPane with a default tab placement of Component.TOP.


Tabs
public Tabs(int tabP)

Creates an empty TabbedPane with the specified tab placement of either:


Component.TOP, Component.BOTTOM, Component.LEFT, or Component.RIGHT.
Parameters:
tabP - the placement for the tabs relative to the content

Method Detail
initLaf
protected void initLaf(UIManager manager)

This method initializes the Component defaults constants


Overrides:
initLaf in class Container
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Container
Parameters:
merge - indicates if the current styles should be merged with the new styles
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

Constructor Detail

1462

Overview (Codename One API)


setTabTextPosition
public void setTabTextPosition(int textPosition)

Sets the position of the text relative to the icon if exists


Parameters:
textPosition - alignment value (LEFT, RIGHT, BOTTOM or TOP)
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP
setTextPosition
protected void setTextPosition(Component tabComponent,
int textPosition)

Invokes set text position on the given tab, the tab should be a toggle button radio by
default but can be anything
Parameters:
tabComponent - the component representing the tab
textPosition - the text position
getTabTextPosition
public int getTabTextPosition()

Returns The position of the text relative to the icon


Returns:
The position of the text relative to the icon, one of: LEFT, RIGHT, BOTTOM,
TOP
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP
setTabPlacement
public void setTabPlacement(int tabPlacement)

Sets the tab placement for this tabbedpane. Possible values are:
Component.TOP
Component.BOTTOM
Component.LEFT
Component.RIGHT
The default value, if not set, is Component.TOP.
Parameters:
tabPlacement - the placement for the tabs relative to the content
addTab
public void addTab(String title,
Image icon,
Component component)

Adds a component represented by a title and/or icon, either of which can be null.
Cover method for insertTab.
Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
component - the component to be displayed when this tab is clicked
See Also:
insertTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component, int), removeTabAt(int)

addTab
public void addTab(String title,
Component component)

Adds a component represented by a title and no icon. Cover method for insertTab.
Parameters:
title - the title to be displayed in this tab
component - the component to be displayed when this tab is clicked
See Also:

Method Detail

1463

Overview (Codename One API)


insertTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component, int), removeTabAt(int)

addTab
public void addTab(Button tab,
Component component)

Deprecated. should use radio button as an argument


Adds a component represented by a button. Cover method for insertTab. The Button
styling will be associated with "Tab" UIID.
Parameters:
tab - represents the tab on top
component - the component to be displayed when this tab is clicked
See Also:
insertTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component, int), removeTabAt(int)

createTab
protected Component createTab(String title,
Image icon)

Creates a tab component by default this is a RadioButton but subclasses can use this
to return anything
Parameters:
title - the title of the tab
icon - the icon of the tab
Returns:
component instance
insertTab
public void insertTab(String title,
Image icon,
Component component,
int index)

Inserts a component, at index, represented by a title and/or icon, either of which


may be null. Uses java.util.Vector internally, see insertElementAt for details of
insertion conventions.
Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
component - The component to be displayed when this tab is clicked.
index - the position to insert this new tab
See Also:
addTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component), removeTabAt(int)

insertTab
public void insertTab(Component tab,
Component component,
int index)

Deprecated. should use radio button as an argument


Inserts a component, at index, represented by a button Uses java.util.Vector
internally, see insertElementAt for details of insertion conventions. The Button
styling will be associated with "Tab" UIID.
Parameters:
tab - represents the tab on top
component - The component to be displayed when this tab is clicked.
index - the position to insert this new tab
See Also:
addTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component), removeTabAt(int)

bindTabActionListener
protected void bindTabActionListener(Component tab,
ActionListener l)

Method Detail

1464

Overview (Codename One API)


Binds an action listener to the tab component. this method should be used when
overriding createTab
Parameters:
tab - the tab component
l - the listener
setTabTitle
public void setTabTitle(String title,
Image icon,
int index)

Updates the information about the tab details


Parameters:
title - the title to be displayed in this tab
icon - the icon to be displayed in this tab
index - the position to insert this new tab
setTabTitle
protected void setTabTitle(Component tab,
String title,
Image icon)

Updates the tabs title . This method should be used when overriding createTab
Parameters:
tab - the tab component
title - the title
icon - the new icon
getTabTitle
public String getTabTitle(int index)

Returns the title of the tab at the given index


Parameters:
index - index for the tab
Returns:
label of the tab at the given index
getTabTitle
protected String getTabTitle(Component tab)

Returns the title of the tab component. This method should be used when overriding
createTab
Parameters:
tab - the tab component
Returns:
label of the tab
getTabIcon
protected Image getTabIcon(Component tab)

Returns the icon of the tab component. This method should be used when overriding
createTab
Parameters:
tab - the tab component
Returns:
icon of the tab
getTabIcon
public Image getTabIcon(int index)

Returns the icon of the tab at the given index


Parameters:
index - index for the tab
Returns:
icon of the tab at the given index

Method Detail

1465

Overview (Codename One API)


getTabSelectedIcon
protected Image getTabSelectedIcon(Component tab)

Returns the selected icon of the tab component. This method should be used when
overriding createTab
Parameters:
tab - the tab component
Returns:
icon of the tab
getTabSelectedIcon
public Image getTabSelectedIcon(int index)

Returns the icon of the tab at the given index


Parameters:
index - index for the tab
Returns:
icon of the tab at the given index
setTabSelectedIcon
public void setTabSelectedIcon(int index,
Image icon)

Sets the selected icon of the tab at the given index


Parameters:
index - index for the tab
icon - of the tab at the given index
setTabSelectedIcon
protected void setTabSelectedIcon(Component tab,
Image icon)

Sets the selected icon of the tab. This method should be used when overriding
createTab
Parameters:
tab - the tab component
icon - of the tab
removeTabAt
public void removeTabAt(int index)

Removes the tab at index. After the component associated with index is removed, its
visibility is reset to true to ensure it will be visible if added to other containers.
Parameters:
index - the index of the tab to be removed
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >=
tab count)
See Also:
addTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component), insertTab(java.lang.String,
com.codename1.ui.Image, com.codename1.ui.Component, int)

getTabComponentAt
public Component getTabComponentAt(int index)

Returns the tab at index.


Parameters:
index - the index of the tab to be removed
Returns:
the component at the given tab location
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >=
tab count)
See Also:

Method Detail

1466

Overview (Codename One API)


addTab(java.lang.String, com.codename1.ui.Image,
com.codename1.ui.Component), insertTab(java.lang.String,
com.codename1.ui.Image, com.codename1.ui.Component, int)

indexOfComponent
public int indexOfComponent(Component component)

Returns the index of the tab for the specified component. Returns -1 if there is no tab
for this component.
Parameters:
component - the component for the tab
Returns:
the first tab which matches this component, or -1 if there is no tab for this
component
getTabCount
public int getTabCount()

Returns the number of tabs in this tabbedpane.


Returns:
an integer specifying the number of tabbed pages
getSelectedIndex
public int getSelectedIndex()

Returns the currently selected index for this tabbedpane. Returns -1 if there is no
currently selected tab.
Returns:
the index of the selected tab
getSelectedComponent
public Component getSelectedComponent()

Returns the component associated with the tab at the given index
Returns:
the component is now showing in the tabbed pane
addTabsFocusListener
public void addTabsFocusListener(FocusListener listener)

Deprecated. use addSelectionListener instead


Adds a focus listener to the tabs buttons
Parameters:
listener - FocusListener
removeTabsFocusListener
public void removeTabsFocusListener(FocusListener listener)

Deprecated. use addSelectionListener instead


Removes a foucs Listener from the tabs buttons
Parameters:
listener - FocusListener
addSelectionListener
public void addSelectionListener(SelectionListener listener)

Adds a selection listener to the tabs.


Parameters:
listener - SelectionListener
removeSelectionListener
public void removeSelectionListener(SelectionListener listener)

Removes a selection Listener from the tabs


Parameters:
listener - SelectionListener

Method Detail

1467

Overview (Codename One API)


toString
public String toString()

Overriden to return a useful value for debugging purposes


Overrides:
toString in class Component
Returns:
a string representation of this component
getTabPlacement
public int getTabPlacement()

Returns the placement of the tabs for this tabbedpane.


Returns:
the tab placement value
See Also:
setTabPlacement(int)

getContentPane
public Container getContentPane()

This method retrieves the Tabs content pane


Returns:
the content pane Container
getTabsContainer
public Container getTabsContainer()

This method retrieves the Tabs buttons Container


Returns:
the Tabs Container
setSelectedIndex
public void setSelectedIndex(int index,
boolean slideToSelected)

Sets the currently selected index in the tabs component


Parameters:
index - the index for the tab starting with tab 0.
slideToSelected - true to animate the transition to the new selection false to
just move immediately
selectTab
protected void selectTab(Component tab)

Invoked to select a specific tab, this method should be overriden for subclasses
overriding createTab
Parameters:
tab - the tab
setSelectedIndex
public void setSelectedIndex(int index)

Sets the selected index for this tabbedpane. The index must be a valid tab index.
Parameters:
index - the index to be selected
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >=
tab count)
hideTabs
public void hideTabs()

Hide the tabs bar

Method Detail

1468

Overview (Codename One API)


showTabs
public void showTabs()

Show the tabs bar if it was hidden


isSwipeActivated
public boolean isSwipeActivated()

Returns true if the swipe between tabs is activated, this is relevant for touch devices
only
Returns:
swipe activated flag
setSwipeActivated
public void setSwipeActivated(boolean swipeActivated)

Setter method for swipe mode


Parameters:
swipeActivated isChangeTabOnFocus
public boolean isChangeTabOnFocus()

Indicates that a tab should change when the focus changes without the user
physically pressing a button
Returns:
the changeTabOnFocus
setChangeTabOnFocus
public void setChangeTabOnFocus(boolean changeTabOnFocus)

Indicates that a tab should change when the focus changes without the user
physically pressing a button
Parameters:
changeTabOnFocus - the changeTabOnFocus to set
isChangeTabContainerStyleOnFocus
public boolean isChangeTabContainerStyleOnFocus()

Indicates that the tabs container should have its style changed to the selected style
when one of the tabs has focus this allows incorporating it into the theme of the
application
Returns:
the changeTabContainerStyleOnFocus
setChangeTabContainerStyleOnFocus

public void setChangeTabContainerStyleOnFocus(boolean changeTabContainerStyleOnFocus

Indicates that the tabs container should have its style changed to the selected style
when one of the tabs has focus this allows incorporating it into the theme of the
application
Parameters:
changeTabContainerStyleOnFocus - the changeTabContainerStyleOnFocus to
set
setTabsContentGap
public void setTabsContentGap(int tabsGap)

This method allows setting the Tabs content pane spacing (right and left), This can
be used to create an effect where the selected tab is smaller and the right and left
tabs are visible on the sides
Parameters:
tabsGap - the gap on the sides of the content in pixels, the value must be
positive.

Method Detail

1469

Overview (Codename One API)


getTabUIID
public String getTabUIID()

The UIID for a tab component which defaults to Tab


Returns:
the tabUIID
setTabUIID
public void setTabUIID(String tabUIID)

The UIID for a tab button which defaults to Tab. Tab buttons used to have two
separate styles for selected and unselected. This was later consolidated so the tabs
behave as a single toggle button (radio button) however one thing that remained is a
call to setUIID that is implicitly made to restore the original "Tab" style.
Effectively Tabs invokes the setUIID call on the Tab switch so if you want to
manipulate the tab UIID manually (have one red and one green tab) this is a
problem..
To enable such code add all the tabs then just just invoke setTabUIID(null) to
disable this behavior.
Parameters:
tabUIID - the tabUIID to set
isEagerSwipeMode
public boolean isEagerSwipeMode()

Allows marking tabs as swipe "eager" which instantly triggers swipe on movement
rather than threshold the swipe.
Returns:
the eagerSwipeMode
setEagerSwipeMode
public void setEagerSwipeMode(boolean eagerSwipeMode)

Allows marking tabs as swipe "eager" which instantly triggers swipe on movement
rather than threshold the swipe.
Parameters:
eagerSwipeMode - the eagerSwipeMode to set
isAnimateTabSelection
public boolean isAnimateTabSelection()

Indicates whether clicking on a tab button should result in an animation to the


selected tab or an immediate switch
Returns:
the animateTabSelection
setAnimateTabSelection
public void setAnimateTabSelection(boolean animateTabSelection)

Indicates whether clicking on a tab button should result in an animation to the


selected tab or an immediate switch
Parameters:
animateTabSelection - the animateTabSelection to set
createTabSlideMotion
protected Motion createTabSlideMotion(int start,
int end)

Allows developers to customize the motion object for the slide effect to provide a
linear slide effect.
Parameters:
start - start position
end - end position for the motion

Method Detail

1470

Overview (Codename One API)


Returns:
the motion object
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

1471

Overview (Codename One API)


com.codename1.ui

Class SwipeableContainer
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.SwipeableContainer
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

allows us to side swipe a component and expose underlying configuration within


it. This is useful for editing, ranking of elements within a set of components e.g. in the sample code
below we use a ranking widget and swiping to expose the elements:
SwipeableContainer

private void showUI() {


Form hi = new Form("Swipe", new BoxLayout(BoxLayout.Y_AXIS));
hi.add(createRankWidget("A Game of Thrones", "1996")).
add(createRankWidget("A Clash Of Kings", "1998")).
add(createRankWidget("A Storm Of Swords", "2000")).
add(createRankWidget("A Feast For Crows", "2005")).
add(createRankWidget("A Dance With Dragons", "2011")).
add(createRankWidget("The Winds of Winter", "TBD")).
add(createRankWidget("A Dream of Spring", "TBD"));
hi.show();
}
public SwipeableContainer createRankWidget(String title, String year) {
MultiButton button = new MultiButton(title);
button.setTextLine2(year);
return new SwipeableContainer(FlowLayout.encloseCenterMiddle(createStarRankSlider()),
button);
}

private void initStarRankStyle(Style s, Image star) {


s.setBackgroundType(Style.BACKGROUND_IMAGE_TILE_BOTH);
s.setBorder(Border.createEmpty());
s.setBgImage(star);
s.setBgTransparency(0);
}
private Slider createStarRankSlider() {
Slider starRank = new Slider();
starRank.setEditable(true);
starRank.setMinValue(0);
starRank.setMaxValue(10);
Font fnt = Font.createTrueTypeFont("native:MainLight", "native:MainLight").
derive(Display.getInstance().convertToPixels(5, true), Font.STYLE_PLAIN);
Style s = new Style(0xffff33, 0, fnt, (byte)0);
Image fullStar = FontImage.createMaterial(FontImage.MATERIAL_STAR, s).toImage();
s.setOpacity(100);
s.setFgColor(0);
Image emptyStar = FontImage.createMaterial(FontImage.MATERIAL_STAR, s).toImage();
initStarRankStyle(starRank.getSliderEmptySelectedStyle(), emptyStar);
initStarRankStyle(starRank.getSliderEmptyUnselectedStyle(), emptyStar);
initStarRankStyle(starRank.getSliderFullSelectedStyle(), fullStar);
initStarRankStyle(starRank.getSliderFullUnselectedStyle(), fullStar);
starRank.setPreferredSize(new Dimension(fullStar.getWidth() * 5, fullStar.getHeight()));
return starRank;
}

Class SwipeableContainer

1472

Overview (Codename One API)


Field

Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
SwipeableContainer(Component bottomLeft, Component top)

Simple Constructor
SwipeableContainer(Component bottomLeft, Component bottomRight, Component top)

Simple Constructor

Method Summary
Modifier and
Type

Method and Description


addSwipeOpenListener(ActionListener l)

void

boolean
void
protected
void

Adds a listener to the SwipeableContainer which will cause an event to


dispatch once the SwipeableContainer is fully opened
animate()

Allows the animation to reduce "repaint" calls when it returns false.


close()

Close the top component if it is currently opened.


deinitialize()

Invoked to indicate that the component initialization is being reversed since


the component was detached from the container hierarchy.
getComponentAt(int x, int y)

Component

protected
void
boolean
boolean
boolean
boolean

Returns a Component that exists in the given x, y coordinates by traversing


component objects and invoking contains
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready
for action" component state
isOpen()

Returns true if the top Component is currently opened


isOpenedToLeft()

Returns true if the top Component is opened to the left side


isOpenedToRight()

Returns true if the top Component is opened to the right side


isSwipeActivated()

Returns true if swipe is activated


openToLeft()

void

This method will open the top Component to the left if there is a Component
to expose on the right.
openToRight()

void

void
void

Field Summary

This method will open the top Component to the right if there is a Component
to expose on the left.
removeSwipeOpenListener(ActionListener l)

Removes the given listener from the SwipeableContainer


setSwipeActivated(boolean swipeActivated)

disable/enable dragging of the top Component

1473

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Container

add, add, add, add, add, add, addComponent, addComponent, addComponent,


addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class com.codename1.ui.Container

1474

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
SwipeableContainer
public SwipeableContainer(Component bottomLeft,
Component top)

Simple Constructor
Parameters:
- the Component below the top, this Component is exposed when
dragging the top to the right
top - the component on top.
SwipeableContainer
bottomLeft

public SwipeableContainer(Component bottomLeft,


Component bottomRight,
Component top)

Simple Constructor
Parameters:
- the Component below the top, this Component is exposed when
dragging the top to the right
bottomRight - the Component below the top, this Component is exposed
when dragging the top to the Left
top - the component on top.
bottomLeft

Method Detail
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
openToRight
public void openToRight()

This method will open the top Component to the right if there is a Component to
expose on the left.
openToLeft
public void openToLeft()

This method will open the top Component to the left if there is a Component to
expose on the right.

Methods inherited from class java.lang.Object

1475

Overview (Codename One API)


close
public void close()

Close the top component if it is currently opened.


getComponentAt
public Component getComponentAt(int x,
int y)

Description copied from class: Container


Returns a Component that exists in the given x, y coordinates by traversing
component objects and invoking contains
Overrides:
getComponentAt in class Container
Parameters:
x - absolute screen location
y - absolute screen location
Returns:
a Component if found, null otherwise
See Also:
Component.contains(int, int)

animate
public boolean animate()

Description copied from class: Component


Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
setSwipeActivated
public void setSwipeActivated(boolean swipeActivated)

disable/enable dragging of the top Component


isSwipeActivated
public boolean isSwipeActivated()

Returns true if swipe is activated


isOpen
public boolean isOpen()

Returns true if the top Component is currently opened


isOpenedToRight
public boolean isOpenedToRight()

Returns true if the top Component is opened to the right side


isOpenedToLeft
public boolean isOpenedToLeft()

Returns true if the top Component is opened to the left side


addSwipeOpenListener
public void addSwipeOpenListener(ActionListener l)

Adds a listener to the SwipeableContainer which will cause an event to dispatch once
the SwipeableContainer is fully opened
Parameters:

Method Detail

1476

Overview (Codename One API)


l - implementation of the action listener interface
removeSwipeOpenListener
public void removeSwipeOpenListener(ActionListener l)

Removes the given listener from the SwipeableContainer


Parameters:
l - implementation of the action listener interface

Method Detail

1477

Overview (Codename One API)


com.codename1.ui

Class Stroke
java.lang.Object

com.codename1.ui.Stroke

public class
extends Object

Encapsulates the stroke used for drawing paths.


See Also:
Graphics#setStroke, Graphics#getStroke

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int

Field and Description


CAP_BUTT

Cap style constant to cap strokes with a butt (or flat).


CAP_ROUND

Cap style constant to cap strokes with a round end.


CAP_SQUARE

Cap style constant to cap strokes with a square end.


JOIN_BEVEL

Join style constant to join strokes bevel.


JOIN_MITER

Join style constant to join strokes MITER (i.e.


JOIN_ROUND

Join style constant to join strokes rounded.

Constructor Summary
Constructor and Description
Stroke()

Creates a stroke with default settings.


Stroke(float lineWidth, int capStyle, int joinStyle, float miterLimit)

Creates a stroke with the specified characteristics.

Method Summary
Modifier and Type
boolean
int
int
float
float
int

Class Stroke

Method and Description


equals(Object obj)

Indicates whether some other object is "equal to" this one.


getCapStyle()

Gets the cap style of the stroke.


getJoinStyle()

Returns the join style used for this stroke.


getLineWidth()

Returns the line width of the stroke.


getMiterLimit()

Gets the miter limit of the stroke.


hashCode()

Returns a hash code value for the object.

1478

Overview (Codename One API)


setCapStyle(int capStyle)

void

Gets the cap style of the stroke.


setJoinStyle(int joinStyle)

void

Sets the join style of the stroke.


setLineWidth(float lineWidth)

void

Sets the line width of the stroke.


setMiterLimit(float miterLimit)

void

Sets the miter limit of the stroke.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
JOIN_MITER
public static final int JOIN_MITER

Join style constant to join strokes MITER (i.e. pointy) Examples can be seen at here.
See Also:
setJoinStyle(int), getJoinStyle(), Constant Field Values
JOIN_ROUND
public static final int JOIN_ROUND

Join style constant to join strokes rounded. Examples can be seen here.
See Also:
setJoinStyle(int), getJoinStyle(), Constant Field Values
JOIN_BEVEL
public static final int JOIN_BEVEL

Join style constant to join strokes bevel. Examples can be seen here.
See Also:
setJoinStyle(int), getJoinStyle(), Constant Field Values
CAP_BUTT
public static final int CAP_BUTT

Cap style constant to cap strokes with a butt (or flat). Examples can be seen here.
See Also:
setCapStyle(int), getCapStyle(), Constant Field Values
CAP_ROUND
public static final int CAP_ROUND

Cap style constant to cap strokes with a round end. Examples can be seen here
See Also:
setCapStyle(int), getCapStyle(), Constant Field Values
CAP_SQUARE
public static final int CAP_SQUARE

Cap style constant to cap strokes with a square end. Examples can be seen here
See Also:
setCapStyle(int), getCapStyle(), Constant Field Values

Constructor Detail

Method Summary

1479

Overview (Codename One API)


Stroke
public Stroke(float lineWidth,
int capStyle,
int joinStyle,
float miterLimit)

Creates a stroke with the specified characteristics.


Parameters:
lineWidth - The width of the stroke pixels.
capStyle - The cap style of the stroke. Should be one of CAP_BUTT,
CAP_ROUND, or CAP_SQUARE.
joinStyle - The join style of the strokes. Should be one of JOIN_MITER,
JOIN_ROUND, or JOIN_BEVEL.
miterLimit - The Miter limit controls the point at which a Miter join
automatically is converted to a Bevel join. If the distance from the inner
intersection point to the tip of the triangle measured in stroke widths is more
than the Miter limit, the join will be drawn in the Bevel style.
Stroke
public Stroke()

Creates a stroke with default settings. Default settings are:


Join style
Cap style
Line Width
Miter Limit

JOIN_MITER
CAP_BUTT

1.0
4.0

Method Detail
getJoinStyle
public int getJoinStyle()

Returns the join style used for this stroke. See visual examples of join styles here.
Returns:
the joinStyle This will be one of JOIN_MITER, JOIN_ROUND, and JOIN_BEVEL.
See Also:
JOIN_MITER, JOIN_BEVEL, JOIN_ROUND
setJoinStyle
public void setJoinStyle(int joinStyle)

Sets the join style of the stroke. See visual examples of join styles here.
Parameters:
joinStyle - the joinStyle to set. This should be one of JOIN_MITER,
JOIN_ROUND, and JOIN_BEVEL.
See Also:
JOIN_MITER, JOIN_BEVEL, JOIN_ROUND
getCapStyle
public int getCapStyle()

Gets the cap style of the stroke. See visual examples of cap styles here.
Returns:
the capStyle. This will be one of CAP_BUTT, CAP_ROUND, and CAP_SQUARE.
See Also:
CAP_BUTT, CAP_SQUARE, CAP_ROUND
setCapStyle
public void setCapStyle(int capStyle)

Gets the cap style of the stroke. See visual examples of cap styles here.
Parameters:

Constructor Detail

1480

Overview (Codename One API)


capStyle - the
CAP_SQUARE.

capStyle to set. This will be one of CAP_BUTT, CAP_ROUND, and

See Also:
CAP_BUTT, CAP_SQUARE, CAP_ROUND

getLineWidth
public float getLineWidth()

Returns the line width of the stroke.


Returns:
the lineWidth
setLineWidth
public void setLineWidth(float lineWidth)

Sets the line width of the stroke.


Parameters:
lineWidth - the lineWidth to set
getMiterLimit
public float getMiterLimit()

Gets the miter limit of the stroke. The Miter limit controls the point at which a Miter
join automatically is converted to a Bevel join. If the distance from the inner
intersection point to the tip of the triangle measured in stroke widths is more than the
Miter limit, the join will be drawn in the Bevel style.
Returns:
the miterLimit
setMiterLimit
public void setMiterLimit(float miterLimit)

Sets the miter limit of the stroke. The Miter limit controls the point at which a Miter join
automatically is converted to a Bevel join. If the distance from the inner intersection
point to the tip of the triangle measured in stroke widths is more than the Miter limit,
the join will be drawn in the Bevel style.
Parameters:
miterLimit - the miterLimit to set
equals
public boolean equals(Object obj)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is

Method Detail

1481

Overview (Codename One API)


modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object

Method Detail

1482

Overview (Codename One API)


com.codename1.ui

Class Slider
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Slider
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
SliderBridge

public class
extends Label

The slider component serves both as a slider widget to allow users to select a value on a scale via
touch/arrows and also to indicate progress. The slider defaults to percentage display but can
represent any positive set of values.

is very versatile and can be used to represent things as diverse as the 5 star ranking UI
demonstrated below. Notice that for the UI to work correctly you need to enclose it in a layout that
preserves its preferred size like flow layout.
Slider

private void showStarPickingForm() {


Form hi = new Form("Star Slider", new BoxLayout(BoxLayout.Y_AXIS));
hi.add(FlowLayout.encloseCenter(createStarRankSlider()));
hi.show();
}
private void initStarRankStyle(Style s, Image star) {
s.setBackgroundType(Style.BACKGROUND_IMAGE_TILE_BOTH);
s.setBorder(Border.createEmpty());
s.setBgImage(star);
s.setBgTransparency(0);
}
private Slider createStarRankSlider() {
Slider starRank = new Slider();
starRank.setEditable(true);
starRank.setMinValue(0);
starRank.setMaxValue(10);
Font fnt = Font.createTrueTypeFont("native:mainLight", "native:mainLight").
derive(Display.getInstance().convertToPixels(5, true), Font.STYLE_PLAIN);
Style s = new Style(0xffff33, 0, fnt, (byte)0);
Image fullStar = FontImage.createMaterial(FontImage.MATERIAL_STAR, s).toImage();
s.setOpacity(100);
s.setFgColor(0);
Image emptyStar = FontImage.createMaterial(FontImage.MATERIAL_STAR, s).toImage();
initStarRankStyle(starRank.getSliderEmptySelectedStyle(), emptyStar);
initStarRankStyle(starRank.getSliderEmptyUnselectedStyle(), emptyStar);
initStarRankStyle(starRank.getSliderFullSelectedStyle(), fullStar);
initStarRankStyle(starRank.getSliderFullUnselectedStyle(), fullStar);
starRank.setPreferredSize(new Dimension(fullStar.getWidth() * 5, fullStar.getHeight()));
return starRank;
}

Class Slider

1483

Overview (Codename One API)


Field

Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Slider()

The default constructor uses internal rendering to draw its state

Method Summary
Modifier
and Type

Method and Description


addActionListener(ActionListener l)

void

Action listeners give a more coarse event only when the user lifts the finger
from the slider
addDataChangedListener(DataChangedListener l)

void

boolean

Adds a listener to data changed events, notice that the status argument to the
data change listener shouldn't be relied upon.
animate()

Allows the animation to reduce "repaint" calls when it returns false.

protected
Dimension

calcPreferredSize()

static
Slider

createInfinite()

Return the size we would generally like for the component


Creates an infinite progress slider
deinitialize()

void

protected
void
protected
String
int

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy.
fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly.
formattedValue(int value)

Allows formatting the appearance of the progress when text is drawn on top
getIncrements()

The increments when the user presses a key to the left/right/up/down etc.

int

getMaxValue()

int

getMinValue()

int

getProgress()

Indicates the value of progress made

Style

getSliderEmptySelectedStyle()
Returns the Style used to paint the

slider when its full and selected

Style

getSliderEmptyUnselectedStyle()
Returns the Style used to paint the

slider when its full

Style

getSliderFullSelectedStyle()
Returns the Style used to paint

Style

getSliderFullUnselectedStyle()
Returns the Style used to paint the

Style

getStyle()

the slider when its full and selected


slider when its full

Returns the current Component Style allowing code to draw the current
component, you should normally use getUnselected/Pressed/DisabledStyle()

Field Summary

1484

Overview (Codename One API)


and not this method since it will return different values based on component
state.
Image

getThumbImage()

The thumb image is drawn on top of the current progress


initComponent()

void

boolean

Allows subclasses to bind functionality that relies on fully initialized and "ready
for action" component state
isEditable()

Indicates the slider is modifyable


isInfinite()

boolean

The infinite slider functionality is used to animate progress for which there is no
defined value.
isRenderPercentageOnTop()

boolean

Indicates that the value of the slider should be rendered with a percentage sign
on top of the slider.

boolean

isRenderValueOnTop()
isSelectableInteraction()

protected
boolean

protected
boolean
boolean
void
void
void
void
void
void

This method allows a component to indicate that it is interested in an "implicit"


select command to appear in the "fire" button when 3 softbuttons are defined
in a device.
isStickyDrag()

Returns true if the component is interested in receiving drag/pointer release


events even after the gesture exceeded its boundaries.
isVertical()

Indicates the slider is vertical


keyPressed(int code)

If this Component is focused, the key pressed event will call this method
keyReleased(int code)

If this Component is focused, the key released event will call this method
paintComponentBackground(Graphics g)

Paint the progress indicator


pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
refreshTheme(boolean merge)

void

Makes sure the component is up to date with the current theme, ONLY
INVOKE THIS METHOD IF YOU CHANGED THE THEME!
removeActionListener(ActionListener l)

void

Action listeners give a more coarse event only when the user lifts the finger
from the slider
removeDataChangedListener(DataChangedListener l)

void

void
void

Removes a listener from data changed events, notice that the status argument
to the data change listener shouldn't be relied upon.
setEditable(boolean editable)

Indicates the slider is modifyable


setIncrements(int increments)

The increments when the user presses a key to the left/right/up/down etc.
setInfinite(boolean i)

void

Activates/disables the infinite slider functionality used to animate progress for


which there is no defined value.

void

setMaxValue(int maxValue)

void

setMinValue(int minValue)

void

setProgress(int value)

Indicates the value of progress made, this method is thread safe and can be
invoked from any thread although discretion should still be kept so one thread

Method Summary

1485

Overview (Codename One API)


doesn't regress progress made by another thread...
setRenderPercentageOnTop(boolean renderPercentageOnTop)
void

Indicates that the value of the slider should be rendered with a percentage sign
on top of the slider.

void

setRenderValueOnTop(boolean renderValueOnTop)
setThumbImage(Image thumbImage)

void

The thumb image is drawn on top of the current progress


setUIID(String id)

void

This method sets the Component the Unique identifier.


setVertical(boolean vertical)

void

Indicates the slider is vertical

protected
boolean

shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from
being used for some other purpose when on top of said component.

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getIcon, getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString, setAlignment,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setIcon, setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setText, setTextPosition, setTickerEnabled, setVerticalAlignment,
shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit,
dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop,
focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles,
getAnimationManager, getBorder, getBottomGap, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX,
getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,

Methods inherited from class com.codename1.ui.Label

1486

Overview (Codename One API)

setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,


setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Slider
public Slider()

The default constructor uses internal rendering to draw its state

Method Detail
setUIID
public void setUIID(String id)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized
Overrides:
setUIID in class Component
Parameters:
id - UIID unique identifier for component type
isStickyDrag
protected boolean isStickyDrag()

Returns true if the component is interested in receiving drag/pointer release events


even after the gesture exceeded its boundaries. This is useful for spinners etc. where
the motion might continue beyond the size of the component
Overrides:
isStickyDrag in class Component
Returns:
false by default
initComponent
public void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
public void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component

Methods inherited from class com.codename1.ui.Component

1487

Overview (Codename One API)


animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Label
Returns:
true if a repaint is desired or false if no repaint is necessary
isInfinite
public boolean isInfinite()

The infinite slider functionality is used to animate progress for which there is no
defined value.
Returns:
true for infinite progress
setInfinite
public void setInfinite(boolean i)

Activates/disables the infinite slider functionality used to animate progress for which
there is no defined value.
Parameters:
i - true for infinite progress
createInfinite
public static Slider createInfinite()

Creates an infinite progress slider


Returns:
a slider instance that has no end value
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Component
Parameters:
merge - indicates if the current styles should be merged with the new styles
getProgress
public int getProgress()

Indicates the value of progress made


Returns:
the progress on the slider
setProgress
public void setProgress(int value)

Indicates the value of progress made, this method is thread safe and can be invoked
from any thread although discretion should still be kept so one thread doesn't regress
progress made by another thread...
Parameters:
value - new value for progress
formattedValue
protected String formattedValue(int value)

Allows formatting the appearance of the progress when text is drawn on top
Parameters:

Method Detail

1488

Overview (Codename One API)


value - the value of the slider
Returns:
a string formatted version
getSliderFullUnselectedStyle
public Style getSliderFullUnselectedStyle()

Returns the Style used to paint the slider when its full
Returns:
the Style object that shows a completely full style.
getSliderFullSelectedStyle
public Style getSliderFullSelectedStyle()

Returns the Style used to paint the slider when its full and selected
Returns:
the Style object that shows a completely full style.
getSliderEmptyUnselectedStyle
public Style getSliderEmptyUnselectedStyle()

Returns the Style used to paint the slider when its full
Returns:
the Style object that shows a completely full style.
getSliderEmptySelectedStyle
public Style getSliderEmptySelectedStyle()

Returns the Style used to paint the slider when its full and selected
Returns:
the Style object that shows a completely full style.
getStyle
public Style getStyle()

Returns the current Component Style allowing code to draw the current component,
you should normally use getUnselected/Pressed/DisabledStyle() and not this method
since it will return different values based on component state.
Overrides:
getStyle in class Component
Returns:
the component Style object
calcPreferredSize
protected Dimension calcPreferredSize()

Return the size we would generally like for the component


Overrides:
calcPreferredSize in class Label
Returns:
the calculated preferred size based on component content
paintComponentBackground
public void paintComponentBackground(Graphics g)

Paint the progress indicator


Parameters:
g - the component graphics
isVertical
public boolean isVertical()

Indicates the slider is vertical


Returns:
true if the slider is vertical

Method Detail

1489

Overview (Codename One API)


setVertical
public void setVertical(boolean vertical)

Indicates the slider is vertical


Parameters:
vertical - true if the slider is vertical
isEditable
public boolean isEditable()

Indicates the slider is modifyable


Returns:
true if the slider is editable
setEditable
public void setEditable(boolean editable)

Indicates the slider is modifyable


Parameters:
editable - true if the slider is editable
pointerPressed
public void pointerPressed(int x,
int y)

Description copied from class: Component


If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component
isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction

Method Detail

1490

Overview (Codename One API)


pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
keyReleased
public void keyReleased(int code)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
code - the key code value to indicate a physical key.
keyPressed
public void keyPressed(int code)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
code - the key code value to indicate a physical key.
getIncrements
public int getIncrements()

The increments when the user presses a key to the left/right/up/down etc.
Returns:
increment value
setIncrements
public void setIncrements(int increments)

The increments when the user presses a key to the left/right/up/down etc.
Parameters:
increments - increment value
addDataChangedListener
public void addDataChangedListener(DataChangedListener l)

Adds a listener to data changed events, notice that the status argument to the data
change listener shouldn't be relied upon.
Parameters:
l - new listener
removeDataChangedListener
public void removeDataChangedListener(DataChangedListener l)

Removes a listener from data changed events, notice that the status argument to the
data change listener shouldn't be relied upon.
Parameters:
l - listener to remove
addActionListener
public void addActionListener(ActionListener l)

Action listeners give a more coarse event only when the user lifts the finger from the
slider
Parameters:
l - the listener

Method Detail

1491

Overview (Codename One API)


removeActionListener
public void removeActionListener(ActionListener l)

Action listeners give a more coarse event only when the user lifts the finger from the
slider
Parameters:
l - the listener
isRenderPercentageOnTop
public boolean isRenderPercentageOnTop()

Indicates that the value of the slider should be rendered with a percentage sign on
top of the slider.
Returns:
true if so
setRenderPercentageOnTop
public void setRenderPercentageOnTop(boolean renderPercentageOnTop)

Indicates that the value of the slider should be rendered with a percentage sign on
top of the slider.
Parameters:
renderPercentageOnTop - true to render percentages
isRenderValueOnTop
public boolean isRenderValueOnTop()

Returns:
the renderValueOnTop
setRenderValueOnTop
public void setRenderValueOnTop(boolean renderValueOnTop)

Parameters:
renderValueOnTop

- the renderValueOnTop to set

getMaxValue
public int getMaxValue()

Returns:
the maxValue
setMaxValue
public void setMaxValue(int maxValue)

Parameters:
maxValue

- the maxValue to set

getMinValue
public int getMinValue()

Returns:
the minValue
setMinValue
public void setMinValue(int minValue)

Parameters:
minValue

- the minValue to set

getThumbImage
public Image getThumbImage()

The thumb image is drawn on top of the current progress


Returns:
the thumbImage

Method Detail

1492

Overview (Codename One API)


setThumbImage
public void setThumbImage(Image thumbImage)

The thumb image is drawn on top of the current progress


Parameters:
thumbImage - the thumbImage to set
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from being
used for some other purpose when on top of said component.
Overrides:
shouldBlockSideSwipe in class Component

Method Detail

1493

Overview (Codename One API)


com.codename1.ui

Class SideMenuBar
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.MenuBar

com.codename1.ui.SideMenuBar
All Implemented Interfaces:
Animation, ActionListener, StyleListener, Iterable<Component>

public class
extends MenuBar

This is Menu Bar that displays it's commands on a side bar navigation similar to Google+/Facbook
apps navigation

Field Summary
Modifier
and
Type
static
String
static
String
static
String
static
String

Field and Description


COMMAND_ACTIONABLE

When using a side component we might want to only have it behave as a visual
tool and still execute the command when it is clicked.
COMMAND_PLACEMENT_KEY

This string can be used in putClientProperty within command to hint about the
placement of the command
COMMAND_PLACEMENT_VALUE_RIGHT

This string can be used in putClientProperty within command to hint about the
placement of the command e.g.
COMMAND_PLACEMENT_VALUE_TOP

This string can be used in putClientProperty within command to hint about the
placement of the command e.g.
COMMAND_SIDE_COMPONENT

static
String

Allows placing a component instance into the client properties of the command so
it is shown instead of the command e.g.:
putClientProperty(SideMenuBar.COMMAND_SIDE_COMPONENT,
myCustomComponentInstance);

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
SideMenuBar()

Empty Constructor

Class SideMenuBar

1494

Overview (Codename One API)

Method Summary
Modifier and
Type
void

Method and Description


addCommand(Command cmd)

Adds a Command to the MenuBar

protected
void

addCommand(Command cmd, int index)

protected
void

addComponentToSideMenu(Container menu, Component cmp)

Add a Command to the MenuBar


This method responsible to add a Component to the side navigation panel.
closeCurrentMenu()

static void

Folds the current side menu if it is open, notice that the menu will close
asynchronously
closeCurrentMenu(Runnable callback)

static void

void

Folds the current side menu if it is open, when the menu is closed it will
invoke the runnable callback method
closeMenu()

Closes the menu if it is currently open

protected
Container

constructSideNavigationComponent()

protected
Button

createOpenButton()

protected
Container

createSideNavigationComponent(Vector commands)

protected
Container

createSideNavigationComponent(Vector commands, String placement)

protected
Button

createTouchCommandButton(Command c)

int

getCommandBehavior()

Creates an empty side navigation panel.


Creates the Side Menu open button.
Creates the side navigation component with the Commands
Creates the side navigation component with the Commands
Creates a touch command for use as a touch menu item
getDragRegionStatus(int x, int y)

protected
int

Form

Indicates if the section within the X/Y area is a "drag region" where we expect
people to drag or press in which case we can instantly start dragging making
perceived performance faster.
getParentForm()

Returns the Parent Form of this menu

protected
void

initMenuBar(Form parent)

protected
void

installMenuBar()

boolean
static
boolean
void
void

Initialize the MenuBar


Adds the MenuBar on the parent Form
isMenuOpen()

Returns true if the Menu is currently open


isShowing()

Returns true if a side menu is currently controlling the screen


keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
openMenu(String direction)

Opens the menu if it is currently closed

protected
void

removeAllCommands()

protected
void

removeCommand(Command cmd)

void
protected
void

Method Summary

Remove all commands from the menuBar


Removes a Command from the MenuBar
setBackCommand(Command backCommand)

Indicates the command that is defined as the back command out of this form.
unInstallMenuBar()

Removes the MenuBar from the parent Form

1495

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.MenuBar

actionPerformed, calcPreferredSize, calculateTouchCommandGridColumns,


createBackCommandButton, createCommandComponent, createCommandList,
createMenuCancelCommand, createMenuSelectCommand, createSelectCommand,
createSoftButton, findCommandComponent, getBackCommand, getCancelMenuItem,
getClearCommand, getCommand, getCommandCount, getCommands,
getDefaultCommand, getMenuStyle, getSelectCommand, getSelectMenuItem,
getTitleAreaContainer, getTitleComponent, handlesKeycode, isMinimizeOnBack,
isReverseSoftButtons, keyPressed, refreshTheme, removeEmptySoftbuttons,
setClearCommand, setCommandUIID, setDefaultCommand, setMenuCellRenderer,
setMinimizeOnBack, setSelectCommand, setTransitions, setUnselectedStyle,
showMenu, showMenuDialog

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, layoutContainer, morph, morphAndWait,
paint, paintComponentBackground, paintGlass, paramString, pointerHover,
pointerPressed, removeAll, removeComponent, replace, replace,
replaceAndWait, replaceAndWait, replaceAndWait, revalidate,
scrollComponentToVisible, setCellRenderer, setEnabled, setLayout,
setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile,
isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable,
isDragRegion, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents,
isHidden, isHideInPortrait, isInClippingRegion, isInitialized, isRTL,
isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid,
isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX,
onScrollY, paintBackground, paintBackgrounds, paintBorder,
paintBorderBackground, paintComponent, paintComponent, paintLock,
paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch,
pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased,
pointerPressed, pointerReleased, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,

Methods inherited from class com.codename1.ui.MenuBar

1496

Overview (Codename One API)

setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,


setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setPropertyValue, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
COMMAND_PLACEMENT_KEY
public static final String COMMAND_PLACEMENT_KEY

This string can be used in putClientProperty within command to hint about the
placement of the command
See Also:
Constant Field Values
COMMAND_PLACEMENT_VALUE_RIGHT
public static final String COMMAND_PLACEMENT_VALUE_RIGHT

This string can be used in putClientProperty within command to hint about the
placement of the command e.g.
putClientProperty(SideMenuBar.COMMAND_PLACEMENT_KEY,
SideMenuBar.COMMAND_PLACEMENT_VALUE_RIGHT);
See Also:
Constant Field Values
COMMAND_PLACEMENT_VALUE_TOP
public static final String COMMAND_PLACEMENT_VALUE_TOP

This string can be used in putClientProperty within command to hint about the
placement of the command e.g.
putClientProperty(SideMenuBar.COMMAND_PLACEMENT_KEY,
SideMenuBar.COMMAND_PLACEMENT_VALUE_TOP);
See Also:
Constant Field Values
COMMAND_SIDE_COMPONENT
public static final String COMMAND_SIDE_COMPONENT

Allows placing a component instance into the client properties of the command so it is
shown instead of the command e.g.:
putClientProperty(SideMenuBar.COMMAND_SIDE_COMPONENT,
myCustomComponentInstance);
See Also:
Constant Field Values
COMMAND_ACTIONABLE
public static final String COMMAND_ACTIONABLE

When using a side component we might want to only have it behave as a visual tool
and still execute the command when it is clicked. The default behavior is to delegate
events to the component, however if this flag is used the command will act as normal

Methods inherited from class com.codename1.ui.Component

1497

Overview (Codename One API)


while using the COMMAND_SIDE_COMPONENT only for visual effect e.g.:
putClientProperty(SideMenuBar.COMMAND_ACTIONABLE, Boolean.TRUE);
See Also:
Constant Field Values

Constructor Detail
SideMenuBar
public SideMenuBar()

Empty Constructor

Method Detail
initMenuBar
protected void initMenuBar(Form parent)

Initialize the MenuBar


Overrides:
initMenuBar in class MenuBar
Parameters:
parent - the associated Form
isShowing
public static boolean isShowing()

Returns true if a side menu is currently controlling the screen


Returns:
true if a side menu is currently controlling the screen
closeCurrentMenu
public static void closeCurrentMenu()

Folds the current side menu if it is open, notice that the menu will close
asynchronously
closeCurrentMenu
public static void closeCurrentMenu(Runnable callback)

Folds the current side menu if it is open, when the menu is closed it will invoke the
runnable callback method
Parameters:
callback - will be invoked when the menu is actually closed
removeAllCommands
protected void removeAllCommands()

Remove all commands from the menuBar


Overrides:
removeAllCommands in class MenuBar
unInstallMenuBar
protected void unInstallMenuBar()

Removes the MenuBar from the parent Form


Overrides:
unInstallMenuBar in class MenuBar
createOpenButton
protected Button createOpenButton()

Creates the Side Menu open button.

Field Detail

1498

Overview (Codename One API)


Returns:
a Button instance to place on the TitleArea
installMenuBar
protected void installMenuBar()

Adds the MenuBar on the parent Form


Overrides:
installMenuBar in class MenuBar
getDragRegionStatus
protected int getDragRegionStatus(int x,
int y)

Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Overrides:
getDragRegionStatus in class MenuBar
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values
addCommand
public void addCommand(Command cmd)

Adds a Command to the MenuBar


Overrides:
addCommand in class MenuBar
Parameters:
cmd - Command to add
setBackCommand
public void setBackCommand(Command backCommand)

Indicates the command that is defined as the back command out of this form. A back
command can be used both to map to a hardware button (e.g. on the Sony Ericsson
devices) and by elements such as transitions etc. to change the behavior based on
direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
Overrides:
setBackCommand in class MenuBar
Parameters:
backCommand - the command to treat as the back Command
getCommandBehavior
public int getCommandBehavior()

Overrides:
getCommandBehavior

in class MenuBar

addCommand
protected void addCommand(Command cmd,
int index)

Add a Command to the MenuBar


Overrides:
addCommand in class MenuBar
Parameters:
cmd - Command to Add
index - determines the order of the added commands

Method Detail

1499

Overview (Codename One API)


removeCommand
protected void removeCommand(Command cmd)

Removes a Command from the MenuBar


Overrides:
removeCommand in class MenuBar
Parameters:
cmd - Command to remove
keyReleased
public void keyReleased(int keyCode)

Description copied from class: MenuBar


If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class MenuBar
Parameters:
keyCode - the key code value to indicate a physical key.
closeMenu
public void closeMenu()

Closes the menu if it is currently open


openMenu
public void openMenu(String direction)

Opens the menu if it is currently closed


isMenuOpen
public boolean isMenuOpen()

Returns true if the Menu is currently open


Returns:
true if menu open
createSideNavigationComponent
protected Container createSideNavigationComponent(Vector commands)

Creates the side navigation component with the Commands


Parameters:
commands - the Command objects
Returns:
the Component to display on the navigation
createSideNavigationComponent
protected Container createSideNavigationComponent(Vector commands,
String placement)

Creates the side navigation component with the Commands


Parameters:
commands - the Command objects
Returns:
the Component to display on the navigation
constructSideNavigationComponent
protected Container constructSideNavigationComponent()

Creates an empty side navigation panel.


addComponentToSideMenu
protected void addComponentToSideMenu(Container menu,
Component cmp)

This method responsible to add a Component to the side navigation panel.


Parameters:

Method Detail

1500

Overview (Codename One API)


- the Menu Container that was created in the
constructSideNavigationComponent() method
cmp - the Component to add to the side menu
createTouchCommandButton
menu

protected Button createTouchCommandButton(Command c)

Creates a touch command for use as a touch menu item


Overrides:
createTouchCommandButton in class MenuBar
Parameters:
c - command to map into the returned button
Returns:
a button that would fire the touch command appropriately
getParentForm
public Form getParentForm()

Returns the Parent Form of this menu


Returns:
Form Object

Method Detail

1501

Overview (Codename One API)


com.codename1.ui

Class RadioButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.ui.RadioButton
All Implemented Interfaces:
Animation, StyleListener

public class
extends Button

RadioButton is a Button that maintains a selection state exclusively within a specific ButtonGroup.
Check out CheckBox for a looser selection approach. Both components support a toggle button mode
using the Button.setToggle(boolean) API.
CheckBox cb1 = new CheckBox("CheckBox No Icon");
cb1.setSelected(true);
CheckBox cb2 = new CheckBox("CheckBox With Icon", icon);
CheckBox cb3 = new CheckBox("CheckBox Opposite True", icon);
CheckBox cb4 = new CheckBox("CheckBox Opposite False", icon);
cb3.setOppositeSide(true);
cb4.setOppositeSide(false);
RadioButton rb1 = new RadioButton("Radio 1");
RadioButton rb2 = new RadioButton("Radio 2");
RadioButton rb3 = new RadioButton("Radio 3", icon);
new ButtonGroup(rb1, rb2, rb3);
rb2.setSelected(true);
hi.add(cb1).add(cb2).add(cb3).add(cb4).add(rb1).add(rb2).add(rb3);

Field Summary

Class RadioButton

1502

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.Button

STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
RadioButton()

Creates an empty radio button


RadioButton(Image icon)

Constructs a radio with the given icon


RadioButton(String text)

Constructs a radio with the given text


RadioButton(String text, Image icon)

Constructs a radio with the given text and icon

Method Summary
Modifier and
Type
void
protected
Dimension
static
RadioButton
static
RadioButton
static
RadioButton
static
RadioButton

Method and Description


bindProperty(String prop, BindTarget target)

Binds the given property name to the given bind target


calcPreferredSize()

Calculates the preferred size based on component content.


createToggle(Command cmd, ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the
command and making it into a toggle button
createToggle(Image icon, ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the
icon/text and making it into a toggle button
createToggle(String text, ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the
icon/text and making it into a toggle button
createToggle(String text, Image icon, ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the
icon/text and making it into a toggle button
getBindablePropertyNames()

String[]

Class[]
Object
String
protected void
boolean

Returns the names of the properties within this component that can be
bound for persistence, the order of these names mean that the first one will
be the first bound
getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


getGroup()

This is a helper method to ease the usage of button groups


initLaf(UIManager uim)

This method initializes the Component defaults constants


isOppositeSide()

Places the radio box on the opposite side at the far end

Fields inherited from class com.codename1.ui.Button

1503

Overview (Codename One API)


boolean

isSelected()

Returns true if the radio button is selected


paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the
PLAF perform the rendering.

void

released(int x, int y)

void

Invoked to change the state of the button to the released state


setBoundPropertyValue(String prop, Object value)

Sets the value of a bound property within this component, notice that this
method MUST NOT fire the property change event when invoked to
prevent recursion!

void

setGroup(String groupName)

void

This is a helper method to ease the usage of button groups


setOppositeSide(boolean oppositeSide)

void

Places the radio box on the opposite side at the far end
setSelected(boolean selected)

void

Selects the current radio button

String

toString()

Overriden to return a useful value for debugging purposes


unbindProperty(String prop, BindTarget target)

void

Removes a bind target from the given property name

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, dragInitiated, fireClicked, getActionListeners,
getBorder, getCommand, getDisabledIcon, getIconFromState, getListeners,
getPressedIcon, getReleaseRadius, getRolloverIcon, getRolloverPressedIcon,
getState, isAutoRelease, isSelectableInteraction, isToggle, keyPressed,
keyReleased, keyRepeated, pointerDragged, pointerHover,
pointerHoverReleased, pointerPressed, pointerReleased, pressed, released,
removeActionListener, resetFocusable, setAlignment, setAutoRelease,
setCommand, setDisabledIcon, setPressedIcon, setReleaseRadius,
setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


getAlignment, getBaseline, getBaselineResizeBehavior, getGap, getIcon,
getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paramString, setDefaultTickerEnabled,
setEndsWith3Points, setGap, setIcon, setLegacyRenderer, setMask,
setMaskName, setPropertyValue, setShiftMillimeters, setShiftText,
setShouldLocalize, setShowEvenIfBlank, setText, setTextPosition,
setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker,
startTicker, stopTicker

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,

Method Summary

1504

Overview (Codename One API)


getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile,
isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable,
isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
RadioButton
public RadioButton(String text)

Constructs a radio with the given text


Parameters:
text - to display next to the button
RadioButton
public RadioButton()

Creates an empty radio button


RadioButton
public RadioButton(Image icon)

Constructs a radio with the given icon


Parameters:
icon - icon to show next to the button
RadioButton
public RadioButton(String text,
Image icon)

Constructs a radio with the given text and icon


Parameters:
text - to display next to the button
icon - icon to show next to the button

Methods inherited from class com.codename1.ui.Component

1505

Overview (Codename One API)

Method Detail
createToggle
public static RadioButton createToggle(String text,
Image icon,
ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the icon/text and
making it into a toggle button
Parameters:
text - the text for the button
icon - the icon for the button
bg - the button group
Returns:
a radio button
createToggle
public static RadioButton createToggle(String text,
ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the icon/text and
making it into a toggle button
Parameters:
text - the text for the button
bg - the button group
Returns:
a radio button
createToggle
public static RadioButton createToggle(Image icon,
ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the icon/text and
making it into a toggle button
Parameters:
icon - the icon for the button
bg - the button group
Returns:
a radio button
createToggle
public static RadioButton createToggle(Command cmd,
ButtonGroup bg)

Shorthand for creating the radio button, adding it to a group, setting the command
and making it into a toggle button
Parameters:
cmd - the command
bg - the button group
Returns:
a radio button
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Component
toString
public String toString()

Overriden to return a useful value for debugging purposes


Overrides:
toString in class Component

Method Detail

1506

Overview (Codename One API)


Returns:
a string representation of this component
isSelected
public boolean isSelected()

Returns true if the radio button is selected


Overrides:
isSelected in class Button
Returns:
true if the radio button is selected
setSelected
public void setSelected(boolean selected)

Selects the current radio button


Parameters:
selected - value for selection
released
public void released(int x,
int y)

Invoked to change the state of the button to the released state


Overrides:
released in class Button
Parameters:
x - the x position if a touch event triggered this, -1 if this isn't relevant
y - the y position if a touch event triggered this, -1 if this isn't relevant
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Label
Parameters:
g - the component graphics
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Button
Returns:
the calculated preferred size based on component content
setGroup
public void setGroup(String groupName)

This is a helper method to ease the usage of button groups


Parameters:
groupName - a name for the goup
getGroup
public String getGroup()

This is a helper method to ease the usage of button groups


Returns:
the name of the group

Method Detail

1507

Overview (Codename One API)


isOppositeSide
public boolean isOppositeSide()

Places the radio box on the opposite side at the far end
Overrides:
isOppositeSide in class Button
Returns:
the oppositeSide
setOppositeSide
public void setOppositeSide(boolean oppositeSide)

Places the radio box on the opposite side at the far end
Parameters:
oppositeSide - the oppositeSide to set
getBindablePropertyNames
public String[] getBindablePropertyNames()

Returns the names of the properties within this component that can be bound for
persistence, the order of these names mean that the first one will be the first bound
Overrides:
getBindablePropertyNames in class Label
Returns:
a string array of property names or null
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
Overrides:
getBindablePropertyTypes in class Label
Returns:
the class for binding
bindProperty
public void bindProperty(String prop,
BindTarget target)

Binds the given property name to the given bind target


Overrides:
bindProperty in class Label
Parameters:
prop - the property name
target - the target binder
unbindProperty
public void unbindProperty(String prop,
BindTarget target)

Removes a bind target from the given property name


Overrides:
unbindProperty in class Label
Parameters:
prop - the property names
target - the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


Overrides:
getBoundPropertyValue in class Label
Parameters:
prop - the property
Returns:

Method Detail

1508

Overview (Codename One API)

the value for the property


setBoundPropertyValue
public void setBoundPropertyValue(String prop,
Object value)

Sets the value of a bound property within this component, notice that this method
MUST NOT fire the property change event when invoked to prevent recursion!
Overrides:
setBoundPropertyValue in class Label
Parameters:
prop - the property whose value should be set
value - the value

Method Detail

1509

Overview (Codename One API)


com.codename1.ui

Class RGBImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.RGBImage

public class
extends Image

An image that stores its data as an integer RGB array internally, this image cannot be manipulated via
Graphics primitives however its array is accessible and modifiable programmatically. This is very
useful for 2 distinct use cases.
The first use case allows us to manipulate images in a custom way while still preserving alpha
information where applicable.
The second use case allows us to store images in the Java heap which is useful for some constrained
devices. In small devices images are often stored in a separate "heap" which runs out eventually, this
allows us to place the image in the Java heap which is potentially more wasteful but might sometimes
be more abundant.
Note that unless specified otherwise most methods inherited from Image will fail when invoked on this
subclass often with a NullPointerException. This image can be drawn on graphics as usual

Constructor Summary
Constructor and Description
RGBImage(Image img)

Converts an image to an RGB image after which the original image can be GC'd
RGBImage(int[] rgb, int width, int height)

Creates an RGB image from scratch the array isn't copied and can be saved and
manipulated

Method Summary
Modifier
and Type
protected
void
Graphics
int

Method and Description


drawImage(Graphics g, Object nativeGraphics, int x, int y)

Callback invoked internally by Codename One to draw the image/frame onto


the display.
getGraphics()

This method is unsupported in this image type


getHeight()

Returns the height of the image


getRGB()

int[]

int

Returns a mutable array that can be used to change the appearance of the
image arranged as AARRGGBB.
getWidth()

Returns the width of the image


isOpaque()

boolean

Indicates if an image should be treated as opaque, this can improve support


for fast drawing of RGB images without alpha support.
modifyAlpha(byte alpha)

Image

Class RGBImage

Creates a new image instance with the alpha channel of opaque/translucent


pixels within the image using the new alpha value.

1510

Overview (Codename One API)


requiresDrawImage()
boolean

New label optimizations don't invoke drawImage and instead just pass the
native image directly to the underlying renderer.
rotate(int degrees)

Unsupported in the current version, this method will be implemented in a


future release

Image

scale(int width, int height)

Scale the image to the given width and height, this is a fast algorithm that
preserves translucent information

void

scaled(int width, int height)


Image

Returns a scaled version of this image image using the given width and
height, this is a fast algorithm that preserves translucent information.

void

setOpaque(boolean opaque)
subImage(int x, int y, int width, int height, boolean processAlpha)

Extracts a subimage from the given image allowing us to breakdown a single


large image into multiple smaller images in RAM, this actually creates a
standalone version of the image for use.

Image

Methods inherited from class com.codename1.ui.Image


animate, applyMask, applyMask, applyMaskAutoScale, asyncLock, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, dispose, drawImage,
flipHorizontally, flipVertically, getImage, getImageName, getRGBCached,
getSVGDocument, isAlphaMutableImageSupported, isAnimation, isLocked, isSVG,
isSVGSupported, lock, mirror, modifyAlpha, modifyAlphaWithTranslucency,
rotate180Degrees, rotate270Degrees, rotate90Degrees, scaledHeight,
scaledLargerRatio, scaledSmallerRatio, scaledWidth, setImageName, toRGB,
unlock

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
RGBImage
public RGBImage(Image img)

Converts an image to an RGB image after which the original image can be GC'd
Parameters:
img - the image to convert to an RGB image
RGBImage
public RGBImage(int[] rgb,
int width,
int height)

Creates an RGB image from scratch the array isn't copied and can be saved and
manipulated
Parameters:
rgb - AARRGGBB array
width - width of image
height - height of image

Method Detail

Method Summary

1511

Overview (Codename One API)


subImage
public Image subImage(int x,
int y,
int width,
int height,
boolean processAlpha)

Extracts a subimage from the given image allowing us to breakdown a single large
image into multiple smaller images in RAM, this actually creates a standalone version
of the image for use.
Overrides:
subImage in class Image
Parameters:
x - the x offset from the image
y - the y offset from the image
width - the width of internal images
height - the height of internal images
processAlpha - whether alpha should be processed as well as part of the
cutting
Returns:
An array of all the possible images that can be created from the source
scaled
public Image scaled(int width,
int height)

Returns a scaled version of this image image using the given width and height, this is
a fast algorithm that preserves translucent information. The method accepts -1 to
preserve aspect ratio in the given axis.
Overrides:
scaled in class Image
Parameters:
width - width for the scaling
height - height of the scaled image
Returns:
new image instance scaled to the given height and width
scale
public void scale(int width,
int height)

Scale the image to the given width and height, this is a fast algorithm that preserves
translucent information
Overrides:
scale in class Image
Parameters:
width - width for the scaling
height - height of the scaled image
rotate
public Image rotate(int degrees)

Unsupported in the current version, this method will be implemented in a future


release
Overrides:
rotate in class Image
Parameters:
degrees - A degree in right angle must be larger than 0 and up to 359
degrees
Returns:
new image instance with the closest possible rotation
modifyAlpha
public Image modifyAlpha(byte alpha)

Method Detail

1512

Overview (Codename One API)


Creates a new image instance with the alpha channel of opaque/translucent pixels
within the image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. All other pixels will have the new alpha value.
Overrides:
modifyAlpha in class Image
Parameters:
alpha - New value for the entire alpha channel
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
getGraphics
public Graphics getGraphics()

This method is unsupported in this image type


Overrides:
getGraphics in class Image
Returns:
Graphics object allowing us to manipulate the content of a mutable image
getRGB
public int[] getRGB()

Returns a mutable array that can be used to change the appearance of the image
arranged as AARRGGBB.
Overrides:
getRGB in class Image
Returns:
ARGB int array
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
setOpaque
public void setOpaque(boolean opaque)

isOpaque
public boolean isOpaque()

Indicates if an image should be treated as opaque, this can improve support for fast
drawing of RGB images without alpha support.
Overrides:
isOpaque in class Image
Returns:
true if the image is completely opqaque which allows for some heavy
optimizations
getWidth
public int getWidth()

Returns the width of the image


Overrides:

Method Detail

1513

Overview (Codename One API)


getWidth in class Image
Returns:
the width of the image
getHeight
public int getHeight()

Returns the height of the image


Overrides:
getHeight in class Image
Returns:
the height of the image
requiresDrawImage
public boolean requiresDrawImage()

New label optimizations don't invoke drawImage and instead just pass the native
image directly to the underlying renderer. This is problematic for some image types
specifically timeline & FontImage and this method allows these classes to indicate
that they need that legacy behavior of calling drawImage.
Overrides:
requiresDrawImage in class Image
Returns:
true if a drawImage call is a required

Method Detail

1514

Overview (Codename One API)


com.codename1.ui

Class PeerComponent
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.PeerComponent
All Implemented Interfaces:
Animation, StyleListener

public class
extends Component

A peer component is essentially a "dummy" Codename One component used to calculate the position
of the actual native platform specific component. The behavior of a peer component is very platform
specific, it is meant for platforms where a native component can be integrated with a Codename One
component. Codename One features such as glass pane, z-ordering, dialogs & menus might not work
as expected in all situations where peer components are involved. E.g. a peer component might hide
itself when a menu/dialog is shown and recreate itself when it is hidden/disposed.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Modifier

Constructor and Description


PeerComponent(Object nativePeer)

protected

This constructor is used by the platform implementation to create instances of


this class use the static create method.

Method Summary
Modifier and
Type
boolean
protected
Dimension
protected
Dimension
static
PeerComponent

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


calcScrollSize()

Method that can be overriden to represent the actual size of the


component when it differs from the desireable size for the viewport
create(Object nativePeer)

Use this method to encapsulate a native UI object


deinitialize()

protected void

Invoked to indicate that the component initialization is being reversed


since the component was detached from the container hierarchy.
fireClicked()

protected void

Class PeerComponent

When working in 3 softbutton mode "fire" key (center softbutton) is sent to


this method in order to allow 3 button devices to work properly.

1515

Overview (Codename One API)


protected void
protected void

focusGained()

Callback allowing a developer to track wheh the component gains focus


focusLost()

Callback allowing a developer to track wheh the component loses focus


generatePeerImage()

protected Image

Object

The native implementation should implement this method to generate a


native peer image representing the component
getNativePeer()

Returns the native peer instance


getPeerImage()

protected Image

boolean

The peer image is drawn when the component doesn't exist or during
transition a placeholder image can be placed in the beginning to show
something while the peer is being created asynchronously.
handlesInput()

Prevents key events from being grabbed for focus traversal.


initComponent()

protected void

void
void
void
void

Allows subclasses to bind functionality that relies on fully initialized and


"ready for action" component state
invalidate()

Updates the size of the component from the native widget


keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
onPositionSizeChange()

protected void

Callback useful for sublclasses that need to track the change in


size/position of the component (notice that this might be invoked too
many times for a single change)!
paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden


by subclasses to perform custom drawing or invoke the UI API's to let the
PLAF perform the rendering.
paintBackground(Graphics g)

protected void

void
protected void

This method paints the Component background, it should be overriden by


subclasses to perform custom background drawing.
paintBackgrounds(Graphics g)

This method paints all the parents Components Background.


paintBorder(Graphics g)

Draws the component border if such a border exists.


paintScrollbars(Graphics g)

protected void

Paints the UI for the scrollbars on the component, this will be invoked
only for scrollable components.
paintScrollbarX(Graphics g)

protected void

Paints the UI for the scrollbar on the X axis, this method allows
component subclasses to customize the look of a scrollbar
paintScrollbarY(Graphics g)

protected void

Paints the UI for the scrollbar on the Y axis, this method allows
component subclasses to customize the look of a scrollbar
pointerDragged(int[] x, int[] y)

void

If this Component is focused, the pointer dragged event will call this
method
pointerDragged(int x, int y)

void

If this Component is focused, the pointer dragged event will call this
method
pointerHover(int[] x, int[] y)

void

Method Summary

Invoked for devices where the pointer can hover without actually clicking
the display.

1516

Overview (Codename One API)


pointerHoverReleased(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking
the display.

void

pointerPressed(int[] x, int[] y)

If this Component is focused, the pointer pressed event will call this
method

void

pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this
method

void

pointerReleased(int[] x, int[] y)

If this Component is focused, the pointer released event will call this
method

void

pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this
method

void

setLightweightMode(boolean l)
protected void

An optional callback for peers indicating that the peer is now rendered as
part of a transition or some other state and is thus not truly visible.
setPeerImage(Image i)

protected void

protected
boolean

The peer image is drawn when the component doesn't exist or during
transition a placeholder image can be placed in the beginning to show
something while the peer is being created asynchronously.
shouldRenderPeerImage()

Subclasses should return true here if the peer image should be rendered
instead of the actual peer

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit,
dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop,
getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline,
getBaselineResizeBehavior, getBindablePropertyNames,
getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue,
getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, hasFocus,
initCustomStyle, initLaf, installDefaultPainter, isAlwaysTensile,
isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable,
isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid,
isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled,
isVisible, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBorderBackground, paintComponent, paintComponent, paintLock,
paintLockRelease, paramString, pinch, pointerHoverPressed,
putClientProperty, refreshTheme, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,

Methods inherited from class com.codename1.ui.Component

1517

Overview (Codename One API)


setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,
setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,
setScrollY, setSelectCommandText, setSelectedStyle,
setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
PeerComponent
protected PeerComponent(Object nativePeer)

This constructor is used by the platform implementation to create instances of this


class use the static create method.
Parameters:
nativePeer - the native platform specific peer component.

Method Detail
getPeerImage
protected Image getPeerImage()

The peer image is drawn when the component doesn't exist or during transition a
placeholder image can be placed in the beginning to show something while the peer
is being created asynchronously. This image might be replaced by an internal image
representing the actual content of the peer
Returns:
an image
generatePeerImage
protected Image generatePeerImage()

The native implementation should implement this method to generate a native peer
image representing the component
Returns:
a screenshot of the component
setPeerImage
protected void setPeerImage(Image i)

The peer image is drawn when the component doesn't exist or during transition a
placeholder image can be placed in the beginning to show something while the peer
is being created asynchronously. This image might be replaced by an internal image
representing the actual content of the peer
Parameters:
i - the peer image
shouldRenderPeerImage
protected boolean shouldRenderPeerImage()

Subclasses should return true here if the peer image should be rendered instead of
the actual peer
Returns:
true to render the peer image

Methods inherited from class java.lang.Object

1518

Overview (Codename One API)


create
public static PeerComponent create(Object nativePeer)

Use this method to encapsulate a native UI object


Parameters:
nativePeer - the native platform specific peer component.
getNativePeer
public Object getNativePeer()

Returns the native peer instance


Returns:
the native peer
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content
calcScrollSize
protected Dimension calcScrollSize()

Method that can be overriden to represent the actual size of the component when it
differs from the desireable size for the viewport
Overrides:
calcScrollSize in class Component
Returns:
scroll size, by default this is the same as the preferred size
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component

Method Detail

1519

Overview (Codename One API)


focusGained
protected void focusGained()

Callback allowing a developer to track wheh the component gains focus


Overrides:
focusGained in class Component
focusLost
protected void focusLost()

Callback allowing a developer to track wheh the component loses focus


Overrides:
focusLost in class Component
handlesInput
public boolean handlesInput()

Prevents key events from being grabbed for focus traversal. E.g. a list component
might use the arrow keys for internal navigation so it will switch this flag to true in
order to prevent the focus manager from moving to the next component.
Overrides:
handlesInput in class Component
Returns:
true if key events are being used for focus traversal ; otherwise false
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
keyRepeated
public void keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
Overrides:
keyRepeated in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.

Method Detail

1520

Overview (Codename One API)


Specified by:
paint

in interface Animation

Overrides:
paint in class Component
Parameters:
g - the component graphics
paintBackground
protected void paintBackground(Graphics g)

This method paints the Component background, it should be overriden by subclasses


to perform custom background drawing.
Overrides:
paintBackground in class Component
Parameters:
g - the component graphics
paintBackgrounds
public void paintBackgrounds(Graphics g)

This method paints all the parents Components Background.


Overrides:
paintBackgrounds in class Component
Parameters:
g - the graphics object
paintBorder
protected void paintBorder(Graphics g)

Draws the component border if such a border exists. The border unlike the content of
the component will not be affected by scrolling for a scrollable component.
Overrides:
paintBorder in class Component
Parameters:
g - graphics context on which the border is painted
paintScrollbarX
protected void paintScrollbarX(Graphics g)

Paints the UI for the scrollbar on the X axis, this method allows component
subclasses to customize the look of a scrollbar
Overrides:
paintScrollbarX in class Component
Parameters:
g - the component graphics
paintScrollbarY
protected void paintScrollbarY(Graphics g)

Paints the UI for the scrollbar on the Y axis, this method allows component
subclasses to customize the look of a scrollbar
Overrides:
paintScrollbarY in class Component
Parameters:
g - the component graphics
paintScrollbars
protected void paintScrollbars(Graphics g)

Paints the UI for the scrollbars on the component, this will be invoked only for
scrollable components. This method invokes the appropriate X/Y versions to do all
the work.
Overrides:
paintScrollbars in class Component
Parameters:
g - the component graphics

Method Detail

1521

Overview (Codename One API)


pointerDragged
public void pointerDragged(int[] x,
int[] y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int[] x,
int[] y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

Method Detail

1522

Overview (Codename One API)


pointerReleased
public void pointerReleased(int[] x,
int[] y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
invalidate
public void invalidate()

Updates the size of the component from the native widget


onPositionSizeChange
protected void onPositionSizeChange()

Callback useful for sublclasses that need to track the change in size/position of the
component (notice that this might be invoked too many times for a single change)!
setLightweightMode
protected void setLightweightMode(boolean l)

An optional callback for peers indicating that the peer is now rendered as part of a
transition or some other state and is thus not truly visible. In this case the peer should
either make itself invisible or render itself as an image instead of natively
Parameters:
l - true to enable lightweight mode, false to disable it

Method Detail

1523

Overview (Codename One API)


com.codename1.ui

Interface Painter
All Known Implementing Classes:
BackgroundPainter, GlassTutorial, PainterChain, Timeline

public interface

Painter can be used to draw on components backgrounds. The use of such painter allows reuse of a
background painters for various components. Note in order to view the painter drawing, component
need to have some level of transparency. Usage:
Painter p = new Painter(cmp) {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
int r = Math.min(rect.getWidth(), rect.getHeight())/2;
int x = rect.getX() + rect.getWidth()/2 - r;
int y = rect.getY() + rect.getHeight()/2 - r;
switch (style) {
case CircleButtonStrokedDark:
case CircleButtonStrokedLight: {
if (cmp.getStyle().getBgTransparency() != 0) {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha <0) {
alpha = 0xff;
}
g.setColor(cmp.getStyle().getBgColor());
g.setAlpha(alpha);
g.fillArc(x, y, 2*r-1, 2*r-1, 0, 360);
g.setAlpha(0xff);
}
g.setColor(cmp.getStyle().getFgColor());
g.drawArc(x, y, 2*r-1, 2*r-1, 0, 360);
break;
}
case CircleButtonFilledDark:
case CircleButtonFilledLight:
case CircleButtonTransparentDark:
case CircleButtonTransparentLight: {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha < 0) {
alpha = 0xff;
}
g.setAlpha(alpha);
g.setColor(cmp.getStyle().getBgColor());
g.fillArc(x, y, 2*r, 2*r, 0, 360);
g.setAlpha(0xff);
break;
}
}
g.setAntiAliased(antiAliased);
}
};
cmp.getAllStyles().setBgPainter(p);

Method Summary
Modifier and Type
void

Method and Description


paint(Graphics g, Rectangle rect)

Draws inside the given rectangle clipping area.

Method Detail
paint
void paint(Graphics g,
Rectangle rect)

Draws inside the given rectangle clipping area.

Interface Painter

1524

Overview (Codename One API)


Parameters:
g - the Graphics object
rect - the given rectangle cliping area

Method Detail

1525

Overview (Codename One API)


com.codename1.ui

Class NavigationCommand
java.lang.Object

com.codename1.ui.Command

com.codename1.ui.NavigationCommand
All Implemented Interfaces:
ActionListener

public class
extends Command

The NavigationCommand is a Command that navigates to a given Form. The NavigationCommand


calls the show() on the Form object that is returned from getNextForm().

Constructor Summary
Constructor and Description
NavigationCommand(String command)

Creates a new instance of NavigationCommand


NavigationCommand(String command, Image icon)

Creates a new instance of NavigationCommand


NavigationCommand(String command, Image icon, int id)

Creates a new instance of NavigationCommand


NavigationCommand(String command, int id)

Creates a new instance of NavigationCommand

Method Summary
Modifier and
Type

Method and Description


actionPerformed(ActionEvent evt)

void

This method is called when the soft button/Menu item is clicked


getNextForm()

Form

Gets the next Form


setNextForm(Form nextForm)

Sets the Form to navigate to when the actionPerformed is invoked on this


Command

void

Methods inherited from class com.codename1.ui.Command


create, equals, getClientProperty, getCommandName, getDisabledIcon,
getIcon, getId, getPressedIcon, getRolloverIcon, hashCode,
isDisposesDialog, isEnabled, putClientProperty, setCommandName,
setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setPressedIcon,
setRolloverIcon, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Class NavigationCommand

1526

Overview (Codename One API)


NavigationCommand
public NavigationCommand(String command)

Creates a new instance of NavigationCommand


Parameters:
command - the string that will be placed on the Soft buttons\Menu
NavigationCommand
public NavigationCommand(String command,
Image icon)

Creates a new instance of NavigationCommand


Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command
NavigationCommand
public NavigationCommand(String command,
int id)

Creates a new instance of NavigationCommand


Parameters:
command - the string that will be placed on the Soft buttons\Menu
id - user defined ID for a command simplifying switch statement code
working with a command
NavigationCommand
public NavigationCommand(String command,
Image icon,
int id)

Creates a new instance of NavigationCommand


Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command
id - user defined ID for a command simplifying switch statement code
working with a command

Method Detail
setNextForm
public void setNextForm(Form nextForm)

Sets the Form to navigate to when the actionPerformed is invoked on this Command
Parameters:
nextForm - The next Form
getNextForm
public Form getNextForm()

Gets the next Form


Returns:
the next Form
actionPerformed
public void actionPerformed(ActionEvent evt)

Description copied from class: Command


This method is called when the soft button/Menu item is clicked
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class Command
Parameters:

Constructor Detail

1527

Overview (Codename One API)


evt

Method Detail

- the Event Object

1528

Overview (Codename One API)


com.codename1.ui

Class MenuBar
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.MenuBar
All Implemented Interfaces:
Animation, ActionListener, StyleListener, Iterable<Component>
Direct Known Subclasses:
SideMenuBar

public class
extends Container
implements ActionListener

This class represents the Form MenuBar. This class is responsible to show the Form Commands and
to handle device soft keys, back key, clear key, etc... This class can be overridden and replaced in the
LookAndFeel
See Also:
LookAndFeel.setMenuBarClass(java.lang.Class)

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
MenuBar()

Empty Constructor

Method Summary
Modifier
and Type
void
void

Method and Description


actionPerformed(ActionEvent evt)

Invoked when a softbutton is pressed


addCommand(Command cmd)

Adds a Command to the MenuBar

protected
void

addCommand(Command cmd, int index)

protected
Dimension

calcPreferredSize()

protected
int
protected
Button

Add a Command to the MenuBar


Prevents scaling down of the menu when there is no text on the menu bar
calculateTouchCommandGridColumns(Container grid)

Calculates the amount of columns to give to the touch commands within the
grid
createBackCommandButton()
createCommandComponent(Vector commands)

Class MenuBar

1529

Overview (Codename One API)


protected
Component

protected
List

Creates the component containing the commands within the given vector used
for showing the menu dialog, this method calls the createCommandList
method by default however it allows more elaborate menu creation.
createCommandList(Vector commands)

Creates the list component containing the commands within the given vector
used for showing the menu dialog

protected
Command

createMenuCancelCommand()

protected
Command

createMenuSelectCommand()

protected
Command

createSelectCommand()

protected
Button

createSoftButton(String uiid)

protected
Button

createTouchCommandButton(Command c)

Button
Command
protected
Command
Command
Command
int
int
protected
Vector

Factory method that returns the Form Menu cancel Command.


Factory method that returns the Form Menu select Command.
Factory method that returns the Form select Command.
Creates a soft button Component
Creates a touch command for use as a touch menu item
findCommandComponent(Command c)

Find the command component instance if such an instance exists


getBackCommand()

Indicates the command that is defined as the back command out of this form.
getCancelMenuItem()

This method returns the cancel menu item, when a menu is opened
getClearCommand()

Indicates the command that is defined as the clear command in this form.
getCommand(int index)

Returns the command occupying the given index


getCommandBehavior()
getCommandCount()

Returns number of commands


getCommands()

This method returns a Vector of Command objects


getDefaultCommand()

Command

Default command is invoked when a user presses fire, this functionality works
well in some situations but might collide with elements such as navigation and
combo boxes.
getDragRegionStatus(int x, int y)

protected
int

Style

Indicates if the section within the X/Y area is a "drag region" where we expect
people to drag or press in which case we can instantly start dragging making
perceived performance faster.
getMenuStyle()

Returns the Menu Dialog Style


getSelectCommand()

Command

The selectCommand is the command to invoke when a Component has foucs


in Third Soft Button state.

protected
Command

getSelectMenuItem()

protected
Container

getTitleAreaContainer()

protected
Component

getTitleComponent()

boolean

This method returns the select menu item, when a menu is opened
Returns the parent Form title area
Gets the Form titleComponent
handlesKeycode(int keyCode)

This method returns true if the MenuBar should handle the given keycode.

protected
void

initMenuBar(Form parent)

protected
void

installMenuBar()

boolean

Method Summary

Initialize the MenuBar


Adds the MenuBar on the parent Form
isMinimizeOnBack()

When set to true the physical back button will minimize the application

1530

Overview (Codename One API)


protected
boolean

isReverseSoftButtons()

Allows an individual form to reverse the layout direction of the softbuttons, this
method is RTL sensitive and might reverse the result based on RTL state
keyPressed(int keyCode)

void

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

void

If this Component is focused, the key released event will call this method
refreshTheme(boolean merge)

void

Makes sure the component is up to date with the current theme, ONLY
INVOKE THIS METHOD IF YOU CHANGED THE THEME!

protected
void

removeAllCommands()

protected
void

removeCommand(Command cmd)

Remove all commands from the menuBar


Removes a Command from the MenuBar
removeEmptySoftbuttons()

void

This method removes empty J2ME softbuttons that don't have a command
setBackCommand(Command backCommand)

void

Indicates the command that is defined as the back command out of this form.
setClearCommand(Command clearCommand)

void

Indicates the command that is defined as the clear command in this form.
setCommandUIID(Command cmd, String uiid)

Sets the command UIID to the given UIID, notice that this won't work for all
menu types since some menu types might be implemented natively or as a list
in which case the UIID won't apply!

void

setDefaultCommand(Command defaultCommand)

Default command is invoked when a user presses fire, this functionality works
well in some situations but might collide with elements such as navigation and
combo boxes.

void

setMenuCellRenderer(ListCellRenderer menuCellRenderer)

The MenuBar default implementation shows the menu commands in a List


contained in a Dialog.

void

setMinimizeOnBack(boolean minimizeOnBack)

void

When set to true the physical back button will minimize the application
setSelectCommand(Command selectCommand)

void

Sets the select command


setTransitions(Transition transitionIn, Transition transitionOut)

void

Sets the menu transitions for showing/hiding the menu, can be null...
setUnselectedStyle(Style style)

Changes the Component Style by replacing the Component Style with the
given Style

void

showMenu()

void

This method shows the menu on the Form.

protected
Command
protected
void

showMenuDialog(Dialog menu)

A menu is implemented as a dialog, this method allows you to override dialog


display in order to customize the dialog menu in various ways
unInstallMenuBar()

Removes the MenuBar from the parent Form

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,

Methods inherited from class com.codename1.ui.Container

1531

Overview (Codename One API)


isSelectableInteraction, iterator, layoutContainer, morph, morphAndWait,
paint, paintComponentBackground, paintGlass, paramString, pointerHover,
pointerPressed, removeAll, removeComponent, replace, replace,
replaceAndWait, replaceAndWait, replaceAndWait, revalidate,
scrollComponentToVisible, setCellRenderer, setEnabled, setLayout,
setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile,
isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable,
isDragRegion, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents,
isHidden, isHideInPortrait, isInClippingRegion, isInitialized, isRTL,
isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid,
isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX,
onScrollY, paintBackground, paintBackgrounds, paintBorder,
paintBorderBackground, paintComponent, paintComponent, paintLock,
paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch,
pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased,
pointerPressed, pointerReleased, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setPropertyValue, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

Methods inherited from class com.codename1.ui.Component

1532

Overview (Codename One API)


MenuBar
public MenuBar()

Empty Constructor

Method Detail
initMenuBar
protected void initMenuBar(Form parent)

Initialize the MenuBar


Parameters:
parent - the associated Form
removeEmptySoftbuttons
public void removeEmptySoftbuttons()

This method removes empty J2ME softbuttons that don't have a command
getCommandBehavior
public int getCommandBehavior()

setDefaultCommand
public void setDefaultCommand(Command defaultCommand)

Default command is invoked when a user presses fire, this functionality works well in
some situations but might collide with elements such as navigation and combo boxes.
Use with caution.
Parameters:
defaultCommand - the command to treat as default
getDefaultCommand
public Command getDefaultCommand()

Default command is invoked when a user presses fire, this functionality works well in
some situations but might collide with elements such as navigation and combo boxes.
Use with caution.
Returns:
the command to treat as default
setClearCommand
public void setClearCommand(Command clearCommand)

Indicates the command that is defined as the clear command in this form. A clear
command can be used both to map to a "clear" hardware button if such a button
exists.
Parameters:
clearCommand - the command to treat as the clear Command
getClearCommand
public Command getClearCommand()

Indicates the command that is defined as the clear command in this form. A clear
command can be used both to map to a "clear" hardware button if such a button
exists.
Returns:
the command to treat as the clear Command
findCommandComponent
public Button findCommandComponent(Command c)

Find the command component instance if such an instance exists


Parameters:
c - the command instance

Constructor Detail

1533

Overview (Codename One API)


Returns:
the button instance
setBackCommand
public void setBackCommand(Command backCommand)

Indicates the command that is defined as the back command out of this form. A back
command can be used both to map to a hardware button (e.g. on the Sony Ericsson
devices) and by elements such as transitions etc. to change the behavior based on
direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
Parameters:
backCommand - the command to treat as the back Command
getBackCommand
public Command getBackCommand()

Indicates the command that is defined as the back command out of this form. A back
command can be used both to map to a hardware button (e.g. on the Sony Ericsson
devices) and by elements such as transitions etc. to change the behavior based on
direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
Returns:
the command to treat as the back Command
getSelectCommand
public Command getSelectCommand()

The selectCommand is the command to invoke when a Component has foucs in


Third Soft Button state.
Returns:
the select command
setSelectCommand
public void setSelectCommand(Command selectCommand)

Sets the select command


Parameters:
selectCommand actionPerformed
public void actionPerformed(ActionEvent evt)

Invoked when a softbutton is pressed


Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - event object describing the source of the action as well as its trigger
createSoftButton
protected Button createSoftButton(String uiid)

Creates a soft button Component


Returns:
the softbutton component
setUnselectedStyle
public void setUnselectedStyle(Style style)

Changes the Component Style by replacing the Component Style with the given Style
Overrides:
setUnselectedStyle in class Component
Parameters:
style - the component Style object
calcPreferredSize
protected Dimension calcPreferredSize()

Prevents scaling down of the menu when there is no text on the menu bar

Method Detail

1534

Overview (Codename One API)


Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content
setTransitions
public void setTransitions(Transition transitionIn,
Transition transitionOut)

Sets the menu transitions for showing/hiding the menu, can be null...
showMenu
public void showMenu()

This method shows the menu on the Form. The method creates a Dialog with the
commands and calls showMenuDialog. The method blocks until the user dispose the
dialog.
createBackCommandButton
protected Button createBackCommandButton()

addCommand
public void addCommand(Command cmd)

Adds a Command to the MenuBar


Parameters:
cmd - Command to add
getCommand
public Command getCommand(int index)

Returns the command occupying the given index


Parameters:
index - offset of the command
Returns:
the command at the given index
getCommandCount
public int getCommandCount()

Returns number of commands


Returns:
number of commands
addCommand
protected void addCommand(Command cmd,
int index)

Add a Command to the MenuBar


Parameters:
cmd - Command to Add
index - determines the order of the added commands
installMenuBar
protected void installMenuBar()

Adds the MenuBar on the parent Form


unInstallMenuBar
protected void unInstallMenuBar()

Removes the MenuBar from the parent Form


removeAllCommands
protected void removeAllCommands()

Remove all commands from the menuBar

Method Detail

1535

Overview (Codename One API)


removeCommand
protected void removeCommand(Command cmd)

Removes a Command from the MenuBar


Parameters:
cmd - Command to remove
createSelectCommand
protected Command createSelectCommand()

Factory method that returns the Form select Command. This Command is used when
Display.getInstance().isThirdSoftButton() returns true. This method can be overridden
to customize the Command on the Form.
Returns:
Command
createMenuSelectCommand
protected Command createMenuSelectCommand()

Factory method that returns the Form Menu select Command. This method can be
overridden to customize the Command on the Form.
Returns:
Command
createMenuCancelCommand
protected Command createMenuCancelCommand()

Factory method that returns the Form Menu cancel Command. This method can be
overridden to customize the Command on the Form.
Returns:
Command
setMenuCellRenderer
public void setMenuCellRenderer(ListCellRenderer menuCellRenderer)

The MenuBar default implementation shows the menu commands in a List contained
in a Dialog. This method replaces the menu ListCellRenderer of the Menu List.
Parameters:
menuCellRenderer getMenuStyle
public Style getMenuStyle()

Returns the Menu Dialog Style


Returns:
Menu Dialog Style
handlesKeycode
public boolean handlesKeycode(int keyCode)

This method returns true if the MenuBar should handle the given keycode.
Parameters:
keyCode - to determine if the MenuBar is responsible for.
Returns:
true if the keycode is a MenuBar related keycode such as softkey, back
button, clear button, ...
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Container
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

1536

Overview (Codename One API)


keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Container
Parameters:
keyCode - the key code value to indicate a physical key.
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Container
Parameters:
merge - indicates if the current styles should be merged with the new styles
showMenuDialog
protected Command showMenuDialog(Dialog menu)

A menu is implemented as a dialog, this method allows you to override dialog display
in order to customize the dialog menu in various ways
Parameters:
menu - a dialog containing menu options that can be customized
Returns:
the command selected by the user in the dialog (not menu) Select or Cancel
isReverseSoftButtons
protected boolean isReverseSoftButtons()

Allows an individual form to reverse the layout direction of the softbuttons, this
method is RTL sensitive and might reverse the result based on RTL state
Returns:
The value of
UIManager.getInstance().getLookAndFeel().isReverseSoftButtons()
calculateTouchCommandGridColumns
protected int calculateTouchCommandGridColumns(Container grid)

Calculates the amount of columns to give to the touch commands within the grid
Parameters:
grid - container that will be arranged in the grid containing the components
Returns:
an integer representing the touch command grid size
setCommandUIID
public void setCommandUIID(Command cmd,
String uiid)

Sets the command UIID to the given UIID, notice that this won't work for all menu
types since some menu types might be implemented natively or as a list in which
case the UIID won't apply!
Parameters:
cmd - the command
uiid - the uiid for the given command
createTouchCommandButton
protected Button createTouchCommandButton(Command c)

Creates a touch command for use as a touch menu item


Parameters:
c - command to map into the returned button
Returns:
a button that would fire the touch command appropriately

Method Detail

1537

Overview (Codename One API)


createCommandComponent
protected Component createCommandComponent(Vector commands)

Creates the component containing the commands within the given vector used for
showing the menu dialog, this method calls the createCommandList method by
default however it allows more elaborate menu creation.
Parameters:
commands - list of command objects
Returns:
Component that will result in the parent menu dialog recieving a command
event
getCommands
protected Vector getCommands()

This method returns a Vector of Command objects


Returns:
Vector of Command objects
createCommandList
protected List createCommandList(Vector commands)

Creates the list component containing the commands within the given vector used for
showing the menu dialog
Parameters:
commands - list of command objects
Returns:
List object
getSelectMenuItem
protected Command getSelectMenuItem()

This method returns the select menu item, when a menu is opened
Returns:
select Command
getCancelMenuItem
protected Command getCancelMenuItem()

This method returns the cancel menu item, when a menu is opened
Returns:
cancel Command
isMinimizeOnBack
public boolean isMinimizeOnBack()

When set to true the physical back button will minimize the application
Returns:
the minimizeOnBack
setMinimizeOnBack
public void setMinimizeOnBack(boolean minimizeOnBack)

When set to true the physical back button will minimize the application
Parameters:
minimizeOnBack - the minimizeOnBack to set
getDragRegionStatus
protected int getDragRegionStatus(int x,
int y)

Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Overrides:

Method Detail

1538

Overview (Codename One API)


getDragRegionStatus in class Component
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values
getTitleAreaContainer
protected Container getTitleAreaContainer()

Returns the parent Form title area


Returns:
the title area Container
getTitleComponent
protected Component getTitleComponent()

Gets the Form titleComponent


Returns:
titleComponent

Method Detail

1539

Overview (Codename One API)


com.codename1.ui

Class List<T>
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.List<T>
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
ComboBox, MultiList, RSSReader

public class
extends Component

A set of elements that is rendered using a ListCellRenderer and are extracted via the ListModel.
A list can represent many UI concepts ranging from a carousel to a "todo" checklist, this is made
possible thanks to extensive use of Swing's style of MVC. Specifically a list component is relatively
simple, it invokes the model in order to extract the displayed/selected information and shows it to the
user by invoking the cell renderer.
The list class itself is completely decoupled from everything, thus it allows us to extract its content
from any source (e.g. network, storage etc.) and display the information in any form (e.g. checkboxed
elemenents, icons etc.).

Important
List is a pretty complex class to use so we generally recommend developers use Container,
InfiniteScrollAdapter or InfiniteContainer coupled with widgets such as MultiButton. Arranging
those in a BoxLayout on the BoxLayout.Y_AXIS can produce the functionality of the List with better

performance and far simpler code!


Another simpler alternative although not as attractive is the MultiList class that removes a lot of the
ListCellRenderer related complexities inherent in building a list.
Sample Usage
The sample below uses the GenericListCellRenderer class instead of the DefaultListCellRenderer.
We generally recommend using the builtin classes as the renderer is probably the greatest source of
pitfalls in Lists.
com.codename1.ui.List list = new com.codename1.ui.List(createGenericListCellRendererModelData());
list.setRenderer(new GenericListCellRenderer(createGenericRendererContainer(), createGenericRendererContainer()));

private Container createGenericRendererContainer() {


Label name = new Label();
name.setFocusable(true);
name.setName("Name");
Label surname = new Label();
surname.setFocusable(true);
surname.setName("Surname");
CheckBox selected = new CheckBox();
selected.setName("Selected");
selected.setFocusable(true);
Container c = BorderLayout.center(name).
add(BorderLayout.SOUTH, surname).
add(BorderLayout.WEST, selected);
c.setUIID("ListRenderer");
return c;
}
private Object[] createGenericListCellRendererModelData() {
Map<String,Object>[] data = new HashMap[5];
data[0] = new HashMap<>();
data[0].put("Name", "Shai");
data[0].put("Surname", "Almog");
data[0].put("Selected", Boolean.TRUE);
data[1] = new HashMap<>();
data[1].put("Name", "Chen");
data[1].put("Surname", "Fishbein");
data[1].put("Selected", Boolean.TRUE);

Class List<T>

1540

Overview (Codename One API)


data[2] = new HashMap<>();
data[2].put("Name", "Ofir");
data[2].put("Surname", "Leitner");
data[3] = new HashMap<>();
data[3].put("Name", "Yaniv");
data[3].put("Surname", "Vakarat");
data[4] = new HashMap<>();
data[4].put("Name", "Meirav");
data[4].put("Surname", "Nachmanovitch");
return data;
}

See Also:
Container, InfiniteContainer, InfiniteScrollAdapter, MultiButton,
com.codename1.ui.list, MultiList

Field Summary
Modifier and
Type
static int

Field and Description


FIXED_CENTER

Indicates the list selection is fixed into place at the center of the list
FIXED_LEAD

static int

static int
static int

Indicates the list selection is fixed into place at the top of the list or at the left
of the list
FIXED_NONE

Indicates the list isn't fixed and that selection is movable


FIXED_NONE_CYCLIC

Indicates that the list is not fixed in place but cycles its elements
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE

static int

Indicates the list selection will only reach the edge when there are no more
elements in the list.
FIXED_TRAIL

static int

static int
static int

Important

Indicates the list selection is fixed into place at the bottom of the list or at the
right of the list
HORIZONTAL

Indicates the list orientation is HORIZONTAL


VERTICAL

1541

Overview (Codename One API)


Indicates the list orientation is VERTICAL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
List()

Creates a new instance of List with an empty default model


List(ListModel model)

Creates a new instance of List with the given model


List(T... items)

Creates a new instance of List


List(Vector items)

Creates a new instance of List

Method Summary
Modifier and
Type
void

Method and Description


addActionListener(ActionListener l)

Allows binding a listener to user selection actions


addItem(T item)

void

void
boolean
protected
Dimension

Allows adding an element to a list if the underlying model supports this, notice that
operation and if the model does not support it (default list model does) then this op
addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


fireActionEvent()

protected void

protected void

This method allows us to detect an action event internally without implementing the
interface.
fireActionEvent(ActionEvent a)

Triggers the event to the listeners


fireClicked()

protected void

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this met
button devices to work properly.
getActionListeners()

Vector

int

Deprecated.
use getListeners instead
getCurrentSelected()

Returns the visual selection during a drag operation, otherwise equivalent to mode
getDragRegionStatus(int x, int y)

protected int

Indicates if the section within the X/Y area is a "drag region" where we expect peop
which case we can instantly start dragging making perceived performance faster.
getFixedSelection()

Field Summary

int

Indicates whether selection is fixable to place in which case all the elements in the
stays in place.

protected int

getGridPosX()

1542

Overview (Codename One API)


This method should be implemented correctly by subclasses to make snap to grid
expected.
getGridPosY()
protected int

String
Image
int
Collection
int
int
int
ListModel<T>
int
ListCellRenderer
T
int
T

This method should be implemented correctly by subclasses to make snap to grid


expected.
getHint()

Returns the hint text


getHintIcon()

Returns the hint icon


getItemGap()

Returns the gap between items


getListeners()

This method allows extracting the action listeners from the current list
getListSizeCalculationSampleCount()

Indicates the number of elements the list should check to determine the element si
getMaxElementHeight()

Maximum number of elements shown in a list, this member is used to calculate the
getMinElementHeight()

Minimum number of elements shown in a list, this member is used to calculate the
getModel()

Returns the model underlying the list


getOrientation()

Returns the list orientation


getRenderer()

Returns the renderer which is used to draw list elements


getRenderingPrototype()

See set rendering prototype


getSelectedIndex()

Returns the current selected offset in the list


getSelectedItem()

Returns the current selected item in the list or null for no selection
getSelectedRect()

Rectangle

int
protected
Rectangle
protected void

Returns the component bounds with absolute screen coordinates, for components
selection behavior and are not containers (currently only List) this method allows re
the selection itself which is useful for things such as the popup dialog and similar U
reference the position of the selection externally
getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis.
getVisibleBounds()

Returns the component bounds for scrolling which might differ from the getBounds
e.g.
initLaf(UIManager uim)

This method initializes the Component defaults constants


isCommandList()

boolean

static boolean
static boolean
boolean
boolean

Indicates that the list should be treated as a list of commands, if the user "clicks" a
its action performed method is invoked.
isDefaultFireOnClick()

Default value for the fire on click behavior


isDefaultIgnoreFocusComponentWhenUnfocused()

Indicates whether the list should not paint the focus component if the list itself has
isIgnoreFocusComponentWhenUnfocused()

Indicates whether the list should not paint the focus component if the list itself has
isLongPointerPressActionEnabled()

Enable/disable list action on long pointer press event


isMutableRendererBackgrounds()

boolean

Indicates that the background of a cell renderer might mutate between one entry a
recommended that this flag remains false for performance reasons.

boolean

isNumericKeyActions()

Method Summary

1543

Overview (Codename One API)


Indicate whether pressing the number keys should trigger an action
boolean
boolean
protected
boolean
protected
boolean
void
void
protected void
protected void

isScrollableX()

Indicates whether the component should/could scroll on the X axis


isScrollableY()

Indicates whether the component should/could scroll on the Y axis


isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" sele


in the "fire" button when 3 softbuttons are defined in a device.
isTactileTouch(int x, int y)

Elaborate components might not provide tactile feedback for all their areas (e.g.
keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
laidOut()

This is a callback method to inform the Component when it's been laidout on the pa
listSelectionChanged(int oldSelected, int newSelected)

Callback to allow subclasses to react to a selection change in the model


longPointerPress(int x, int y)

void

protected void

If this Component is focused this method is invoked when the user presses and ho
Component
modelChanged(int status, int index)

Callback to allow subclasses to react to a change in the model


paint(Graphics g)

void

protected String
void
void
void
void
void

This method paints the Component on the screen, it should be overriden by subcla
drawing or invoke the UI API's to let the PLAF perform the rendering.
paramString()

Returns a string representing the state of this component.


pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerHover(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the displa
pointerHoverReleased(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the displa
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
refreshTheme(boolean merge)

void

void
void
void

Makes sure the component is up to date with the current theme, ONLY INVOKE TH
CHANGED THE THEME!
removeActionListener(ActionListener l)

Allows binding a listener to user selection actions


removeSelectionListener(SelectionListener l)

Invoked to indicate no further interest in future selection events


scrollRectToVisible(Rectangle rect)

Makes sure the selected index is visible if it is not in the current view rect the list w
setCommandList(boolean commandList)

void

static void
static void

Indicates that the list should be treated as a list of commands, if the user "clicks" a
its action performed method is invoked.
setDefaultFireOnClick(boolean aDefaultFireOnClick)

Default value for the fire on click behavior

setDefaultIgnoreFocusComponentWhenUnfocused(boolean aDefaultIgnoreFocusCo

Indicates whether the list should not paint the focus component if the list itself has
setFireOnClick(boolean fireOnClick)

void

Method Summary

This method determines if the List fires the action event when the pointer was click
or only if the item was the selected item By default the value is true, this setting is o
fixed Lists

1544

Overview (Codename One API)


setFixedSelection(int fixedSelection)
void

void
void

Indicates whether selection is fixable to place in which case all the elements in the
stays in place.
setHandlesInput(boolean b)

Prevents key events from being grabbed for focus traversal.


setHint(String hint)

Sets the TextArea hint text, the hint text is displayed on the TextArea When there i
setHint(String hint, Image icon)

void

void
void

Sets the TextArea hint text and Icon, the hint text and icon are displayed on the Te
text in the TextArea
setHintIcon(Image icon)

Sets the TextArea hint icon, the hint is displayed on the TextArea When there is no

setIgnoreFocusComponentWhenUnfocused(boolean ignoreFocusComponentWhenUnfo

Indicates whether the list should not paint the focus component if the list itself has
setInputOnFocus(boolean inputOnFocus)

void

void

A list can start handling input implicitly upon gaining focus, this can make for a mor
other focus elements exist or when their use case is infrequent.
setItemGap(int itemGap)

Set the gap between items


setListCellRenderer(ListCellRenderer renderer)

void

void
void
void
void
void

Deprecated.
use setRenderer instead, this method was deprecated to confirm better to JavaBea
the getter/setter with the same name
setListSizeCalculationSampleCount(int listSizeCalculationSampleCount)

Indicates the number of elements the list should check to determine the element si
setLongPointerPressActionEnabled(boolean longPointerPressAction)

Enable/disable list action on long pointer press event


setMaxElementHeight(int maxElementHeight)

Maximum number of elements shown in a list, this member is used to calculate the
setMinElementHeight(int minElementHeight)

Minimum number of elements shown in a list, this member is used to calculate the
setModel(ListModel model)

Replaces/sets the model underlying the list


setMutableRendererBackgrounds(boolean mutableRendererBackgrounds)

void

void
void
void
void

Indicates that the background of a cell renderer might mutate between one entry a
recommended that this flag remains false for performance reasons.
setNumericKeyActions(boolean numericKeyActions)

Indicate whether pressing the number keys should trigger an action


setOrientation(int orientation)

Sets the list orientation HORIZONTAL or VERTICAL


setPaintFocusBehindList(boolean paintFocusBehindList)

This method determines if the animated focus is drawn on top of the List or behind
setRenderer(ListCellRenderer renderer)

Sets the renderer which is used to draw list elements


setRenderingPrototype(T renderingPrototype)

void

void

The rendering prototype is optionally used in calculating the size of the List and is r
performance reasons.
setScrollToSelected(boolean scrollToSelected)

This flag indicates to the List if the List should scroll to the selected element when
setSelectedIndex(int index)

void

void
void
void

Method Summary

Sets the current selected offset in the list, by default this implementation will scroll
the selection is outside of the screen
setSelectedIndex(int index, boolean scrollToSelection)

Sets the current selected offset in the list


setSelectedItem(T item)

Sets the current selected item in the list


setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and preferred size should

1545

Overview (Codename One API)


protected
boolean

shouldRenderSelection()

Allows subclasses to override the selection rendering for the component, specifica
themes
size()

int

Returns the number of elements in the list, shorthand for getModel().getSize()

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitialize, deinitializeCustomStyle,
dragEnter, dragExit, dragFinished, draggingOver, dragInitiated,
drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedStyle, getStyle, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getWidth, getX, getY, growShrink, handlesInput,
hasFocus, initComponent, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, longKeyPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
FIXED_NONE
public static final int FIXED_NONE

Indicates the list isn't fixed and that selection is movable

Methods inherited from class com.codename1.ui.Component

1546

Overview (Codename One API)


See Also:
Constant Field Values
FIXED_NONE_CYCLIC
public static final int FIXED_NONE_CYCLIC

Indicates that the list is not fixed in place but cycles its elements
See Also:
Constant Field Values
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE
public static final int FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE

Indicates the list selection will only reach the edge when there are no more elements
in the list.
See Also:
Constant Field Values
FIXED_LEAD
public static final int FIXED_LEAD

Indicates the list selection is fixed into place at the top of the list or at the left of the
list
See Also:
Constant Field Values
FIXED_TRAIL
public static final int FIXED_TRAIL

Indicates the list selection is fixed into place at the bottom of the list or at the right of
the list
See Also:
Constant Field Values
FIXED_CENTER
public static final int FIXED_CENTER

Indicates the list selection is fixed into place at the center of the list
See Also:
Constant Field Values
VERTICAL
public static final int VERTICAL

Indicates the list orientation is VERTICAL


See Also:
Constant Field Values
HORIZONTAL
public static final int HORIZONTAL

Indicates the list orientation is HORIZONTAL


See Also:
Constant Field Values

Constructor Detail
List
public List(Vector items)

Creates a new instance of List


Parameters:
items - set of items placed into the list model

Field Detail

1547

Overview (Codename One API)


List
public List(T... items)

Creates a new instance of List


Parameters:
items - set of items placed into the list model
List
public List()

Creates a new instance of List with an empty default model


List
public List(ListModel model)

Creates a new instance of List with the given model


Parameters:
model - the model instance

Method Detail
isDefaultIgnoreFocusComponentWhenUnfocused
public static boolean isDefaultIgnoreFocusComponentWhenUnfocused()

Indicates whether the list should not paint the focus component if the list itself has no
focus.
Returns:
the defaultIgnoreFocusComponentWhenUnfocused
setDefaultIgnoreFocusComponentWhenUnfocused

public static void setDefaultIgnoreFocusComponentWhenUnfocused(boolean aDefaultIgnor

Indicates whether the list should not paint the focus component if the list itself has no
focus.
Parameters:
aDefaultIgnoreFocusComponentWhenUnfocused - the
defaultIgnoreFocusComponentWhenUnfocused to set
isDefaultFireOnClick
public static boolean isDefaultFireOnClick()

Default value for the fire on click behavior


Returns:
the defaultFireOnClick
setDefaultFireOnClick
public static void setDefaultFireOnClick(boolean aDefaultFireOnClick)

Default value for the fire on click behavior


Parameters:
aDefaultFireOnClick - the defaultFireOnClick to set
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Component
laidOut
protected void laidOut()

This is a callback method to inform the Component when it's been laidout on the
parent Container

Constructor Detail

1548

Overview (Codename One API)


Overrides:
laidOut

in class Component

modelChanged
protected void modelChanged(int status,
int index)

Callback to allow subclasses to react to a change in the model


Parameters:
status - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model
listSelectionChanged
protected void listSelectionChanged(int oldSelected,
int newSelected)

Callback to allow subclasses to react to a selection change in the model


Parameters:
oldSelected - the old selection value
newSelected - the new selection value
getSideGap
public int getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis. This method is used by
layout managers to determine the room they should leave for the scrollbar. (note:
side scrollbar rather than left scrollbar is used for a future version that would support
bidi).
Overrides:
getSideGap in class Component
Returns:
the gap to be left for the side scrollbar on the Y axis
isScrollableY
public boolean isScrollableY()

Indicates whether the component should/could scroll on the Y axis


Overrides:
isScrollableY in class Component
Returns:
whether the component is scrollable on the X axis
isScrollableX
public boolean isScrollableX()

Indicates whether the component should/could scroll on the X axis


Overrides:
isScrollableX in class Component
Returns:
whether the component is scrollable on the X axis
getMaxElementHeight
public int getMaxElementHeight()

Maximum number of elements shown in a list, this member is used to calculate the
list preferred size. If the number of elements in the model is larger than this then this
value is used in the calculations.
Returns:
the maximum number of elements
setMaxElementHeight
public void setMaxElementHeight(int maxElementHeight)

Maximum number of elements shown in a list, this member is used to calculate the
list preferred size. If the number of elements in the model is larger than this then this
value is used in the calculations.
Parameters:

Method Detail

1549

Overview (Codename One API)


maxElementHeight

- the maximum number of elements

getMinElementHeight
public int getMinElementHeight()

Minimum number of elements shown in a list, this member is used to calculate the list
preferred size. If the number of elements in the model is smaller than this then this
value is used in the calculations.
Returns:
the minimum number of elements
setMinElementHeight
public void setMinElementHeight(int minElementHeight)

Minimum number of elements shown in a list, this member is used to calculate the list
preferred size. If the number of elements in the model is smaller than this then this
value is used in the calculations.
Parameters:
minElementHeight - the minimum number of elements
size
public int size()

Returns the number of elements in the list, shorthand for getModel().getSize()


Returns:
the number of elements in the list
getCurrentSelected
public int getCurrentSelected()

Returns the visual selection during a drag operation, otherwise equivalent to


model.getSelectedIndex
Returns:
visual selection
getSelectedIndex
public int getSelectedIndex()

Returns the current selected offset in the list


Returns:
the current selected offset in the list
setSelectedIndex
public void setSelectedIndex(int index)

Sets the current selected offset in the list, by default this implementation will scroll the
list to the selection if the selection is outside of the screen
Parameters:
index - the current selected offset in the list
getVisibleBounds
protected Rectangle getVisibleBounds()

Returns the component bounds for scrolling which might differ from the getBounds for
large components e.g. list.
Overrides:
getVisibleBounds in class Component
Returns:
the component bounds
See Also:
Component.getX(), Component.getY()
getDragRegionStatus
protected int getDragRegionStatus(int x,
int y)

Method Detail

1550

Overview (Codename One API)


Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Overrides:
getDragRegionStatus in class Component
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values
setSelectedIndex
public void setSelectedIndex(int index,
boolean scrollToSelection)

Sets the current selected offset in the list


Parameters:
index - the current selected offset in the list
scrollToSelection - indicates whether scrolling to selection should occur if
the selection is outside of view
getSelectedItem
public T getSelectedItem()

Returns the current selected item in the list or null for no selection
Returns:
the current selected item in the list
setSelectedItem
public void setSelectedItem(T item)

Sets the current selected item in the list


Parameters:
item - the current selected item in the list
getModel
public ListModel<T> getModel()

Returns the model underlying the list


Returns:
the model underlying the list
setShouldCalcPreferredSize
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and preferred size should
be recalculated
Overrides:
setShouldCalcPreferredSize in class Component
Parameters:
shouldCalcPreferredSize - indicate whether this component need to
recalculate his preferred size
setModel
public void setModel(ListModel model)

Replaces/sets the model underlying the list


Parameters:
model - the new model underlying the list
isNumericKeyActions
public boolean isNumericKeyActions()

Indicate whether pressing the number keys should trigger an action


Returns:

Method Detail

1551

Overview (Codename One API)


true if pressing the number keys should trigger an action
setNumericKeyActions
public void setNumericKeyActions(boolean numericKeyActions)

Indicate whether pressing the number keys should trigger an action


Parameters:
numericKeyActions - true to trigger an action on number keys
isCommandList
public boolean isCommandList()

Indicates that the list should be treated as a list of commands, if the user "clicks" a
command from the list its action performed method is invoked.
Returns:
true if the list is treated as a command list
setCommandList
public void setCommandList(boolean commandList)

Indicates that the list should be treated as a list of commands, if the user "clicks" a
command from the list its action performed method is invoked.
Parameters:
commandList - true for the list to be treated as a command list
isIgnoreFocusComponentWhenUnfocused
public boolean isIgnoreFocusComponentWhenUnfocused()

Indicates whether the list should not paint the focus component if the list itself has no
focus.
Returns:
the ignoreFocusComponentWhenUnfocused
setIgnoreFocusComponentWhenUnfocused

public void setIgnoreFocusComponentWhenUnfocused(boolean ignoreFocusComponentWhenUnf

Indicates whether the list should not paint the focus component if the list itself has no
focus.
Parameters:
ignoreFocusComponentWhenUnfocused - true to ignore the focus component
false otherwise
isMutableRendererBackgrounds
public boolean isMutableRendererBackgrounds()

Indicates that the background of a cell renderer might mutate between one entry and
the next, it is recommended that this flag remains false for performance reasons.
Returns:
the value of the flag
setMutableRendererBackgrounds
public void setMutableRendererBackgrounds(boolean mutableRendererBackgrounds)

Indicates that the background of a cell renderer might mutate between one entry and
the next, it is recommended that this flag remains false for performance reasons.
Parameters:
mutableRendererBackgrounds - the new value for the flag
getListSizeCalculationSampleCount
public int getListSizeCalculationSampleCount()

Indicates the number of elements the list should check to determine the element
sizes. This is ignored when a rendering prototype is present.
Returns:
the listSizeCalculationSampleCount

Method Detail

1552

Overview (Codename One API)


setListSizeCalculationSampleCount
public void setListSizeCalculationSampleCount(int listSizeCalculationSampleCount)

Indicates the number of elements the list should check to determine the element
sizes. This is ignored when a rendering prototype is present.
Parameters:
listSizeCalculationSampleCount - the listSizeCalculationSampleCount to
set
isLongPointerPressActionEnabled
public boolean isLongPointerPressActionEnabled()

Enable/disable list action on long pointer press event


Returns:
the longPointerPressAction
setLongPointerPressActionEnabled
public void setLongPointerPressActionEnabled(boolean longPointerPressAction)

Enable/disable list action on long pointer press event


Parameters:
longPointerPressAction - the longPointerPressAction to set
setRenderer
public void setRenderer(ListCellRenderer renderer)

Sets the renderer which is used to draw list elements


Parameters:
renderer - cell renderer instance
setListCellRenderer
public void setListCellRenderer(ListCellRenderer renderer)

Deprecated. use setRenderer instead, this method was deprecated to confirm better
to JavaBean convention of having the getter/setter with the same name
Sets the renderer which is used to draw list elements
Parameters:
renderer - cell renderer instance
getRenderer
public ListCellRenderer getRenderer()

Returns the renderer which is used to draw list elements


Returns:
the renderer which is used to draw list elements
getOrientation
public int getOrientation()

Returns the list orientation


Returns:
the list orientation HORIZONTAL or VERTICAL
See Also:
HORIZONTAL, VERTICAL
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Component
Parameters:
merge - indicates if the current styles should be merged with the new styles

Method Detail

1553

Overview (Codename One API)


setOrientation
public void setOrientation(int orientation)

Sets the list orientation HORIZONTAL or VERTICAL


Parameters:
orientation - the list orientation HORIZONTAL or VERTICAL
See Also:
HORIZONTAL, VERTICAL
scrollRectToVisible
public void scrollRectToVisible(Rectangle rect)

Makes sure the selected index is visible if it is not in the current view rect the list will
scroll so it fits within
Parameters:
rect - the rectangle area to scroll to
setHandlesInput
public void setHandlesInput(boolean b)

Prevents key events from being grabbed for focus traversal. E.g. a list component
might use the arrow keys for internal navigation so it will switch this flag to true in
order to prevent the focus manager from moving to the next component.
Overrides:
setHandlesInput in class Component
Parameters:
b - indicates whether key events can be grabbed for focus traversal
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component
isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

1554

Overview (Codename One API)


paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
shouldRenderSelection
protected boolean shouldRenderSelection()

Allows subclasses to override the selection rendering for the component, specifically
the spinner in some themes
Returns:
true to render the selection, false otherwise.
addSelectionListener
public void addSelectionListener(SelectionListener l)

Invoked to indicate interest in future selection events


Parameters:
l - the selection listener to be added
removeSelectionListener
public void removeSelectionListener(SelectionListener l)

Invoked to indicate no further interest in future selection events


Parameters:
l - the selection listener to be removed
addActionListener
public void addActionListener(ActionListener l)

Allows binding a listener to user selection actions


Parameters:
l - the action listener to be added
getActionListeners
public Vector getActionListeners()

Deprecated. use getListeners instead


This method allows extracting the action listeners from the current list
Returns:
vector containing the action listeners on the list
getListeners
public Collection getListeners()

This method allows extracting the action listeners from the current list
Returns:
Collection containing the action listeners on the list
removeActionListener
public void removeActionListener(ActionListener l)

Allows binding a listener to user selection actions


Parameters:
l - the action listener to be removed

Method Detail

1555

Overview (Codename One API)


fireActionEvent
protected void fireActionEvent()

This method allows us to detect an action event internally without implementing the
action listener interface.
fireActionEvent
protected void fireActionEvent(ActionEvent a)

Triggers the event to the listeners


Parameters:
evt - the event to fire
setInputOnFocus
public void setInputOnFocus(boolean inputOnFocus)

A list can start handling input implicitly upon gaining focus, this can make for a more
intuitive UI when no other focus elements exist or when their use case is infrequent.
However, it might be odd in some cases where the list "steals" focus.
Parameters:
inputOnFocus - true is a list can start handling input implicitly upon gaining
focus
setPaintFocusBehindList
public void setPaintFocusBehindList(boolean paintFocusBehindList)

This method determines if the animated focus is drawn on top of the List or behind
the List when moving.
Parameters:
paintFocusBehindList getItemGap
public int getItemGap()

Returns the gap between items


Returns:
the gap between items
setItemGap
public void setItemGap(int itemGap)

Set the gap between items


Parameters:
itemGap - the gap between items
setRenderingPrototype
public void setRenderingPrototype(T renderingPrototype)

The rendering prototype is optionally used in calculating the size of the List and is
recommended for performance reasons. You should invoke it with an object
representing a theoretical value in the list which will be used to calculate the size
required for each element in the list.
This allows list size calculations to work across look and feels and allows developers
to predetermine size for list elements.
e.g. For a list of Strings which you would like to always be 5 characters wide you can
use a prototype "XXXXX" which would use the preferred size of the XXXXX String to
determine the size of the list element. E.g. for a list of dates you can use new
Date(30, 12, 00) etc..
The example below was designed for MultiList but should work for any list. Its goal
is to render 2 lines of text with 20 characters and a 5mm square icon:
Map<String, Object> proto = new HashMap<>();

Method Detail

1556

Overview (Codename One API)


map.put("Line1", "WWWWWWWWWWWWWWWWWWWW");
map.put("Line2", "WWWWWWWWWWWWWWWWWWWW");
int mm5 = Display.getInstance().convertToPixels(5, true);
map.put("icon", Image.create(mm5, mm5));
myMultiList.setRenderingPrototype(map);

Parameters:
- a value that can be passed to the renderer to indicate
the preferred size of a list component.
getRenderingPrototype
renderingPrototype

public T getRenderingPrototype()

See set rendering prototype


Returns:
the value of the rendering prototype
See Also:
setRenderingPrototype(java.lang.Object)

longPointerPress
public void longPointerPress(int x,
int y)

If this Component is focused this method is invoked when the user presses and holds
the pointer on the Component
Overrides:
longPointerPress in class Component
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
getSelectedRect
public Rectangle getSelectedRect()

Returns the component bounds with absolute screen coordinates, for components
that include an internal selection behavior and are not containers (currently only List)
this method allows returning the position of the selection itself which is useful for
things such as the popup dialog and similar UI's that need to reference the position of

Method Detail

1557

Overview (Codename One API)


the selection externally
Overrides:
getSelectedRect in class Component
Returns:
the bounds of the component with absolute screen coordinates
setFireOnClick
public void setFireOnClick(boolean fireOnClick)

This method determines if the List fires the action event when the pointer was clicked
on one of the items, or only if the item was the selected item By default the value is
true, this setting is only relevant for none fixed Lists
Parameters:
fireOnClick pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content
addItem
public void addItem(T item)

Allows adding an element to a list if the underlying model supports this, notice that it
is an optional operation and if the model does not support it (default list model does)
then this operation may failed.
Parameters:
item - the item to be added to a list model
getFixedSelection
public int getFixedSelection()

Indicates whether selection is fixable to place in which case all the elements in the list
move and selection stays in place.
Returns:
one of: FIXED_NONE, FIXED_TRAIL, FIXED_LEAD, FIXED_CENTER,
FIXED_NONE_CYCLIC

Method Detail

1558

Overview (Codename One API)


setFixedSelection
public void setFixedSelection(int fixedSelection)

Indicates whether selection is fixable to place in which case all the elements in the list
move and selection stays in place.
Parameters:
fixedSelection - one of: FIXED_NONE, FIXED_TRAIL, FIXED_LEAD,
FIXED_CENTER, FIXED_NONE_CYCLIC
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
isTactileTouch
protected boolean isTactileTouch(int x,
int y)

Elaborate components might not provide tactile feedback for all their areas (e.g. Lists)
this method defaults to returning the value of isTactileTouch
Overrides:
isTactileTouch in class Component
Parameters:
x - the x position
y - the y position
Returns:
True if the device should vibrate
setScrollToSelected
public void setScrollToSelected(boolean scrollToSelected)

This flag indicates to the List if the List should scroll to the selected element when it's
been initialized.
Parameters:
scrollToSelected - if true the List scrolls to the selected element when It's
been initialized.
getGridPosY
protected int getGridPosY()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid Y position closest to the current
Y position.
Overrides:
getGridPosY in class Component
Returns:
a valid Y position in the grid
getGridPosX
protected int getGridPosX()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid X position closest to the current
X position.
Overrides:
getGridPosX in class Component
Returns:
a valid Y position in the grid

Method Detail

1559

Overview (Codename One API)


paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Overrides:
paramString in class Component
Returns:
a string representation of this component's state
setHint
public void setHint(String hint)

Sets the TextArea hint text, the hint text is displayed on the TextArea When there is
no text in the TextArea
Parameters:
hint - the hint text to display
getHint
public String getHint()

Returns the hint text


Returns:
the hint text or null
setHintIcon
public void setHintIcon(Image icon)

Sets the TextArea hint icon, the hint is displayed on the TextArea When there is no
text in the TextArea
Parameters:
icon - the icon
getHintIcon
public Image getHintIcon()

Returns the hint icon


Returns:
the hint icon
setHint
public void setHint(String hint,
Image icon)

Sets the TextArea hint text and Icon, the hint text and icon are displayed on the
TextArea when there is no text in the TextArea
Parameters:
hint - the hint text to display
icon - the hint icon to display

Method Detail

1560

Overview (Codename One API)


com.codename1.ui

Class Label
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
Button, DefaultListCellRenderer, ScaleImageLabel, Slider

public class
extends Component

Allows displaying a single line of text and icon (both optional) with different alignment options. This
class is a base class for several components allowing them to declare alignment/icon appearance
universally.
Label text can be positioned in one of 4 locations as such:
Label left = new Label("Left", icon);
left.setTextPosition(Component.LEFT);
Label right = new Label("Right", icon);
right.setTextPosition(Component.RIGHT);
Label bottom = new Label("Bottom", icon);
bottom.setTextPosition(Component.BOTTOM);
Label top = new Label("Top", icon);
top.setTextPosition(Component.TOP);
hi.add(left).add(right).add(bottom).add(top);

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,

Class Label

1561

Overview (Codename One API)


DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Label()

Construct an empty label


Label(Image icon)

Constructs a new label with the specified icon


Label(Image icon, String uiid)

Constructs a new label with the specified icon and UIID


Label(String text)

Constructs a new label with the specified string of text, left justified.
Label(String text, Image icon)

Constructs a new label with the specified icon and text


Label(String text, Image icon, String uiid)

Constructs a new label with the specified icon text and UIID
Label(String text, String uiid)

Constructs a new label with the specified string of text and uiid

Method Summary
Modifier
and Type
boolean
void
protected
Dimension

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


bindProperty(String prop, BindTarget target)

Binds the given property name to the given bind target


calcPreferredSize()

Calculates the preferred size based on component content.


getAlignment()

int

Deprecated.
use Style.getAlignment instead
getBaseline(int width, int height)

int

int

The baseline for the component text according to which it should be aligned with other co
visual look.
getBaselineResizeBehavior()

Returns a constant indicating how the baseline varies with the size of the component.
getBindablePropertyNames()

String[]

Class[]
Object
int
Image
Object
Image
String

Returns the names of the properties within this component that can be bound for persiste
names mean that the first one will be the first bound
getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


getGap()

Returns the gap in pixels between the icon/text to the Label boundaries
getIcon()

Returns the labels icon


getMask()

Returns the mask matching the given image


getMaskedIcon()

If a mask is applied returns the icon with a mask, otherwise returns the icon
getMaskName()

Fields inherited from class com.codename1.ui.Component

1562

Overview (Codename One API)

Determines the name of the mask from the image constants thus allowing the mask to be
theme
getPropertyNames()
String[]

A component may expose mutable property names for a UI designer to manipulate, this A
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
int
int
int
String
int

This method is here to workaround an XMLVM array type bug where property types aren'
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListM
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder
getShiftMillimeters()

Returns the number of millimeters that should be shifted in tickering


getShiftText()

Simple getter to return how many pixels to shift the text inside the Label
getStringWidth(Font fnt)

This method is equivalent to label.getStyle().getFont().stringWidth(label.getText()) but its


getText()

Returns the label text


getTextPosition()

Returns The position of the text relative to the icon


getVerticalAlignment()

int

Returns the vertical alignment of the Label, this will only work when the icon is in the side
above or bellow it.

static
boolean

isDefaultTickerEnabled()

boolean
boolean

Allows disabling/enabling tickers globally


isEndsWith3Points()

Simple getter
isLegacyRenderer()

Fallback to the old default look and feel renderer for cases where compatibility is essentia
isShouldLocalize()

boolean

Indicates if text should be localized when set to the label, by default all text is localized so
automatic localization for a specific label.
isShowEvenIfBlank()

boolean

boolean
boolean

By default labels and subclasses become 0 sized when they are blank even ignoring their
to true makes the padding take effect even in a blank field.
isTickerEnabled()

This method return true if the ticker is enabled on this Label


isTickerRunning()

Returns true if the ticker is running


paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden by subclasses to
drawing or invoke the UI API's to let the PLAF perform the rendering.

protected
String

paramString()

Returns a string representing the state of this component.


setAlignment(int align)

void

Deprecated.
use Style.setAlignment instead
setBoundPropertyValue(String prop, Object value)

void

Sets the value of a bound property within this component, notice that this method MUST N
change event when invoked to prevent recursion!

static
void

setDefaultTickerEnabled(boolean aDefaultTickerEnabled)

void
void

Method Summary

Allows disabling/enabling tickers globally


setEndsWith3Points(boolean endsWith3Points)

If the Label text is too long fit the text to the widget and add "..." points at the end.
setGap(int gap)

Set the gap in pixels between the icon/text to the Label boundaries

1563

Overview (Codename One API)


setIcon(Image icon)

void

Sets the Label icon, if the icon is unmodified a repaint would not be triggered
setLegacyRenderer(boolean legacyRenderer)

void

Fallback to the old default look and feel renderer for cases where compatibility is essentia
setMask(Object mask)

A mask image can be applied to the label (see the image mask method for details) which
rounded image appearance etc.

void

setMaskName(String maskName)

Determines the name of the mask from the image constants thus allowing the mask to be
theme

void

setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and null if succe
setShiftMillimeters(int shiftMillimeters)

void

Sets the millimeters that should be shifted in tickering


setShiftText(int shiftText)

void

This method shifts the text from it's position in pixels.


setShouldLocalize(boolean shouldLocalize)

Indicates if text should be localized when set to the label, by default all text is localized so
automatic localization for a specific label.

void

setShowEvenIfBlank(boolean showEvenIfBlank)

By default labels and subclasses become 0 sized when they are blank even ignoring their
to true makes the padding take effect even in a blank field.

void

setText(String text)

void

Sets the Label text


setTextPosition(int textPosition)

void

Sets the position of the text relative to the icon if exists


setTickerEnabled(boolean tickerEnabled)

void

Sets the Label to allow ticking of the text.


setVerticalAlignment(int valign)

Sets the vertical alignment of the Label to one of: CENTER, TOP, BOTTOM The valign p
relevant relatively to the icon and not the entire label, this will only work when there

void

boolean

shouldTickerStart()

Returns true if a ticker should be started since there is no room to show the text in the lab
startTicker()

void

This method will start the text ticker


startTicker(long delay, boolean rightToLeft)

void

This method will start the text ticker


stopTicker()

void

Stops the text ticker


unbindProperty(String prop, BindTarget target)

void

Removes a bind target from the given property name

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID,
getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY,
growShrink, handlesInput, hasFocus, initComponent, initCustomStyle,

Methods inherited from class com.codename1.ui.Component

1564

Overview (Codename One API)


initLaf, installDefaultPainter, isAlwaysTensile, isCellRenderer,
isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion,
isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents,
isHidden, isHideInPortrait, isInClippingRegion, isInitialized, isRTL,
isScrollable, isScrollableX, isScrollableY, isScrollVisible,
isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerPressed,
pointerReleased, pointerReleased, putClientProperty, refreshTheme,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Label
public Label(String text)

Constructs a new label with the specified string of text, left justified.
Parameters:
text - the string that the label presents.
Label
public Label(String text,
String uiid)

Constructs a new label with the specified string of text and uiid
Parameters:
text - the string that the label presents.
uiid - the uiid for the label
Label
public Label()

Construct an empty label


Label
public Label(Image icon)

Constructs a new label with the specified icon


Parameters:
icon - the image that the label presents.

Methods inherited from class java.lang.Object

1565

Overview (Codename One API)


Label
public Label(Image icon,
String uiid)

Constructs a new label with the specified icon and UIID


Parameters:
icon - the image that the label presents.
uiid - the uiid for the label
Label
public Label(String text,
Image icon,
String uiid)

Constructs a new label with the specified icon text and UIID
Parameters:
text - the text of the label
icon - the image that the label presents.
uiid - the uiid for the label
Label
public Label(String text,
Image icon)

Constructs a new label with the specified icon and text


Parameters:
text - the text of the label
icon - the image that the label presents.

Method Detail
getBaselineResizeBehavior
public int getBaselineResizeBehavior()

Returns a constant indicating how the baseline varies with the size of the component.
Overrides:
getBaselineResizeBehavior in class Component
Returns:
one of BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT,
BRB_CENTER_OFFSET or BRB_OTHER
getBaseline
public int getBaseline(int width,
int height)

Description copied from class: Component


The baseline for the component text according to which it should be aligned with
other components for best visual look.
Overrides:
getBaseline in class Component
Parameters:
width - the component width
height - the component height
Returns:
baseline value from the top of the component
setText
public void setText(String text)

Sets the Label text


Parameters:
text - the string that the label presents.

Constructor Detail

1566

Overview (Codename One API)


getText
public String getText()

Returns the label text


Returns:
the label text
setIcon
public void setIcon(Image icon)

Sets the Label icon, if the icon is unmodified a repaint would not be triggered
Parameters:
icon - the image that the label presents.
getIcon
public Image getIcon()

Returns the labels icon


Returns:
the labels icon
setAlignment
public void setAlignment(int align)

Deprecated. use Style.setAlignment instead


Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
setVerticalAlignment
public void setVerticalAlignment(int valign)

Sets the vertical alignment of the Label to one of: CENTER, TOP, BOTTOM The
valign property is only relevant relatively to the icon and not the entire label,
this will only work when there is an icon
Parameters:
valign - alignment value
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM
getVerticalAlignment
public int getVerticalAlignment()

Returns the vertical alignment of the Label, this will only work when the icon is in the
side of the text and not above or bellow it. The valign property is only relevant
relatively to the icon and not the entire label, this will only work when there is
an icon
Returns:
the vertical alignment of the Label one of: CENTER, TOP, BOTTOM
See Also:
Component.CENTER, Component.TOP, Component.BOTTOM
getAlignment
public int getAlignment()

Deprecated. use Style.getAlignment instead


Returns the alignment of the Label
Returns:
the alignment of the Label one of: CENTER, LEFT, RIGHT
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT

Method Detail

1567

Overview (Codename One API)


setTextPosition
public void setTextPosition(int textPosition)

Sets the position of the text relative to the icon if exists


Parameters:
textPosition - alignment value (LEFT, RIGHT, BOTTOM or TOP)
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP
getTextPosition
public int getTextPosition()

Returns The position of the text relative to the icon


Returns:
The position of the text relative to the icon, one of: LEFT, RIGHT, BOTTOM,
TOP
See Also:
Component.LEFT, Component.RIGHT, Component.BOTTOM, Component.TOP
setGap
public void setGap(int gap)

Set the gap in pixels between the icon/text to the Label boundaries
Parameters:
gap - the gap in pixels
getGap
public int getGap()

Returns the gap in pixels between the icon/text to the Label boundaries
Returns:
the gap in pixels between the icon/text to the Label boundaries
paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Overrides:
paramString in class Component
Returns:
a string representation of this component's state
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:

Method Detail

1568

Overview (Codename One API)


the calculated preferred size based on component content
getShiftText
public int getShiftText()

Simple getter to return how many pixels to shift the text inside the Label
Returns:
number of pixels to shift
setShiftText
public void setShiftText(int shiftText)

This method shifts the text from it's position in pixels. The value can be
positive/negative to move the text to the right/left
Parameters:
shiftText - The number of pixels to move the text
shouldTickerStart
public boolean shouldTickerStart()

Returns true if a ticker should be started since there is no room to show the text in the
label.
Returns:
true if a ticker should start running
startTicker
public void startTicker()

This method will start the text ticker


startTicker
public void startTicker(long delay,
boolean rightToLeft)

This method will start the text ticker


Parameters:
delay - the delay in millisecods between animation intervals
rightToLeft - if true move the text to the left
stopTicker
public void stopTicker()

Stops the text ticker


isTickerRunning
public boolean isTickerRunning()

Returns true if the ticker is running


Returns:
true if the ticker is running
setTickerEnabled
public void setTickerEnabled(boolean tickerEnabled)

Sets the Label to allow ticking of the text. By default is true


Parameters:
tickerEnabled isTickerEnabled
public boolean isTickerEnabled()

This method return true if the ticker is enabled on this Label


Returns:
tickerEnabled

Method Detail

1569

Overview (Codename One API)


setEndsWith3Points
public void setEndsWith3Points(boolean endsWith3Points)

If the Label text is too long fit the text to the widget and add "..." points at the end. By
default this is set to true
Parameters:
endsWith3Points - true if text should add "..." at the end
isEndsWith3Points
public boolean isEndsWith3Points()

Simple getter
Returns:
true if this Label adds "..." when the text is too long
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
isDefaultTickerEnabled
public static boolean isDefaultTickerEnabled()

Allows disabling/enabling tickers globally


Returns:
the defaultTickerEnabled
setDefaultTickerEnabled
public static void setDefaultTickerEnabled(boolean aDefaultTickerEnabled)

Allows disabling/enabling tickers globally


Parameters:
aDefaultTickerEnabled - the defaultTickerEnabled to set
setMask
public void setMask(Object mask)

A mask image can be applied to the label (see the image mask method for details)
which allows for things like rounded image appearance etc.
Parameters:
mask - the mask returned from the image object
getMask
public Object getMask()

Returns the mask matching the given image


Returns:
the mask for the given label
getMaskName
public String getMaskName()

Determines the name of the mask from the image constants thus allowing the mask
to be applied from the theme
Returns:
the maskName

Method Detail

1570

Overview (Codename One API)


setMaskName
public void setMaskName(String maskName)

Determines the name of the mask from the image constants thus allowing the mask
to be applied from the theme
Parameters:
maskName - the maskName to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

1571

Overview (Codename One API)


getMaskedIcon
public Image getMaskedIcon()

If a mask is applied returns the icon with a mask, otherwise returns the icon
Returns:
the icon masked or otherwise
getBindablePropertyNames
public String[] getBindablePropertyNames()

Returns the names of the properties within this component that can be bound for
persistence, the order of these names mean that the first one will be the first bound
Overrides:
getBindablePropertyNames in class Component
Returns:
a string array of property names or null
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
Overrides:
getBindablePropertyTypes in class Component
Returns:
the class for binding
bindProperty
public void bindProperty(String prop,
BindTarget target)

Binds the given property name to the given bind target


Overrides:
bindProperty in class Component
Parameters:
prop - the property name
target - the target binder
unbindProperty
public void unbindProperty(String prop,
BindTarget target)

Removes a bind target from the given property name


Overrides:
unbindProperty in class Component
Parameters:
prop - the property names
target - the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


Overrides:
getBoundPropertyValue in class Component
Parameters:
prop - the property
Returns:
the value for the property
setBoundPropertyValue
public void setBoundPropertyValue(String prop,
Object value)

Sets the value of a bound property within this component, notice that this method
MUST NOT fire the property change event when invoked to prevent recursion!
Overrides:

Method Detail

1572

Overview (Codename One API)


setBoundPropertyValue

in class Component

Parameters:
prop - the property
value - the value

whose value should be set

isShouldLocalize
public boolean isShouldLocalize()

Indicates if text should be localized when set to the label, by default all text is
localized so this allows disabling automatic localization for a specific label.
Returns:
the shouldLocalize value
setShouldLocalize
public void setShouldLocalize(boolean shouldLocalize)

Indicates if text should be localized when set to the label, by default all text is
localized so this allows disabling automatic localization for a specific label.
Parameters:
shouldLocalize - the shouldLocalize to set
getShiftMillimeters
public int getShiftMillimeters()

Returns the number of millimeters that should be shifted in tickering


Returns:
the shiftMillimeters
setShiftMillimeters
public void setShiftMillimeters(int shiftMillimeters)

Sets the millimeters that should be shifted in tickering


Parameters:
shiftMillimeters - the shiftMillimeters to set
isShowEvenIfBlank
public boolean isShowEvenIfBlank()

By default labels and subclasses become 0 sized when they are blank even ignoring
their padding setting this to true makes the padding take effect even in a blank field.
Returns:
the showEvenIfBlank
setShowEvenIfBlank
public void setShowEvenIfBlank(boolean showEvenIfBlank)

By default labels and subclasses become 0 sized when they are blank even ignoring
their padding setting this to true makes the padding take effect even in a blank field.
Parameters:
showEvenIfBlank - the showEvenIfBlank to set
getStringWidth
public int getStringWidth(Font fnt)

This method is equivalent to label.getStyle().getFont().stringWidth(label.getText()) but


its faster
Parameters:
fnt - the font is passed as an optimization to save a call to getStyle
Returns:
the string width
isLegacyRenderer
public boolean isLegacyRenderer()

Fallback to the old default look and feel renderer for cases where compatibility is
essential
Returns:

Method Detail

1573

Overview (Codename One API)


the legacyRenderer
setLegacyRenderer
public void setLegacyRenderer(boolean legacyRenderer)

Fallback to the old default look and feel renderer for cases where compatibility is
essential
Parameters:
legacyRenderer - the legacyRenderer to set

Method Detail

1574

Overview (Codename One API)


com.codename1.ui

Class InfiniteContainer
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.InfiniteContainer
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public abstract class


extends Container

This abstract Container can scroll indefinitely (or at least until we run out of data). This class uses the
InfiniteScrollAdapter to bring more data and the pull to refresh feature to refresh current displayed
data.
The sample code shows the usage of the nestoria API to fill out an infinitely scrolling list.
Form hi = new Form("InfiniteContainer", new BorderLayout());
Style s = UIManager.getInstance().getComponentStyle("MultiLine1");
FontImage p = FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
EncodedImage placeholder = EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 3), false);
InfiniteContainer ic = new InfiniteContainer() {
{@literal @}Override
public Component[] fetchComponents(int index, int amount) {
java.util.List<Map<String, Object>> data = fetchPropertyData("Leeds");
MultiButton[] cmps = new MultiButton[data.size()];
for(int iter = 0 ; iter < cmps.length ; iter++) {
Map<String, Object> currentListing = data.get(iter);
if(currentListing == null) {
return null;
}
String thumb_url = (String)currentListing.get("thumb_url");
String guid = (String)currentListing.get("guid");
String summary = (String)currentListing.get("summary");
cmps[iter] = new MultiButton(summary);
cmps[iter].setIcon(URLImage.createToStorage(placeholder, guid, thumb_url));
}
return cmps;
}
};
hi.add(BorderLayout.CENTER, ic);

Class InfiniteContainer

1575

Overview (Codename One API)

int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
r.addArgument("page", "" + pageNumber);
pageNumber++;
r.addArgument("country", "uk");
r.addArgument("place_name", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getRes
Map<String, Object> response = (Map<String, Object>)result.get("response");
return (java.util.List<Map<String, Object>>)response.get("listings");
} catch(Exception err) {
Log.e(err);
return null;
}
}

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
InfiniteContainer()

Creates the InfiniteContainer.


InfiniteContainer(int amount)

Creates the InfiniteContainer.

Field Summary

1576

Overview (Codename One API)

Method Summary
Modifier and Type
abstract
Component[]
InfiniteProgress

Method and Description


fetchComponents(int index, int amount)

This is an abstract method that should be implemented by the sub


classes to fetch the data.
getInfiniteProgress()

Lets us manipulate the infinite progress object e.g.


initComponent()

protected void

Allows subclasses to bind functionality that relies on fully initialized


and "ready for action" component state

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,

Method Summary

1577

Overview (Codename One API)

removePointerReleasedListener, removeScrollListener, repaint, repaint,


requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
InfiniteContainer
public InfiniteContainer()

Creates the InfiniteContainer. The InfiniteContainer is created with BoxLayout Y


layout.
InfiniteContainer
public InfiniteContainer(int amount)

Creates the InfiniteContainer. The InfiniteContainer is created with BoxLayout Y


layout.
Parameters:
amount - the number of items to fetch in each call to fetchComponents

Method Detail
initComponent
protected void initComponent()

Description copied from class: Component


Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
fetchComponents
public abstract Component[] fetchComponents(int index,
int amount)

This is an abstract method that should be implemented by the sub classes to fetch
the data. This method is invoked on a background thread, sub classes should
preform their networking/data fetching here. Notice - this method might cause EDT
violations warnings, since the subclasses will need to create the Components not on
the EDT, these warnings are legit and can be ignored.
Parameters:
index - the index from which to bring data
amount - the size of components to bring
Returns:
Components array of the returned data, size of the array can be the size of
the amount or smaller, if no data to fetch method can return null.

Methods inherited from class com.codename1.ui.Component

1578

Overview (Codename One API)


getInfiniteProgress
public InfiniteProgress getInfiniteProgress()

Lets us manipulate the infinite progress object e.g. set the animation image etc.
Returns:
the infinite progress component underlying this container

Method Detail

1579

Overview (Codename One API)


com.codename1.ui

Class Image
java.lang.Object

com.codename1.ui.Image
Direct Known Subclasses:
EncodedImage, FontImage, RGBImage, Timeline

public class
extends Object

Abstracts the underlying platform images allowing us to treat them as a uniform object.

Constructor Summary
Modifier

Constructor and Description


Image(Object image)

protected

Subclasses may use this and point to an underlying native image which might be
null for a case of an image that doesn't use native drawing

Method Summary
Modifier
and Type
boolean

Method and Description


animate()
applyMask(Object mask)

Image

Applies the given alpha mask onto this image and returns the resulting image
see the createMask method for indication on how to convert an image into an
alpha mask.
applyMask(Object mask, int x, int y)

Image

Applies the given alpha mask onto this image and returns the resulting image
see the createMask method for indication on how to convert an image into an
alpha mask.
applyMaskAutoScale(Object mask)

Image

Applies the given alpha mask onto this image and returns the resulting image
see the createMask method for indication on how to convert an image into an
alpha mask.
asyncLock(Image internal)

void

Async lock is the equivalent of a lock operation, however it uses the given
image as the hard cache and performs the actual image loading
asynchronously.

static
Image

createImage(byte[] bytes, int offset, int len)

static
Image

createImage(InputStream stream)

static
Image

createImage(int[] rgb, int width, int height)

creates an image from a given byte array data


creates an image from an InputStream
creates an image from an RGB image
createImage(int width, int height)

static
Image

static
Image

Class Image

Creates a white opaque mutable image that may be manipulated using


getGraphics().
The sample below shows this method being used to create a screenshot for
sharing the image:
createImage(int width, int height, int fillColor)

Creates a mutable image that may be manipulated using getGraphics().


The sample below shows this method being used to create a screenshot for

1580

Overview (Codename One API)


sharing the image:
createImage(Object nativeImage)
static
Image

static
Image
static
Image

Deprecated.
this method is deprecated as a warning! Don't use this method unless you
actually know what you are doing, if you are invoking this method without
understanding the distinction between native image and Codename One image
then you are using the wrong method.
createImage(String path)

creates an image from the given path based on MIDP's createImage(path)


createIndexed(int width, int height, int[] palette, byte[] data)

Deprecated.
try to avoid using indexed images explicitly
createMask()

Object

static
Image

Creates a mask from the given image, a mask can be used to apply an arbitrary
alpha channel to any image.
createSVG(String baseURL, boolean animated, byte[] data)

Creates an SVG Image from the given byte array data and the base URL, this
method will throw an exception if SVG is unsupported.
dispose()

void

protected
void

protected
void

Image
Image
Graphics
int

DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE
DOING! Images dispose automatically for most cases except for very rare
special cases.
drawImage(Graphics g, Object nativeGraphics, int x, int y)

Callback invoked internally by Codename One to draw the image/frame onto


the display.
drawImage(Graphics g, Object nativeGraphics, int x, int y, int w,
int h)

Callback invoked internally by Codename One to draw the image/frame onto


the display.
flipHorizontally(boolean maintainOpacity)

Flips this image on the horizontal axis


flipVertically(boolean maintainOpacity)

Flips this image on the vertical axis


getGraphics()

If this is a mutable image a graphics object allowing us to draw on it is returned.


getHeight()

Returns the height of the image


getImage()

Object

Returns the platform specific image implementation, warning the


implementation class can change between revisions of Codename One and
platforms.
getImageName()

String

int[]

The name of the image is set for some images mostly to ease the debugging of
Codename One application
getRGB()

Returns the content of this image as a newly created ARGB array.


getRGBCached()

int[]

Returns the content of this image as a newly created ARGB array or a cached
instance if possible.
getSVGDocument()

Object

int
static
boolean
boolean
boolean

Method Summary

Returns a platform specific DOM object that can be manipulated by the user to
change the SVG Image
getWidth()

Returns the width of the image


isAlphaMutableImageSupported()

Returns true if mutable images support alpha transparency


isAnimation()

Returns true if this is an animated image


isLocked()

Returns true if the image is locked

1581

Overview (Codename One API)


boolean
boolean
static
boolean

isOpaque()

Indicates whether this image is opaque or not


isSVG()

Indicates if this image represents an SVG file or a bitmap file


isSVGSupported()

Indicates whether the underlying platform supports creating an SVG Image


lock()

void

This callback indicates that a component pointing at this image is initialized, this
allows an image to make performance sensitive considerations e.g.
mirror()

Image

Creates a mirror image for the given image which is useful for some RTL
scenarios.
modifyAlpha(byte alpha)

Image

Creates a new image instance with the alpha channel of opaque/translucent


pixels within the image using the new alpha value.
modifyAlpha(byte alpha, int removeColor)

Image

Creates a new image instance with the alpha channel of opaque/translucent


pixels within the image using the new alpha value.
modifyAlphaWithTranslucency(byte alpha)

Image

Creates a new image instance with the alpha channel of opaque pixels within
the image using the new alpha value.
requiresDrawImage()

boolean

Image
Image
Image
Image

New label optimizations don't invoke drawImage and instead just pass the
native image directly to the underlying renderer.
rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees.


rotate180Degrees(boolean maintainOpacity)

Rotates the image by 180 degrees


rotate270Degrees(boolean maintainOpacity)

Rotates the image by 270 degrees while changing the ratio of the picture
rotate90Degrees(boolean maintainOpacity)

Rotates this image by 90 degrees while changing the ratio of the picture
scale(int width, int height)

void

Deprecated.
scale should return an image rather than modify the image in place use
scaled(int, int) instead
scaled(int width, int height)

Image

Returns a scaled version of this image image using the given width and height,
this is a fast algorithm that preserves translucent information.
scaledHeight(int height)

Image

Image
Image

Scales the image to the given height while updating the width based on the
aspect ratio of the height
scaledLargerRatio(int width, int height)

Scales the image while maintaining the aspect ratio to the larger size image
scaledSmallerRatio(int width, int height)

Scales the image while maintaining the aspect ratio to the smaller size image
scaledWidth(int width)

Image

Scales the image to the given width while updating the height based on the
aspect ratio of the width
setImageName(String imageName)

void

The name of the image is set for some images mostly to ease the debugging of
Codename One application
subImage(int x, int y, int width, int height, boolean processAlpha)

Image

void

Extracts a subimage from the given image allowing us to breakdown a single


large image into multiple smaller images in RAM, this actually creates a
standalone version of the image for use.
toRGB(RGBImage image, int destX, int destY, int x, int y, int width,
int height)

Extracts data from this image into the given RGBImage

Method Summary

1582

Overview (Codename One API)


unlock()

This callback indicates that a component pointing at this image is now


deinitilized This method may be invoked multiple times.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Image
protected Image(Object image)

Subclasses may use this and point to an underlying native image which might be null
for a case of an image that doesn't use native drawing
Parameters:
image - native image object passed to the Codename One implementation

Method Detail
asyncLock
public void asyncLock(Image internal)

Async lock is the equivalent of a lock operation, however it uses the given image as
the hard cache and performs the actual image loading asynchronously. On
completion this method will invoke repaint on the main form if applicable.
Parameters:
internal - the image to show while the actual image loads.
lock
public void lock()

This callback indicates that a component pointing at this image is initialized, this
allows an image to make performance sensitive considerations e.g. an encoded
image might choose to cache itself in RAM. This method may be invoked multiple
times.
isLocked
public boolean isLocked()

Returns true if the image is locked


Returns:
false by default
unlock
public void unlock()

This callback indicates that a component pointing at this image is now deinitilized
This method may be invoked multiple times.
isSVGSupported
public static boolean isSVGSupported()

Indicates whether the underlying platform supports creating an SVG Image


Returns:
true if the method create SVG image would return a valid image object from
an SVG Input stream

Methods inherited from class java.lang.Object

1583

Overview (Codename One API)


getSVGDocument
public Object getSVGDocument()

Returns a platform specific DOM object that can be manipulated by the user to
change the SVG Image
Returns:
Platform dependent object, when JSR 226 is supported an SVGSVGElement
might be returned.
createSVG
public static Image createSVG(String baseURL,
boolean animated,
byte[] data)
throws IOException

Creates an SVG Image from the given byte array data and the base URL, this
method will throw an exception if SVG is unsupported.
Parameters:
baseURL - URL which is used to resolve relative references within the SVG file
animated - indicates if the SVG features an animation
data - the conten of the SVG file
Returns:
an image object that can be used as any other image object.
Throws:
IOException - if resource lookup fail SVG is unsupported
isSVG
public boolean isSVG()

Indicates if this image represents an SVG file or a bitmap file


Returns:
true if this is an SVG file
createMask
public Object createMask()

Creates a mask from the given image, a mask can be used to apply an arbitrary
alpha channel to any image. A mask is derived from the blue channel (LSB) of the
given image. The generated mask can be used with the apply mask method.
Returns:
mask object that can be used with applyMask
applyMask
public Image applyMask(Object mask,
int x,
int y)

Applies the given alpha mask onto this image and returns the resulting image see the
createMask method for indication on how to convert an image into an alpha mask.
Parameters:
mask - mask object created by the createMask() method.
x - starting x where to apply the mask
y - starting y where to apply the mask
Returns:
image masked based on the given object
applyMask
public Image applyMask(Object mask)

Applies the given alpha mask onto this image and returns the resulting image see the
createMask method for indication on how to convert an image into an alpha mask.
Parameters:
mask - mask object created by the createMask() method.
Returns:
image masked based on the given object
Throws:

Method Detail

1584

Overview (Codename One API)


IllegalArgumentException

- if the image size doesn't match the mask size

applyMaskAutoScale
public Image applyMaskAutoScale(Object mask)

Applies the given alpha mask onto this image and returns the resulting image see the
createMask method for indication on how to convert an image into an alpha mask. If
the image is of a different size it will be scaled to mask size.
Parameters:
mask - mask object created by the createMask() method.
Returns:
image masked based on the given object
subImage
public Image subImage(int x,
int y,
int width,
int height,
boolean processAlpha)

Extracts a subimage from the given image allowing us to breakdown a single large
image into multiple smaller images in RAM, this actually creates a standalone version
of the image for use.
Parameters:
x - the x offset from the image
y - the y offset from the image
width - the width of internal images
height - the height of internal images
processAlpha - whether alpha should be processed as well as part of the
cutting
Returns:
An array of all the possible images that can be created from the source
mirror
public Image mirror()

Creates a mirror image for the given image which is useful for some RTL scenarios.
Notice that this method isn't the most efficient way to perform this task and is
designed for portability over efficiency.
Returns:
a mirrored image
rotate
public Image rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees. By default
90 degree angle divisions are supported, anything else is implementation dependent.
This method assumes a square image. Notice that it is inefficient in the current
implementation to rotate to non-square angles,
E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90
and then rotate the 45 to another 90 degrees to achieve the same effect with less
memory.
Parameters:
- A degree in right angle must be larger than 0 and up to 359
degrees
Returns:
new image instance with the closest possible rotation
createIndexed
degrees

public static Image createIndexed(int width,


int height,
int[] palette,
byte[] data)

Deprecated. try to avoid using indexed images explicitly

Method Detail

1585

Overview (Codename One API)


Creates an indexed image with byte data this method may return a native indexed
image rather than an instance of the IndexedImage class
Parameters:
width - image width
height - image height
palette - the color palette to use with the byte data
data - byte data containing palette offsets to map to ARGB colors
modifyAlpha
public Image modifyAlpha(byte alpha)

Creates a new image instance with the alpha channel of opaque/translucent pixels
within the image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. All other pixels will have the new alpha value.
Parameters:
alpha - New value for the entire alpha channel
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
modifyAlphaWithTranslucency
public Image modifyAlphaWithTranslucency(byte alpha)

Creates a new image instance with the alpha channel of opaque pixels within the
image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. Semi translucent pixels will be multiplied by the ratio difference and their
translucency reduced appropriately.
Parameters:
alpha - New value for the entire alpha channel
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
modifyAlpha
public Image modifyAlpha(byte alpha,
int removeColor)

Creates a new image instance with the alpha channel of opaque/translucent pixels
within the image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. All other pixels will have the new alpha value.
Parameters:
alpha - New value for the entire alpha channel
removeColor - pixels matching this color are made transparent (alpha channel
ignored)
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
createImage
public static Image createImage(String path)
throws IOException

creates an image from the given path based on MIDP's createImage(path)


Parameters:
path Returns:
newly created image object
Throws:
IOException

createImage
public static Image createImage(Object nativeImage)

Deprecated. this method is deprecated as a warning! Don't use this method unless
you actually know what you are doing, if you are invoking this method without
understanding the distinction between native image and Codename One image then
you are using the wrong method.

Method Detail

1586

Overview (Codename One API)


creates an image from the given native image (e.g. MIDP image object)
Parameters:
nativeImage Returns:
newly created Codename One image object
createImage
public static Image createImage(InputStream stream)
throws IOException

creates an image from an InputStream


Parameters:
stream - a given InputStream
Returns:
the newly created image
Throws:
IOException

createImage
public static Image createImage(int[] rgb,
int width,
int height)

creates an image from an RGB image


Parameters:
rgb - the RGB image array data
width - the image width
height - the image height
Returns:
an image from an RGB image
createImage
public static Image createImage(int width,
int height)

Creates a white opaque mutable image that may be manipulated using


getGraphics().
The sample below shows this method being used to create a screenshot for sharing
the image:
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");

Parameters:
width - the image width
height - the image height

Returns:
an image in a given width and height dimension
isAlphaMutableImageSupported
public static boolean isAlphaMutableImageSupported()

Returns true if mutable images support alpha transparency


Returns:
true if mutable images support alpha in their fillColor argument

Method Detail

1587

Overview (Codename One API)


createImage
public static Image createImage(int width,
int height,
int fillColor)

Creates a mutable image that may be manipulated using getGraphics().


The sample below shows this method being used to create a screenshot for sharing
the image:
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");

Parameters:
width - the image width
height - the image height
fillColor - the color with

which the image should be initially filled


Returns:
an image in a given width and height dimension
createImage
public static Image createImage(byte[] bytes,
int offset,
int len)

creates an image from a given byte array data


Parameters:
bytes - the array of image data in a supported image format
offset - the offset of the start of the data in the array
len - the length of the data in the array
Returns:
the newly created image
getGraphics
public Graphics getGraphics()

If this is a mutable image a graphics object allowing us to draw on it is returned.


Returns:
Graphics object allowing us to manipulate the content of a mutable image
getWidth
public int getWidth()

Returns the width of the image


Returns:
the width of the image
getHeight
public int getHeight()

Returns the height of the image


Returns:
the height of the image

Method Detail

1588

Overview (Codename One API)


drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y,
int w,
int h)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
w - the width to occupy
h - the height to occupy
toRGB
public void toRGB(RGBImage image,
int destX,
int destY,
int x,
int y,
int width,
int height)

Extracts data from this image into the given RGBImage


Parameters:
image - RGBImage that would receive pixel data
destX - x location within RGBImage into which the data will be written
destY - y location within RGBImage into which the data will be written
x - location within the source image
y - location within the source image
width - size of the image to extract from the source image
height - size of the image to extract from the source image
getRGB
public int[] getRGB()

Returns the content of this image as a newly created ARGB array.


Returns:
new array instance containing the ARGB data within this image
getRGBCached
public int[] getRGBCached()

Returns the content of this image as a newly created ARGB array or a cached
instance if possible. Note that cached instances may be garbage collected.
Returns:

Method Detail

1589

Overview (Codename One API)


array instance containing the ARGB data within this image
scaledWidth
public Image scaledWidth(int width)

Scales the image to the given width while updating the height based on the aspect
ratio of the width
Parameters:
width - the given new image width
Returns:
the newly created image
scaledHeight
public Image scaledHeight(int height)

Scales the image to the given height while updating the width based on the aspect
ratio of the height
Parameters:
height - the given new image height
Returns:
the newly created image
scaledSmallerRatio
public Image scaledSmallerRatio(int width,
int height)

Scales the image while maintaining the aspect ratio to the smaller size image
Parameters:
width - the given new image width
height - the given new image height
Returns:
the newly created image
scaledLargerRatio
public Image scaledLargerRatio(int width,
int height)

Scales the image while maintaining the aspect ratio to the larger size image
Parameters:
width - the given new image width
height - the given new image height
Returns:
the newly created image
scaled
public Image scaled(int width,
int height)

Returns a scaled version of this image image using the given width and height, this is
a fast algorithm that preserves translucent information. The method accepts -1 to
preserve aspect ratio in the given axis.
Parameters:
width - width for the scaling
height - height of the scaled image
Returns:
new image instance scaled to the given height and width
getImage
public Object getImage()

Returns the platform specific image implementation, warning the implementation


class can change between revisions of Codename One and platforms.
Returns:
platform specific native implementation for this image object

Method Detail

1590

Overview (Codename One API)


scale
public void scale(int width,
int height)

Deprecated. scale should return an image rather than modify the image in place use
scaled(int, int) instead
Scale the image to the given width and height, this is a fast algorithm that preserves
translucent information
Parameters:
width - width for the scaling
height - height of the scaled image
isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Returns:
true if this image represents an animation
animate
public boolean animate()

isOpaque
public boolean isOpaque()

Indicates whether this image is opaque or not


Returns:
true if the image is completely opqaque which allows for some heavy
optimizations
getImageName
public String getImageName()

The name of the image is set for some images mostly to ease the debugging of
Codename One application
Returns:
the imageName
setImageName
public void setImageName(String imageName)

The name of the image is set for some images mostly to ease the debugging of
Codename One application
Parameters:
imageName - the imageName to set
dispose
public void dispose()

DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING!
Images dispose automatically for most cases except for very rare special cases.
Images on devices usually holds a native memory, some platforms garbage
collectors might fail to release the native and to fail with out of memory errors. Use
this method to make sure the image will be released from memory, after calling this
the image will become unusable.
rotate90Degrees
public Image rotate90Degrees(boolean maintainOpacity)

Rotates this image by 90 degrees while changing the ratio of the picture
Parameters:
maintainOpacity - whether the opacity in the image should be maintained
Returns:
a new image rotated by 90 degrees

Method Detail

1591

Overview (Codename One API)


rotate180Degrees
public Image rotate180Degrees(boolean maintainOpacity)

Rotates the image by 180 degrees


Parameters:
maintainOpacity - whether the opacity in the image should be maintained
Returns:
a new image rotated by 180 degrees
rotate270Degrees
public Image rotate270Degrees(boolean maintainOpacity)

Rotates the image by 270 degrees while changing the ratio of the picture
Parameters:
maintainOpacity - whether the opacity in the image should be maintained
Returns:
a new image rotated by 270 degrees
flipHorizontally
public Image flipHorizontally(boolean maintainOpacity)

Flips this image on the horizontal axis


Parameters:
maintainOpacity - whether the opacity in the image should be maintained
Returns:
a new image flipped
flipVertically
public Image flipVertically(boolean maintainOpacity)

Flips this image on the vertical axis


Parameters:
maintainOpacity - whether the opacity in the image should be maintained
Returns:
a new image flipped
requiresDrawImage
public boolean requiresDrawImage()

New label optimizations don't invoke drawImage and instead just pass the native
image directly to the underlying renderer. This is problematic for some image types
specifically timeline & FontImage and this method allows these classes to indicate
that they need that legacy behavior of calling drawImage.
Returns:
true if a drawImage call is a required

Method Detail

1592

Overview (Codename One API)


com.codename1.ui

Class Graphics
java.lang.Object

com.codename1.ui.Graphics

public final class


extends Object

Abstracts the underlying platform graphics context thus allowing us to achieve portability between
MIDP devices and CDC devices. This abstaction simplifies and unifies the Graphics implementations
of various platforms.
A graphics instance should never be created by the developer and is always accessed using either a
paint callback or a mutable image. There is no supported way to create this object directly.

Method Summary
Modifier
and Type

Method and Description


beginNativeGraphicsAccess()

Object

Starts accessing the native graphics in the underlying OS, when accessing the
native graphics Codename One shouldn't be used! The native graphics is
unclipped and untranslated by default and its the responsibility of the caller to
clip/translate appropriately.
clipRect(int x, int y, int width, int height)

void

void

void

Clips the given rectangle by intersecting with the current clipping region, this
method can thus only shrink the clipping region and never increase it.
darkerColor(int factor)

Makes the current color slightly darker, this is useful for many visual effects
drawArc(int x, int y, int width, int height, int startAngle,
int arcAngle)

Draws a circular or elliptical arc based on the given angles and bounding box
void

drawChar(char character, int x, int y)

Draw the given char using the current font and color in the x,y coordinates.
drawChars(char[] data, int offset, int length, int x, int y)

void

void

Draw the given char array using the current font and color in the x,y
coordinates.
drawImage(Image img, int x, int y)

Draws the image so its top left coordinate corresponds to x/y


drawImage(Image img, int x, int y, int w, int h)

void

void
void
void
void

void

void

Class Graphics

Draws the image so its top left coordinate corresponds to x/y and scales it to
width/height
drawLine(int x1, int y1, int x2, int y2)

Draws a line between the 2 X/Y coordinates


drawPolygon(int[] xPoints, int[] yPoints, int nPoints)

Draws a closed polygon defined by arrays of x and y coordinates.


drawRect(int x, int y, int width, int height)

Draws a rectangle in the given coordinates


drawRect(int x, int y, int width, int height, int thickness)

Draws a rectangle in the given coordinates with the given thickness


drawRoundRect(int x, int y, int width, int height, int arcWidth,
int arcHeight)

Draws a rounded corner rectangle in the given coordinates with the


arcWidth/height matching the last two arguments respectively.
drawShape(Shape shape, Stroke stroke)

1593

Overview (Codename One API)


Draws a outline shape inside the specified bounding box.
void
void
void
void

drawString(String str, int x, int y)

Draw a string using the current font and color in the x,y coordinates.
drawString(String str, int x, int y, int textDecoration)

Draw a string using the current font and color in the x,y coordinates.
drawStringBaseline(String str, int x, int y)

Draws a string using baseline coordinates.


drawStringBaseline(String str, int x, int y, int textDecoration)

Draws a string using baseline coordinates.


endNativeGraphicsAccess()

void

void

Invoke this to restore Codename One's graphics settings into the native
graphics
fillArc(int x, int y, int width, int height, int startAngle,
int arcAngle)

Fills a circular or elliptical arc based on the given angles and bounding box.
void

void

void

fillLinearGradient(int startColor, int endColor, int x, int y,


int width, int height, boolean horizontal)

Draws a linear gradient in the given coordinates with the given colors, doesn't
take alpha into consideration when drawing the gradient
fillPolygon(int[] xPoints, int[] yPoints, int nPoints)

Fills a closed polygon defined by arrays of x and y coordinates.


fillRadialGradient(int startColor, int endColor, int x, int y,
int width, int height)

Draws a radial gradient in the given coordinates with the given colors, doesn't
take alpha into consideration when drawing the gradient.
fillRect(int x, int y, int width, int height)

void

void

void

Fills the rectangle from the given position according to the width/height minus 1
pixel according to the convention in Java.
fillRect(int x, int y, int w, int h, byte alpha)

Fills a rectangle with an optionally translucent fill color


fillRectRadialGradient(int startColor, int endColor, int x, int y,
int width, int height, float relativeX, float relativeY,
float relativeSize)

Draws a radial gradient in the given coordinates with the given colors, doesn't
take alpha into consideration when drawing the gradient.
void

fillRoundRect(int x, int y, int width, int height, int arcWidth,


int arcHeight)

Fills a rounded rectangle in the same way as drawRoundRect


void
void

fillShape(Shape shape)

Fills the given shape using the current alpha and color settings.
fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)

Draws a filled triangle with the given coordinates


getAlpha()

int

int[]
int
int
int
int
int
Font
float

Method Summary

Returnes the alpha as a value between 0-255 (0 - 0xff) where 255 is


completely opaque and 0 is completely transparent
getClip()

Returns the clip as an x,y,w,h array


getClipHeight()

Returns the clip height


getClipWidth()

Returns the clip width


getClipX()

Returns the x clipping position


getClipY()

Returns the y clipping position


getColor()

Returns the current color


getFont()

Returns the font used with the drawString method calls


getScaleX()

1594

Overview (Codename One API)


Returns the affine X scale
float
Transform
int
int

getScaleY()

Returns the affine Y scale


getTransform()

Gets the transformation matrix that is currently applied to this graphics context.
getTranslateX()

Returns the current x translate value


getTranslateY()

Returns the current y translate value


isAffineSupported()

boolean

Indicates whether the underlying implementation can draw using an affine


transform hence methods such as rotate, scale and shear would work
isAlphaSupported()

boolean

boolean

Indicates whether invoking set/getAlpha would have an effect on all further


rendering from this graphics object.
isAntiAliased()

Returns true if anti-aliasing for standard rendering operations is turned on.


isAntiAliasedText()

boolean

Indicates whether anti-aliasing for text is active, notice that text anti-aliasing is
a separate attribute from standard anti-alisaing.
isAntiAliasedTextSupported()

boolean

Returns true if anti-aliasing for text is supported, notice that text anti-aliasing is
a separate attribute from standard anti-alisaing.
isAntiAliasingSupported()

boolean

boolean

Returns true if anti-aliasing for standard rendering operations is supported,


notice that text anti-aliasing is a separate attribute.
isPerspectiveTransformSupported()
Checks to see if perspective (3D) com.codename1.ui.geom.Matrix

transforms

are supported by this graphics context.


boolean

boolean

isShapeSupported()

Checks to see if this graphics context supports drawing shapes (i.e.


isTransformSupported()
Checks to see if com.codename1.ui.geom.Matrix

transforms are supported by

this graphics context.


void
void
void
void
void
void
void

lighterColor(int factor)

Makes the current color slightly lighter, this is useful for many visual effects
popClip()

Pops the top clip from the clip stack and sets it as the current clip.
pushClip()

Pushes the current clip onto the clip stack.


resetAffine()

Resets the affine transform to the default value


rotate(float angle)

Rotates the coordinate system around a radian angle using the affine transform
rotate(float angle, int pivotX, int pivotY)

Rotates the coordinate system around a radian angle using the affine transform
scale(float x, float y)

Scales the coordinate system using the affine transform


setAlpha(int a)

void

void

Sets alpha as a value between 0-255 (0 - 0xff) where 255 is completely opaque
and 0 is completely transparent
setAntiAliased(boolean a)

Set whether anti-aliasing for standard rendering operations is turned on.


setAntiAliasedText(boolean a)

void

void

Method Summary

Set whether anti-aliasing for text is active, notice that text anti-aliasing is a
separate attribute from standard anti-alisaing.
setClip(int[] clip)

Sets the clip from an array containing x, y, width, height value

1595

Overview (Codename One API)


setClip(int x, int y, int width, int height)

void

Updates the clipping region to match the given region exactly


setColor(int RGB)

Sets the current rgb color while ignoring any potential alpha component within
said color value.

void

setFont(Font font)

void

Sets the font to use with the drawString method calls


setTransform(Transform transform)
Sets the transformation com.codename1.ui.geom.Matrix

void

to apply to drawing in

this graphics context.


shear(float x, float y)

void

Shear the graphics coordinate system using the affine transform


tileImage(Image img, int x, int y, int w, int h)

void

Allows an implementation to optimize image tiling rendering logic


translate(int x, int y)

void

Translates the X/Y location for drawing on the underlying surface.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
translate
public void translate(int x,
int y)

Translates the X/Y location for drawing on the underlying surface. Translation is
incremental so the new value will be added to the current translation and in order to
reset translation we have to invoke translate(-getTranslateX(),
-getTranslateY())

Parameters:
x - the x coordinate
y - the y coordinate
getTranslateX
public int getTranslateX()

Returns the current x translate value


Returns:
the current x translate value
getTranslateY
public int getTranslateY()

Returns the current y translate value


Returns:
the current y translate value
getColor
public int getColor()

Returns the current color


Returns:
the RGB graphics color
setColor
public void setColor(int RGB)

Sets the current rgb color while ignoring any potential alpha component within said
color value.
Parameters:

Methods inherited from class java.lang.Object

1596

Overview (Codename One API)


RGB

- the RGB value for the color.

getFont
public Font getFont()

Returns the font used with the drawString method calls


Returns:
the font used with the drawString method calls
setFont
public void setFont(Font font)

Sets the font to use with the drawString method calls


Parameters:
font - the font used with the drawString method calls
getClipX
public int getClipX()

Returns the x clipping position


Returns:
the x clipping position
getClip
public int[] getClip()

Returns the clip as an x,y,w,h array


Returns:
clip array copy
setClip
public void setClip(int[] clip)

Sets the clip from an array containing x, y, width, height value


Parameters:
clip - 4 element array
getClipY
public int getClipY()

Returns the y clipping position


Returns:
the y clipping position
getClipWidth
public int getClipWidth()

Returns the clip width


Returns:
the clip width
getClipHeight
public int getClipHeight()

Returns the clip height


Returns:
the clip height
clipRect
public void clipRect(int
int
int
int

x,
y,
width,
height)

Clips the given rectangle by intersecting with the current clipping region, this method
can thus only shrink the clipping region and never increase it.
Parameters:
x - the x coordinate of the rectangle to intersect the clip with

Method Detail

1597

Overview (Codename One API)


y - the y coordinate of the rectangle to intersect the clip with
width - the width of the rectangle to intersect the clip with
height - the height of the rectangle to intersect the clip with

setClip
public void setClip(int
int
int
int

x,
y,
width,
height)

Updates the clipping region to match the given region exactly


Parameters:
x - the x coordinate of the new clip rectangle.
y - the y coordinate of the new clip rectangle.
width - the width of the new clip rectangle.
height - the height of the new clip rectangle.
pushClip
public void pushClip()

Pushes the current clip onto the clip stack. It can later be restored using popClip().
popClip
public void popClip()

Pops the top clip from the clip stack and sets it as the current clip.
drawLine
public void drawLine(int
int
int
int

x1,
y1,
x2,
y2)

Draws a line between the 2 X/Y coordinates


Parameters:
x1 - first x position
y1 - first y position
x2 - second x position
y2 - second y position
fillRect
public void fillRect(int
int
int
int

x,
y,
width,
height)

Fills the rectangle from the given position according to the width/height minus 1 pixel
according to the convention in Java.
Parameters:
x - the x coordinate of the rectangle to be filled.
y - the y coordinate of the rectangle to be filled.
width - the width of the rectangle to be filled.
height - the height of the rectangle to be filled.
drawRect
public void drawRect(int
int
int
int

x,
y,
width,
height)

Draws a rectangle in the given coordinates


Parameters:
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.

Method Detail

1598

Overview (Codename One API)


drawRect
public void drawRect(int
int
int
int
int

x,
y,
width,
height,
thickness)

Draws a rectangle in the given coordinates with the given thickness


Parameters:
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.
thickness - the thickness in pixels
drawRoundRect
public void drawRoundRect(int
int
int
int
int
int

x,
y,
width,
height,
arcWidth,
arcHeight)

Draws a rounded corner rectangle in the given coordinates with the arcWidth/height
matching the last two arguments respectively.
Parameters:
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
lighterColor
public void lighterColor(int factor)

Makes the current color slightly lighter, this is useful for many visual effects
Parameters:
factor - the degree of lightening a color per channel a number from 1 to 255
darkerColor
public void darkerColor(int factor)

Makes the current color slightly darker, this is useful for many visual effects
Parameters:
factor - the degree of lightening a color per channel a number from 1 to 255
fillRoundRect
public void fillRoundRect(int
int
int
int
int
int

x,
y,
width,
height,
arcWidth,
arcHeight)

Fills a rounded rectangle in the same way as drawRoundRect


Parameters:
x - the x coordinate of the rectangle to be filled.
y - the y coordinate of the rectangle to be filled.
width - the width of the rectangle to be filled.
height - the height of the rectangle to be filled.
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
See Also:
drawRoundRect(int, int, int, int, int, int)

Method Detail

1599

Overview (Codename One API)


fillArc
public void fillArc(int
int
int
int
int
int

x,
y,
width,
height,
startAngle,
arcAngle)

Fills a circular or elliptical arc based on the given angles and bounding box. The
resulting arc begins at startAngle and extends for arcAngle degrees. Usage:
Painter p = new Painter(cmp) {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
int r = Math.min(rect.getWidth(), rect.getHeight())/2;
int x = rect.getX() + rect.getWidth()/2 - r;
int y = rect.getY() + rect.getHeight()/2 - r;
switch (style) {
case CircleButtonStrokedDark:
case CircleButtonStrokedLight: {
if (cmp.getStyle().getBgTransparency() != 0) {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha <0) {
alpha = 0xff;
}
g.setColor(cmp.getStyle().getBgColor());
g.setAlpha(alpha);
g.fillArc(x, y, 2*r-1, 2*r-1, 0, 360);
g.setAlpha(0xff);
}
g.setColor(cmp.getStyle().getFgColor());
g.drawArc(x, y, 2*r-1, 2*r-1, 0, 360);
break;
}
case CircleButtonFilledDark:
case CircleButtonFilledLight:
case CircleButtonTransparentDark:
case CircleButtonTransparentLight: {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha < 0) {
alpha = 0xff;
}
g.setAlpha(alpha);
g.setColor(cmp.getStyle().getBgColor());
g.fillArc(x, y, 2*r, 2*r, 0, 360);
g.setAlpha(0xff);
break;
}
}
g.setAntiAliased(antiAliased);
}
};
cmp.getAllStyles().setBgPainter(p);

Parameters:
x - the x coordinate of the upper-left corner of the arc to be filled.
y - the y coordinate of the upper-left corner of the arc to be filled.
width - the width of the arc to be filled.
height - the height of the arc to be filled.
startAngle - the beginning angle.
arcAngle - the angular extent of the arc, relative to the start angle.
drawArc
public void drawArc(int
int
int
int
int
int

x,
y,
width,
height,
startAngle,
arcAngle)

Draws a circular or elliptical arc based on the given angles and bounding box
Parameters:
x - the x coordinate of the upper-left corner of the arc to be drawn.
y - the y coordinate of the upper-left corner of the arc to be drawn.
width - the width of the arc to be drawn.
height - the height of the arc to be drawn.
startAngle - the beginning angle.

Method Detail

1600

Overview (Codename One API)


arcAngle

- the angular extent of the arc, relative to the start angle.

drawString
public void drawString(String str,
int x,
int y,
int textDecoration)

Draw a string using the current font and color in the x,y coordinates. The font is
drawn from the top position and not the baseline.
Parameters:
str - the string to be drawn.
x - the x coordinate.
y - the y coordinate.
textDecoration - Text decoration bitmask (See Style's
TEXT_DECORATION_* constants)
drawStringBaseline
public void drawStringBaseline(String str,
int x,
int y)

Draws a string using baseline coordinates.


Parameters:
str - The string to be drawn.
x - The x-coordinate of the start of left edge of the text block.
y - The y-coordinate of the baseline of the text.
See Also:
drawString(java.lang.String, int, int)

drawStringBaseline
public void drawStringBaseline(String str,
int x,
int y,
int textDecoration)

Draws a string using baseline coordinates.


Parameters:
str - The string to be drawn.
x - The x-coordinate of the start of left edge of the text block.
y - The y-coordinate of the baseline of the text.
textDecoration - Text decoration bitmask (See Style's
TEXT_DECORATION_* constants)
See Also:
drawString(java.lang.String, int, int, int)

drawString
public void drawString(String str,
int x,
int y)

Draw a string using the current font and color in the x,y coordinates. The font is
drawn from the top position and not the baseline.
Parameters:
str - the string to be drawn.
x - the x coordinate.
y - the y coordinate.
drawChar
public void drawChar(char character,
int x,
int y)

Draw the given char using the current font and color in the x,y coordinates. The font
is drawn from the top position and not the baseline.
Parameters:
character - - the character to be drawn
x - the x coordinate of the baseline of the text
y - the y coordinate of the baseline of the text

Method Detail

1601

Overview (Codename One API)


drawChars
public void drawChars(char[] data,
int offset,
int length,
int x,
int y)

Draw the given char array using the current font and color in the x,y coordinates. The
font is drawn from the top position and not the baseline.
Parameters:
data - the array of characters to be drawn
offset - the start offset in the data
length - the number of characters to be drawn
x - the x coordinate of the baseline of the text
y - the y coordinate of the baseline of the text
drawImage
public void drawImage(Image img,
int x,
int y)

Draws the image so its top left coordinate corresponds to x/y


Parameters:
img - the specified image to be drawn. This method does nothing if img is
null.
x - the x coordinate.
y - the y coordinate.
drawImage
public void drawImage(Image img,
int x,
int y,
int w,
int h)

Draws the image so its top left coordinate corresponds to x/y and scales it to
width/height
Parameters:
img - the specified image to be drawn. This method does nothing if img is
null.
x - the x coordinate.
y - the y coordinate.
w - the width to occupy
h - the height to occupy
drawShape
public void drawShape(Shape shape,
Stroke stroke)

Draws a outline shape inside the specified bounding box. The bounding box will
resize the shape to fit in its dimensions.
This is not supported on all platforms and contexts currently. Use
isShapeSupported() to check if the current context supports drawing shapes.
Parameters:
shape - The shape to be drawn.
stroke - the stroke to use

See Also:
#setStroke, isShapeSupported()

fillShape
public void fillShape(Shape shape)

Fills the given shape using the current alpha and color settings.

Method Detail

1602

Overview (Codename One API)


This is not supported on all platforms and contexts currently. Use
isShapeSupported() to check if the current context supports drawing shapes.
Parameters:
shape

- The shape to be filled.

See Also:
isShapeSupported()

isTransformSupported
public boolean isTransformSupported()

Checks to see if com.codename1.ui.geom.Matrix transforms are supported by this


graphics context.
Returns:
true if this graphics context supports com.codename1.ui.geom.Matrix
transforms.
Note that this method only confirms that 2D transforms are supported. If you
need to perform 3D transformations, you should use the
isPerspectiveTransformSupported() method.
See Also:
setTransform(com.codename1.ui.Transform), getTransform(),
isPerspectiveTransformSupported()

isPerspectiveTransformSupported
public boolean isPerspectiveTransformSupported()

Checks to see if perspective (3D) com.codename1.ui.geom.Matrix transforms are


supported by this graphics context. If 3D transforms are supported, you can use a
4x4 transformation com.codename1.ui.geom.Matrix via
setTransform(com.codename1.ui.Transform) to perform 3D transforms.
Note: It is possible for 3D transforms to not be supported but Affine (2D) transforms
to be supported. In this case you would be limited to a 3x3 transformation matrix in
setTransform(com.codename1.ui.Transform). You can check for 2D transformation
support using the isTransformSupported() method.
Returns:
true if Perspective (3D) transforms are supported. false otherwise.
See Also:
isTransformSupported(), setTransform(com.codename1.ui.Transform),
getTransform()

isShapeSupported
public boolean isShapeSupported()

Checks to see if this graphics context supports drawing shapes (i.e.


drawShape(com.codename1.ui.geom.Shape, com.codename1.ui.Stroke) and
fillShape(com.codename1.ui.geom.Shape) methods. If this returns false, and
drawShape(com.codename1.ui.geom.Shape, com.codename1.ui.Stroke) or
fillShape(com.codename1.ui.geom.Shape), then nothing will be drawn.

you call

Returns:
true If drawShape(com.codename1.ui.geom.Shape,
com.codename1.ui.Stroke) and fillShape(com.codename1.ui.geom.Shape)
are supported.
See Also:
drawShape(com.codename1.ui.geom.Shape, com.codename1.ui.Stroke),
fillShape(com.codename1.ui.geom.Shape)

setTransform
public void setTransform(Transform transform)

Sets the transformation com.codename1.ui.geom.Matrix to apply to drawing in this


graphics context. In order to use this for 2D/Affine transformations you should first
check to make sure that transforms are supported by calling the
isTransformSupported() method. For 3D/Perspective transformations, you should

Method Detail

1603

Overview (Codename One API)


first check to make sure that 3D/Perspective transformations are supported by calling
the isPerspectiveTransformSupported().
Transformations are applied with (0,0) as the origin. So rotations and scales are
anchored at this point on the screen. You can use a different anchor point by either
embedding it in the transformation matrix (i.e. pre-transform the
com.codename1.ui.geom.Matrix to anchor at a different point) or use the
#setTransform(com.codename1.ui.geom.Matrix,int,int) variation that allows you to
explicitly set the anchor point.
Parameters:
- The transformation com.codename1.ui.geom.Matrix to use for
drawing. 2D/Affine transformations can be achieved using a 3x3
transformation com.codename1.ui.geom.Matrix. 3D/Perspective
transformations can be achieved using a 4x3 transformation
com.codename1.ui.geom.Matrix.
See Also:
isTransformSupported(), isPerspectiveTransformSupported(),
transform

#setTransform(com.codename1.ui.geom.Matrix,int,int)

getTransform
public Transform getTransform()

Gets the transformation matrix that is currently applied to this graphics context.
Returns:
The current transformation matrix.
See Also:
setTransform(com.codename1.ui.Transform)

fillTriangle
public void fillTriangle(int
int
int
int
int
int

x1,
y1,
x2,
y2,
x3,
y3)

Draws a filled triangle with the given coordinates


Parameters:
x1 - the x coordinate of the first vertex of the triangle
y1 - the y coordinate of the first vertex of the triangle
x2 - the x coordinate of the second vertex of the triangle
y2 - the y coordinate of the second vertex of the triangle
x3 - the x coordinate of the third vertex of the triangle
y3 - the y coordinate of the third vertex of the triangle
fillRadialGradient
public void fillRadialGradient(int
int
int
int
int
int

startColor,
endColor,
x,
y,
width,
height)

Draws a radial gradient in the given coordinates with the given colors, doesn't take
alpha into consideration when drawing the gradient. Notice that a radial gradient will
result in a circular shape, to create a square use fillRect or draw a larger shape and
clip to the appropriate size.
Parameters:
startColor - the starting RGB color
endColor - the ending RGB color
x - the x coordinate
y - the y coordinate
width - the width of the region to be filled
height - the height of the region to be filled

Method Detail

1604

Overview (Codename One API)


fillRectRadialGradient
public void fillRectRadialGradient(int startColor,
int endColor,
int x,
int y,
int width,
int height,
float relativeX,
float relativeY,
float relativeSize)

Draws a radial gradient in the given coordinates with the given colors, doesn't take
alpha into consideration when drawing the gradient. Notice that this method differs
from fillRadialGradient since it draws a square gradient at all times and can thus be
cached Notice that a radial gradient will result in a circular shape, to create a square
use fillRect or draw a larger shape and clip to the appropriate size.
Parameters:
startColor - the starting RGB color
endColor - the ending RGB color
x - the x coordinate
y - the y coordinate
width - the width of the region to be filled
height - the height of the region to be filled
relativeX - indicates the relative position of the gradient within the drawing
region
relativeY - indicates the relative position of the gradient within the drawing
region
relativeSize - indicates the relative size of the gradient within the drawing
region
fillLinearGradient
public void fillLinearGradient(int startColor,
int endColor,
int x,
int y,
int width,
int height,
boolean horizontal)

Draws a linear gradient in the given coordinates with the given colors, doesn't take
alpha into consideration when drawing the gradient
Parameters:
startColor - the starting RGB color
endColor - the ending RGB color
x - the x coordinate
y - the y coordinate
width - the width of the region to be filled
height - the height of the region to be filled
horizontal - indicating wheter it is a horizontal fill or vertical
fillRect
public void fillRect(int x,
int y,
int w,
int h,
byte alpha)

Fills a rectangle with an optionally translucent fill color


Parameters:
x - the x coordinate of the rectangle to be filled
y - the y coordinate of the rectangle to be filled
w - the width of the rectangle to be filled
h - the height of the rectangle to be filled
alpha - the alpha values specify semitransparency

Method Detail

1605

Overview (Codename One API)


fillPolygon
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)

Fills a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y)
coordinates defines a point.
Parameters:
xPoints - - a an array of x coordinates.
yPoints - - a an array of y coordinates.
nPoints - - a the total number of points.
drawPolygon
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)

Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y)
coordinates defines a point.
Parameters:
xPoints - - a an array of x coordinates.
yPoints - - a an array of y coordinates.
nPoints - - a the total number of points.
isAlphaSupported
public boolean isAlphaSupported()

Indicates whether invoking set/getAlpha would have an effect on all further rendering
from this graphics object.
Returns:
false if setAlpha has no effect true if it applies to everything some effect
setAlpha
public void setAlpha(int a)

Sets alpha as a value between 0-255 (0 - 0xff) where 255 is completely opaque and 0
is completely transparent
Parameters:
a - the alpha value
getAlpha
public int getAlpha()

Returnes the alpha as a value between 0-255 (0 - 0xff) where 255 is completely
opaque and 0 is completely transparent
Returns:
the alpha value
isAntiAliasingSupported
public boolean isAntiAliasingSupported()

Returns true if anti-aliasing for standard rendering operations is supported, notice that
text anti-aliasing is a separate attribute.
Returns:
true if anti aliasing is supported
isAntiAliasedTextSupported
public boolean isAntiAliasedTextSupported()

Returns true if anti-aliasing for text is supported, notice that text anti-aliasing is a
separate attribute from standard anti-alisaing.
Returns:
true if text anti aliasing is supported

Method Detail

1606

Overview (Codename One API)


isAntiAliased
public boolean isAntiAliased()

Returns true if anti-aliasing for standard rendering operations is turned on.


Returns:
true if anti aliasing is active
setAntiAliased
public void setAntiAliased(boolean a)

Set whether anti-aliasing for standard rendering operations is turned on.


Parameters:
a - true if anti aliasing is active
setAntiAliasedText
public void setAntiAliasedText(boolean a)

Set whether anti-aliasing for text is active, notice that text anti-aliasing is a separate
attribute from standard anti-alisaing.
Parameters:
a - true if text anti aliasing is supported
isAntiAliasedText
public boolean isAntiAliasedText()

Indicates whether anti-aliasing for text is active, notice that text anti-aliasing is a
separate attribute from standard anti-alisaing.
Returns:
true if text anti aliasing is supported
isAffineSupported
public boolean isAffineSupported()

Indicates whether the underlying implementation can draw using an affine transform
hence methods such as rotate, scale and shear would work
Returns:
true if an affine transformation matrix is present
resetAffine
public void resetAffine()

Resets the affine transform to the default value


scale
public void scale(float x,
float y)

Scales the coordinate system using the affine transform


Parameters:
x - scale factor for x
y - scale factor for y
rotate
public void rotate(float angle)

Rotates the coordinate system around a radian angle using the affine transform
Parameters:
angle - the rotation angle in radians
rotate
public void rotate(float angle,
int pivotX,
int pivotY)

Rotates the coordinate system around a radian angle using the affine transform
Parameters:
angle - the rotation angle in radians

Method Detail

1607

Overview (Codename One API)


pivotX
pivotY

- the pivot point


- the pivot point

shear
public void shear(float x,
float y)

Shear the graphics coordinate system using the affine transform


Parameters:
x - shear factor for x
y - shear factor for y
beginNativeGraphicsAccess
public Object beginNativeGraphicsAccess()

Starts accessing the native graphics in the underlying OS, when accessing the native
graphics Codename One shouldn't be used! The native graphics is unclipped and
untranslated by default and its the responsibility of the caller to clip/translate
appropriately.
When finished with the native graphics it is essential to invoke
endNativeGraphicsAccess
Returns:
an instance of the underlying native graphics object
endNativeGraphicsAccess
public void endNativeGraphicsAccess()

Invoke this to restore Codename One's graphics settings into the native graphics
tileImage
public void tileImage(Image img,
int x,
int y,
int w,
int h)

Allows an implementation to optimize image tiling rendering logic


Parameters:
img - the image
x - coordinate to tile the image along
y - coordinate to tile the image along
w - coordinate to tile the image along
h - coordinate to tile the image along
getScaleX
public float getScaleX()

Returns the affine X scale


Returns:
the current scale
getScaleY
public float getScaleY()

Returns the affine Y scale


Returns:
the current scale

Method Detail

1608

Overview (Codename One API)


com.codename1.ui

Class Form
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Form
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
Dialog

public class
extends Container

Top level component that serves as the root for the UI, this Container handles the menus and title
while placing content between them. By default a forms central content (the content pane) is
scrollable. Form contains Title bar, MenuBar and a ContentPane. Calling to addComponent on the
Form is delegated to the contenPane.addComponent
**************************
*
Title
*
**************************
*
*
*
*
*
ContentPane
*
*
*
*
*
**************************
*
MenuBar
*
**************************

Field Summary
Modifier and
Type

Field and Description


focusScrolling

protected
boolean

Indicates whether lists and containers should scroll only via focus and thus
"jump" when moving to a larger component as was the case in older versions
of Codename One.

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Form()

Default constructor creates a simple form


Form(Layout contentPaneLayout)

Constructor that accepts a layout


Form(String title)

Sets the title after invoking the constructor

Class Form

1609

Overview (Codename One API)


Form(String title, Layout contentPaneLayout)

Sets the title after invoking the constructor

Method Summary
Modifier and
Type

Method and Description


actionCommand(Command cmd)

protected void

void

Invoked to allow subclasses of form to handle a command from one point rather th
command instances.
addCommand(Command cmd)

Adds a command to the menu bar softkeys.


addCommand(Command cmd, int offset)

void

Adds a command to the menu bar softkeys or into the menu dialog, this version of
command in an arbitrary location.
addCommandListener(ActionListener l)

void

void
void
void
void
void
void
void
void
void
boolean
void
void
Component
Component
AnimationManager
Command
Command
Command
int
Form

Constructor Summary

A listener that is invoked when a command is clicked allowing multiple commands


block
addComponent(Component cmp)

Adds Component to the Form's Content Pane


addComponent(int index, Component cmp)

Adds Component to the Form's Content Pane


addComponent(int index, Object constraints, Component cmp)

Adds a Component to the Container


addComponent(Object constraints, Component cmp)

Adds a Component to the Container


addGameKeyListener(int keyCode, ActionListener listener)

Add a game key listener to the given gamekey for a callback when the key is relea
addKeyListener(int keyCode, ActionListener listener)

Add a key listener to the given keycode for a callback when the key is released
addOrientationListener(ActionListener l)

This listener is invoked when device orientation changes on devices that support o
addShowListener(ActionListener l)

This listener would be invoked when show is completed


addSizeChangedListener(ActionListener l)

This listener is invoked when device size is changed


animate()

Allows the animation to reduce "repaint" calls when it returns false.


deregisterAnimated(Animation cmp)

Indicate that cmp would no longer like to receive animation events


dispatchCommand(Command cmd, ActionEvent ev)

Dispatches a command via the standard form mechanism of firing a command eve
findNextFocusHorizontal(boolean right)

This method returns the next focusable Component horizontally


findNextFocusVertical(boolean down)

This method returns the next focusable Component vertically


getAnimationManager()

Returns the animation manager instance responsible for this form, this can be used
getBackCommand()

Indicates the command that is defined as the back command out of this form.
getClearCommand()

Indicates the command that is defined as the clear command in this form.
getCommand(int index)

Returns the command occupying the given index


getCommandCount()

A helper method to check the amount of commands within the form menu
getComponentForm()

1610

Overview (Codename One API)


Returns the Component Form or null if this Component is not added yet to a form
int
Container

getComponentIndex(Component cmp)

Returns the Component index in the Container


getContentPane()

This method returns the Content pane instance


getDefaultCommand()

Command

Default command is invoked when a user presses fire, this functionality works well
collide with elements such as navigation and combo boxes.
getDragRegionStatus(int x, int y)

int

TextArea
Component

Indicates if the section within the X/Y area is a "drag region" where we expect peop
case we can instantly start dragging making perceived performance faster.
getEditOnShow()

A text component that will receive focus and start editing immediately as the form i
getFocused()

Returns the current focus component for this form


getGlassPane()

Painter

Allows a developer that doesn't derive from the form to draw on top of the form reg
changes or animations.
getLayeredPane()

Container

Container
Layout
MenuBar
Style

This method returns the layered pane of the Form, the layered pane is laid on top o
created lazily upon calling this method the layer will be created.
getLayeredPane(Class c, boolean top)

Returns the layered pane for the class and if one doesn't exist a new one is create
getLayout()

Returns the layout manager responsible for arranging this container


getMenuBar()

Returns the associated Menu Bar object


getMenuStyle()

Returns the style of the menu


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object

This method is here to workaround an XMLVM array type bug where property type
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI bu
getScrollAnimationSpeed()

int

Scroll animation speed in milliseconds allowing a developer to slow down or accele


mode
getSoftButton(int offset)

Button

int
int
String

Returns the button representing the softbutton, this allows modifying softbutton attr
programmatically rather than by using the command API.
getSoftButtonCount()

Returns the number of buttons on the menu bar for use with getSoftButton()
getTintColor()

Default color for the screen tint when a dialog or a menu is shown
getTitle()

Returns the Form title text


getTitleArea()

Container

Label
Style

Method Summary

Deprecated.
this method was exposed to allow some hacks, you are advised not to use it. There
as command behavior (thru Display or the theme constants)
getTitleComponent()

Allows modifying the title attributes beyond style (e.g.


getTitleStyle()

1611

Overview (Codename One API)


Returns the style of the title
Toolbar
Transition
Transition
UIManager

getToolbar()

Gets the Form Toolbar if exists or null


getTransitionInAnimator()

This property allows us to define a an animation that will draw the transition for ent
getTransitionOutAnimator()

This property allows us to define a an animation that will draw the transition for exit
getUIManager()

This method should be used by the Component to retrieve the correct UIManager t
grabAnimationLock()

boolean

boolean

Deprecated.
this is effectively invalidated by the newer animation framework
hasMedia()

Used by the implementation to prevent flickering when flushing the double buffer
hideNotify()

protected void

protected void

This method is only invoked when the underlying canvas for the form is hidden this
based events and is generally usable for suspend/resume based behavior
initLaf(UIManager uim)

This method initializes the Component defaults constants


isAlwaysTensile()

boolean

boolean

Enable the tensile drag to work even when a component doesn't have a scroll show
needs to be set to true)
isCyclicFocus()

Indicates whether focus should cycle within the form


isDragRegion(int x, int y)

boolean

Deprecated.
this method was replaced by getDragRegionStatus
isFocusScrolling()

boolean

Indicates whether lists and containers should scroll only via focus and thus "jump"
component as was the case in older versions of Codename One.
isFormBottomPaddingEditingMode()

boolean

boolean
boolean
boolean
boolean
void
void
void
protected void

Toggles the way the virtual keyboard behaves, enabling this mode shrinks the scre
possible when working with text fields that aren't in a scrollable container.
isMinimizeOnBack()

When set to true the physical back button will minimize the application
isScrollable()

Indicates whether the component should/could scroll by default a component is no


isSingleFocusMode()

Returns true if there is only one focusable member in this form.


isSmoothScrolling()

Indicates that scrolling through the component should work as an animation


keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
longKeyPress(int keyCode)

If this Component is focused this method is invoked when the user presses and ho
longPointerPress(int x, int y)

void

protected void

If this Component is focused this method is invoked when the user presses and ho
Component
onShow()

Allows subclasses to bind functionality that occurs when a specific form or dialog a
onShowCompleted()

protected void

Allows subclasses to bind functionality that occurs when a specific form or dialog is
when the transition is totally complete (unlike onShow which is called on intent).

void

paint(Graphics g)

Method Summary

1612

Overview (Codename One API)

This method paints the Component on the screen, it should be overriden by subcla
drawing or invoke the UI API's to let the PLAF perform the rendering.
void
protected String
void
void
void
void
void
void
void

paintBackground(Graphics g)

Exposing the background painting for the benefit of animations


paramString()

Returns a string representing the state of this component.


pointerDragged(int[] x, int[] y)

If this Component is focused, the pointer dragged event will call this method
pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerHover(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the displa
pointerHoverPressed(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the displa
pointerHoverReleased(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the displa
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
refreshTheme(boolean merge)

void

Makes sure the component is up to date with the current theme, ONLY INVOKE TH
CHANGED THE THEME!
registerAnimated(Animation cmp)

void

The given component is interested in animating its appearance and will start receiv
visible in the form allowing it to animate its appearance.
releaseAnimationLock()

void

void
void
void
void

Deprecated.
this is effectively invalidated by the newer animation framework
removeAll()

Removes all Components from the Content Pane


removeAllCommands()

Clear menu commands from the menu bar


removeAllShowListeners()

Removes all Show Listeners from this Form


removeCommand(Command cmd)

Removes the command from the menu bar softkeys


removeCommandListener(ActionListener l)

void

void
void
void
void
void
void
void
void
void

Method Summary

A listener that is invoked when a command is clicked allowing multiple commands


block
removeComponent(Component cmp)

Removes a component from the Form's Content Pane


removeGameKeyListener(int keyCode, ActionListener listener)

Removes a game key listener from the given game keycode


removeKeyListener(int keyCode, ActionListener listener)

Removes a key listener from the given keycode


removeOrientationListener(ActionListener l)

This listener is invoked when device orientation changes on devices that support o
removeShowListener(ActionListener l)

Removes the show listener


removeSizeChangedListener(ActionListener l)

Remove SizeChangedListener
replace(Component current, Component next, Transition t)

This method replaces the current Component with the next Component.
replaceAndWait(Component current, Component next, Transition t)

This method replaces the current Component with the next Component.
scrollComponentToVisible(Component c)

Makes sure the component is visible in the scroll if this container is scrollable

1613

Overview (Codename One API)


setAlwaysTensile(boolean alwaysTensile)
void

void

Enable the tensile drag to work even when a component doesn't have a scroll show
needs to be set to true)
setBackCommand(Command backCommand)

Indicates the command that is defined as the back command out of this form.
setBgImage(Image bgImage)

void

void
void

Deprecated.
Use the style directly
setClearCommand(Command clearCommand)

Indicates the command that is defined as the clear command in this form.
setCyclicFocus(boolean cyclicFocus)

Indicates whether focus should cycle within the form


setDefaultCommand(Command defaultCommand)

void

void
void

Default command is invoked when a user presses fire, this functionality works well
collide with elements such as navigation and combo boxes.
setEditOnShow(TextArea editOnShow)

A text component that will receive focus and start editing immediately as the form i
setFocused(Component focused)

Sets the focused component and fires the appropriate events to make it so
setFocusScrolling(boolean focusScrolling)

void

Indicates whether lists and containers should scroll only via focus and thus "jump"
component as was the case in older versions of Codename One.
setFormBottomPaddingEditingMode(boolean b)

void

Toggles the way the virtual keyboard behaves, enabling this mode shrinks the scre
possible when working with text fields that aren't in a scrollable container.
setGlassPane(Painter glassPane)

void

void
void
void
void
void
String
void
void
void
void

Allows a developer that doesn't derive from the form to draw on top of the form reg
changes or animations.
setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


setMenuBar(MenuBar menuBar)

Sets the associated MenuBar Object.


setMenuCellRenderer(ListCellRenderer menuCellRenderer)

Determine the cell renderer used to render menu elements for themeing the look o
setMenuTransitions(Transition transitionIn, Transition transitionOut)

Sets the menu transitions for showing/hiding the menu, can be null...
setMinimizeOnBack(boolean minimizeOnBack)

When set to true the physical back button will minimize the application
setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null
setRTL(boolean r)

Is the component a bidi RTL component


setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


setScrollableX(boolean scrollableX)

Sets whether the component should/could scroll on the X axis


setScrollableY(boolean scrollableY)

Sets whether the component should/could scroll on the Y axis


setScrollAnimationSpeed(int animationSpeed)

void

void
void
void
void

Method Summary

Scroll animation speed in milliseconds allowing a developer to slow down or accele


mode
setSmoothScrolling(boolean smoothScrolling)

Indicates that scrolling through the component should work as an animation


setTintColor(int tintColor)

Default color for the screen tint when a dialog or a menu is shown
setTitle(String title)

Sets the Form title to the given text


setTitleComponent(Label title)

1614

Overview (Codename One API)


Allows replacing the title with a different title component, thus allowing developers
objects.
setTitleComponent(Label title, Transition t)

Allows replacing the title with a different title component, thus allowing developers
objects.

void

setTitleStyle(Style s)

Deprecated.
this method doesn't take into consideration multiple styles

void

setToolbar(Toolbar toolbar)

void

Sets the Form Toolbar


setToolBar(Toolbar toolbar)

Deprecated.
use setToolbar instead (lower case b)

void

setTransitionInAnimator(Transition transitionInAnimator)

void

This property allows us to define a an animation that will draw the transition for ent
setTransitionOutAnimator(Transition transitionOutAnimator)

void

This property allows us to define a an animation that will draw the transition for exit
setUIManager(UIManager uiManager)

Allows replacing the UIManager in a component hierarchy to update the look and f
hierarchy

void

setVisible(boolean visible)

void

Toggles visibility of the component

protected
boolean

shouldSendPointerReleaseToOtherForm()

Indicates whether this form wants to receive pointerReleased events for touch eve
form
show()

void

Displays the current form on the screen


showBack()

Displays the current form on the screen, this version of the method is useful for "ba
reverses the direction of the transition.

void

showNotify()
protected void

protected void

This method is only invoked when the underlying canvas for the form is shown this
based events and is generally usable for suspend/resume based behavior
sizeChanged(int w, int h)

This method is only invoked when the underlying canvas for the form gets a size ch

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getGridPosX,
getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled,
isScrollableX, isScrollableY, isSelectableInteraction, iterator,
layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass,
replace, replaceAndWait, replaceAndWait, revalidate, setCellRenderer,
setEnabled, setLeadComponent, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,

Methods inherited from class com.codename1.ui.Container

1615

Overview (Codename One API)


getCloudDestinationProperty, getComponentState, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed,
getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollVisible, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
onScrollX, onScrollY, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerPressed,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setSameHeight, setSameWidth, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString,
unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
focusScrolling
protected boolean focusScrolling

Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of Codename
One.

Constructor Detail
Form
public Form()

Default constructor creates a simple form


Form
public Form(Layout contentPaneLayout)

Constructor that accepts a layout


Parameters:
contentPaneLayout - the layout for the content pane

Methods inherited from class com.codename1.ui.Component

1616

Overview (Codename One API)


Form
public Form(String title)

Sets the title after invoking the constructor


Parameters:
title - the form title
Form
public Form(String title,
Layout contentPaneLayout)

Sets the title after invoking the constructor


Parameters:
title - the form title
contentPaneLayout - the layout for the content pane

Method Detail
getAnimationManager
public AnimationManager getAnimationManager()

Returns the animation manager instance responsible for this form, this can be used
to track/queue animations
Overrides:
getAnimationManager in class Component
Returns:
the animation manager
setFormBottomPaddingEditingMode
public void setFormBottomPaddingEditingMode(boolean b)

Toggles the way the virtual keyboard behaves, enabling this mode shrinks the screen
but makes editing possible when working with text fields that aren't in a scrollable
container.
Parameters:
b - true to enable false to disable
isFormBottomPaddingEditingMode
public boolean isFormBottomPaddingEditingMode()

Toggles the way the virtual keyboard behaves, enabling this mode shrinks the screen
but makes editing possible when working with text fields that aren't in a scrollable
container.
Returns:
true when this mode is enabled
isAlwaysTensile
public boolean isAlwaysTensile()

Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Overrides:
isAlwaysTensile in class Component
Returns:
the alwaysTensile
grabAnimationLock
public boolean grabAnimationLock()

Deprecated. this is effectively invalidated by the newer animation framework


Allows grabbing a flag that is used by convention to indicate that you are running an
exclusive animation. This is used by some code to prevent collision between optional
animation
Returns:

Constructor Detail

1617

Overview (Codename One API)


whether the lock was acquired or not
releaseAnimationLock
public void releaseAnimationLock()

Deprecated. this is effectively invalidated by the newer animation framework


Invoke this to release the animation lock that was grabbed in grabAnimationLock
setAlwaysTensile
public void setAlwaysTensile(boolean alwaysTensile)

Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Overrides:
setAlwaysTensile in class Component
Parameters:
alwaysTensile - the alwaysTensile to set
getTitleArea
public Container getTitleArea()

Deprecated. this method was exposed to allow some hacks, you are advised not to
use it. There are some alternatives such as command behavior (thru Display or the
theme constants)
Title area manipulation might break with future changes to Codename One and might
damage themeing/functionality of the Codename One application in some platforms
Returns:
the container containing the title
getUIManager
public UIManager getUIManager()

Description copied from class: Container


This method should be used by the Component to retrieve the correct UIManager to
work with
Overrides:
getUIManager in class Container
Returns:
a UIManager instance
setUIManager
public void setUIManager(UIManager uiManager)

Description copied from class: Container


Allows replacing the UIManager in a component hierarchy to update the look and feel
only to a specific hierarchy
Overrides:
setUIManager in class Container
Parameters:
uiManager - UIManager instance
addShowListener
public void addShowListener(ActionListener l)

This listener would be invoked when show is completed


Parameters:
l - listener
removeShowListener
public void removeShowListener(ActionListener l)

Removes the show listener


Parameters:
l - the listener

Method Detail

1618

Overview (Codename One API)


removeAllShowListeners
public void removeAllShowListeners()

Removes all Show Listeners from this Form


addOrientationListener
public void addOrientationListener(ActionListener l)

This listener is invoked when device orientation changes on devices that support
orientation change
Parameters:
l - listener
removeOrientationListener
public void removeOrientationListener(ActionListener l)

This listener is invoked when device orientation changes on devices that support
orientation change
Parameters:
l - the listener
addSizeChangedListener
public void addSizeChangedListener(ActionListener l)

This listener is invoked when device size is changed


Parameters:
l - listener
removeSizeChangedListener
public void removeSizeChangedListener(ActionListener l)

Remove SizeChangedListener
Parameters:
l - the listener
hideNotify
protected void hideNotify()

This method is only invoked when the underlying canvas for the form is hidden this
method isn't called for form based events and is generally usable for suspend/resume
based behavior
showNotify
protected void showNotify()

This method is only invoked when the underlying canvas for the form is shown this
method isn't called for form based events and is generally usable for suspend/resume
based behavior
sizeChanged
protected void sizeChanged(int w,
int h)

This method is only invoked when the underlying canvas for the form gets a size
changed event. This method will trigger a relayout of the Form. This method will get
the callback only if this Form is the Current Form
Parameters:
w - the new width of the Form
h - the new height of the Form
setGlassPane
public void setGlassPane(Painter glassPane)

Allows a developer that doesn't derive from the form to draw on top of the form
regardless of underlying changes or animations. This is useful for watermarks or
special effects (such as tinting) it is also useful for generic drawing of validation errors

Method Detail

1619

Overview (Codename One API)


etc... A glass pane is generally transparent or translucent and allows the the UI
bellow to be seen.
Parameters:
glassPane - a new glass pane to install. It is generally recommended to use a
painter chain if more than one painter is required.
isDragRegion
public boolean isDragRegion(int x,
int y)

Deprecated. this method was replaced by getDragRegionStatus


Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag and never actually "press" in which case we can instantly start dragging
making perceived performance faster. This is invoked by the implementation code to
optimize drag start behavior
Overrides:
isDragRegion in class Component
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
true if the touch is in a region specifically designated as a "drag region"
getDragRegionStatus
public int getDragRegionStatus(int x,
int y)

Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Overrides:
getDragRegionStatus in class Component
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values
getGlassPane
public Painter getGlassPane()

Allows a developer that doesn't derive from the form to draw on top of the form
regardless of underlying changes or animations. This is useful for watermarks or
special effects (such as tinting) it is also useful for generic drawing of validation errors
etc... A glass pane is generally transparent or translucent and allows the the UI
bellow to be seen.
Returns:
the instance of the glass pane for this form
See Also:
PainterChain.installGlassPane(Form, com.codename1.ui.Painter)

setTitleStyle
public void setTitleStyle(Style s)

Deprecated. this method doesn't take into consideration multiple styles


Sets the style of the title programmatically
Parameters:
s - new style
getTitleComponent
public Label getTitleComponent()

Allows modifying the title attributes beyond style (e.g. setting icon/alignment etc.)
Returns:
the component representing the title for the form

Method Detail

1620

Overview (Codename One API)


setTitleComponent
public void setTitleComponent(Label title)

Allows replacing the title with a different title component, thus allowing developers to
create more elaborate title objects.
Parameters:
title - new title component
setTitleComponent
public void setTitleComponent(Label title,
Transition t)

Allows replacing the title with a different title component, thus allowing developers to
create more elaborate title objects. This version of the method allows special effects
for title replacement such as transitions for title entering
Parameters:
title - new title component
t - transition for title replacement
addKeyListener
public void addKeyListener(int keyCode,
ActionListener listener)

Add a key listener to the given keycode for a callback when the key is released
Parameters:
keyCode - code on which to send the event
listener - listener to invoke when the key code released.
removeKeyListener
public void removeKeyListener(int keyCode,
ActionListener listener)

Removes a key listener from the given keycode


Parameters:
keyCode - code on which the event is sent
listener - listener instance to remove
removeGameKeyListener
public void removeGameKeyListener(int keyCode,
ActionListener listener)

Removes a game key listener from the given game keycode


Parameters:
keyCode - code on which the event is sent
listener - listener instance to remove
addGameKeyListener
public void addGameKeyListener(int keyCode,
ActionListener listener)

Add a game key listener to the given gamekey for a callback when the key is
released
Parameters:
keyCode - code on which to send the event
listener - listener to invoke when the key code released.
getSoftButtonCount
public int getSoftButtonCount()

Returns the number of buttons on the menu bar for use with getSoftButton()
Returns:
the number of softbuttons
getSoftButton
public Button getSoftButton(int offset)

Method Detail

1621

Overview (Codename One API)


Returns the button representing the softbutton, this allows modifying softbutton
attributes and behavior programmatically rather than by using the command API.
Notice that this API behavior is fragile since the button mapped to a particular offset
might change based on the command API
Parameters:
offset - the offest of the softbutton
Returns:
a button that can be manipulated
getMenuStyle
public Style getMenuStyle()

Returns the style of the menu


Returns:
the style of the menu
getTitleStyle
public Style getTitleStyle()

Returns the style of the title


Returns:
the style of the title
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Container
setDefaultCommand
public void setDefaultCommand(Command defaultCommand)

Default command is invoked when a user presses fire, this functionality works well in
some situations but might collide with elements such as navigation and combo boxes.
Use with caution.
Parameters:
defaultCommand - the command to treat as default
getDefaultCommand
public Command getDefaultCommand()

Default command is invoked when a user presses fire, this functionality works well in
some situations but might collide with elements such as navigation and combo boxes.
Use with caution.
Returns:
the command to treat as default
setClearCommand
public void setClearCommand(Command clearCommand)

Indicates the command that is defined as the clear command in this form. A clear
command can be used both to map to a "clear" hardware button if such a button
exists.
Parameters:
clearCommand - the command to treat as the clear Command
getClearCommand
public Command getClearCommand()

Indicates the command that is defined as the clear command in this form. A clear
command can be used both to map to a "clear" hardware button if such a button
exists.
Returns:
the command to treat as the clear Command

Method Detail

1622

Overview (Codename One API)


setBackCommand
public void setBackCommand(Command backCommand)

Indicates the command that is defined as the back command out of this form. A back
command can be used both to map to a hardware button (e.g. on the Sony Ericsson
devices) and by elements such as transitions etc. to change the behavior based on
direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
Parameters:
backCommand - the command to treat as the back Command
getBackCommand
public Command getBackCommand()

Indicates the command that is defined as the back command out of this form. A back
command can be used both to map to a hardware button (e.g. on the Sony Ericsson
devices) and by elements such as transitions etc. to change the behavior based on
direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
Returns:
the command to treat as the back Command
getContentPane
public Container getContentPane()

This method returns the Content pane instance


Returns:
a content pane instance
getLayeredPane
public Container getLayeredPane()

This method returns the layered pane of the Form, the layered pane is laid on top of
the content pane and is created lazily upon calling this method the layer will be
created. This is equivalent to getLayeredPane(null, false).
Returns:
the LayeredPane
getLayeredPane
public Container getLayeredPane(Class c,
boolean top)

Returns the layered pane for the class and if one doesn't exist a new one is created
dynamically and returned
Parameters:
c - the class with which this layered pane is associated, null for the global
layered pane which is always on the bottom
top - if created this indicates whether the layered pane should be added on
top or bottom
Returns:
the layered pane instance
removeAll
public void removeAll()

Removes all Components from the Content Pane


Overrides:
removeAll in class Container
setBgImage
public void setBgImage(Image bgImage)

Deprecated. Use the style directly


Sets the background image to show behind the form
Parameters:
bgImage - the background image

Method Detail

1623

Overview (Codename One API)


setLayout
public void setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


Overrides:
setLayout in class Container
Parameters:
layout - the specified layout manager
setTitle
public void setTitle(String title)

Sets the Form title to the given text


Parameters:
title - the form title
getTitle
public String getTitle()

Returns the Form title text


Returns:
returns the form title
addComponent
public void addComponent(Component cmp)

Adds Component to the Form's Content Pane


Overrides:
addComponent in class Container
Parameters:
cmp - the added param
addComponent
public void addComponent(Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Container
Parameters:
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Container
Parameters:
index - location to insert the Component
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Component cmp)

Adds Component to the Form's Content Pane


Overrides:

Method Detail

1624

Overview (Codename One API)


addComponent in class Container
Parameters:
cmp - the added param
index - location to insert the Component
replace
public void replace(Component current,
Component next,
Transition t)

This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method return immediately.
Overrides:
replace in class Container
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
replaceAndWait
public void replaceAndWait(Component current,
Component next,
Transition t)

This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method returns when transition
has finished.
Overrides:
replaceAndWait in class Container
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
removeComponent
public void removeComponent(Component cmp)

Removes a component from the Form's Content Pane


Overrides:
removeComponent in class Container
Parameters:
cmp - the component to be removed
hasMedia
public final boolean hasMedia()

Used by the implementation to prevent flickering when flushing the double buffer
Returns:
true if the form has media components within it
registerAnimated
public void registerAnimated(Animation cmp)

The given component is interested in animating its appearance and will start
receiving callbacks when it is visible in the form allowing it to animate its appearance.
This method would not register a compnent instance more than once
Parameters:
cmp - component that would be animated
deregisterAnimated
public void deregisterAnimated(Animation cmp)

Indicate that cmp would no longer like to receive animation events


Parameters:
cmp - component that would no longer receive animation events

Method Detail

1625

Overview (Codename One API)


animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Container
Parameters:
merge - indicates if the current styles should be merged with the new styles
paintBackground
public void paintBackground(Graphics g)

Exposing the background painting for the benefit of animations


Overrides:
paintBackground in class Component
Parameters:
g - the form graphics
getTransitionInAnimator
public Transition getTransitionInAnimator()

This property allows us to define a an animation that will draw the transition for
entering this form. A transition is an animation that would occur when switching from
one form to another.
Returns:
the Form in transition
setTransitionInAnimator
public void setTransitionInAnimator(Transition transitionInAnimator)

This property allows us to define a an animation that will draw the transition for
entering this form. A transition is an animation that would occur when switching from
one form to another.
Parameters:
transitionInAnimator - the Form in transition
getTransitionOutAnimator
public Transition getTransitionOutAnimator()

This property allows us to define a an animation that will draw the transition for exiting
this form. A transition is an animation that would occur when switching from one form
to another.
Returns:
the Form out transition
setTransitionOutAnimator
public void setTransitionOutAnimator(Transition transitionOutAnimator)

This property allows us to define a an animation that will draw the transition for exiting
this form. A transition is an animation that would occur when switching from one form
to another.
Parameters:
transitionOutAnimator - the Form out transition

Method Detail

1626

Overview (Codename One API)


addCommandListener
public void addCommandListener(ActionListener l)

A listener that is invoked when a command is clicked allowing multiple commands to


be handled by a single block
Parameters:
l - the command action listener
removeCommandListener
public void removeCommandListener(ActionListener l)

A listener that is invoked when a command is clicked allowing multiple commands to


be handled by a single block
Parameters:
l - the command action listener
actionCommand
protected void actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point rather than
implementing many command instances. All commands selected on the form will
trigger this method implicitly.
Parameters:
cmd - the form commmand object
dispatchCommand
public void dispatchCommand(Command cmd,
ActionEvent ev)

Dispatches a command via the standard form mechanism of firing a command event
Parameters:
cmd - The command to dispatch
ev - the event to dispatch
show
public void show()

Displays the current form on the screen


showBack
public void showBack()

Displays the current form on the screen, this version of the method is useful for
"back" navigation since it reverses the direction of the transition.
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling)

Indicates that scrolling through the component should work as an animation


Overrides:
setSmoothScrolling in class Component
Parameters:
smoothScrolling - indicates if a component uses smooth scrolling
isSmoothScrolling
public boolean isSmoothScrolling()

Indicates that scrolling through the component should work as an animation


Overrides:
isSmoothScrolling in class Component
Returns:
whether this component use smooth scrolling

Method Detail

1627

Overview (Codename One API)


getScrollAnimationSpeed
public int getScrollAnimationSpeed()

Scroll animation speed in milliseconds allowing a developer to slow down or


accelerate the smooth animation mode
Overrides:
getScrollAnimationSpeed in class Component
Returns:
scroll animation speed in milliseconds
setScrollAnimationSpeed
public void setScrollAnimationSpeed(int animationSpeed)

Scroll animation speed in milliseconds allowing a developer to slow down or


accelerate the smooth animation mode
Overrides:
setScrollAnimationSpeed in class Component
Parameters:
animationSpeed - scroll animation speed in milliseconds
onShow
protected void onShow()

Allows subclasses to bind functionality that occurs when a specific form or dialog
appears on the screen
onShowCompleted
protected void onShowCompleted()

Allows subclasses to bind functionality that occurs when a specific form or dialog is
"really" showing hence when the transition is totally complete (unlike onShow which is
called on intent). The necessity for this is for special cases like media that might
cause artifacts if played during a transition.
getComponentForm
public final Form getComponentForm()

Returns the Component Form or null if this Component is not added yet to a form
Overrides:
getComponentForm in class Component
Returns:
the Component Form
setFocused
public void setFocused(Component focused)

Sets the focused component and fires the appropriate events to make it so
Parameters:
focused - the newly focused component or null for no focus
getFocused
public Component getFocused()

Returns the current focus component for this form


Returns:
the current focus component for this form
longKeyPress
protected void longKeyPress(int keyCode)

If this Component is focused this method is invoked when the user presses and holds
the key
Overrides:
longKeyPress in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

1628

Overview (Codename One API)


longPointerPress
public void longPointerPress(int x,
int y)

If this Component is focused this method is invoked when the user presses and holds
the pointer on the Component
Overrides:
longPointerPress in class Component
shouldSendPointerReleaseToOtherForm
protected boolean shouldSendPointerReleaseToOtherForm()

Indicates whether this form wants to receive pointerReleased events for touch events
that started in a different form
Returns:
false by default
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Container
Parameters:
keyCode - the key code value to indicate a physical key.
getLayout
public Layout getLayout()

Returns the layout manager responsible for arranging this container


Overrides:
getLayout in class Container
Returns:
the container layout manager
isMinimizeOnBack
public boolean isMinimizeOnBack()

When set to true the physical back button will minimize the application
Returns:
the minimizeOnBack
setMinimizeOnBack
public void setMinimizeOnBack(boolean minimizeOnBack)

When set to true the physical back button will minimize the application
Parameters:
minimizeOnBack - the minimizeOnBack to set
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Container
Parameters:
keyCode - the key code value to indicate a physical key.
keyRepeated
public void keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
Overrides:
keyRepeated in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

1629

Overview (Codename One API)


pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Container
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int[] x,
int[] y)

Description copied from class: Component


If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverPressed
public void pointerHoverPressed(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Container
Parameters:

Method Detail

1630

Overview (Codename One API)


- the pointer x coordinate
- the pointer y coordinate
isSingleFocusMode
x
y

public boolean isSingleFocusMode()

Returns true if there is only one focusable member in this form. This is useful so
setHandlesInput would always be true for this case.
Returns:
true if there is one focusable component in this form, false for 0 or more
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
setScrollableY
public void setScrollableY(boolean scrollableY)

Sets whether the component should/could scroll on the Y axis


Overrides:
setScrollableY in class Container
Parameters:
scrollableY - whether the component should/could scroll on the Y axis
setScrollableX
public void setScrollableX(boolean scrollableX)

Sets whether the component should/could scroll on the X axis


Overrides:
setScrollableX in class Container
Parameters:
scrollableX - whether the component should/could scroll on the X axis
getComponentIndex
public int getComponentIndex(Component cmp)

Returns the Component index in the Container


Overrides:
getComponentIndex in class Container
Parameters:
cmp - the component to search for
Returns:
the Component index in the Container or -1 if not found
addCommand
public void addCommand(Command cmd,
int offset)

Adds a command to the menu bar softkeys or into the menu dialog, this version of
add allows us to place a command in an arbitrary location. This allows us to force a
command into the softkeys when order of command addition can't be changed.
Parameters:
cmd - the Form command to be added
offset - position in which the command is added
getCommandCount
public int getCommandCount()

A helper method to check the amount of commands within the form menu
Returns:

Method Detail

1631

Overview (Codename One API)


the number of commands
getCommand
public Command getCommand(int index)

Returns the command occupying the given index


Parameters:
index - offset of the command
Returns:
the command at the given index
addCommand
public void addCommand(Command cmd)

Adds a command to the menu bar softkeys. The Commands are placed in the order
they are added. If the Form has 1 Command it will be placed on the right. If the Form
has 2 Commands the first one that was added will be placed on the right and the
second one will be placed on the left. If the Form has more then 2 Commands the
first one will stay on the left and a Menu will be added with all the remain Commands.
Parameters:
cmd - the Form command to be added
removeCommand
public void removeCommand(Command cmd)

Removes the command from the menu bar softkeys


Parameters:
cmd - the Form command to be removed
setCyclicFocus
public void setCyclicFocus(boolean cyclicFocus)

Indicates whether focus should cycle within the form


Parameters:
cyclicFocus - marks whether focus should cycle
findNextFocusVertical
public Component findNextFocusVertical(boolean down)

This method returns the next focusable Component vertically


Parameters:
down - if true will the return the next focusable on the bottom else on the top
Returns:
a focusable Component or null if not found
findNextFocusHorizontal
public Component findNextFocusHorizontal(boolean right)

This method returns the next focusable Component horizontally


Parameters:
right - if true will the return the next focusable on the right else on the left
Returns:
a focusable Component or null if not found
isCyclicFocus
public boolean isCyclicFocus()

Indicates whether focus should cycle within the form


Returns:
true if focus should cycle
scrollComponentToVisible
public void scrollComponentToVisible(Component c)

Makes sure the component is visible in the scroll if this container is scrollable
Overrides:
scrollComponentToVisible in class Container

Method Detail

1632

Overview (Codename One API)


Parameters:
c - the componant to be visible
setMenuCellRenderer
public void setMenuCellRenderer(ListCellRenderer menuCellRenderer)

Determine the cell renderer used to render menu elements for themeing the look of
the menu options
Parameters:
menuCellRenderer - the menu cell renderer
removeAllCommands
public void removeAllCommands()

Clear menu commands from the menu bar


setRTL
public void setRTL(boolean r)

Is the component a bidi RTL component


Overrides:
setRTL in class Component
Parameters:
r - true if the component should work in a right to left mode
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Container
Parameters:
g - the component graphics
setScrollable
public void setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


Overrides:
setScrollable in class Container
Parameters:
scrollable - whether the component should/could scroll on the X and Y axis
isScrollable
public boolean isScrollable()

Indicates whether the component should/could scroll by default a component is not


scrollable.
Overrides:
isScrollable in class Component
Returns:
whether the component is scrollable
setVisible
public void setVisible(boolean visible)

Toggles visibility of the component


Overrides:
setVisible in class Component
Parameters:
visible - true if component is visible; otherwise false

Method Detail

1633

Overview (Codename One API)


getTintColor
public int getTintColor()

Default color for the screen tint when a dialog or a menu is shown
Returns:
the tint color when a dialog or a menu is shown
setTintColor
public void setTintColor(int tintColor)

Default color for the screen tint when a dialog or a menu is shown
Parameters:
tintColor - the tint color when a dialog or a menu is shown
setMenuTransitions
public void setMenuTransitions(Transition transitionIn,
Transition transitionOut)

Sets the menu transitions for showing/hiding the menu, can be null...
Parameters:
transitionIn - the transition that will play when the menu appears
transitionOut - the transition that will play when the menu is folded
paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Overrides:
paramString in class Container
Returns:
a string representation of this component's state
getMenuBar
public MenuBar getMenuBar()

Returns the associated Menu Bar object


Returns:
the associated Menu Bar object
setMenuBar
public void setMenuBar(MenuBar menuBar)

Sets the associated MenuBar Object.


Parameters:
menuBar setToolBar
public void setToolBar(Toolbar toolbar)

Deprecated. use setToolbar instead (lower case b)


Sets the Form Toolbar
Parameters:
toolbar setToolbar
public void setToolbar(Toolbar toolbar)

Sets the Form Toolbar


Parameters:
toolbar -

Method Detail

1634

Overview (Codename One API)


getToolbar
public Toolbar getToolbar()

Gets the Form Toolbar if exists or null


Returns:
the Toolbar instance or null if does not exists.
isFocusScrolling
public boolean isFocusScrolling()

Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of Codename
One.
Returns:
the value of focusScrolling
setFocusScrolling
public void setFocusScrolling(boolean focusScrolling)

Indicates whether lists and containers should scroll only via focus and thus "jump"
when moving to a larger component as was the case in older versions of Codename
One.
Parameters:
focusScrolling - the new value for focus scrolling
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:

Method Detail

1635

Overview (Codename One API)


the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getEditOnShow
public TextArea getEditOnShow()

A text component that will receive focus and start editing immediately as the form is
shown
Returns:
the component instance
setEditOnShow
public void setEditOnShow(TextArea editOnShow)

A text component that will receive focus and start editing immediately as the form is
shown
Parameters:
editOnShow - text component to edit when the form is shown

Method Detail

1636

Overview (Codename One API)


com.codename1.ui

Class FontImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.FontImage

public class
extends Image

An image based on icon fonts that adapts its environment

Field Summary
Modifier and
Type

Field and Description


MATERIAL_3D_ROTATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AC_UNIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCESS_ALARM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCESS_ALARMS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCESS_TIME

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCESSIBILITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCESSIBLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCOUNT_BALANCE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCOUNT_BALANCE_WALLET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCOUNT_BOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ACCOUNT_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_ADD_A_PHOTO

Class FontImage

1637

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_ADD_ALARM
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_ALERT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_BOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_CIRCLE_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_LOCATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_SHOPPING_CART

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_TO_PHOTOS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADD_TO_QUEUE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ADJUST

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_FLAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_FLAT_ANGLED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_INDIVIDUAL_SUITE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_LEGROOM_EXTRA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_LEGROOM_NORMAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_LEGROOM_REDUCED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_RECLINE_EXTRA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRLINE_SEAT_RECLINE_NORMAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRPLANEMODE_ACTIVE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_AIRPLANEMODE_INACTIVE

1638

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_AIRPLAY
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AIRPORT_SHUTTLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALARM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALARM_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALARM_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALARM_ON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALBUM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALL_INCLUSIVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ALL_OUT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ANDROID

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ANNOUNCEMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_APPS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARCHIVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_BACK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_DOWNWARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_DROP_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_DROP_DOWN_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_DROP_UP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ARROW_FORWARD

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_ARROW_UPWARD

1639

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_ART_TRACK
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASPECT_RATIO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSESSMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT_IND

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT_LATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT_RETURN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT_RETURNED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSIGNMENT_TURNED_IN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSISTANT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ASSISTANT_PHOTO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ATTACH_FILE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ATTACH_MONEY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ATTACHMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AUDIOTRACK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AUTORENEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_AV_TIMER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BACKSPACE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BACKUP

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_BATTERY_ALERT

1640

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_BATTERY_CHARGING_FULL
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BATTERY_FULL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BATTERY_STD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BATTERY_UNKNOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BEACH_ACCESS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BEENHERE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUETOOTH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUETOOTH_AUDIO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUETOOTH_CONNECTED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUETOOTH_DISABLED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUETOOTH_SEARCHING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUR_CIRCULAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUR_LINEAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUR_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BLUR_ON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BOOK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BOOKMARK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BOOKMARK_BORDER

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_BORDER_ALL

1641

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_BOTTOM
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_CLEAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_COLOR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_HORIZONTAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_INNER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_OUTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_STYLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_TOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BORDER_VERTICAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_1

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_2

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_3

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_4

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_6

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_7

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_AUTO

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_BRIGHTNESS_HIGH

1642

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_LOW
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRIGHTNESS_MEDIUM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BROKEN_IMAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BRUSH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BUG_REPORT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BUILD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BUSINESS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_BUSINESS_CENTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CACHED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAKE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_END

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_MADE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_MERGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_MISSED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_MISSED_OUTGOING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_RECEIVED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CALL_SPLIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAMERA

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_CAMERA_ALT

1643

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_CAMERA_ENHANCE
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAMERA_FRONT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAMERA_REAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAMERA_ROLL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CANCEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CARD_GIFTCARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CARD_MEMBERSHIP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CARD_TRAVEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CASINO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAST

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CAST_CONNECTED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CENTER_FOCUS_STRONG

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CENTER_FOCUS_WEAK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHANGE_HISTORY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHAT_BUBBLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHAT_BUBBLE_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHECK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHECK_BOX

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_CHECK_BOX_OUTLINE_BLANK

1644

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_CHECK_CIRCLE
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHEVRON_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHEVRON_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHILD_CARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHILD_FRIENDLY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CHROME_READER_MODE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLASS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLEAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLEAR_ALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOSE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOSED_CAPTION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_DONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_DOWNLOAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_QUEUE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CLOUD_UPLOAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CODE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_COLLECTIONS

1645

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_COLLECTIONS_BOOKMARK
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COLOR_LENS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COLORIZE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COMMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COMPARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COMPARE_ARROWS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COMPUTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONFIRMATION_NUMBER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTACT_MAIL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTACT_PHONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTACTS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTENT_COPY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTENT_CUT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTENT_PASTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTROL_POINT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CONTROL_POINT_DUPLICATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_COPYRIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CREATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CREATE_NEW_FOLDER

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_CREDIT_CARD

1646

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_CROP
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_16_9

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_3_2

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_5_4

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_7_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_DIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_FREE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_LANDSCAPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_ORIGINAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_PORTRAIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_ROTATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_CROP_SQUARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DASHBOARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DATA_USAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DATE_RANGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEHAZE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DELETE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DESCRIPTION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DESKTOP_MAC

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_DESKTOP_WINDOWS

1647

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_DETAILS
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEVELOPER_BOARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEVELOPER_MODE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEVICE_HUB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEVICES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DEVICES_OTHER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIALER_SIP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIALPAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_BIKE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_BOAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_BUS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_CAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_RAILWAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_RUN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_SUBWAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_TRANSIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DIRECTIONS_WALK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DISC_FULL

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_DNS

1648

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_DO_NOT_DISTURB
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DO_NOT_DISTURB_ALT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DOMAIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DONE_ALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DONUT_LARGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DONUT_SMALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DRAFTS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DRAG_HANDLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DRIVE_ETA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_DVR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EDIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EDIT_LOCATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EJECT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EMAIL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ENHANCED_ENCRYPTION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EQUALIZER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ERROR

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_ERROR_OUTLINE

1649

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_EVENT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EVENT_AVAILABLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EVENT_BUSY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EVENT_NOTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EVENT_SEAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXIT_TO_APP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPAND_LESS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPAND_MORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPLICIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPLORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE_NEG_1

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE_NEG_2

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE_PLUS_1

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE_PLUS_2

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXPOSURE_ZERO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_EXTENSION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FACE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FAST_FORWARD

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_FAST_REWIND

1650

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_FAVORITE
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FAVORITE_BORDER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FEEDBACK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIBER_DVR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIBER_MANUAL_RECORD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIBER_NEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIBER_PIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIBER_SMART_RECORD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILE_DOWNLOAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILE_UPLOAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_1

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_2

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_3

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_4

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_6

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_7

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_8

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_FILTER_9

1651

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_9_PLUS
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_B_AND_W

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_CENTER_FOCUS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_DRAMA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_FRAMES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_HDR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_LIST

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_NONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_TILT_SHIFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FILTER_VINTAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIND_IN_PAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FIND_REPLACE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FINGERPRINT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FITNESS_CENTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLAG

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLASH_AUTO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLASH_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLASH_ON

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_FLIGHT

1652

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_FLIGHT_LAND
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLIGHT_TAKEOFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLIP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLIP_TO_BACK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FLIP_TO_FRONT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FOLDER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FOLDER_OPEN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FOLDER_SHARED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FOLDER_SPECIAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FONT_DOWNLOAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_ALIGN_CENTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_ALIGN_JUSTIFY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_ALIGN_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_ALIGN_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_BOLD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_CLEAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_COLOR_FILL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_COLOR_RESET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_COLOR_TEXT

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_FORMAT_INDENT_DECREASE

1653

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_INDENT_INCREASE
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_ITALIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_LINE_SPACING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_LIST_BULLETED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_LIST_NUMBERED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_PAINT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_QUOTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_SHAPES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_SIZE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_STRIKETHROUGH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_TEXTDIRECTION_L_TO_R

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_TEXTDIRECTION_R_TO_L

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORMAT_UNDERLINED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORUM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORWARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORWARD_10

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORWARD_30

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FORWARD_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FREE_BREAKFAST

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_FULLSCREEN

1654

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_FULLSCREEN_EXIT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_FUNCTIONS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GAMEPAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GAMES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GAVEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GESTURE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GET_APP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GIF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GOLF_COURSE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GPS_FIXED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GPS_NOT_FIXED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GPS_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRADE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRADIENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRAIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRAPHIC_EQ

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRID_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GRID_ON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_GROUP

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_GROUP_ADD

1655

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_GROUP_WORK
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HDR_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HDR_ON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HDR_STRONG

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HDR_WEAK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HEADSET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HEADSET_MIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HEALING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HEARING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HELP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HELP_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HIGH_QUALITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HIGHLIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HIGHLIGHT_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HISTORY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HOME

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HOT_TUB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HOTEL

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_HOURGLASS_EMPTY

1656

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_HOURGLASS_FULL
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HTTP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_HTTPS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_IMAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_IMAGE_ASPECT_RATIO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_IMPORT_CONTACTS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_IMPORT_EXPORT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_IMPORTANT_DEVICES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INBOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INDETERMINATE_CHECK_BOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INFO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INFO_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INPUT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_CHART

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_COMMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_DRIVE_FILE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_EMOTICON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_INVITATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INSERT_LINK

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_INSERT_PHOTO

1657

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_INVERT_COLORS
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_INVERT_COLORS_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ISO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_ARROW_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_ARROW_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_ARROW_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_ARROW_UP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_BACKSPACE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_CAPSLOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_HIDE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_RETURN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_TAB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KEYBOARD_VOICE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_KITCHEN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LABEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LABEL_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LANDSCAPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LANGUAGE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_LAPTOP

1658

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_LAPTOP_CHROMEBOOK
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LAPTOP_MAC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LAPTOP_WINDOWS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LAUNCH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LAYERS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LAYERS_CLEAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LEAK_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LEAK_REMOVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LENS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LIBRARY_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LIBRARY_BOOKS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LIBRARY_MUSIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LIGHTBULB_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LINE_STYLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LINE_WEIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LINEAR_SCALE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LINK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LINKED_CAMERA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LIST

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_LIVE_HELP

1659

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_LIVE_TV
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_ACTIVITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_AIRPORT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_ATM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_BAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_CAFE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_CAR_WASH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_CONVENIENCE_STORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_DINING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_DRINK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_FLORIST

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_GAS_STATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_GROCERY_STORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_HOSPITAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_HOTEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_LAUNDRY_SERVICE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_LIBRARY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_MALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_MOVIES

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_LOCAL_OFFER

1660

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PARKING
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PHARMACY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PHONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PIZZA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PLAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_POST_OFFICE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_PRINTSHOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_SEE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_SHIPPING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCAL_TAXI

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCATION_CITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCATION_DISABLED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCATION_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCATION_ON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCATION_SEARCHING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCK_OPEN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOCK_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_LOOKS_3

1661

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS_4
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS_6

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS_ONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOKS_TWO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOUPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_LOYALTY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MAIL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MAIL_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MAP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MARKUNREAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MARKUNREAD_MAILBOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MEMORY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MENU

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MERGE_TYPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MESSAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MIC_NONE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_MIC_OFF

1662

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_MMS
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MODE_COMMENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MODE_EDIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MONEY_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MONOCHROME_PHOTOS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOOD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOOD_BAD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MORE_HORIZ

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MORE_VERT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOTORCYCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOUSE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOVE_TO_INBOX

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOVIE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOVIE_CREATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MOVIE_FILTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MUSIC_NOTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MUSIC_VIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_MY_LOCATION

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_NATURE

1663

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_NATURE_PEOPLE
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NAVIGATE_BEFORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NAVIGATE_NEXT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NAVIGATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NEAR_ME

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NETWORK_CELL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NETWORK_CHECK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NETWORK_LOCKED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NETWORK_WIFI

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NEW_RELEASES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NEXT_WEEK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NFC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NO_ENCRYPTION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NO_SIM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NOT_INTERESTED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NOTE_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NOTIFICATIONS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NOTIFICATIONS_ACTIVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_NOTIFICATIONS_NONE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_NOTIFICATIONS_OFF

1664

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_NOTIFICATIONS_PAUSED
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_OFFLINE_PIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ONDEMAND_VIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_OPACITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_OPEN_IN_BROWSER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_OPEN_IN_NEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_OPEN_WITH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PAGES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PAGEVIEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PALETTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PAN_TOOL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PANORAMA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PANORAMA_FISH_EYE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PANORAMA_HORIZONTAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PANORAMA_VERTICAL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PANORAMA_WIDE_ANGLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PARTY_MODE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PAUSE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PAUSE_CIRCLE_FILLED

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_PAUSE_CIRCLE_OUTLINE

1665

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_PAYMENT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PEOPLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PEOPLE_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_CAMERA_MIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_CONTACT_CALENDAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_DATA_SETTING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_DEVICE_INFORMATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_IDENTITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_MEDIA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_PHONE_MSG

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERM_SCAN_WIFI

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSON

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSON_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSON_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSON_PIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSON_PIN_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PERSONAL_VIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PETS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_PHONE_ANDROID

1666

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_BLUETOOTH_SPEAKER
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_FORWARDED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_IN_TALK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_IPHONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_LOCKED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_MISSED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONE_PAUSED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK_ERASE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK_LOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK_RING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHONELINK_SETUP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_ALBUM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_CAMERA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_FILTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_LIBRARY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_SIZE_SELECT_ACTUAL

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_PHOTO_SIZE_SELECT_LARGE

1667

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_PHOTO_SIZE_SELECT_SMALL
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PICTURE_AS_PDF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PICTURE_IN_PICTURE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PICTURE_IN_PICTURE_ALT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PIN_DROP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLACE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAY_ARROW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAY_CIRCLE_FILLED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAY_CIRCLE_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAY_FOR_WORK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAYLIST_ADD

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAYLIST_ADD_CHECK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLAYLIST_PLAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PLUS_ONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_POLL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_POLYMER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_POOL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PORTABLE_WIFI_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PORTRAIT

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_POWER

1668

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_POWER_INPUT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_POWER_SETTINGS_NEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PREGNANT_WOMAN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PRESENT_TO_ALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PRINT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PUBLIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_PUBLISH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_QUERY_BUILDER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_QUESTION_ANSWER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_QUEUE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_QUEUE_MUSIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_QUEUE_PLAY_NEXT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RADIO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RADIO_BUTTON_CHECKED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RADIO_BUTTON_UNCHECKED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RATE_REVIEW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RECEIPT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RECENT_ACTORS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RECORD_VOICE_OVER

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_REDEEM

1669

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_REDO
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REFRESH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REMOVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REMOVE_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REMOVE_CIRCLE_OUTLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REMOVE_FROM_QUEUE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REMOVE_RED_EYE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REORDER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPEAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPEAT_ONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLAY_10

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLAY_30

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLAY_5

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPLY_ALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPORT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_REPORT_PROBLEM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RESTAURANT_MENU

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_RESTORE

1670

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_RING_VOLUME
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROOM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROOM_SERVICE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROTATE_90_DEGREES_CCW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROTATE_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROTATE_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROUNDED_CORNER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROUTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ROWING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_RV_HOOKUP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SATELLITE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SAVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCANNER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCHEDULE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCHOOL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCREEN_LOCK_LANDSCAPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCREEN_LOCK_PORTRAIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCREEN_LOCK_ROTATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SCREEN_ROTATION

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_SCREEN_SHARE

1671

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_SD_CARD
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SD_STORAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SEARCH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SECURITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SELECT_ALL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SEND

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_APPLICATIONS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_BACKUP_RESTORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_BLUETOOTH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_BRIGHTNESS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_CELL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_ETHERNET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_INPUT_ANTENNA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_INPUT_COMPONENT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_INPUT_COMPOSITE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_INPUT_HDMI

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_INPUT_SVIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_OVERSCAN

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_SETTINGS_PHONE

1672

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_POWER
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_REMOTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_SYSTEM_DAYDREAM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SETTINGS_VOICE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHOP_TWO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHOPPING_BASKET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHOPPING_CART

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHORT_TEXT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SHUFFLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_CELLULAR_4_BAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_CELLULAR_CONNECTED_NO_INTERNET_4_BAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_CELLULAR_NO_SIM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_CELLULAR_NULL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_CELLULAR_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_WIFI_4_BAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_WIFI_4_BAR_LOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SIGNAL_WIFI_OFF

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_SIM_CARD

1673

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_SIM_CARD_ALERT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SKIP_NEXT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SKIP_PREVIOUS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SLIDESHOW

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SLOW_MOTION_VIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SMARTPHONE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SMOKE_FREE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SMOKING_ROOMS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SMS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SMS_FAILED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SNOOZE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SORT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SORT_BY_ALPHA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPACE_BAR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPEAKER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPEAKER_GROUP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPEAKER_NOTES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SPEAKER_PHONE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_SPELLCHECK

1674

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_STAR
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAR_BORDER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAR_HALF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STARS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAY_CURRENT_LANDSCAPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAY_CURRENT_PORTRAIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAY_PRIMARY_LANDSCAPE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STAY_PRIMARY_PORTRAIT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STOP_SCREEN_SHARE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STORAGE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STORE_MALL_DIRECTORY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STRAIGHTEN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STRIKETHROUGH_S

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_STYLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SUBDIRECTORY_ARROW_LEFT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SUBDIRECTORY_ARROW_RIGHT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SUBJECT

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_SUBSCRIPTIONS

1675

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_SUBTITLES
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SUPERVISOR_ACCOUNT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SURROUND_SOUND

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWAP_CALLS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWAP_HORIZ

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWAP_VERT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWAP_VERTICAL_CIRCLE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWITCH_CAMERA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SWITCH_VIDEO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SYNC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SYNC_DISABLED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SYNC_PROBLEM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SYSTEM_UPDATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_SYSTEM_UPDATE_ALT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TAB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TAB_UNSELECTED

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TABLET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TABLET_ANDROID

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TABLET_MAC

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_TAG_FACES

1676

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_TAP_AND_PLAY
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TERRAIN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TEXT_FIELDS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TEXT_FORMAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TEXTSMS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TEXTURE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_THEATERS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_THUMB_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_THUMB_UP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_THUMBS_UP_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIME_TO_LEAVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMELAPSE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMELINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMER_10

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMER_3

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TIMER_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TOC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TODAY

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_TOLL

1677

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_TONALITY
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TOUCH_APP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TOYS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRACK_CHANGES

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRAFFIC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRANSFORM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRANSLATE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRENDING_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRENDING_FLAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TRENDING_UP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TUNE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TURNED_IN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TURNED_IN_NOT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_TV

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_UNARCHIVE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_UNDO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_UNFOLD_LESS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_UNFOLD_MORE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_UPDATE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_USB

1678

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_VERIFIED_USER
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VERTICAL_ALIGN_BOTTOM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VERTICAL_ALIGN_CENTER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VERTICAL_ALIGN_TOP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIBRATION

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIDEO_LIBRARY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIDEOCAM

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIDEOCAM_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIDEOGAME_ASSET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_AGENDA

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_ARRAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_CAROUSEL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_COLUMN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_COMFY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_COMPACT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_DAY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_HEADLINE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_LIST

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_MODULE

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_VIEW_QUILT

1679

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_STREAM
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIEW_WEEK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VIGNETTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VISIBILITY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VISIBILITY_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOICE_CHAT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOICEMAIL

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOLUME_DOWN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOLUME_MUTE

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOLUME_OFF

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VOLUME_UP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VPN_KEY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_VPN_LOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WALLPAPER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WARNING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WATCH

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WATCH_LATER

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WB_AUTO

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WB_CLOUDY

Field Summary

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

static char

MATERIAL_WB_INCANDESCENT

1680

Overview (Codename One API)


Material design icon font character code see
https://www.google.com/design/icons/ for full list
MATERIAL_WB_IRIDESCENT
static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WB_SUNNY

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WC

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WEB

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WEB_ASSET

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WEEKEND

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WHATSHOT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WIDGETS

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WIFI

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WIFI_LOCK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WIFI_TETHERING

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WORK

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_WRAP_TEXT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_YOUTUBE_SEARCHED_FOR

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ZOOM_IN

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ZOOM_OUT

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list
MATERIAL_ZOOM_OUT_MAP

static char

Material design icon font character code see


https://www.google.com/design/icons/ for full list

Method Summary
Modifier and
Type

Method Summary

Method and Description

1681

Overview (Codename One API)


boolean

animate()

static
FontImage

create(String text, Style s)

static
FontImage

create(String text, Style s, Font fnt)

static
FontImage
static
FontImage
void

Creates the font image


Creates the font image
createFixed(String text, Font fnt, int color, int width,
int height)

Creates a font image


createMaterial(char icon, Style s)

Creates a material design icon font for the given style


dispose()

Does nothing
drawImage(Graphics g, Object nativeGraphics, int x, int y)

protected void

protected void

static int

Callback invoked internally by Codename One to draw the image/frame


onto the display.
drawImage(Graphics g, Object nativeGraphics, int x, int y, int w,
int h)

Callback invoked internally by Codename One to draw the image/frame


onto the display.
getDefaultPadding()

Indicates the default value for the padding in millimeters


getDefaultSize()

static float

Default factor for image size, icons without a given size are sized as
defaultSize X default font height.
getFont()

Font

Graphics
int

Useful method to reuse the Font object when creating multiple image
objects
getGraphics()

Throws a runtime exception


getHeight()

Returns the height of the image


getImageName()

String

The name of the image is set for some images mostly to ease the
debugging of Codename One application
getMaterialDesignFont()

static Font

int
int
boolean
boolean

The material design icon font allows creating icons based on the material
design icon catalog
getPadding()

The padding for the image in millimeters


getWidth()

Returns the width of the image


isAnimation()

Returns true if this is an animated image


isOpaque()

Indicates whether this image is opaque or not


requiresDrawImage()

boolean

Image
static void

New label optimizations don't invoke drawImage and instead just pass the
native image directly to the underlying renderer.
rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees.


setDefaultPadding(int aDefaultPadding)

Indicates the default value for the padding in millimeters


setDefaultSize(float aDefaultSize)

static void

Default factor for image size, icons without a given size are sized as
defaultSize X default font height.
setMaterialIcon(Label l, char icon)

static void

Applies a material design icon (one of the MATERIAL_* icons above) to the
given label using the styling of the label

static void

setMaterialIcon(MultiButton l, char icon)

Method Summary

1682

Overview (Codename One API)


Applies a material design icon (one of the MATERIAL_* icons above) to the
given component using the styling of the label
setMaterialIcon(SpanButton l, char icon)
static void

Applies a material design icon (one of the MATERIAL_* icons above) to the
given component using the styling of the label
setPadding(int padding)

void

The padding for the image in millimeters

EncodedImage

toEncodedImage()

Converts the icon image to an encoded image if possible


toImage()

Image

Converts the icon image to an image if possible

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, asyncLock, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, flipHorizontally,
flipVertically, getImage, getRGB, getRGBCached, getSVGDocument,
isAlphaMutableImageSupported, isLocked, isSVG, isSVGSupported, lock,
mirror, modifyAlpha, modifyAlpha, modifyAlphaWithTranslucency,
rotate180Degrees, rotate270Degrees, rotate90Degrees, scale, scaled,
scaledHeight, scaledLargerRatio, scaledSmallerRatio, scaledWidth,
setImageName, subImage, toRGB, unlock

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
MATERIAL_3D_ROTATION
public static final char MATERIAL_3D_ROTATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AC_UNIT
public static final char MATERIAL_AC_UNIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCESS_ALARM
public static final char MATERIAL_ACCESS_ALARM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCESS_ALARMS
public static final char MATERIAL_ACCESS_ALARMS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Methods inherited from class com.codename1.ui.Image

1683

Overview (Codename One API)


MATERIAL_ACCESS_TIME
public static final char MATERIAL_ACCESS_TIME

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCESSIBILITY
public static final char MATERIAL_ACCESSIBILITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCESSIBLE
public static final char MATERIAL_ACCESSIBLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCOUNT_BALANCE
public static final char MATERIAL_ACCOUNT_BALANCE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCOUNT_BALANCE_WALLET
public static final char MATERIAL_ACCOUNT_BALANCE_WALLET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCOUNT_BOX
public static final char MATERIAL_ACCOUNT_BOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ACCOUNT_CIRCLE
public static final char MATERIAL_ACCOUNT_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADB
public static final char MATERIAL_ADB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1684

Overview (Codename One API)


MATERIAL_ADD
public static final char MATERIAL_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_A_PHOTO
public static final char MATERIAL_ADD_A_PHOTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_ALARM
public static final char MATERIAL_ADD_ALARM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_ALERT
public static final char MATERIAL_ADD_ALERT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_BOX
public static final char MATERIAL_ADD_BOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_CIRCLE
public static final char MATERIAL_ADD_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_CIRCLE_OUTLINE
public static final char MATERIAL_ADD_CIRCLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_LOCATION
public static final char MATERIAL_ADD_LOCATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1685

Overview (Codename One API)


MATERIAL_ADD_SHOPPING_CART
public static final char MATERIAL_ADD_SHOPPING_CART

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_TO_PHOTOS
public static final char MATERIAL_ADD_TO_PHOTOS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADD_TO_QUEUE
public static final char MATERIAL_ADD_TO_QUEUE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ADJUST
public static final char MATERIAL_ADJUST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_FLAT
public static final char MATERIAL_AIRLINE_SEAT_FLAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_FLAT_ANGLED
public static final char MATERIAL_AIRLINE_SEAT_FLAT_ANGLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_INDIVIDUAL_SUITE
public static final char MATERIAL_AIRLINE_SEAT_INDIVIDUAL_SUITE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_LEGROOM_EXTRA
public static final char MATERIAL_AIRLINE_SEAT_LEGROOM_EXTRA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1686

Overview (Codename One API)


MATERIAL_AIRLINE_SEAT_LEGROOM_NORMAL
public static final char MATERIAL_AIRLINE_SEAT_LEGROOM_NORMAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_LEGROOM_REDUCED
public static final char MATERIAL_AIRLINE_SEAT_LEGROOM_REDUCED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_RECLINE_EXTRA
public static final char MATERIAL_AIRLINE_SEAT_RECLINE_EXTRA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRLINE_SEAT_RECLINE_NORMAL
public static final char MATERIAL_AIRLINE_SEAT_RECLINE_NORMAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRPLANEMODE_ACTIVE
public static final char MATERIAL_AIRPLANEMODE_ACTIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRPLANEMODE_INACTIVE
public static final char MATERIAL_AIRPLANEMODE_INACTIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRPLAY
public static final char MATERIAL_AIRPLAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AIRPORT_SHUTTLE
public static final char MATERIAL_AIRPORT_SHUTTLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1687

Overview (Codename One API)


MATERIAL_ALARM
public static final char MATERIAL_ALARM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALARM_ADD
public static final char MATERIAL_ALARM_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALARM_OFF
public static final char MATERIAL_ALARM_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALARM_ON
public static final char MATERIAL_ALARM_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALBUM
public static final char MATERIAL_ALBUM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALL_INCLUSIVE
public static final char MATERIAL_ALL_INCLUSIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ALL_OUT
public static final char MATERIAL_ALL_OUT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ANDROID
public static final char MATERIAL_ANDROID

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1688

Overview (Codename One API)


MATERIAL_ANNOUNCEMENT
public static final char MATERIAL_ANNOUNCEMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_APPS
public static final char MATERIAL_APPS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARCHIVE
public static final char MATERIAL_ARCHIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_BACK
public static final char MATERIAL_ARROW_BACK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_DOWNWARD
public static final char MATERIAL_ARROW_DOWNWARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_DROP_DOWN
public static final char MATERIAL_ARROW_DROP_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_DROP_DOWN_CIRCLE
public static final char MATERIAL_ARROW_DROP_DOWN_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_DROP_UP
public static final char MATERIAL_ARROW_DROP_UP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1689

Overview (Codename One API)


MATERIAL_ARROW_FORWARD
public static final char MATERIAL_ARROW_FORWARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ARROW_UPWARD
public static final char MATERIAL_ARROW_UPWARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ART_TRACK
public static final char MATERIAL_ART_TRACK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASPECT_RATIO
public static final char MATERIAL_ASPECT_RATIO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSESSMENT
public static final char MATERIAL_ASSESSMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSIGNMENT
public static final char MATERIAL_ASSIGNMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSIGNMENT_IND
public static final char MATERIAL_ASSIGNMENT_IND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSIGNMENT_LATE
public static final char MATERIAL_ASSIGNMENT_LATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1690

Overview (Codename One API)


MATERIAL_ASSIGNMENT_RETURN
public static final char MATERIAL_ASSIGNMENT_RETURN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSIGNMENT_RETURNED
public static final char MATERIAL_ASSIGNMENT_RETURNED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSIGNMENT_TURNED_IN
public static final char MATERIAL_ASSIGNMENT_TURNED_IN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSISTANT
public static final char MATERIAL_ASSISTANT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ASSISTANT_PHOTO
public static final char MATERIAL_ASSISTANT_PHOTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ATTACH_FILE
public static final char MATERIAL_ATTACH_FILE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ATTACH_MONEY
public static final char MATERIAL_ATTACH_MONEY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ATTACHMENT
public static final char MATERIAL_ATTACHMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1691

Overview (Codename One API)


MATERIAL_AUDIOTRACK
public static final char MATERIAL_AUDIOTRACK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AUTORENEW
public static final char MATERIAL_AUTORENEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_AV_TIMER
public static final char MATERIAL_AV_TIMER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BACKSPACE
public static final char MATERIAL_BACKSPACE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BACKUP
public static final char MATERIAL_BACKUP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BATTERY_ALERT
public static final char MATERIAL_BATTERY_ALERT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BATTERY_CHARGING_FULL
public static final char MATERIAL_BATTERY_CHARGING_FULL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BATTERY_FULL
public static final char MATERIAL_BATTERY_FULL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1692

Overview (Codename One API)


MATERIAL_BATTERY_STD
public static final char MATERIAL_BATTERY_STD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BATTERY_UNKNOWN
public static final char MATERIAL_BATTERY_UNKNOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BEACH_ACCESS
public static final char MATERIAL_BEACH_ACCESS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BEENHERE
public static final char MATERIAL_BEENHERE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLOCK
public static final char MATERIAL_BLOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUETOOTH
public static final char MATERIAL_BLUETOOTH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUETOOTH_AUDIO
public static final char MATERIAL_BLUETOOTH_AUDIO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUETOOTH_CONNECTED
public static final char MATERIAL_BLUETOOTH_CONNECTED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1693

Overview (Codename One API)


MATERIAL_BLUETOOTH_DISABLED
public static final char MATERIAL_BLUETOOTH_DISABLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUETOOTH_SEARCHING
public static final char MATERIAL_BLUETOOTH_SEARCHING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUR_CIRCULAR
public static final char MATERIAL_BLUR_CIRCULAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUR_LINEAR
public static final char MATERIAL_BLUR_LINEAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUR_OFF
public static final char MATERIAL_BLUR_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BLUR_ON
public static final char MATERIAL_BLUR_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BOOK
public static final char MATERIAL_BOOK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BOOKMARK
public static final char MATERIAL_BOOKMARK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1694

Overview (Codename One API)


MATERIAL_BOOKMARK_BORDER
public static final char MATERIAL_BOOKMARK_BORDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_ALL
public static final char MATERIAL_BORDER_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_BOTTOM
public static final char MATERIAL_BORDER_BOTTOM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_CLEAR
public static final char MATERIAL_BORDER_CLEAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_COLOR
public static final char MATERIAL_BORDER_COLOR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_HORIZONTAL
public static final char MATERIAL_BORDER_HORIZONTAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_INNER
public static final char MATERIAL_BORDER_INNER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_LEFT
public static final char MATERIAL_BORDER_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1695

Overview (Codename One API)


MATERIAL_BORDER_OUTER
public static final char MATERIAL_BORDER_OUTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_RIGHT
public static final char MATERIAL_BORDER_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_STYLE
public static final char MATERIAL_BORDER_STYLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_TOP
public static final char MATERIAL_BORDER_TOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BORDER_VERTICAL
public static final char MATERIAL_BORDER_VERTICAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_1
public static final char MATERIAL_BRIGHTNESS_1

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_2
public static final char MATERIAL_BRIGHTNESS_2

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_3
public static final char MATERIAL_BRIGHTNESS_3

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1696

Overview (Codename One API)


MATERIAL_BRIGHTNESS_4
public static final char MATERIAL_BRIGHTNESS_4

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_5
public static final char MATERIAL_BRIGHTNESS_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_6
public static final char MATERIAL_BRIGHTNESS_6

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_7
public static final char MATERIAL_BRIGHTNESS_7

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_AUTO
public static final char MATERIAL_BRIGHTNESS_AUTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_HIGH
public static final char MATERIAL_BRIGHTNESS_HIGH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_LOW
public static final char MATERIAL_BRIGHTNESS_LOW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRIGHTNESS_MEDIUM
public static final char MATERIAL_BRIGHTNESS_MEDIUM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1697

Overview (Codename One API)


MATERIAL_BROKEN_IMAGE
public static final char MATERIAL_BROKEN_IMAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BRUSH
public static final char MATERIAL_BRUSH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BUG_REPORT
public static final char MATERIAL_BUG_REPORT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BUILD
public static final char MATERIAL_BUILD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BUSINESS
public static final char MATERIAL_BUSINESS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_BUSINESS_CENTER
public static final char MATERIAL_BUSINESS_CENTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CACHED
public static final char MATERIAL_CACHED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAKE
public static final char MATERIAL_CAKE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1698

Overview (Codename One API)


MATERIAL_CALL
public static final char MATERIAL_CALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_END
public static final char MATERIAL_CALL_END

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_MADE
public static final char MATERIAL_CALL_MADE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_MERGE
public static final char MATERIAL_CALL_MERGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_MISSED
public static final char MATERIAL_CALL_MISSED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_MISSED_OUTGOING
public static final char MATERIAL_CALL_MISSED_OUTGOING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_RECEIVED
public static final char MATERIAL_CALL_RECEIVED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CALL_SPLIT
public static final char MATERIAL_CALL_SPLIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1699

Overview (Codename One API)


MATERIAL_CAMERA
public static final char MATERIAL_CAMERA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAMERA_ALT
public static final char MATERIAL_CAMERA_ALT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAMERA_ENHANCE
public static final char MATERIAL_CAMERA_ENHANCE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAMERA_FRONT
public static final char MATERIAL_CAMERA_FRONT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAMERA_REAR
public static final char MATERIAL_CAMERA_REAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAMERA_ROLL
public static final char MATERIAL_CAMERA_ROLL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CANCEL
public static final char MATERIAL_CANCEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CARD_GIFTCARD
public static final char MATERIAL_CARD_GIFTCARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1700

Overview (Codename One API)


MATERIAL_CARD_MEMBERSHIP
public static final char MATERIAL_CARD_MEMBERSHIP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CARD_TRAVEL
public static final char MATERIAL_CARD_TRAVEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CASINO
public static final char MATERIAL_CASINO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAST
public static final char MATERIAL_CAST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CAST_CONNECTED
public static final char MATERIAL_CAST_CONNECTED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CENTER_FOCUS_STRONG
public static final char MATERIAL_CENTER_FOCUS_STRONG

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CENTER_FOCUS_WEAK
public static final char MATERIAL_CENTER_FOCUS_WEAK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHANGE_HISTORY
public static final char MATERIAL_CHANGE_HISTORY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1701

Overview (Codename One API)


MATERIAL_CHAT
public static final char MATERIAL_CHAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHAT_BUBBLE
public static final char MATERIAL_CHAT_BUBBLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHAT_BUBBLE_OUTLINE
public static final char MATERIAL_CHAT_BUBBLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHECK
public static final char MATERIAL_CHECK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHECK_BOX
public static final char MATERIAL_CHECK_BOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHECK_BOX_OUTLINE_BLANK
public static final char MATERIAL_CHECK_BOX_OUTLINE_BLANK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHECK_CIRCLE
public static final char MATERIAL_CHECK_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHEVRON_LEFT
public static final char MATERIAL_CHEVRON_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1702

Overview (Codename One API)


MATERIAL_CHEVRON_RIGHT
public static final char MATERIAL_CHEVRON_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHILD_CARE
public static final char MATERIAL_CHILD_CARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHILD_FRIENDLY
public static final char MATERIAL_CHILD_FRIENDLY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CHROME_READER_MODE
public static final char MATERIAL_CHROME_READER_MODE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLASS
public static final char MATERIAL_CLASS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLEAR
public static final char MATERIAL_CLEAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLEAR_ALL
public static final char MATERIAL_CLEAR_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOSE
public static final char MATERIAL_CLOSE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1703

Overview (Codename One API)


MATERIAL_CLOSED_CAPTION
public static final char MATERIAL_CLOSED_CAPTION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD
public static final char MATERIAL_CLOUD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_CIRCLE
public static final char MATERIAL_CLOUD_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_DONE
public static final char MATERIAL_CLOUD_DONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_DOWNLOAD
public static final char MATERIAL_CLOUD_DOWNLOAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_OFF
public static final char MATERIAL_CLOUD_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_QUEUE
public static final char MATERIAL_CLOUD_QUEUE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CLOUD_UPLOAD
public static final char MATERIAL_CLOUD_UPLOAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1704

Overview (Codename One API)


MATERIAL_CODE
public static final char MATERIAL_CODE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COLLECTIONS
public static final char MATERIAL_COLLECTIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COLLECTIONS_BOOKMARK
public static final char MATERIAL_COLLECTIONS_BOOKMARK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COLOR_LENS
public static final char MATERIAL_COLOR_LENS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COLORIZE
public static final char MATERIAL_COLORIZE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COMMENT
public static final char MATERIAL_COMMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COMPARE
public static final char MATERIAL_COMPARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COMPARE_ARROWS
public static final char MATERIAL_COMPARE_ARROWS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1705

Overview (Codename One API)


MATERIAL_COMPUTER
public static final char MATERIAL_COMPUTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONFIRMATION_NUMBER
public static final char MATERIAL_CONFIRMATION_NUMBER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTACT_MAIL
public static final char MATERIAL_CONTACT_MAIL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTACT_PHONE
public static final char MATERIAL_CONTACT_PHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTACTS
public static final char MATERIAL_CONTACTS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTENT_COPY
public static final char MATERIAL_CONTENT_COPY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTENT_CUT
public static final char MATERIAL_CONTENT_CUT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTENT_PASTE
public static final char MATERIAL_CONTENT_PASTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1706

Overview (Codename One API)


MATERIAL_CONTROL_POINT
public static final char MATERIAL_CONTROL_POINT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CONTROL_POINT_DUPLICATE
public static final char MATERIAL_CONTROL_POINT_DUPLICATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_COPYRIGHT
public static final char MATERIAL_COPYRIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CREATE
public static final char MATERIAL_CREATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CREATE_NEW_FOLDER
public static final char MATERIAL_CREATE_NEW_FOLDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CREDIT_CARD
public static final char MATERIAL_CREDIT_CARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP
public static final char MATERIAL_CROP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_16_9
public static final char MATERIAL_CROP_16_9

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1707

Overview (Codename One API)


MATERIAL_CROP_3_2
public static final char MATERIAL_CROP_3_2

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_5_4
public static final char MATERIAL_CROP_5_4

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_7_5
public static final char MATERIAL_CROP_7_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_DIN
public static final char MATERIAL_CROP_DIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_FREE
public static final char MATERIAL_CROP_FREE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_LANDSCAPE
public static final char MATERIAL_CROP_LANDSCAPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_ORIGINAL
public static final char MATERIAL_CROP_ORIGINAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_PORTRAIT
public static final char MATERIAL_CROP_PORTRAIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1708

Overview (Codename One API)


MATERIAL_CROP_ROTATE
public static final char MATERIAL_CROP_ROTATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_CROP_SQUARE
public static final char MATERIAL_CROP_SQUARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DASHBOARD
public static final char MATERIAL_DASHBOARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DATA_USAGE
public static final char MATERIAL_DATA_USAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DATE_RANGE
public static final char MATERIAL_DATE_RANGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEHAZE
public static final char MATERIAL_DEHAZE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DELETE
public static final char MATERIAL_DELETE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DESCRIPTION
public static final char MATERIAL_DESCRIPTION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1709

Overview (Codename One API)


MATERIAL_DESKTOP_MAC
public static final char MATERIAL_DESKTOP_MAC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DESKTOP_WINDOWS
public static final char MATERIAL_DESKTOP_WINDOWS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DETAILS
public static final char MATERIAL_DETAILS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEVELOPER_BOARD
public static final char MATERIAL_DEVELOPER_BOARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEVELOPER_MODE
public static final char MATERIAL_DEVELOPER_MODE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEVICE_HUB
public static final char MATERIAL_DEVICE_HUB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEVICES
public static final char MATERIAL_DEVICES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DEVICES_OTHER
public static final char MATERIAL_DEVICES_OTHER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1710

Overview (Codename One API)


MATERIAL_DIALER_SIP
public static final char MATERIAL_DIALER_SIP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIALPAD
public static final char MATERIAL_DIALPAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS
public static final char MATERIAL_DIRECTIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_BIKE
public static final char MATERIAL_DIRECTIONS_BIKE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_BOAT
public static final char MATERIAL_DIRECTIONS_BOAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_BUS
public static final char MATERIAL_DIRECTIONS_BUS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_CAR
public static final char MATERIAL_DIRECTIONS_CAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_RAILWAY
public static final char MATERIAL_DIRECTIONS_RAILWAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1711

Overview (Codename One API)


MATERIAL_DIRECTIONS_RUN
public static final char MATERIAL_DIRECTIONS_RUN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_SUBWAY
public static final char MATERIAL_DIRECTIONS_SUBWAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_TRANSIT
public static final char MATERIAL_DIRECTIONS_TRANSIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DIRECTIONS_WALK
public static final char MATERIAL_DIRECTIONS_WALK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DISC_FULL
public static final char MATERIAL_DISC_FULL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DNS
public static final char MATERIAL_DNS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DO_NOT_DISTURB
public static final char MATERIAL_DO_NOT_DISTURB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DO_NOT_DISTURB_ALT
public static final char MATERIAL_DO_NOT_DISTURB_ALT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1712

Overview (Codename One API)


MATERIAL_DOCK
public static final char MATERIAL_DOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DOMAIN
public static final char MATERIAL_DOMAIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DONE
public static final char MATERIAL_DONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DONE_ALL
public static final char MATERIAL_DONE_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DONUT_LARGE
public static final char MATERIAL_DONUT_LARGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DONUT_SMALL
public static final char MATERIAL_DONUT_SMALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DRAFTS
public static final char MATERIAL_DRAFTS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DRAG_HANDLE
public static final char MATERIAL_DRAG_HANDLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1713

Overview (Codename One API)


MATERIAL_DRIVE_ETA
public static final char MATERIAL_DRIVE_ETA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_DVR
public static final char MATERIAL_DVR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EDIT
public static final char MATERIAL_EDIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EDIT_LOCATION
public static final char MATERIAL_EDIT_LOCATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EJECT
public static final char MATERIAL_EJECT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EMAIL
public static final char MATERIAL_EMAIL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ENHANCED_ENCRYPTION
public static final char MATERIAL_ENHANCED_ENCRYPTION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EQUALIZER
public static final char MATERIAL_EQUALIZER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1714

Overview (Codename One API)


MATERIAL_ERROR
public static final char MATERIAL_ERROR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ERROR_OUTLINE
public static final char MATERIAL_ERROR_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EVENT
public static final char MATERIAL_EVENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EVENT_AVAILABLE
public static final char MATERIAL_EVENT_AVAILABLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EVENT_BUSY
public static final char MATERIAL_EVENT_BUSY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EVENT_NOTE
public static final char MATERIAL_EVENT_NOTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EVENT_SEAT
public static final char MATERIAL_EVENT_SEAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXIT_TO_APP
public static final char MATERIAL_EXIT_TO_APP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1715

Overview (Codename One API)


MATERIAL_EXPAND_LESS
public static final char MATERIAL_EXPAND_LESS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPAND_MORE
public static final char MATERIAL_EXPAND_MORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPLICIT
public static final char MATERIAL_EXPLICIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPLORE
public static final char MATERIAL_EXPLORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPOSURE
public static final char MATERIAL_EXPOSURE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPOSURE_NEG_1
public static final char MATERIAL_EXPOSURE_NEG_1

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPOSURE_NEG_2
public static final char MATERIAL_EXPOSURE_NEG_2

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPOSURE_PLUS_1
public static final char MATERIAL_EXPOSURE_PLUS_1

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1716

Overview (Codename One API)


MATERIAL_EXPOSURE_PLUS_2
public static final char MATERIAL_EXPOSURE_PLUS_2

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXPOSURE_ZERO
public static final char MATERIAL_EXPOSURE_ZERO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_EXTENSION
public static final char MATERIAL_EXTENSION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FACE
public static final char MATERIAL_FACE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FAST_FORWARD
public static final char MATERIAL_FAST_FORWARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FAST_REWIND
public static final char MATERIAL_FAST_REWIND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FAVORITE
public static final char MATERIAL_FAVORITE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FAVORITE_BORDER
public static final char MATERIAL_FAVORITE_BORDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1717

Overview (Codename One API)


MATERIAL_FEEDBACK
public static final char MATERIAL_FEEDBACK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIBER_DVR
public static final char MATERIAL_FIBER_DVR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIBER_MANUAL_RECORD
public static final char MATERIAL_FIBER_MANUAL_RECORD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIBER_NEW
public static final char MATERIAL_FIBER_NEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIBER_PIN
public static final char MATERIAL_FIBER_PIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIBER_SMART_RECORD
public static final char MATERIAL_FIBER_SMART_RECORD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILE_DOWNLOAD
public static final char MATERIAL_FILE_DOWNLOAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILE_UPLOAD
public static final char MATERIAL_FILE_UPLOAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1718

Overview (Codename One API)


MATERIAL_FILTER
public static final char MATERIAL_FILTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_1
public static final char MATERIAL_FILTER_1

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_2
public static final char MATERIAL_FILTER_2

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_3
public static final char MATERIAL_FILTER_3

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_4
public static final char MATERIAL_FILTER_4

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_5
public static final char MATERIAL_FILTER_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_6
public static final char MATERIAL_FILTER_6

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_7
public static final char MATERIAL_FILTER_7

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1719

Overview (Codename One API)


MATERIAL_FILTER_8
public static final char MATERIAL_FILTER_8

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_9
public static final char MATERIAL_FILTER_9

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_9_PLUS
public static final char MATERIAL_FILTER_9_PLUS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_B_AND_W
public static final char MATERIAL_FILTER_B_AND_W

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_CENTER_FOCUS
public static final char MATERIAL_FILTER_CENTER_FOCUS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_DRAMA
public static final char MATERIAL_FILTER_DRAMA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_FRAMES
public static final char MATERIAL_FILTER_FRAMES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_HDR
public static final char MATERIAL_FILTER_HDR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1720

Overview (Codename One API)


MATERIAL_FILTER_LIST
public static final char MATERIAL_FILTER_LIST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_NONE
public static final char MATERIAL_FILTER_NONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_TILT_SHIFT
public static final char MATERIAL_FILTER_TILT_SHIFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FILTER_VINTAGE
public static final char MATERIAL_FILTER_VINTAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIND_IN_PAGE
public static final char MATERIAL_FIND_IN_PAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FIND_REPLACE
public static final char MATERIAL_FIND_REPLACE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FINGERPRINT
public static final char MATERIAL_FINGERPRINT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FITNESS_CENTER
public static final char MATERIAL_FITNESS_CENTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1721

Overview (Codename One API)


MATERIAL_FLAG
public static final char MATERIAL_FLAG

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLARE
public static final char MATERIAL_FLARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLASH_AUTO
public static final char MATERIAL_FLASH_AUTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLASH_OFF
public static final char MATERIAL_FLASH_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLASH_ON
public static final char MATERIAL_FLASH_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLIGHT
public static final char MATERIAL_FLIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLIGHT_LAND
public static final char MATERIAL_FLIGHT_LAND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLIGHT_TAKEOFF
public static final char MATERIAL_FLIGHT_TAKEOFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1722

Overview (Codename One API)


MATERIAL_FLIP
public static final char MATERIAL_FLIP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLIP_TO_BACK
public static final char MATERIAL_FLIP_TO_BACK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FLIP_TO_FRONT
public static final char MATERIAL_FLIP_TO_FRONT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FOLDER
public static final char MATERIAL_FOLDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FOLDER_OPEN
public static final char MATERIAL_FOLDER_OPEN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FOLDER_SHARED
public static final char MATERIAL_FOLDER_SHARED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FOLDER_SPECIAL
public static final char MATERIAL_FOLDER_SPECIAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FONT_DOWNLOAD
public static final char MATERIAL_FONT_DOWNLOAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1723

Overview (Codename One API)


MATERIAL_FORMAT_ALIGN_CENTER
public static final char MATERIAL_FORMAT_ALIGN_CENTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_ALIGN_JUSTIFY
public static final char MATERIAL_FORMAT_ALIGN_JUSTIFY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_ALIGN_LEFT
public static final char MATERIAL_FORMAT_ALIGN_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_ALIGN_RIGHT
public static final char MATERIAL_FORMAT_ALIGN_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_BOLD
public static final char MATERIAL_FORMAT_BOLD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_CLEAR
public static final char MATERIAL_FORMAT_CLEAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_COLOR_FILL
public static final char MATERIAL_FORMAT_COLOR_FILL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_COLOR_RESET
public static final char MATERIAL_FORMAT_COLOR_RESET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1724

Overview (Codename One API)


MATERIAL_FORMAT_COLOR_TEXT
public static final char MATERIAL_FORMAT_COLOR_TEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_INDENT_DECREASE
public static final char MATERIAL_FORMAT_INDENT_DECREASE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_INDENT_INCREASE
public static final char MATERIAL_FORMAT_INDENT_INCREASE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_ITALIC
public static final char MATERIAL_FORMAT_ITALIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_LINE_SPACING
public static final char MATERIAL_FORMAT_LINE_SPACING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_LIST_BULLETED
public static final char MATERIAL_FORMAT_LIST_BULLETED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_LIST_NUMBERED
public static final char MATERIAL_FORMAT_LIST_NUMBERED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_PAINT
public static final char MATERIAL_FORMAT_PAINT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1725

Overview (Codename One API)


MATERIAL_FORMAT_QUOTE
public static final char MATERIAL_FORMAT_QUOTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_SHAPES
public static final char MATERIAL_FORMAT_SHAPES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_SIZE
public static final char MATERIAL_FORMAT_SIZE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_STRIKETHROUGH
public static final char MATERIAL_FORMAT_STRIKETHROUGH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_TEXTDIRECTION_L_TO_R
public static final char MATERIAL_FORMAT_TEXTDIRECTION_L_TO_R

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_TEXTDIRECTION_R_TO_L
public static final char MATERIAL_FORMAT_TEXTDIRECTION_R_TO_L

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORMAT_UNDERLINED
public static final char MATERIAL_FORMAT_UNDERLINED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORUM
public static final char MATERIAL_FORUM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1726

Overview (Codename One API)


MATERIAL_FORWARD
public static final char MATERIAL_FORWARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORWARD_10
public static final char MATERIAL_FORWARD_10

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORWARD_30
public static final char MATERIAL_FORWARD_30

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FORWARD_5
public static final char MATERIAL_FORWARD_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FREE_BREAKFAST
public static final char MATERIAL_FREE_BREAKFAST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FULLSCREEN
public static final char MATERIAL_FULLSCREEN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FULLSCREEN_EXIT
public static final char MATERIAL_FULLSCREEN_EXIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_FUNCTIONS
public static final char MATERIAL_FUNCTIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1727

Overview (Codename One API)


MATERIAL_GAMEPAD
public static final char MATERIAL_GAMEPAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GAMES
public static final char MATERIAL_GAMES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GAVEL
public static final char MATERIAL_GAVEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GESTURE
public static final char MATERIAL_GESTURE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GET_APP
public static final char MATERIAL_GET_APP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GIF
public static final char MATERIAL_GIF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GOLF_COURSE
public static final char MATERIAL_GOLF_COURSE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GPS_FIXED
public static final char MATERIAL_GPS_FIXED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1728

Overview (Codename One API)


MATERIAL_GPS_NOT_FIXED
public static final char MATERIAL_GPS_NOT_FIXED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GPS_OFF
public static final char MATERIAL_GPS_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRADE
public static final char MATERIAL_GRADE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRADIENT
public static final char MATERIAL_GRADIENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRAIN
public static final char MATERIAL_GRAIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRAPHIC_EQ
public static final char MATERIAL_GRAPHIC_EQ

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRID_OFF
public static final char MATERIAL_GRID_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GRID_ON
public static final char MATERIAL_GRID_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1729

Overview (Codename One API)


MATERIAL_GROUP
public static final char MATERIAL_GROUP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GROUP_ADD
public static final char MATERIAL_GROUP_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_GROUP_WORK
public static final char MATERIAL_GROUP_WORK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HD
public static final char MATERIAL_HD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HDR_OFF
public static final char MATERIAL_HDR_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HDR_ON
public static final char MATERIAL_HDR_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HDR_STRONG
public static final char MATERIAL_HDR_STRONG

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HDR_WEAK
public static final char MATERIAL_HDR_WEAK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1730

Overview (Codename One API)


MATERIAL_HEADSET
public static final char MATERIAL_HEADSET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HEADSET_MIC
public static final char MATERIAL_HEADSET_MIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HEALING
public static final char MATERIAL_HEALING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HEARING
public static final char MATERIAL_HEARING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HELP
public static final char MATERIAL_HELP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HELP_OUTLINE
public static final char MATERIAL_HELP_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HIGH_QUALITY
public static final char MATERIAL_HIGH_QUALITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HIGHLIGHT
public static final char MATERIAL_HIGHLIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1731

Overview (Codename One API)


MATERIAL_HIGHLIGHT_OFF
public static final char MATERIAL_HIGHLIGHT_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HISTORY
public static final char MATERIAL_HISTORY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HOME
public static final char MATERIAL_HOME

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HOT_TUB
public static final char MATERIAL_HOT_TUB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HOTEL
public static final char MATERIAL_HOTEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HOURGLASS_EMPTY
public static final char MATERIAL_HOURGLASS_EMPTY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HOURGLASS_FULL
public static final char MATERIAL_HOURGLASS_FULL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_HTTP
public static final char MATERIAL_HTTP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1732

Overview (Codename One API)


MATERIAL_HTTPS
public static final char MATERIAL_HTTPS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_IMAGE
public static final char MATERIAL_IMAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_IMAGE_ASPECT_RATIO
public static final char MATERIAL_IMAGE_ASPECT_RATIO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_IMPORT_CONTACTS
public static final char MATERIAL_IMPORT_CONTACTS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_IMPORT_EXPORT
public static final char MATERIAL_IMPORT_EXPORT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_IMPORTANT_DEVICES
public static final char MATERIAL_IMPORTANT_DEVICES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INBOX
public static final char MATERIAL_INBOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INDETERMINATE_CHECK_BOX
public static final char MATERIAL_INDETERMINATE_CHECK_BOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1733

Overview (Codename One API)


MATERIAL_INFO
public static final char MATERIAL_INFO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INFO_OUTLINE
public static final char MATERIAL_INFO_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INPUT
public static final char MATERIAL_INPUT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_CHART
public static final char MATERIAL_INSERT_CHART

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_COMMENT
public static final char MATERIAL_INSERT_COMMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_DRIVE_FILE
public static final char MATERIAL_INSERT_DRIVE_FILE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_EMOTICON
public static final char MATERIAL_INSERT_EMOTICON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_INVITATION
public static final char MATERIAL_INSERT_INVITATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1734

Overview (Codename One API)


MATERIAL_INSERT_LINK
public static final char MATERIAL_INSERT_LINK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INSERT_PHOTO
public static final char MATERIAL_INSERT_PHOTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INVERT_COLORS
public static final char MATERIAL_INVERT_COLORS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_INVERT_COLORS_OFF
public static final char MATERIAL_INVERT_COLORS_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ISO
public static final char MATERIAL_ISO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD
public static final char MATERIAL_KEYBOARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_ARROW_DOWN
public static final char MATERIAL_KEYBOARD_ARROW_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_ARROW_LEFT
public static final char MATERIAL_KEYBOARD_ARROW_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1735

Overview (Codename One API)


MATERIAL_KEYBOARD_ARROW_RIGHT
public static final char MATERIAL_KEYBOARD_ARROW_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_ARROW_UP
public static final char MATERIAL_KEYBOARD_ARROW_UP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_BACKSPACE
public static final char MATERIAL_KEYBOARD_BACKSPACE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_CAPSLOCK
public static final char MATERIAL_KEYBOARD_CAPSLOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_HIDE
public static final char MATERIAL_KEYBOARD_HIDE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_RETURN
public static final char MATERIAL_KEYBOARD_RETURN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_TAB
public static final char MATERIAL_KEYBOARD_TAB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_KEYBOARD_VOICE
public static final char MATERIAL_KEYBOARD_VOICE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1736

Overview (Codename One API)


MATERIAL_KITCHEN
public static final char MATERIAL_KITCHEN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LABEL
public static final char MATERIAL_LABEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LABEL_OUTLINE
public static final char MATERIAL_LABEL_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LANDSCAPE
public static final char MATERIAL_LANDSCAPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LANGUAGE
public static final char MATERIAL_LANGUAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAPTOP
public static final char MATERIAL_LAPTOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAPTOP_CHROMEBOOK
public static final char MATERIAL_LAPTOP_CHROMEBOOK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAPTOP_MAC
public static final char MATERIAL_LAPTOP_MAC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1737

Overview (Codename One API)


MATERIAL_LAPTOP_WINDOWS
public static final char MATERIAL_LAPTOP_WINDOWS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAUNCH
public static final char MATERIAL_LAUNCH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAYERS
public static final char MATERIAL_LAYERS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LAYERS_CLEAR
public static final char MATERIAL_LAYERS_CLEAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LEAK_ADD
public static final char MATERIAL_LEAK_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LEAK_REMOVE
public static final char MATERIAL_LEAK_REMOVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LENS
public static final char MATERIAL_LENS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LIBRARY_ADD
public static final char MATERIAL_LIBRARY_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1738

Overview (Codename One API)


MATERIAL_LIBRARY_BOOKS
public static final char MATERIAL_LIBRARY_BOOKS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LIBRARY_MUSIC
public static final char MATERIAL_LIBRARY_MUSIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LIGHTBULB_OUTLINE
public static final char MATERIAL_LIGHTBULB_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LINE_STYLE
public static final char MATERIAL_LINE_STYLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LINE_WEIGHT
public static final char MATERIAL_LINE_WEIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LINEAR_SCALE
public static final char MATERIAL_LINEAR_SCALE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LINK
public static final char MATERIAL_LINK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LINKED_CAMERA
public static final char MATERIAL_LINKED_CAMERA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1739

Overview (Codename One API)


MATERIAL_LIST
public static final char MATERIAL_LIST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LIVE_HELP
public static final char MATERIAL_LIVE_HELP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LIVE_TV
public static final char MATERIAL_LIVE_TV

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_ACTIVITY
public static final char MATERIAL_LOCAL_ACTIVITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_AIRPORT
public static final char MATERIAL_LOCAL_AIRPORT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_ATM
public static final char MATERIAL_LOCAL_ATM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_BAR
public static final char MATERIAL_LOCAL_BAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_CAFE
public static final char MATERIAL_LOCAL_CAFE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1740

Overview (Codename One API)


MATERIAL_LOCAL_CAR_WASH
public static final char MATERIAL_LOCAL_CAR_WASH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_CONVENIENCE_STORE
public static final char MATERIAL_LOCAL_CONVENIENCE_STORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_DINING
public static final char MATERIAL_LOCAL_DINING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_DRINK
public static final char MATERIAL_LOCAL_DRINK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_FLORIST
public static final char MATERIAL_LOCAL_FLORIST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_GAS_STATION
public static final char MATERIAL_LOCAL_GAS_STATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_GROCERY_STORE
public static final char MATERIAL_LOCAL_GROCERY_STORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_HOSPITAL
public static final char MATERIAL_LOCAL_HOSPITAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1741

Overview (Codename One API)


MATERIAL_LOCAL_HOTEL
public static final char MATERIAL_LOCAL_HOTEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_LAUNDRY_SERVICE
public static final char MATERIAL_LOCAL_LAUNDRY_SERVICE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_LIBRARY
public static final char MATERIAL_LOCAL_LIBRARY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_MALL
public static final char MATERIAL_LOCAL_MALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_MOVIES
public static final char MATERIAL_LOCAL_MOVIES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_OFFER
public static final char MATERIAL_LOCAL_OFFER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_PARKING
public static final char MATERIAL_LOCAL_PARKING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_PHARMACY
public static final char MATERIAL_LOCAL_PHARMACY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1742

Overview (Codename One API)


MATERIAL_LOCAL_PHONE
public static final char MATERIAL_LOCAL_PHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_PIZZA
public static final char MATERIAL_LOCAL_PIZZA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_PLAY
public static final char MATERIAL_LOCAL_PLAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_POST_OFFICE
public static final char MATERIAL_LOCAL_POST_OFFICE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_PRINTSHOP
public static final char MATERIAL_LOCAL_PRINTSHOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_SEE
public static final char MATERIAL_LOCAL_SEE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_SHIPPING
public static final char MATERIAL_LOCAL_SHIPPING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCAL_TAXI
public static final char MATERIAL_LOCAL_TAXI

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1743

Overview (Codename One API)


MATERIAL_LOCATION_CITY
public static final char MATERIAL_LOCATION_CITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCATION_DISABLED
public static final char MATERIAL_LOCATION_DISABLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCATION_OFF
public static final char MATERIAL_LOCATION_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCATION_ON
public static final char MATERIAL_LOCATION_ON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCATION_SEARCHING
public static final char MATERIAL_LOCATION_SEARCHING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCK
public static final char MATERIAL_LOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCK_OPEN
public static final char MATERIAL_LOCK_OPEN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOCK_OUTLINE
public static final char MATERIAL_LOCK_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1744

Overview (Codename One API)


MATERIAL_LOOKS
public static final char MATERIAL_LOOKS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_3
public static final char MATERIAL_LOOKS_3

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_4
public static final char MATERIAL_LOOKS_4

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_5
public static final char MATERIAL_LOOKS_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_6
public static final char MATERIAL_LOOKS_6

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_ONE
public static final char MATERIAL_LOOKS_ONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOKS_TWO
public static final char MATERIAL_LOOKS_TWO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOOP
public static final char MATERIAL_LOOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1745

Overview (Codename One API)


MATERIAL_LOUPE
public static final char MATERIAL_LOUPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_LOYALTY
public static final char MATERIAL_LOYALTY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MAIL
public static final char MATERIAL_MAIL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MAIL_OUTLINE
public static final char MATERIAL_MAIL_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MAP
public static final char MATERIAL_MAP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MARKUNREAD
public static final char MATERIAL_MARKUNREAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MARKUNREAD_MAILBOX
public static final char MATERIAL_MARKUNREAD_MAILBOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MEMORY
public static final char MATERIAL_MEMORY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1746

Overview (Codename One API)


MATERIAL_MENU
public static final char MATERIAL_MENU

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MERGE_TYPE
public static final char MATERIAL_MERGE_TYPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MESSAGE
public static final char MATERIAL_MESSAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MIC
public static final char MATERIAL_MIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MIC_NONE
public static final char MATERIAL_MIC_NONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MIC_OFF
public static final char MATERIAL_MIC_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MMS
public static final char MATERIAL_MMS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MODE_COMMENT
public static final char MATERIAL_MODE_COMMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1747

Overview (Codename One API)


MATERIAL_MODE_EDIT
public static final char MATERIAL_MODE_EDIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MONEY_OFF
public static final char MATERIAL_MONEY_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MONOCHROME_PHOTOS
public static final char MATERIAL_MONOCHROME_PHOTOS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOOD
public static final char MATERIAL_MOOD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOOD_BAD
public static final char MATERIAL_MOOD_BAD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MORE
public static final char MATERIAL_MORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MORE_HORIZ
public static final char MATERIAL_MORE_HORIZ

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MORE_VERT
public static final char MATERIAL_MORE_VERT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1748

Overview (Codename One API)


MATERIAL_MOTORCYCLE
public static final char MATERIAL_MOTORCYCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOUSE
public static final char MATERIAL_MOUSE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOVE_TO_INBOX
public static final char MATERIAL_MOVE_TO_INBOX

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOVIE
public static final char MATERIAL_MOVIE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOVIE_CREATION
public static final char MATERIAL_MOVIE_CREATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MOVIE_FILTER
public static final char MATERIAL_MOVIE_FILTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MUSIC_NOTE
public static final char MATERIAL_MUSIC_NOTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_MUSIC_VIDEO
public static final char MATERIAL_MUSIC_VIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1749

Overview (Codename One API)


MATERIAL_MY_LOCATION
public static final char MATERIAL_MY_LOCATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NATURE
public static final char MATERIAL_NATURE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NATURE_PEOPLE
public static final char MATERIAL_NATURE_PEOPLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NAVIGATE_BEFORE
public static final char MATERIAL_NAVIGATE_BEFORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NAVIGATE_NEXT
public static final char MATERIAL_NAVIGATE_NEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NAVIGATION
public static final char MATERIAL_NAVIGATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NEAR_ME
public static final char MATERIAL_NEAR_ME

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NETWORK_CELL
public static final char MATERIAL_NETWORK_CELL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1750

Overview (Codename One API)


MATERIAL_NETWORK_CHECK
public static final char MATERIAL_NETWORK_CHECK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NETWORK_LOCKED
public static final char MATERIAL_NETWORK_LOCKED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NETWORK_WIFI
public static final char MATERIAL_NETWORK_WIFI

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NEW_RELEASES
public static final char MATERIAL_NEW_RELEASES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NEXT_WEEK
public static final char MATERIAL_NEXT_WEEK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NFC
public static final char MATERIAL_NFC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NO_ENCRYPTION
public static final char MATERIAL_NO_ENCRYPTION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NO_SIM
public static final char MATERIAL_NO_SIM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1751

Overview (Codename One API)


MATERIAL_NOT_INTERESTED
public static final char MATERIAL_NOT_INTERESTED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTE_ADD
public static final char MATERIAL_NOTE_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTIFICATIONS
public static final char MATERIAL_NOTIFICATIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTIFICATIONS_ACTIVE
public static final char MATERIAL_NOTIFICATIONS_ACTIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTIFICATIONS_NONE
public static final char MATERIAL_NOTIFICATIONS_NONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTIFICATIONS_OFF
public static final char MATERIAL_NOTIFICATIONS_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_NOTIFICATIONS_PAUSED
public static final char MATERIAL_NOTIFICATIONS_PAUSED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_OFFLINE_PIN
public static final char MATERIAL_OFFLINE_PIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1752

Overview (Codename One API)


MATERIAL_ONDEMAND_VIDEO
public static final char MATERIAL_ONDEMAND_VIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_OPACITY
public static final char MATERIAL_OPACITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_OPEN_IN_BROWSER
public static final char MATERIAL_OPEN_IN_BROWSER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_OPEN_IN_NEW
public static final char MATERIAL_OPEN_IN_NEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_OPEN_WITH
public static final char MATERIAL_OPEN_WITH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PAGES
public static final char MATERIAL_PAGES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PAGEVIEW
public static final char MATERIAL_PAGEVIEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PALETTE
public static final char MATERIAL_PALETTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1753

Overview (Codename One API)


MATERIAL_PAN_TOOL
public static final char MATERIAL_PAN_TOOL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PANORAMA
public static final char MATERIAL_PANORAMA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PANORAMA_FISH_EYE
public static final char MATERIAL_PANORAMA_FISH_EYE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PANORAMA_HORIZONTAL
public static final char MATERIAL_PANORAMA_HORIZONTAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PANORAMA_VERTICAL
public static final char MATERIAL_PANORAMA_VERTICAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PANORAMA_WIDE_ANGLE
public static final char MATERIAL_PANORAMA_WIDE_ANGLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PARTY_MODE
public static final char MATERIAL_PARTY_MODE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PAUSE
public static final char MATERIAL_PAUSE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1754

Overview (Codename One API)


MATERIAL_PAUSE_CIRCLE_FILLED
public static final char MATERIAL_PAUSE_CIRCLE_FILLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PAUSE_CIRCLE_OUTLINE
public static final char MATERIAL_PAUSE_CIRCLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PAYMENT
public static final char MATERIAL_PAYMENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PEOPLE
public static final char MATERIAL_PEOPLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PEOPLE_OUTLINE
public static final char MATERIAL_PEOPLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_CAMERA_MIC
public static final char MATERIAL_PERM_CAMERA_MIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_CONTACT_CALENDAR
public static final char MATERIAL_PERM_CONTACT_CALENDAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_DATA_SETTING
public static final char MATERIAL_PERM_DATA_SETTING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1755

Overview (Codename One API)


MATERIAL_PERM_DEVICE_INFORMATION
public static final char MATERIAL_PERM_DEVICE_INFORMATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_IDENTITY
public static final char MATERIAL_PERM_IDENTITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_MEDIA
public static final char MATERIAL_PERM_MEDIA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_PHONE_MSG
public static final char MATERIAL_PERM_PHONE_MSG

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERM_SCAN_WIFI
public static final char MATERIAL_PERM_SCAN_WIFI

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERSON
public static final char MATERIAL_PERSON

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERSON_ADD
public static final char MATERIAL_PERSON_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERSON_OUTLINE
public static final char MATERIAL_PERSON_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1756

Overview (Codename One API)


MATERIAL_PERSON_PIN
public static final char MATERIAL_PERSON_PIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERSON_PIN_CIRCLE
public static final char MATERIAL_PERSON_PIN_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PERSONAL_VIDEO
public static final char MATERIAL_PERSONAL_VIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PETS
public static final char MATERIAL_PETS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE
public static final char MATERIAL_PHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_ANDROID
public static final char MATERIAL_PHONE_ANDROID

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_BLUETOOTH_SPEAKER
public static final char MATERIAL_PHONE_BLUETOOTH_SPEAKER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_FORWARDED
public static final char MATERIAL_PHONE_FORWARDED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1757

Overview (Codename One API)


MATERIAL_PHONE_IN_TALK
public static final char MATERIAL_PHONE_IN_TALK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_IPHONE
public static final char MATERIAL_PHONE_IPHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_LOCKED
public static final char MATERIAL_PHONE_LOCKED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_MISSED
public static final char MATERIAL_PHONE_MISSED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONE_PAUSED
public static final char MATERIAL_PHONE_PAUSED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONELINK
public static final char MATERIAL_PHONELINK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONELINK_ERASE
public static final char MATERIAL_PHONELINK_ERASE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONELINK_LOCK
public static final char MATERIAL_PHONELINK_LOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1758

Overview (Codename One API)


MATERIAL_PHONELINK_OFF
public static final char MATERIAL_PHONELINK_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONELINK_RING
public static final char MATERIAL_PHONELINK_RING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHONELINK_SETUP
public static final char MATERIAL_PHONELINK_SETUP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO
public static final char MATERIAL_PHOTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_ALBUM
public static final char MATERIAL_PHOTO_ALBUM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_CAMERA
public static final char MATERIAL_PHOTO_CAMERA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_FILTER
public static final char MATERIAL_PHOTO_FILTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_LIBRARY
public static final char MATERIAL_PHOTO_LIBRARY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1759

Overview (Codename One API)


MATERIAL_PHOTO_SIZE_SELECT_ACTUAL
public static final char MATERIAL_PHOTO_SIZE_SELECT_ACTUAL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_SIZE_SELECT_LARGE
public static final char MATERIAL_PHOTO_SIZE_SELECT_LARGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PHOTO_SIZE_SELECT_SMALL
public static final char MATERIAL_PHOTO_SIZE_SELECT_SMALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PICTURE_AS_PDF
public static final char MATERIAL_PICTURE_AS_PDF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PICTURE_IN_PICTURE
public static final char MATERIAL_PICTURE_IN_PICTURE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PICTURE_IN_PICTURE_ALT
public static final char MATERIAL_PICTURE_IN_PICTURE_ALT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PIN_DROP
public static final char MATERIAL_PIN_DROP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLACE
public static final char MATERIAL_PLACE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1760

Overview (Codename One API)


MATERIAL_PLAY_ARROW
public static final char MATERIAL_PLAY_ARROW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAY_CIRCLE_FILLED
public static final char MATERIAL_PLAY_CIRCLE_FILLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAY_CIRCLE_OUTLINE
public static final char MATERIAL_PLAY_CIRCLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAY_FOR_WORK
public static final char MATERIAL_PLAY_FOR_WORK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAYLIST_ADD
public static final char MATERIAL_PLAYLIST_ADD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAYLIST_ADD_CHECK
public static final char MATERIAL_PLAYLIST_ADD_CHECK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLAYLIST_PLAY
public static final char MATERIAL_PLAYLIST_PLAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PLUS_ONE
public static final char MATERIAL_PLUS_ONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1761

Overview (Codename One API)


MATERIAL_POLL
public static final char MATERIAL_POLL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_POLYMER
public static final char MATERIAL_POLYMER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_POOL
public static final char MATERIAL_POOL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PORTABLE_WIFI_OFF
public static final char MATERIAL_PORTABLE_WIFI_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PORTRAIT
public static final char MATERIAL_PORTRAIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_POWER
public static final char MATERIAL_POWER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_POWER_INPUT
public static final char MATERIAL_POWER_INPUT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_POWER_SETTINGS_NEW
public static final char MATERIAL_POWER_SETTINGS_NEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1762

Overview (Codename One API)


MATERIAL_PREGNANT_WOMAN
public static final char MATERIAL_PREGNANT_WOMAN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PRESENT_TO_ALL
public static final char MATERIAL_PRESENT_TO_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PRINT
public static final char MATERIAL_PRINT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PUBLIC
public static final char MATERIAL_PUBLIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_PUBLISH
public static final char MATERIAL_PUBLISH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_QUERY_BUILDER
public static final char MATERIAL_QUERY_BUILDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_QUESTION_ANSWER
public static final char MATERIAL_QUESTION_ANSWER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_QUEUE
public static final char MATERIAL_QUEUE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1763

Overview (Codename One API)


MATERIAL_QUEUE_MUSIC
public static final char MATERIAL_QUEUE_MUSIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_QUEUE_PLAY_NEXT
public static final char MATERIAL_QUEUE_PLAY_NEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RADIO
public static final char MATERIAL_RADIO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RADIO_BUTTON_CHECKED
public static final char MATERIAL_RADIO_BUTTON_CHECKED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RADIO_BUTTON_UNCHECKED
public static final char MATERIAL_RADIO_BUTTON_UNCHECKED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RATE_REVIEW
public static final char MATERIAL_RATE_REVIEW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RECEIPT
public static final char MATERIAL_RECEIPT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RECENT_ACTORS
public static final char MATERIAL_RECENT_ACTORS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1764

Overview (Codename One API)


MATERIAL_RECORD_VOICE_OVER
public static final char MATERIAL_RECORD_VOICE_OVER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REDEEM
public static final char MATERIAL_REDEEM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REDO
public static final char MATERIAL_REDO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REFRESH
public static final char MATERIAL_REFRESH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REMOVE
public static final char MATERIAL_REMOVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REMOVE_CIRCLE
public static final char MATERIAL_REMOVE_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REMOVE_CIRCLE_OUTLINE
public static final char MATERIAL_REMOVE_CIRCLE_OUTLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REMOVE_FROM_QUEUE
public static final char MATERIAL_REMOVE_FROM_QUEUE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1765

Overview (Codename One API)


MATERIAL_REMOVE_RED_EYE
public static final char MATERIAL_REMOVE_RED_EYE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REORDER
public static final char MATERIAL_REORDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPEAT
public static final char MATERIAL_REPEAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPEAT_ONE
public static final char MATERIAL_REPEAT_ONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPLAY
public static final char MATERIAL_REPLAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPLAY_10
public static final char MATERIAL_REPLAY_10

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPLAY_30
public static final char MATERIAL_REPLAY_30

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPLAY_5
public static final char MATERIAL_REPLAY_5

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1766

Overview (Codename One API)


MATERIAL_REPLY
public static final char MATERIAL_REPLY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPLY_ALL
public static final char MATERIAL_REPLY_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPORT
public static final char MATERIAL_REPORT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_REPORT_PROBLEM
public static final char MATERIAL_REPORT_PROBLEM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RESTAURANT_MENU
public static final char MATERIAL_RESTAURANT_MENU

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RESTORE
public static final char MATERIAL_RESTORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RING_VOLUME
public static final char MATERIAL_RING_VOLUME

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROOM
public static final char MATERIAL_ROOM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1767

Overview (Codename One API)


MATERIAL_ROOM_SERVICE
public static final char MATERIAL_ROOM_SERVICE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROTATE_90_DEGREES_CCW
public static final char MATERIAL_ROTATE_90_DEGREES_CCW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROTATE_LEFT
public static final char MATERIAL_ROTATE_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROTATE_RIGHT
public static final char MATERIAL_ROTATE_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROUNDED_CORNER
public static final char MATERIAL_ROUNDED_CORNER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROUTER
public static final char MATERIAL_ROUTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ROWING
public static final char MATERIAL_ROWING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_RV_HOOKUP
public static final char MATERIAL_RV_HOOKUP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1768

Overview (Codename One API)


MATERIAL_SATELLITE
public static final char MATERIAL_SATELLITE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SAVE
public static final char MATERIAL_SAVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCANNER
public static final char MATERIAL_SCANNER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCHEDULE
public static final char MATERIAL_SCHEDULE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCHOOL
public static final char MATERIAL_SCHOOL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCREEN_LOCK_LANDSCAPE
public static final char MATERIAL_SCREEN_LOCK_LANDSCAPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCREEN_LOCK_PORTRAIT
public static final char MATERIAL_SCREEN_LOCK_PORTRAIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCREEN_LOCK_ROTATION
public static final char MATERIAL_SCREEN_LOCK_ROTATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1769

Overview (Codename One API)


MATERIAL_SCREEN_ROTATION
public static final char MATERIAL_SCREEN_ROTATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SCREEN_SHARE
public static final char MATERIAL_SCREEN_SHARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SD_CARD
public static final char MATERIAL_SD_CARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SD_STORAGE
public static final char MATERIAL_SD_STORAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SEARCH
public static final char MATERIAL_SEARCH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SECURITY
public static final char MATERIAL_SECURITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SELECT_ALL
public static final char MATERIAL_SELECT_ALL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SEND
public static final char MATERIAL_SEND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1770

Overview (Codename One API)


MATERIAL_SETTINGS
public static final char MATERIAL_SETTINGS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_APPLICATIONS
public static final char MATERIAL_SETTINGS_APPLICATIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_BACKUP_RESTORE
public static final char MATERIAL_SETTINGS_BACKUP_RESTORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_BLUETOOTH
public static final char MATERIAL_SETTINGS_BLUETOOTH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_BRIGHTNESS
public static final char MATERIAL_SETTINGS_BRIGHTNESS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_CELL
public static final char MATERIAL_SETTINGS_CELL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_ETHERNET
public static final char MATERIAL_SETTINGS_ETHERNET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_INPUT_ANTENNA
public static final char MATERIAL_SETTINGS_INPUT_ANTENNA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1771

Overview (Codename One API)


MATERIAL_SETTINGS_INPUT_COMPONENT
public static final char MATERIAL_SETTINGS_INPUT_COMPONENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_INPUT_COMPOSITE
public static final char MATERIAL_SETTINGS_INPUT_COMPOSITE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_INPUT_HDMI
public static final char MATERIAL_SETTINGS_INPUT_HDMI

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_INPUT_SVIDEO
public static final char MATERIAL_SETTINGS_INPUT_SVIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_OVERSCAN
public static final char MATERIAL_SETTINGS_OVERSCAN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_PHONE
public static final char MATERIAL_SETTINGS_PHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_POWER
public static final char MATERIAL_SETTINGS_POWER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_REMOTE
public static final char MATERIAL_SETTINGS_REMOTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1772

Overview (Codename One API)


MATERIAL_SETTINGS_SYSTEM_DAYDREAM
public static final char MATERIAL_SETTINGS_SYSTEM_DAYDREAM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SETTINGS_VOICE
public static final char MATERIAL_SETTINGS_VOICE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHARE
public static final char MATERIAL_SHARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHOP
public static final char MATERIAL_SHOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHOP_TWO
public static final char MATERIAL_SHOP_TWO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHOPPING_BASKET
public static final char MATERIAL_SHOPPING_BASKET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHOPPING_CART
public static final char MATERIAL_SHOPPING_CART

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SHORT_TEXT
public static final char MATERIAL_SHORT_TEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1773

Overview (Codename One API)


MATERIAL_SHUFFLE
public static final char MATERIAL_SHUFFLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_CELLULAR_4_BAR
public static final char MATERIAL_SIGNAL_CELLULAR_4_BAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_CELLULAR_CONNECTED_NO_INTERNET_4_BAR
public static final char MATERIAL_SIGNAL_CELLULAR_CONNECTED_NO_INTERNET_4_BAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_CELLULAR_NO_SIM
public static final char MATERIAL_SIGNAL_CELLULAR_NO_SIM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_CELLULAR_NULL
public static final char MATERIAL_SIGNAL_CELLULAR_NULL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_CELLULAR_OFF
public static final char MATERIAL_SIGNAL_CELLULAR_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_WIFI_4_BAR
public static final char MATERIAL_SIGNAL_WIFI_4_BAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIGNAL_WIFI_4_BAR_LOCK
public static final char MATERIAL_SIGNAL_WIFI_4_BAR_LOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1774

Overview (Codename One API)


MATERIAL_SIGNAL_WIFI_OFF
public static final char MATERIAL_SIGNAL_WIFI_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIM_CARD
public static final char MATERIAL_SIM_CARD

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SIM_CARD_ALERT
public static final char MATERIAL_SIM_CARD_ALERT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SKIP_NEXT
public static final char MATERIAL_SKIP_NEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SKIP_PREVIOUS
public static final char MATERIAL_SKIP_PREVIOUS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SLIDESHOW
public static final char MATERIAL_SLIDESHOW

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SLOW_MOTION_VIDEO
public static final char MATERIAL_SLOW_MOTION_VIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SMARTPHONE
public static final char MATERIAL_SMARTPHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1775

Overview (Codename One API)


MATERIAL_SMOKE_FREE
public static final char MATERIAL_SMOKE_FREE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SMOKING_ROOMS
public static final char MATERIAL_SMOKING_ROOMS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SMS
public static final char MATERIAL_SMS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SMS_FAILED
public static final char MATERIAL_SMS_FAILED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SNOOZE
public static final char MATERIAL_SNOOZE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SORT
public static final char MATERIAL_SORT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SORT_BY_ALPHA
public static final char MATERIAL_SORT_BY_ALPHA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPA
public static final char MATERIAL_SPA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1776

Overview (Codename One API)


MATERIAL_SPACE_BAR
public static final char MATERIAL_SPACE_BAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPEAKER
public static final char MATERIAL_SPEAKER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPEAKER_GROUP
public static final char MATERIAL_SPEAKER_GROUP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPEAKER_NOTES
public static final char MATERIAL_SPEAKER_NOTES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPEAKER_PHONE
public static final char MATERIAL_SPEAKER_PHONE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SPELLCHECK
public static final char MATERIAL_SPELLCHECK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAR
public static final char MATERIAL_STAR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAR_BORDER
public static final char MATERIAL_STAR_BORDER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1777

Overview (Codename One API)


MATERIAL_STAR_HALF
public static final char MATERIAL_STAR_HALF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STARS
public static final char MATERIAL_STARS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAY_CURRENT_LANDSCAPE
public static final char MATERIAL_STAY_CURRENT_LANDSCAPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAY_CURRENT_PORTRAIT
public static final char MATERIAL_STAY_CURRENT_PORTRAIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAY_PRIMARY_LANDSCAPE
public static final char MATERIAL_STAY_PRIMARY_LANDSCAPE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STAY_PRIMARY_PORTRAIT
public static final char MATERIAL_STAY_PRIMARY_PORTRAIT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STOP
public static final char MATERIAL_STOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STOP_SCREEN_SHARE
public static final char MATERIAL_STOP_SCREEN_SHARE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1778

Overview (Codename One API)


MATERIAL_STORAGE
public static final char MATERIAL_STORAGE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STORE
public static final char MATERIAL_STORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STORE_MALL_DIRECTORY
public static final char MATERIAL_STORE_MALL_DIRECTORY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STRAIGHTEN
public static final char MATERIAL_STRAIGHTEN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STRIKETHROUGH_S
public static final char MATERIAL_STRIKETHROUGH_S

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_STYLE
public static final char MATERIAL_STYLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SUBDIRECTORY_ARROW_LEFT
public static final char MATERIAL_SUBDIRECTORY_ARROW_LEFT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SUBDIRECTORY_ARROW_RIGHT
public static final char MATERIAL_SUBDIRECTORY_ARROW_RIGHT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1779

Overview (Codename One API)


MATERIAL_SUBJECT
public static final char MATERIAL_SUBJECT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SUBSCRIPTIONS
public static final char MATERIAL_SUBSCRIPTIONS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SUBTITLES
public static final char MATERIAL_SUBTITLES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SUPERVISOR_ACCOUNT
public static final char MATERIAL_SUPERVISOR_ACCOUNT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SURROUND_SOUND
public static final char MATERIAL_SURROUND_SOUND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SWAP_CALLS
public static final char MATERIAL_SWAP_CALLS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SWAP_HORIZ
public static final char MATERIAL_SWAP_HORIZ

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SWAP_VERT
public static final char MATERIAL_SWAP_VERT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1780

Overview (Codename One API)


MATERIAL_SWAP_VERTICAL_CIRCLE
public static final char MATERIAL_SWAP_VERTICAL_CIRCLE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SWITCH_CAMERA
public static final char MATERIAL_SWITCH_CAMERA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SWITCH_VIDEO
public static final char MATERIAL_SWITCH_VIDEO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SYNC
public static final char MATERIAL_SYNC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SYNC_DISABLED
public static final char MATERIAL_SYNC_DISABLED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SYNC_PROBLEM
public static final char MATERIAL_SYNC_PROBLEM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SYSTEM_UPDATE
public static final char MATERIAL_SYSTEM_UPDATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_SYSTEM_UPDATE_ALT
public static final char MATERIAL_SYSTEM_UPDATE_ALT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1781

Overview (Codename One API)


MATERIAL_TAB
public static final char MATERIAL_TAB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TAB_UNSELECTED
public static final char MATERIAL_TAB_UNSELECTED

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TABLET
public static final char MATERIAL_TABLET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TABLET_ANDROID
public static final char MATERIAL_TABLET_ANDROID

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TABLET_MAC
public static final char MATERIAL_TABLET_MAC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TAG_FACES
public static final char MATERIAL_TAG_FACES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TAP_AND_PLAY
public static final char MATERIAL_TAP_AND_PLAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TERRAIN
public static final char MATERIAL_TERRAIN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1782

Overview (Codename One API)


MATERIAL_TEXT_FIELDS
public static final char MATERIAL_TEXT_FIELDS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TEXT_FORMAT
public static final char MATERIAL_TEXT_FORMAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TEXTSMS
public static final char MATERIAL_TEXTSMS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TEXTURE
public static final char MATERIAL_TEXTURE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_THEATERS
public static final char MATERIAL_THEATERS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_THUMB_DOWN
public static final char MATERIAL_THUMB_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_THUMB_UP
public static final char MATERIAL_THUMB_UP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_THUMBS_UP_DOWN
public static final char MATERIAL_THUMBS_UP_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1783

Overview (Codename One API)


MATERIAL_TIME_TO_LEAVE
public static final char MATERIAL_TIME_TO_LEAVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMELAPSE
public static final char MATERIAL_TIMELAPSE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMELINE
public static final char MATERIAL_TIMELINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMER
public static final char MATERIAL_TIMER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMER_10
public static final char MATERIAL_TIMER_10

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMER_3
public static final char MATERIAL_TIMER_3

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TIMER_OFF
public static final char MATERIAL_TIMER_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TOC
public static final char MATERIAL_TOC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1784

Overview (Codename One API)


MATERIAL_TODAY
public static final char MATERIAL_TODAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TOLL
public static final char MATERIAL_TOLL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TONALITY
public static final char MATERIAL_TONALITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TOUCH_APP
public static final char MATERIAL_TOUCH_APP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TOYS
public static final char MATERIAL_TOYS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRACK_CHANGES
public static final char MATERIAL_TRACK_CHANGES

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRAFFIC
public static final char MATERIAL_TRAFFIC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRANSFORM
public static final char MATERIAL_TRANSFORM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1785

Overview (Codename One API)


MATERIAL_TRANSLATE
public static final char MATERIAL_TRANSLATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRENDING_DOWN
public static final char MATERIAL_TRENDING_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRENDING_FLAT
public static final char MATERIAL_TRENDING_FLAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TRENDING_UP
public static final char MATERIAL_TRENDING_UP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TUNE
public static final char MATERIAL_TUNE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TURNED_IN
public static final char MATERIAL_TURNED_IN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TURNED_IN_NOT
public static final char MATERIAL_TURNED_IN_NOT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_TV
public static final char MATERIAL_TV

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1786

Overview (Codename One API)


MATERIAL_UNARCHIVE
public static final char MATERIAL_UNARCHIVE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_UNDO
public static final char MATERIAL_UNDO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_UNFOLD_LESS
public static final char MATERIAL_UNFOLD_LESS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_UNFOLD_MORE
public static final char MATERIAL_UNFOLD_MORE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_UPDATE
public static final char MATERIAL_UPDATE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_USB
public static final char MATERIAL_USB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VERIFIED_USER
public static final char MATERIAL_VERIFIED_USER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VERTICAL_ALIGN_BOTTOM
public static final char MATERIAL_VERTICAL_ALIGN_BOTTOM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1787

Overview (Codename One API)


MATERIAL_VERTICAL_ALIGN_CENTER
public static final char MATERIAL_VERTICAL_ALIGN_CENTER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VERTICAL_ALIGN_TOP
public static final char MATERIAL_VERTICAL_ALIGN_TOP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIBRATION
public static final char MATERIAL_VIBRATION

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIDEO_LIBRARY
public static final char MATERIAL_VIDEO_LIBRARY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIDEOCAM
public static final char MATERIAL_VIDEOCAM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIDEOCAM_OFF
public static final char MATERIAL_VIDEOCAM_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIDEOGAME_ASSET
public static final char MATERIAL_VIDEOGAME_ASSET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_AGENDA
public static final char MATERIAL_VIEW_AGENDA

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1788

Overview (Codename One API)


MATERIAL_VIEW_ARRAY
public static final char MATERIAL_VIEW_ARRAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_CAROUSEL
public static final char MATERIAL_VIEW_CAROUSEL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_COLUMN
public static final char MATERIAL_VIEW_COLUMN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_COMFY
public static final char MATERIAL_VIEW_COMFY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_COMPACT
public static final char MATERIAL_VIEW_COMPACT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_DAY
public static final char MATERIAL_VIEW_DAY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_HEADLINE
public static final char MATERIAL_VIEW_HEADLINE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_LIST
public static final char MATERIAL_VIEW_LIST

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1789

Overview (Codename One API)


MATERIAL_VIEW_MODULE
public static final char MATERIAL_VIEW_MODULE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_QUILT
public static final char MATERIAL_VIEW_QUILT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_STREAM
public static final char MATERIAL_VIEW_STREAM

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIEW_WEEK
public static final char MATERIAL_VIEW_WEEK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VIGNETTE
public static final char MATERIAL_VIGNETTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VISIBILITY
public static final char MATERIAL_VISIBILITY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VISIBILITY_OFF
public static final char MATERIAL_VISIBILITY_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VOICE_CHAT
public static final char MATERIAL_VOICE_CHAT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1790

Overview (Codename One API)


MATERIAL_VOICEMAIL
public static final char MATERIAL_VOICEMAIL

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VOLUME_DOWN
public static final char MATERIAL_VOLUME_DOWN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VOLUME_MUTE
public static final char MATERIAL_VOLUME_MUTE

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VOLUME_OFF
public static final char MATERIAL_VOLUME_OFF

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VOLUME_UP
public static final char MATERIAL_VOLUME_UP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VPN_KEY
public static final char MATERIAL_VPN_KEY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_VPN_LOCK
public static final char MATERIAL_VPN_LOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WALLPAPER
public static final char MATERIAL_WALLPAPER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1791

Overview (Codename One API)


MATERIAL_WARNING
public static final char MATERIAL_WARNING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WATCH
public static final char MATERIAL_WATCH

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WATCH_LATER
public static final char MATERIAL_WATCH_LATER

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WB_AUTO
public static final char MATERIAL_WB_AUTO

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WB_CLOUDY
public static final char MATERIAL_WB_CLOUDY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WB_INCANDESCENT
public static final char MATERIAL_WB_INCANDESCENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WB_IRIDESCENT
public static final char MATERIAL_WB_IRIDESCENT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WB_SUNNY
public static final char MATERIAL_WB_SUNNY

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1792

Overview (Codename One API)


MATERIAL_WC
public static final char MATERIAL_WC

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WEB
public static final char MATERIAL_WEB

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WEB_ASSET
public static final char MATERIAL_WEB_ASSET

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WEEKEND
public static final char MATERIAL_WEEKEND

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WHATSHOT
public static final char MATERIAL_WHATSHOT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WIDGETS
public static final char MATERIAL_WIDGETS

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WIFI
public static final char MATERIAL_WIFI

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WIFI_LOCK
public static final char MATERIAL_WIFI_LOCK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Field Detail

1793

Overview (Codename One API)


MATERIAL_WIFI_TETHERING
public static final char MATERIAL_WIFI_TETHERING

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WORK
public static final char MATERIAL_WORK

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_WRAP_TEXT
public static final char MATERIAL_WRAP_TEXT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_YOUTUBE_SEARCHED_FOR
public static final char MATERIAL_YOUTUBE_SEARCHED_FOR

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ZOOM_IN
public static final char MATERIAL_ZOOM_IN

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ZOOM_OUT
public static final char MATERIAL_ZOOM_OUT

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values
MATERIAL_ZOOM_OUT_MAP
public static final char MATERIAL_ZOOM_OUT_MAP

Material design icon font character code see https://www.google.com/design/icons/


for full list
See Also:
Constant Field Values

Method Detail
getMaterialDesignFont
public static Font getMaterialDesignFont()

The material design icon font allows creating icons based on the material design icon
catalog
Returns:

Field Detail

1794

Overview (Codename One API)


the font that can be used to create font image instances.
setMaterialIcon
public static void setMaterialIcon(Label l,
char icon)

Applies a material design icon (one of the MATERIAL_* icons above) to the given
label using the styling of the label
Parameters:
l - a label or subclass (e.g. Button etc.)
icon - one of the MATERIAL_* icons
setMaterialIcon
public static void setMaterialIcon(MultiButton l,
char icon)

Applies a material design icon (one of the MATERIAL_* icons above) to the given
component using the styling of the label
Parameters:
l - a multibutton
icon - one of the MATERIAL_* icons
setMaterialIcon
public static void setMaterialIcon(SpanButton l,
char icon)

Applies a material design icon (one of the MATERIAL_* icons above) to the given
component using the styling of the label
Parameters:
l - a SpanButton
icon - one of the MATERIAL_* icons
getDefaultSize
public static float getDefaultSize()

Default factor for image size, icons without a given size are sized as defaultSize X
default font height.
Returns:
the defaultSize
setDefaultSize
public static void setDefaultSize(float aDefaultSize)

Default factor for image size, icons without a given size are sized as defaultSize X
default font height.
Parameters:
aDefaultSize - the defaultSize to set
getDefaultPadding
public static int getDefaultPadding()

Indicates the default value for the padding in millimeters


Returns:
the defaultPadding
setDefaultPadding
public static void setDefaultPadding(int aDefaultPadding)

Indicates the default value for the padding in millimeters


Parameters:
aDefaultPadding - the defaultPadding to set
createFixed
public static FontImage createFixed(String text,
Font fnt,
int color,
int width,
int height)

Method Detail

1795

Overview (Codename One API)


Creates a font image
Parameters:
text - the text of the font image
fnt - the font
color - the color for the image foreground
width - the width in pixels
height - the height in pixels
Returns:
the image instance
create
public static FontImage create(String text,
Style s)

Creates the font image


Parameters:
text - the text for the font image
s - the style
Returns:
the font image
create
public static FontImage create(String text,
Style s,
Font fnt)

Creates the font image


Parameters:
text - the text for the font image
s - the style
fnt - the icon font used (needs to be sized correctly!)
Returns:
the font image
createMaterial
public static FontImage createMaterial(char icon,
Style s)

Creates a material design icon font for the given style


Parameters:
icon - the icon, one of the MATERIAL_* constants
s - the style to use, notice the font in the style only matters in terms of size
and nothing else
Returns:
a new icon
getGraphics
public Graphics getGraphics()

Throws a runtime exception


Overrides:
getGraphics in class Image
Returns:
Graphics object allowing us to manipulate the content of a mutable image
getWidth
public int getWidth()

Returns the width of the image


Overrides:
getWidth in class Image
Returns:
the width of the image

Method Detail

1796

Overview (Codename One API)


getHeight
public int getHeight()

Returns the height of the image


Overrides:
getHeight in class Image
Returns:
the height of the image
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y,
int w,
int h)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
w - the width to occupy
h - the height to occupy
getPadding
public int getPadding()

The padding for the image in millimeters


Returns:
the padding
setPadding
public void setPadding(int padding)

The padding for the image in millimeters


Parameters:
padding - the padding to set
getFont
public Font getFont()

Useful method to reuse the Font object when creating multiple image objects

Method Detail

1797

Overview (Codename One API)


Returns:
the font used
isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class Image
Returns:
true if this image represents an animation
animate
public boolean animate()

Overrides:
animate

in class Image

isOpaque
public boolean isOpaque()

Indicates whether this image is opaque or not


Overrides:
isOpaque in class Image
Returns:
true if the image is completely opqaque which allows for some heavy
optimizations
getImageName
public String getImageName()

The name of the image is set for some images mostly to ease the debugging of
Codename One application
Overrides:
getImageName in class Image
Returns:
the imageName
dispose
public void dispose()

Does nothing
Overrides:
dispose

in class Image

rotate
public Image rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees. By default
90 degree angle divisions are supported, anything else is implementation dependent.
This method assumes a square image. Notice that it is inefficient in the current
implementation to rotate to non-square angles,
E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90
and then rotate the 45 to another 90 degrees to achieve the same effect with less
memory.
Overrides:
rotate

in class Image

Parameters:
- A degree in right angle must be larger than 0 and up to 359
degrees
Returns:
new image instance with the closest possible rotation
degrees

Method Detail

1798

Overview (Codename One API)


toEncodedImage
public EncodedImage toEncodedImage()

Converts the icon image to an encoded image if possible


Returns:
the encoded image or null if the operation failed
toImage
public Image toImage()

Converts the icon image to an image if possible


Returns:
the encoded image or null if the operation failed
requiresDrawImage
public boolean requiresDrawImage()

New label optimizations don't invoke drawImage and instead just pass the native
image directly to the underlying renderer. This is problematic for some image types
specifically timeline & FontImage and this method allows these classes to indicate
that they need that legacy behavior of calling drawImage.
Overrides:
requiresDrawImage in class Image
Returns:
true if a drawImage call is a required

Method Detail

1799

Overview (Codename One API)


com.codename1.ui

Class Font
java.lang.Object

com.codename1.ui.Font

public class
extends Object

Codename One currently supports 3 font types:


System fonts - these are very simplistic builtin fonts. They work on all platforms and come in
one of 3 sizes. However, they are ubiquitous and work in every platform in all languages. A
system font can be created using createSystemFont(int, int, int).
TTF files - you can just place a TTF file in the src directory of the project and it will appear in
the Codename One Designer as an option. You can load such a font using
createTrueTypeFont(java.lang.String, java.lang.String).
Native fonts - these aren't supported on all platforms but generally they allow you to use a
set of platform native good looking fonts. E.g. on Android the devices Roboto font will be used
and on iOS Helvetica Neue will be used. You can load such a font using
createTrueTypeFont(java.lang.String, java.lang.String).
WARNING: If you use a TTF file MAKE SURE not to delete the file when there MIGHT be a reference
to it. This can cause hard to track down issues!
IMPORTANT: due to copyright restrictions we cannot distribute Helvetica and thus can't simulate it. In
the simulator you will see Roboto as the fallback in some cases and not the device font unless you
are running on a Mac. Notice that the Roboto font from Google doesn't support all languages and thus
special characters might not work on the simulator but would work on the device.
The Font class also supports bitmap fonts but this support is strictly aimed at legacy applications. We
no longer maintain that functionality.

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Class Font

Field and Description


FACE_MONOSPACE

Constant allowing us to author portable system fonts


FACE_PROPORTIONAL

Constant allowing us to author portable system fonts


FACE_SYSTEM

Constant allowing us to author portable system fonts


SIZE_LARGE

Constant allowing us to author portable system fonts


SIZE_MEDIUM

Constant allowing us to author portable system fonts


SIZE_SMALL

Constant allowing us to author portable system fonts


STYLE_BOLD

Constant allowing us to author portable system fonts


STYLE_ITALIC

Constant allowing us to author portable system fonts


STYLE_PLAIN

Constant allowing us to author portable system fonts


STYLE_UNDERLINED

Constant allowing us to author portable system fonts

1800

Overview (Codename One API)

Method Summary
Modifier
and Type

Method and Description


addContrast(byte value)

void

int
int

Deprecated.
bitmap font functionality is now deprecated
charsWidth(char[] ch, int offset, int length)

Return the width of the given characters in this font instance


charWidth(char ch)

Return the width of the specific character when rendered alone


clearBitmapCache()

static void

Deprecated.
bitmap font functionality is now deprecated
create(String lookup)

static Font

static Font

static Font

static Font

Creates a new font instance based on the platform specific string name of the
font.
createBitmapFont(Image bitmap, int[] cutOffsets, int[] charWidth,
String charsets)

Deprecated.
bitmap font functionality is now deprecated
createBitmapFont(String name, Image bitmap, int[] cutOffsets,
int[] charWidth, String charsets)

Deprecated.
bitmap font functionality is now deprecated
createSystemFont(int face, int style, int size)

Creates a system native font in a similar way to common MIDP fonts


createTrueTypeFont(String fontName, String fileName)

static Font

Creates a true type font with the given name/filename (font name might be
different from the file name and is required by some devices e.g.
derive(float sizePixels, int weight)

Font

boolean
int

Creates a font based on this truetype font with the given pixel, WARNING!
This method will only work in the case of truetype fonts!
Important some platforms e.g.
equals(Object o)

Indicates whether some other object is "equal to" this one.


getAscent()

The ascent is the amount by which the character ascends above the baseline.
getBitmapFont(String fontName)

static Font

String
static Font

Deprecated.
bitmap font functionality is now deprecated
getCharset()

Returns a string containing all the characters supported by this font.


getDefaultFont()

Return the global default font instance


getDescent()

int

int
int
Object

The descent is the amount by which the character descends below the
baseline
getFace()

Return Optional operation returning the font face for system fonts
getHeight()

Return the total height of the font


getNativeFont()

Returns the internal implementation specific font object


getPixelSize()

float

int

Method Summary

Returns the size with which the font object was created in case of truetype
fonts/derived fonts.
getSize()

Return Optional operation returning the font size for system fonts

1801

Overview (Codename One API)

getStyle()

int

Return Optional operation returning the font style for system fonts

static
boolean
static
boolean
static
boolean
static
boolean
boolean

isBitmapFontEnabled()

Indicates whether bitmap fonts should be enabled when loading or the fallback
system font should be used instead.
isCreationByStringSupported()

Returns true if the underlying platform allows creating a font based on a user
submitted string.
isNativeFontSchemeSupported()

Indicates whether the implementation supports loading a font "natively" to


handle one of the common native prefixes
isTrueTypeFileSupported()

Returns true if the underlying platform supports loading truetype fonts from a
file.
isTTFNativeFont()

Indicates if this is a TTF native font that can be derived and manipulated.
setBitmapFontEnabled(boolean enabled)

static void

static void

Indicates whether bitmap fonts should be enabled by default when loading or


the fallback system font should be used instead.
setDefaultFont(Font f)

Sets the global default font instance


stringWidth(String str)

int

Return the width of the given string in this font instance


substringWidth(String str, int offset, int len)

int

Return the width of the given string subset in this font instance

Methods inherited from class java.lang.Object


getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
FACE_MONOSPACE
public static final int FACE_MONOSPACE

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
FACE_PROPORTIONAL
public static final int FACE_PROPORTIONAL

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
FACE_SYSTEM
public static final int FACE_SYSTEM

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
SIZE_LARGE
public static final int SIZE_LARGE

Constant allowing us to author portable system fonts


See Also:
Constant Field Values

Methods inherited from class java.lang.Object

1802

Overview (Codename One API)


SIZE_MEDIUM
public static final int SIZE_MEDIUM

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
SIZE_SMALL
public static final int SIZE_SMALL

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
STYLE_BOLD
public static final int STYLE_BOLD

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
STYLE_ITALIC
public static final int STYLE_ITALIC

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
STYLE_UNDERLINED
public static final int STYLE_UNDERLINED

Constant allowing us to author portable system fonts


See Also:
Constant Field Values
STYLE_PLAIN
public static final int STYLE_PLAIN

Constant allowing us to author portable system fonts


See Also:
Constant Field Values

Method Detail
getBitmapFont
public static Font getBitmapFont(String fontName)

Deprecated. bitmap font functionality is now deprecated


Returns a previously loaded bitmap font from cache
Parameters:
fontName - the font name is the logical name of the font
Returns:
the font object
See Also:
clearBitmapCache()

clearBitmapCache
public static void clearBitmapCache()

Deprecated. bitmap font functionality is now deprecated


Bitmap fonts are cached this method allows us to flush the cache thus allows us to
reload a font

Field Detail

1803

Overview (Codename One API)


isTrueTypeFileSupported
public static boolean isTrueTypeFileSupported()

Returns true if the underlying platform supports loading truetype fonts from a file.
Returns:
true if the underlying platform supports loading truetype fonts from a file
isCreationByStringSupported
public static boolean isCreationByStringSupported()

Returns true if the underlying platform allows creating a font based on a user
submitted string.
Returns:
true if the underlying platform allows creating a font based on a user
submitted string
isNativeFontSchemeSupported
public static boolean isNativeFontSchemeSupported()

Indicates whether the implementation supports loading a font "natively" to handle one
of the common native prefixes
Returns:
true if the "native:" prefix is supported by loadTrueTypeFont
createTrueTypeFont
public static Font createTrueTypeFont(String fontName,
String fileName)

Creates a true type font with the given name/filename (font name might be different
from the file name and is required by some devices e.g. iOS). The font file must
reside in the src root of the project in order to be detectable. The file name should
contain no slashes or any such value.
Important some platforms e.g. iOS don't support changing the weight of the font and
require you to use the font name matching the weight, so the weight argument to
derive will be ignored!
This system also supports a special "native:" prefix that uses system native fonts e.g.
HelveticaNeue on iOS and Roboto on Android. It supports the following types:
native:MainThin, native:MainLight, native:MainRegular, native:MainBold,
native:MainBlack, native:ItalicThin, native:ItalicLight, native:ItalicRegular,
native:ItalicBold, native:ItalicBlack. Important due to copyright restrictions we cannot
distribute Helvetica and thus can't simulate it. In the simulator you will see Roboto
and not the device font unless you are running on a Mac
Parameters:
fontName - the name of the font
fileName - the file name of the font as it appears in the src directory of the
project, it MUST end with the .ttf extension!
Returns:
the font object created or null if true type fonts aren't supported on this
platform
derive
public Font derive(float sizePixels,
int weight)

Creates a font based on this truetype font with the given pixel, WARNING! This
method will only work in the case of truetype fonts!
Important some platforms e.g. iOS don't support changing the weight of the font and
require you to use the font name matching the weight, so the weight argument to
derive will be ignored!
Parameters:
sizePixels - the size of the font in pixels
weight - PLAIN, BOLD or ITALIC weight based on the constants in this class
Returns:
scaled font instance

Method Detail

1804

Overview (Codename One API)


isTTFNativeFont
public boolean isTTFNativeFont()

Indicates if this is a TTF native font that can be derived and manipulated. This is true
for a font loaded from file (TTF) or using the native: font name
Returns:
true if this is a native font
create
public static Font create(String lookup)

Creates a new font instance based on the platform specific string name of the font.
This method isn't supported on some platforms.
Parameters:
lookup - a set of platform specific names delimited by commas, the first
succefully loaded font will be used
Returns:
newly created font or null if creation failed
addContrast
public void addContrast(byte value)

Deprecated. bitmap font functionality is now deprecated


Increase the contrast of the bitmap font for rendering on top of a surface whose color
is darker. This is useful when drawing anti-aliased bitmap fonts using a light color
(e.g. white) on top of a dark surface (e.g. black), the font often breaks down if its
contrast is not increased due to the way alpha blending appears to the eye.
Notice that this method only works in one way, contrast cannot be decreased
properly in a font and it should be cleared and reloaed with a Look and Feel switch.
Parameters:
value - the value to increase
createBitmapFont
public static Font createBitmapFont(String name,
Image bitmap,
int[] cutOffsets,
int[] charWidth,
String charsets)

Deprecated. bitmap font functionality is now deprecated


Creates a bitmap font with the given arguments and places said font in the cache
Parameters:
name - the name for the font in the cache
bitmap - a transparency map in red and black that indicates the characters
cutOffsets - character offsets matching the bitmap pixels and characters in
the font
charWidth - The width of the character when drawing... this should not be
confused with the number of cutOffset[o + 1] - cutOffset[o]. They are
completely different since a character can be "wider" and "seep" into the next
region. This is especially true with italic characters all of which "lean" outside
of their bounds.
charsets - the set of characters in the font
Returns:
a font object to draw bitmap fonts
createBitmapFont
public static Font createBitmapFont(Image bitmap,
int[] cutOffsets,
int[] charWidth,
String charsets)

Deprecated. bitmap font functionality is now deprecated


Creates a bitmap font with the given arguments
Parameters:

Method Detail

1805

Overview (Codename One API)


bitmap - a transparency map in red and black that indicates the characters
cutOffsets - character offsets matching the bitmap pixels and characters in

the font
- The width of the character when drawing... this should not be
confused with the number of cutOffset[o + 1] - cutOffset[o]. They are
completely different since a character can be "wider" and "seep" into the next
region. This is especially true with italic characters all of which "lean" outside
of their bounds.
charsets - the set of characters in the font
Returns:
a font object to draw bitmap fonts
createSystemFont
charWidth

public static Font createSystemFont(int face,


int style,
int size)

Creates a system native font in a similar way to common MIDP fonts


Parameters:
face - One of FACE_SYSTEM, FACE_PROPORTIONAL,
FACE_MONOSPACE
style - one of STYLE_PLAIN, STYLE_ITALIC, STYLE_BOLD
size - One of SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE
Returns:
A newly created system font instance
charsWidth
public int charsWidth(char[] ch,
int offset,
int length)

Return the width of the given characters in this font instance


Parameters:
ch - array of characters
offset - characters offsets
length - characters length
Returns:
the width of the given characters in this font instance
substringWidth
public int substringWidth(String str,
int offset,
int len)

Return the width of the given string subset in this font instance
Parameters:
str - the given string
offset - the string offset
len - the len od string
Returns:
the width of the given string subset in this font instance
stringWidth
public int stringWidth(String str)

Return the width of the given string in this font instance


Parameters:
str - the given string *
Returns:
the width of the given string in this font instance
charWidth
public int charWidth(char ch)

Return the width of the specific character when rendered alone


Parameters:
ch - the specific character

Method Detail

1806

Overview (Codename One API)


Returns:
the width of the specific character when rendered alone
getHeight
public int getHeight()

Return the total height of the font


Returns:
the total height of the font
getDefaultFont
public static Font getDefaultFont()

Return the global default font instance


Returns:
the global default font instance
setDefaultFont
public static void setDefaultFont(Font f)

Sets the global default font instance


Parameters:
f - the global default font instance
getFace
public int getFace()

Return Optional operation returning the font face for system fonts
Returns:
Optional operation returning the font face for system fonts
getSize
public int getSize()

Return Optional operation returning the font size for system fonts
Returns:
Optional operation returning the font size for system fonts
getStyle
public int getStyle()

Return Optional operation returning the font style for system fonts
Returns:
Optional operation returning the font style for system fonts
getCharset
public String getCharset()

Returns a string containing all the characters supported by this font. Will return null
for system fonts.
Returns:
String containing the characters supported by a bitmap font or null otherwise.
setBitmapFontEnabled
public static void setBitmapFontEnabled(boolean enabled)

Indicates whether bitmap fonts should be enabled by default when loading or the
fallback system font should be used instead. This allows easy toggling of font loading.
Parameters:
enabled - true to enable bitmap font loading (if they exist in the resource)
isBitmapFontEnabled
public static boolean isBitmapFontEnabled()

Indicates whether bitmap fonts should be enabled when loading or the fallback
system font should be used instead. This allows easy toggling of font loading.
Returns:

Method Detail

1807

Overview (Codename One API)


true by default indicating that bitmap font loading is enabled
getNativeFont
public Object getNativeFont()

Returns the internal implementation specific font object


Returns:
platform specific font object for use by implementation classes or native code
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
getAscent
public int getAscent()

The ascent is the amount by which the character ascends above the baseline.
Returns:
the ascent in pixels
getDescent
public int getDescent()

The descent is the amount by which the character descends below the baseline
Returns:
the descent in pixels
getPixelSize
public float getPixelSize()

Returns the size with which the font object was created in case of truetype
fonts/derived fonts. This is useful since a platform might change things slightly based
on platform constraints but this value should be 100% consistent
Returns:
the size requested in the derive method

Method Detail

1808

Overview (Codename One API)


com.codename1.ui

Class EncodedImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage
Direct Known Subclasses:
FileEncodedImage, FileEncodedImageAsync, ReplaceableImage, StorageImage,
StorageImageAsync, URLImage

public class
extends Image

An image that only keeps the binary data of the source file used to load it in permanent memory. This
allows the bitmap to get collected while the binary data remains, a weak reference is used for
caching.

Constructor Summary
Modifier

Constructor and Description


EncodedImage(int width, int height)

protected

Allows subclasses to create more advanced variations of this class that lazily
store the data in an arbitrary location.

Method Summary
Modifier and
Type

Method and Description


asyncLock(Image internal)

void

static
EncodedImage
static
EncodedImage
static
EncodedImage
static
EncodedImage

Async lock is the equivalent of a lock operation, however it uses the given
image as the hard cache and performs the actual image loading
asynchronously.
create(byte[] data)

Creates an image from the given byte array


create(byte[] data, int width, int height, boolean opacity)

Creates an image from the given byte array with the variables set
appropriately.
create(InputStream i)

Creates an image from the input stream


create(InputStream i, int size)

Creates an image from the input stream, this version of the method is
somewhat faster than the version that doesn't accept size

static
EncodedImage

create(String i)

static
EncodedImage

createFromImage(Image i, boolean jpeg)

Creates an image from the input stream


Converts an image to encoded image
createFromRGB(int[] argb, int width, int height, boolean jpeg)

static Image

Tries to create an encoded image from RGB which is more efficient,


however if this fails it falls back to regular RGB image.
createMulti(int[] dpis, byte[][] data)

static
EncodedImage

Class EncodedImage

Deprecated.
this method is meant for internal use only, it would be very expensive to
use this method for real applications. Its here for simulators and
development purposes where screen DPI/resolution can vary significantly
in runtime (something that just doesn't happen on devices).

1809

Overview (Codename One API)


drawImage(Graphics g, Object nativeGraphics, int x, int y)
protected void

protected void

Callback invoked internally by Codename One to draw the image/frame


onto the display.
drawImage(Graphics g, Object nativeGraphics, int x, int y, int w,
int h)

Callback invoked internally by Codename One to draw the image/frame


onto the display.
getGraphics()

Graphics

int

If this is a mutable image a graphics object allowing us to draw on it is


returned.
getHeight()

Returns the height of the image


getImage()

Object

Returns the platform specific image implementation, warning the


implementation class can change between revisions of Codename One
and platforms.
getImageData()

byte[]

protected
Image
int
boolean
boolean
boolean

Returns the byte array data backing the image allowing the image to be
stored and discarded completely from RAM.
getInternal()

Returns the actual image represented by the encoded image, this image
will be cached in a weak/soft reference internally.
getWidth()

Returns the width of the image


isAnimation()

Returns true if this is an animated image


isLocked()

Returns true if the image is locked


isOpaque()

Indicates whether this image is opaque or not


lock()

void

This callback indicates that a component pointing at this image is


initialized, this allows an image to make performance sensitive
considerations e.g.
modifyAlpha(byte alpha)

Image

Creates a new image instance with the alpha channel of


opaque/translucent pixels within the image using the new alpha value.
modifyAlpha(byte alpha, int removeColor)

Image

Creates a new image instance with the alpha channel of


opaque/translucent pixels within the image using the new alpha value.
resetCache()

protected void

Image

A subclass might choose to load asynchroniously and reset the cache


when the image is ready.
rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees.


scale(int width, int height)

void

Scale the image to the given width and height, this is a fast algorithm that
preserves translucent information
scaled(int width, int height)

Image

EncodedImage

Returns a scaled version of this image image using the given width and
height, this is a fast algorithm that preserves translucent information.
scaledEncoded(int width, int height)

Performs scaling using ImageIO to generate an encoded Image


scaledHeight(int height)

Image

Scales the image to the given height while updating the width based on the
aspect ratio of the height
scaledSmallerRatio(int width, int height)

Image

Scales the image while maintaining the aspect ratio to the smaller size
image

Image

scaledWidth(int width)

Method Summary

1810

Overview (Codename One API)


Scales the image to the given width while updating the height based on the
aspect ratio of the width
subImage(int x, int y, int width, int height,
boolean processAlpha)

Extracts a subimage from the given image allowing us to breakdown a


single large image into multiple smaller images in RAM, this actually
creates a standalone version of the image for use.

Image

toRGB(RGBImage image, int destX, int destY, int x, int y,


int width, int height)

void

Extracts data from this image into the given RGBImage


unlock()

This callback indicates that a component pointing at this image is now


deinitilized This method may be invoked multiple times.

void

Methods inherited from class com.codename1.ui.Image


animate, applyMask, applyMask, applyMaskAutoScale, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, dispose,
flipHorizontally, flipVertically, getImageName, getRGB, getRGBCached,
getSVGDocument, isAlphaMutableImageSupported, isSVG, isSVGSupported,
mirror, modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
EncodedImage
protected EncodedImage(int width,
int height)

Allows subclasses to create more advanced variations of this class that lazily store
the data in an arbitrary location.
Parameters:
width - -1 if unknown ideally the width/height should be known in advance
height - -1 if unknown ideally the width/height should be known in advance

Method Detail
resetCache
protected void resetCache()

A subclass might choose to load asynchroniously and reset the cache when the
image is ready.
createMulti
public static EncodedImage createMulti(int[] dpis,
byte[][] data)

Deprecated. this method is meant for internal use only, it would be very expensive to
use this method for real applications. Its here for simulators and development
purposes where screen DPI/resolution can vary significantly in runtime (something
that just doesn't happen on devices).
Creates an encoded image that acts as a multi-image, DO NOT USE THIS
METHOD. Its for internal use to improve the user experience of the simulator
Parameters:
dpis - device DPI's
data - the data matching each multi-image DPI

Methods inherited from class com.codename1.ui.Image

1811

Overview (Codename One API)


Returns:
an encoded image that acts as a multi-image in runtime
createFromImage
public static EncodedImage createFromImage(Image i,
boolean jpeg)

Converts an image to encoded image


Parameters:
i - image
jpeg - true to try and set jpeg, will do a best effort but this isn't guaranteed
Returns:
an encoded image or null
createFromRGB
public static Image createFromRGB(int[] argb,
int width,
int height,
boolean jpeg)

Tries to create an encoded image from RGB which is more efficient, however if this
fails it falls back to regular RGB image. This method is slower than creating an RGB
image (not to be confused with the RGBImage class which is something ENTIRELY
different!).
Parameters:
argb - an argb array
width - the width for the image
height - the height for the image
jpeg - uses jpeg format internally which is opaque and could be faster/smaller
Returns:
an image which we hope is an encoded image
getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
create
public static EncodedImage create(byte[] data)

Creates an image from the given byte array


Parameters:
data - the data of the image
Returns:
newly created encoded image
create
public static EncodedImage create(byte[] data,
int width,
int height,
boolean opacity)

Creates an image from the given byte array with the variables set appropriately. This
saves LWUIT allot of resources since it doesn't need to actually traverse the pixels of
an image to find out details about it.
Parameters:
data - the data of the image
width - the width of the image
height - the height of the image
opacity - true for an opaque image
Returns:
newly created encoded image

Method Detail

1812

Overview (Codename One API)


getImage
public Object getImage()

Returns the platform specific image implementation, warning the implementation


class can change between revisions of Codename One and platforms.
Overrides:
getImage in class Image
Returns:
platform specific native implementation for this image object
create
public static EncodedImage create(InputStream i)
throws IOException

Creates an image from the input stream


Parameters:
i - the input stream
Returns:
newly created encoded image
Throws:
IOException - if thrown by the input stream
create
public static EncodedImage create(InputStream i,
int size)
throws IOException

Creates an image from the input stream, this version of the method is somewhat
faster than the version that doesn't accept size
Parameters:
i - the input stream
size - the size of the stream
Returns:
newly created encoded image
Throws:
IOException - if thrown by the input stream
getInternal
protected Image getInternal()

Returns the actual image represented by the encoded image, this image will be
cached in a weak/soft reference internally. This method is useful to detect when the
system actually created an image instance. You shouldn't invoke this method
manually!
Returns:
drawable image instance
isLocked
public boolean isLocked()

Returns true if the image is locked


Overrides:
isLocked in class Image
Returns:
false by default
asyncLock
public void asyncLock(Image internal)

Async lock is the equivalent of a lock operation, however it uses the given image as
the hard cache and performs the actual image loading asynchronously. On
completion this method will invoke repaint on the main form if applicable.
Overrides:
asyncLock in class Image
Parameters:
internal - the image to show while the actual image loads.

Method Detail

1813

Overview (Codename One API)


lock
public void lock()

This callback indicates that a component pointing at this image is initialized, this
allows an image to make performance sensitive considerations e.g. an encoded
image might choose to cache itself in RAM. This method may be invoked multiple
times.
Overrides:
lock in class Image
unlock
public void unlock()

This callback indicates that a component pointing at this image is now deinitilized
This method may be invoked multiple times.
Overrides:
unlock in class Image
create
public static EncodedImage create(String i)
throws IOException

Creates an image from the input stream


Parameters:
i - the resource
Returns:
newly created encoded image
Throws:
IOException - if thrown by the input stream
subImage
public Image subImage(int x,
int y,
int width,
int height,
boolean processAlpha)

Extracts a subimage from the given image allowing us to breakdown a single large
image into multiple smaller images in RAM, this actually creates a standalone version
of the image for use.
Overrides:
subImage in class Image
Parameters:
x - the x offset from the image
y - the y offset from the image
width - the width of internal images
height - the height of internal images
processAlpha - whether alpha should be processed as well as part of the
cutting
Returns:
An array of all the possible images that can be created from the source
rotate
public Image rotate(int degrees)

Returns an instance of this image rotated by the given number of degrees. By default
90 degree angle divisions are supported, anything else is implementation dependent.
This method assumes a square image. Notice that it is inefficient in the current
implementation to rotate to non-square angles,
E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90
and then rotate the 45 to another 90 degrees to achieve the same effect with less
memory.
Overrides:
rotate

Method Detail

in class Image

1814

Overview (Codename One API)


Parameters:
- A degree in right angle must be larger than 0 and up to 359
degrees
Returns:
new image instance with the closest possible rotation
modifyAlpha
degrees

public Image modifyAlpha(byte alpha)

Creates a new image instance with the alpha channel of opaque/translucent pixels
within the image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. All other pixels will have the new alpha value.
Overrides:
modifyAlpha in class Image
Parameters:
alpha - New value for the entire alpha channel
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
modifyAlpha
public Image modifyAlpha(byte alpha,
int removeColor)

Creates a new image instance with the alpha channel of opaque/translucent pixels
within the image using the new alpha value. Transparent (alpha == 0) pixels remain
transparent. All other pixels will have the new alpha value.
Overrides:
modifyAlpha in class Image
Parameters:
alpha - New value for the entire alpha channel
removeColor - pixels matching this color are made transparent (alpha channel
ignored)
Returns:
Translucent/Opaque image based on the alpha value and the pixels of this
image
getGraphics
public Graphics getGraphics()

If this is a mutable image a graphics object allowing us to draw on it is returned.


Overrides:
getGraphics in class Image
Returns:
Graphics object allowing us to manipulate the content of a mutable image
getWidth
public int getWidth()

Returns the width of the image


Overrides:
getWidth in class Image
Returns:
the width of the image
getHeight
public int getHeight()

Returns the height of the image


Overrides:
getHeight in class Image
Returns:
the height of the image

Method Detail

1815

Overview (Codename One API)


drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
drawImage
protected void drawImage(Graphics g,
Object nativeGraphics,
int x,
int y,
int w,
int h)

Callback invoked internally by Codename One to draw the image/frame onto the
display. Image subclasses can override this method to perform drawing of custom
image types.
Overrides:
drawImage in class Image
Parameters:
g - the graphics object
nativeGraphics - the underlying native graphics which might be essential for
some image types
x - the x coordinate
y - the y coordinate
w - the width to occupy
h - the height to occupy
toRGB
public void toRGB(RGBImage image,
int destX,
int destY,
int x,
int y,
int width,
int height)

Extracts data from this image into the given RGBImage


Overrides:
toRGB in class Image
Parameters:
image - RGBImage that would receive pixel data
destX - x location within RGBImage into which the data will be written
destY - y location within RGBImage into which the data will be written
x - location within the source image
y - location within the source image
width - size of the image to extract from the source image
height - size of the image to extract from the source image
scaledWidth
public Image scaledWidth(int width)

Scales the image to the given width while updating the height based on the aspect
ratio of the width
Overrides:
scaledWidth in class Image

Method Detail

1816

Overview (Codename One API)


Parameters:
width - the given new image width
Returns:
the newly created image
scaledHeight
public Image scaledHeight(int height)

Scales the image to the given height while updating the width based on the aspect
ratio of the height
Overrides:
scaledHeight in class Image
Parameters:
height - the given new image height
Returns:
the newly created image
scaledSmallerRatio
public Image scaledSmallerRatio(int width,
int height)

Scales the image while maintaining the aspect ratio to the smaller size image
Overrides:
scaledSmallerRatio in class Image
Parameters:
width - the given new image width
height - the given new image height
Returns:
the newly created image
scaledEncoded
public EncodedImage scaledEncoded(int width,
int height)

Performs scaling using ImageIO to generate an encoded Image


Parameters:
width - the width of the image, -1 to scale based on height and preserve
aspect ratio
height - the height of the image, -1 to scale based on width and preserve
aspect ratio
Returns:
new encoded image
scaled
public Image scaled(int width,
int height)

Returns a scaled version of this image image using the given width and height, this is
a fast algorithm that preserves translucent information. The method accepts -1 to
preserve aspect ratio in the given axis.
Overrides:
scaled in class Image
Parameters:
width - width for the scaling
height - height of the scaled image
Returns:
new image instance scaled to the given height and width
scale
public void scale(int width,
int height)

Scale the image to the given width and height, this is a fast algorithm that preserves
translucent information
Overrides:
scale in class Image
Parameters:

Method Detail

1817

Overview (Codename One API)


width - width for the scaling
height - height of the scaled

image

isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class Image
Returns:
true if this image represents an animation
isOpaque
public boolean isOpaque()

Indicates whether this image is opaque or not


Overrides:
isOpaque in class Image
Returns:
true if the image is completely opqaque which allows for some heavy
optimizations

Method Detail

1818

Overview (Codename One API)


com.codename1.ui

Class Display
java.lang.Object

com.codename1.ui.Display

public final class


extends Object

Central class for the API that manages rendering/events and is used to place top level components
(Form) on the "display".
This class handles the main thread for the toolkit referenced here on as the EDT (Event Dispatch
Thread) similar to the Swing EDT. This thread encapsulates the platform specific event delivery and
painting semantics and enables threading features such as animations etc...
The EDT should not be blocked since paint operations and events would also be blocked in much the
same way as they would be in other platforms. In order to serialize calls back into the EDT use the
methods callSerially(java.lang.Runnable) & callSeriallyAndWait(java.lang.Runnable).
Notice that all Codename One calls occur on the EDT (events, painting, animations etc...), Codename
One should normally be manipulated on the EDT as well (hence the
callSerially(java.lang.Runnable) & callSeriallyAndWait(java.lang.Runnable) methods).
Theoretically it should be possible to manipulate some Codename One features from other threads
but this can't be guaranteed to work for all use cases.

Field Summary
Modifier
and Type

Field and Description


COMMAND_BEHAVIOR_BUTTON_BAR

static int

Indicates that commands should be added to an always visible bar at the


bottom of the form.
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK

static int

Identical to the bar behavior, places the back command within the title bar of the
form/dialg
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT

static int

Places all commands on the right side of the title bar with a uniform size grid
layout
COMMAND_BEHAVIOR_DEFAULT

static int

Indicates that the Codename One implementation should decide internally the
command behavior most appropriate for this platform.
COMMAND_BEHAVIOR_ICS

static int

static int
static int

Commands are placed in the same was as they are in the ice cream sandwich
Android OS update where the back button has a theme icon the application icon
appears next to the
COMMAND_BEHAVIOR_NATIVE

Indicates that commands should try to add themselves to the native menus
COMMAND_BEHAVIOR_SIDE_NAVIGATION

Commands are placed in a side menu similar to Facebook/Google+ apps


COMMAND_BEHAVIOR_SOFTKEY

static int

Indicates the classic Codename One command behavior where the commands
are placed in a list within a dialog.
COMMAND_BEHAVIOR_TOUCH_MENU

static int

Indicates the touch menu dialog rendered by Codename One where commands
are placed into a scrollable dialog

static int DENSITY_2HD

Class Display

1819

Overview (Codename One API)


Double the HD level density
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

DENSITY_4K

4K level density
DENSITY_560

Intermediate density for screens that sit somewhere between HD to 2HD


DENSITY_HD

HD Up To 1920x1080
DENSITY_HIGH

Hi Density Up To 480x854
DENSITY_LOW

Low Density Up To 240x320


DENSITY_MEDIUM

Medium Density Up To 360x480


DENSITY_VERY_HIGH

Very Hi Density Up To 1440x720


DENSITY_VERY_LOW

Very Low Density 176x220 And Smaller


GALLERY_ALL

Used by openGallery
GALLERY_IMAGE

Used by openGallery
GALLERY_VIDEO

Used by openGallery
GAME_DOWN

Game action for down key


GAME_FIRE

Game action for fire


GAME_LEFT

Game action for left key


GAME_RIGHT

Game action for right key


GAME_UP

Game action for UP key


KEY_POUND

An attribute that encapsulates '#' int value.


KEYBOARD_TYPE_HALF_QWERTY

Half QWERTY which needs software assistance for completion


KEYBOARD_TYPE_NUMERIC

Numeric keypad keyboard type


KEYBOARD_TYPE_QWERTY

Full QWERTY keypad keyboard type, even if a numeric keyboard also exists
KEYBOARD_TYPE_UNKNOWN

static int

static int
static int
static int
static int
static int
static int
static int

Field Summary

Unknown keyboard type is the default indicating the software should try to
detect the keyboard type if necessary
KEYBOARD_TYPE_VIRTUAL

Touch device without a physical keyboard that should popup a keyboad


MEDIA_KEY_FAST_BACKWARD

Special case game key used for media playback events


MEDIA_KEY_FAST_FORWARD

Special case game key used for media playback events


MEDIA_KEY_PLAY

Special case game key used for media playback events


MEDIA_KEY_PLAY_PAUSE

Special case game key used for media playback events


MEDIA_KEY_PLAY_STOP

Special case game key used for media playback events


MEDIA_KEY_SKIP_BACK

Special case game key used for media playback events

1820

Overview (Codename One API)


static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

MEDIA_KEY_SKIP_FORWARD

Special case game key used for media playback events


MEDIA_KEY_STOP

Special case game key used for media playback events


PICKER_TYPE_DATE

Date native picker type, it returns a java.util.Date result.


PICKER_TYPE_DATE_AND_TIME

Date and time native picker type, it returns a java.util.Date result.


PICKER_TYPE_STRINGS

Strings native picker type, it returns a String result and accepts a String array.
PICKER_TYPE_TIME

Time native picker type, it returns an integer with minutes since midnight.
SHOW_DURING_EDIT_ALLOW_DISCARD

Allow show to occur during edit and discard all user input at this moment
SHOW_DURING_EDIT_ALLOW_SAVE

Allow show to occur during edit and save all user input at this moment
SHOW_DURING_EDIT_EXCEPTION

If show is called while editing text in the native text box an exception is thrown
SHOW_DURING_EDIT_IGNORE

Ignore all calls to show occurring during edit, they are discarded immediately
SHOW_DURING_EDIT_SET_AS_NEXT

static int

Show will update the current form to which the OK button of the text box will
return
SMS_BOTH

static int

Used by getSMSSupport to indicate that SMS can be sent in either seamless or


interactive mode
SMS_INTERACTIVE

static int

static int

Used by getSMSSupport to indicate that SMS triggers the native SMS app
which will show a compose UI
SMS_NOT_SUPPORTED

Used by getSMSSupport to indicate that SMS is not supported


SMS_SEAMLESS

static int

Used by getSMSSupport to indicate that SMS is sent in the background without


a compose UI

static
String

SOUND_TYPE_ALARM

static
String

SOUND_TYPE_BUTTON_PRESS

static
String

SOUND_TYPE_CONFIRMATION

static
String

SOUND_TYPE_ERROR

static
String

SOUND_TYPE_INFO

static
String

SOUND_TYPE_WARNING

A common sound type that can be used with playBuiltinSound


A common sound type that can be used with playBuiltinSound
A common sound type that can be used with playBuiltinSound
A common sound type that can be used with playBuiltinSound
A common sound type that can be used with playBuiltinSound
A common sound type that can be used with playBuiltinSound

Method Summary
Modifier and Type

Method and Descript


addEdtErrorHandler(ActionListener e)

void

An error handler will receive an action event with the


EDT once an error handler is installed the default Co
no longer appear
areMutableImagesFast()

boolean

Method Summary

On most platforms it is quite fast to draw on a mutab


image, however some platforms have much slower m
to just drawing on the screen.

1821

Overview (Codename One API)


void

callSerially(Runnable r)

Causes the runnable to be invoked on the event dis


callSeriallyAndWait(Runnable r)

void

Identical to callSerially with the added benefit of wai


complete.
callSeriallyAndWait(Runnable r, int timeout)

void

void
boolean

Identical to callSerially with the added benefit of wai


complete.

cancelLocalNotification(String notificationId)

Cancels a local notification by ID.


canDial()

Returns true if the device has dialing capabilities


canExecute(String url)

Boolean

Returns true if executing this URL should work, retu


this is unknown.
canForceOrientation()

boolean

void
void
void

Returns true if the device allows forcing the orientati


not allow this although some include a jad property a
captureAudio(ActionListener response)

This method tries to invoke the device native hardwa


capturePhoto(ActionListener response)

This method tries to invoke the device native camera


captureVideo(ActionListener response)

This method tries to invoke the device native camera


convertBidiLogicalToVisual(String s)

String

int

Converts the given string from logical bidi layout to v


rendered properly on the screen.

convertToPixels(int dipCount, boolean horizont

Converts the dips count to pixels, dips are roughly 1


copyToClipboard(Object obj)

void

Media

String

Performs a clipboard copy operation, if the native cli


implementation it would be used
createBackgroundMedia(String uri)

Creates an audio media that can be played in the ba

createContact(String firstName, String familyN


String homePhone, String cellPhone, String ema

Create a contact to the device contacts book

createMedia(InputStream stream, String mimeTyp


Media

Media
Media

Create the sound in the given stream Notice that an


completion and cannot be played twice!

createMedia(String uri, boolean isVideo, Runna

Creates a sound in the given URI which is partially p


createMediaRecorder(String path)

Deprecated.

createMediaRecorder(String path, String mimeTy


Media

Creates a Media recorder Object which will record fr


the given path.
createSoftWeakRef(Object o)

Object

Creates a soft/weak reference to an object that allow


it.
deinitialize()

static void

void
boolean
void

Method Summary

Closes down the EDT and Codename One, under n


completely unnecessary since exiting the application
One.
delete(String databaseName)

Deletes database
deleteContact(String id)

removed a contact from the device contacts book


deregisterPush()

1822

Overview (Codename One API)

Stop receiving push notifications to this client applic


void
void

dial(String phoneNumber)

Opens the device Dialer application with the given p


dismissNotification(Object o)

Removes the notification previously posted with the

editString(Component cmp, int maxSize, int con


void

void

void

Encapsulates the editing code which is specific to th


would allow "in place editing" MIDP does not.

editString(Component cmp, int maxSize, int con


int initiatingKeycode)

Encapsulates the editing code which is specific to th


would allow "in place editing" MIDP does not.
execute(String url)

Executes the given URL on the native platform


execute(String url, ActionListener response)

void

boolean
void
Object
void
Image
String[]

Executes the given URL on the native platform, this


has the ability to send an event to the app when the
this works only for Android platform to invoke other i
exists(String databaseName)

Indicates weather a database exists


exitApplication()

Exits the application...


extractHardRef(Object o)

Extracts the hard reference from the soft/weak refer


flashBacklight(int duration)

Flash the backlight of the device for the given length


gaussianBlurImage(Image image, float radius)

Create a blur image from the given image.


getAllContacts(boolean withNumbers)

Gets all contacts from the address book of the devic

getAllContacts(boolean withNumbers, boolean in


boolean includesPicture, boolean includesNumbe
boolean includeAddress)
Contact[]

String[]

Notice: this method might be very slow and should b


It might have platform specific optimizations over ge
over individual contacts but that isn't guaranteed.
getAvailableRecordingMimeTypes()

Gets the available recording MimeTypes


getCharLocation(String source, int index)

int

Returns the index of the given char within the source


necessarily the same when bidi is involved See this
getCodeScanner()

CodeScanner

Deprecated.
Use the cn1-codescanner cn1lib.
getCommandBehavior()

int

Contact

Contact

Indicates the way commands should be added to a


constants defined in this class
getContactById(String id)

Get a Contact according to it's contact id.

getContactById(String id, boolean includesFull


boolean includesPicture, boolean includesNumbe
boolean includeAddress)

This method returns a Contact by the contact id and


given flags
CrashReport

getCrashReporter()

The crash reporter gets invoked when an uncaught


getCurrent()

Form

Return the form currently displayed on the screen or


displayed.

String

getDatabasePath(String databaseName)

Method Summary

1823

Overview (Codename One API)


Returns the file path of the Database if exists and if
com.codename1.impl.VirtualKeyboardInterface

getDefaultVirtualKeyboard()

Get the default virtual keyboard or null if the VirtualK


getDeviceDensity()

int

int
int
float
int
int
int
ImageIO

Returns one of the density variables appropriate for


doesn't always correspond to resolution and an impl
change the density based on DPI constraints.
getDisplayHeight()

Return the height of the display


getDisplayWidth()

Return the width of the display


getDragSpeed(boolean yAxis)

This method returns the dragging speed based on th


getDragStartPercentage()

This method allows us to manipulate the drag starte


getFrameRate()

Indicates the maximum frames the API will try to dra


getGameAction(int keyCode)

Returns the game action code matching the given k


getImageIO()

Returns the image IO instance that allows scaling im


getInAppPurchase()

Purchase

Returns the native OS purchase implementation if a


method will try to fallback to a custom purchase imp
return null
getInAppPurchase(boolean d)

Purchase

static Display

Deprecated.
use the version that accepts no arguments, the phys
manual payment if applicable
getInstance()

Return the Display instance


getKeyboardType()

int

Returns the type of the input device one of: KEYBO


KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE
KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_
getKeyCode(int gameAction)

int

L10NManager
LocationManager

Deprecated.
this method doesn't work properly across device and
the case of unit testing. Do not use it for anything ot
getKeyCode(GAME_*) == keyCodeFromKeyEvent,
getLocalizationManager()

Returns the localization manager instance for this pl


getLocationManager()

This method returns the platform Location Manager


getLongPointerPressInterval()

int

Long pointer press is invoked after the given interva


events shorter/longer
getMediaRecorderingMimeType()

String

String
Object
String

Deprecated.
see getAvailableRecordingMimeTypes() instead
getMsisdn()

Returns the MSISDN for devices that expose it


getPasteDataFromClipboard()

Returns the current content of the clipboard


getPlatformName()

Returns a 2-3 letter code representing the platform n


getPlatformOverrides()

String[]

Method Summary

Returns the suffixes for ovr files that should be used


resource file on this platform

1824

Overview (Codename One API)


getProperty(String key, String defaultValue)
String

Returns the property from the underlying platform de


no deployment values are supported.

getResourceAsStream(Class cls, String resource


InputStream

int

This method is essentially equivalent to cls.getReso


some platforms might define unique ways in which t
implementation.
getShowDuringEditBehavior()

Returns the status of the show during edit flag


getSMSSupport()

int

String[]
String
boolean

Indicates the level of SMS support in the platform as


SMS_NOT_SUPPORTED (for desktop, tablet etc.),
interaction), SMS_INTERACTIVE (with compose UI
getSupportedVirtualKeyboard()

Returns all platform supported virtual keyboards nam


getUdid()

Returns the UDID for devices that support it


hasCamera()

Returns true if the device has camera false otherwis


hasDragOccured()

boolean

boolean

This method should be invoked by components that


pointerReleased callback.
hasNativeTheme()

Indicates if the implemenetation has a native underl


hideNotify()

void

Broadcasts hide notify into Codename One, this me


Codename One implementation to notify Codename
init(Object m)

static void

Deprecated.
this method is invoked internally do not invoke it!

installBuiltinSound(String soundIdentifier, In
void

void

Installs a replacement sound as the builtin sound re


identifier (this will override the system sound if such
installNativeTheme()

Installs the native theme, this is only applicable if ha


invokeAndBlock(Runnable r)

void

Invokes runnable and blocks the current thread, if th


still be blocked however a separate thread would be
of the EDT while it is blocked.

invokeAndBlock(Runnable r, boolean dropEvents)


void

Invokes runnable and blocks the current thread, if th


still be blocked however a separate thread would be
of the EDT while it is blocked.
isAllowMinimizing()

boolean

Allows a Codename One application to minimize wit


whenever a new dialog is poped up
isAutoFoldVKBOnFormSwitch()

boolean

boolean

Normally Codename One folds the VKB when switch


block that behavior.
isBadgingSupported()

Returns true if the underlying OS supports numeric b


isBidiAlgorithm()

boolean

boolean
boolean
boolean

Method Summary

Indicates whether Codename One should consider t


drawing text or navigating with the text field cursor.

isBuiltinSoundAvailable(String soundIdentifier

Indicates whether a user installed or system sound i


isBuiltinSoundsEnabled()

Allows muting/unmuting the builtin sounds easily


isClickTouchScreen()

1825

Overview (Codename One API)

Indicates whether the device has a double layer scre


touch events: click and hover.
isContactsPermissionGranted()
boolean

boolean
boolean
boolean

Some platforms allow the user to block contacts acc


(specifically iOS).
isDesktop()

Returns true if this is a desktop application


isEdt()

Returns true if we are currently in the event dispatch


isGaussianBlurSupported()

Returns true if gaussian blur is supported on this pla


isGetAllContactsFast()

boolean

static boolean
boolean

Indicates if the getAllContacts is platform optimized,


still take seconds or more to run so you should still u
isInitialized()

This method returns true if the Display is initialized.


isMinimized()

Indicates whether an application is minimized


isMultiKeyMode()

boolean

When set to true Codename One allows multiple ha


once, this isn't on by default since it can trigger som
navigation to/from native code
isMultiTouch()

boolean

Indicates whether the device supports multi-touch e


touch events are supported
isNativeCommands()

boolean

Deprecated.
use getCommandBehavior() == Display.COMMAND
isNativeInputSupported()

boolean

Indicates whether the device supports native in plac


lightweight input logic shouldn't be used for input.
isNativePickerTypeSupported(int pickerType)

boolean

boolean

Indicates whether the native picker dialog is support


include one of PICKER_TYPE_DATE_AND_TIME, P
PICKER_TYPE_DATE
isNativeShareSupported()

Indicates if the underlying platform supports sharing


isNativeTitle()

boolean

boolean
boolean
boolean
boolean

Indicates if the title of the Form is native title(in andr


behavior is native the ActionBar is used to display th
isNativeVideoPlayerControlsIncluded()

Indicates if the native video player includes its own p


isNotificationSupported()

Indicates whether the notify status bar method will p


isOpenNativeNavigationAppSupported()

Returns true if the underlying OS supports opening


isPortrait()

Returns true if the device is currently in portrait mod


isPureTouch()

boolean

boolean

A pure touch device has no focus showing when the


interface.
isRTL(char c)

Returns true if the given character is an RTL charac


isScreenSaverDisableSupported()

boolean

Checks if the device supports disabling the screen d


the developer to keep the screen display on.
isSimulator()

boolean

Method Summary

Allows detecting development mode so debugging c


used to simplify flow

1826

Overview (Codename One API)


boolean
boolean

isTablet()

Indicates whether the device is a tablet, notice that t


isThirdSoftButton()

Indicates whether the 3rd softbutton should be supp


isTouchScreenDevice()

boolean

boolean
void
void

Indicates if this is a touch screen device that will retu


if the device has pen events but can be overriden by
isVirtualKeyboardShowing()

Indicates if the virtual keyboard is currently showing


keyPressed(int keyCode)

Pushes a key press event with the given keycode in


keyReleased(int keyCode)

Pushes a key release event with the given keycode


lockOrientation(boolean portrait)

void

On devices that return true for canForceOrientation(


device orientation either to portrait or landscape mo
minimizeApplication()

boolean

void

Object

Minimizes the current application if minimization is s


fail).

notifyStatusBar(String tickerText, String cont


String contentBody, boolean vibrate, boolean f

Deprecated.
there is a new version of this method with a slightly i

notifyStatusBar(String tickerText, String cont


String contentBody, boolean vibrate, boolean f

Deprecated.
use scheduleLocalNotification instead
numAlphaLevels()

int

Deprecated.
this method isn't implemented in most modern devic
numColors()

int

Deprecated.
this method isn't implemented in most modern devic
onEditingComplete(Component c, String text)

void

Called by the underlying implementation to indicate


has completed and changes should propagate into C

openGallery(ActionListener response, int type)


void

Opens the device gallery to pick an image or a video


The method returns immediately and the response i
given ActionListener Object as the source value of t
openImageGallery(ActionListener response)

void

void
Database

Deprecated.
see openGallery instead

openNativeNavigationApp(double latitude, doubl

Opens the native navigation app in the given coordin


openOrCreate(String databaseName)

Opens a database or create one if not exists


playBuiltinSound(String soundIdentifier)

void

void
void

Plays a builtin device sound matching the given iden


themes can offer additional identifiers to the ones th
pointerDragged(int[] x, int[] y)

Pushes a pointer drag event with the given coordina


pointerHover(int[] x, int[] y)

Pushes a pointer hover event with the given coordin


pointerHoverPressed(int[] x, int[] y)

void

Pushes a pointer hover release event with the given


One
pointerHoverReleased(int[] x, int[] y)

void

Method Summary

Pushes a pointer hover release event with the given


One

1827

Overview (Codename One API)


void
void

pointerPressed(int[] x, int[] y)

Pushes a pointer press event with the given coordin


pointerReleased(int[] x, int[] y)

Pushes a pointer release event with the given coord


refreshNativeTitle()

void

if the title is native(e.g the android action bar), notify


be refreshed

registerPush(Hashtable metaData, boolean noFal


void

Register to receive push notification, invoke this met


notifications.
registerPush(String id, boolean noFallback)

void

void

Deprecated.
use the version that doesn't take an id argument this
ignored!

registerVirtualKeyboard(com.codename1.impl.Vir

Register a virtual keyboard


removeEdtErrorHandler(ActionListener e)

void

void
void
void
void
void
void

An error handler will receive an action event with the


EDT once an error handler is installed the default Co
no longer appear
restoreMinimizedApplication()

Restore the minimized application if minimization is


scheduleBackgroundTask(Runnable r)

Allows executing a background task in a separate lo

scheduleLocalNotification(LocalNotification n,

Schedules a local notification to occur.

sendMessage(String[] recipients, String subjec

Send an email using the platform mail client


sendSMS(String phoneNumber, String message)

Sends a SMS message to the given phone number

sendSMS(String phoneNumber, String message, bo

Sends a SMS message to the given phone number


setAllowMinimizing(boolean allowMinimizing)

void

Allows a Codename One application to minimize wit


whenever a new dialog is poped up

setAutoFoldVKBOnFormSwitch(boolean autoFoldVKB
void

void

Normally Codename One folds the VKB when switch


block that behavior.
setBadgeNumber(int number)

Sets the number that appears on the application ico


setBidiAlgorithm(boolean activate)

void

void

Indicates whether Codename One should consider t


drawing text or navigating with the text field cursor.
setBuiltinSoundsEnabled(boolean enabled)

Allows muting/unmuting the builtin sounds easily


setCommandBehavior(int commandBehavior)

void

void
void
void

Indicates the way commands should be added to a


constants defined in this class
setCrashReporter(CrashReport crashReporter)

The crash reporter gets invoked when an uncaught

setDefaultVirtualKeyboard(com.codename1.impl.V

Sets the default virtual keyboard to be used by the p

setDragStartPercentage(int dragStartPercentage

This method allows us to manipulate the drag starte


setFramerate(int rate)

void

Indicates the maximum frames the API will try to dra


is set to 10.

void

setLongPointerPressInterval(int v)

Method Summary

1828

Overview (Codename One API)

Long pointer press is invoked after the given interva


events shorter/longer
setMultiKeyMode(boolean multiKeyMode)
void

When set to true Codename One allows multiple ha


once, this isn't on by default since it can trigger som
navigation to/from native code
setNativeCommands(boolean nativeCommands)

void

void
void

Deprecated.
use setCommandBehavior(Display.COMMAND_BE
setNoSleep(boolean noSleep)

Calling this method with noSleep=true will cause the


setPollingFrequency(int freq)

Sets the frequency for polling the server in case of p


setProperty(String key, String value)

void

Sets a local property to the application, this method


implementation code and only allows the user to ove
for internal application purposes.
setPureTouch(boolean pureTouch)

void

A pure touch device has no focus showing when the


interface.
setScreenSaverEnabled(boolean e)

void

If isScreenSaverDisableSupported() returns true cal


screen display on
setShowDuringEditBehavior(int showDuringEdit)

void

Invoking the show() method of a form/dialog while th


native text box can have several behaviors: SHOW_
SHOW_DURING_EDIT_EXCEPTION, SHOW_DUR
SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DU
setShowVirtualKeyboard(boolean show)

void

void

Displays the virtual keyboard on devices that suppo


keyboard
setThirdSoftButton(boolean thirdSoftButton)

Indicates whether the 3rd softbutton should be supp


setTouchScreenDevice(boolean touchScreen)

void

Indicates if this is a touch screen device that will retu


if the device has pen events but can be overriden by
setTransitionYield(int transitionD)

void

Indicates whether a delay should exist between calls


transition.
share(String toShare)

void

void
void

Deprecated.
use the method share that accepts an image and m

share(String text, String image, String mimeTy

Share the required information using the platform sh

share(String text, String image, String mimeTy

Share the required information using the platform sh


shouldRenderSelection()

boolean

This is an internal state flag relevant only for pureTo


always be true).
shouldRenderSelection(Component c)

boolean

This is an internal state flag relevant only for pureTo


always be true).

showNativePicker(int type, Component source, O


Object data)
Object

void
void

Method Summary

Shows a native modal dialog allowing us to perform


which can include one of PICKER_TYPE_DATE_AN
PICKER_TYPE_TIME, PICKER_TYPE_DATE
showNativeScreen(Object nativeFullScreenPeer)

Shows a native Form/Canvas or some other heavyw


showNotify()

1829

Overview (Codename One API)

Broadcasts show notify into Codename One, this me


Codename One implementation to notify Codename
sizeChanged(int w, int h)

Notifies Codename One of display size changes, thi


implementation class and is for internal use

void

startThread(Runnable r, String name)

Start a Codename One thread that supports crash p


One features.

Thread

stopEditing(Component cmp)

void

Allows us to stop editString on the given text compo


unlockOrientation()

This is the reverse method for lock orientation allowi


disabled

void

vibrate(int duration)

void

Vibrates the device for the given length of time

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
SOUND_TYPE_ALARM
public static final String SOUND_TYPE_ALARM

A common sound type that can be used with playBuiltinSound


See Also:
Constant Field Values
SOUND_TYPE_CONFIRMATION
public static final String SOUND_TYPE_CONFIRMATION

A common sound type that can be used with playBuiltinSound


See Also:
Constant Field Values
SOUND_TYPE_ERROR
public static final String SOUND_TYPE_ERROR

A common sound type that can be used with playBuiltinSound


See Also:
Constant Field Values
SOUND_TYPE_INFO
public static final String SOUND_TYPE_INFO

A common sound type that can be used with playBuiltinSound


See Also:
Constant Field Values
SOUND_TYPE_WARNING
public static final String SOUND_TYPE_WARNING

A common sound type that can be used with playBuiltinSound


See Also:
Constant Field Values
SOUND_TYPE_BUTTON_PRESS
public static final String SOUND_TYPE_BUTTON_PRESS

A common sound type that can be used with playBuiltinSound


See Also:

Methods inherited from class java.lang.Object

1830

Overview (Codename One API)


Constant Field Values
KEYBOARD_TYPE_UNKNOWN
public static final int KEYBOARD_TYPE_UNKNOWN

Unknown keyboard type is the default indicating the software should try to detect the
keyboard type if necessary
See Also:
Constant Field Values
KEYBOARD_TYPE_NUMERIC
public static final int KEYBOARD_TYPE_NUMERIC

Numeric keypad keyboard type


See Also:
Constant Field Values
KEYBOARD_TYPE_QWERTY
public static final int KEYBOARD_TYPE_QWERTY

Full QWERTY keypad keyboard type, even if a numeric keyboard also exists
See Also:
Constant Field Values
KEYBOARD_TYPE_VIRTUAL
public static final int KEYBOARD_TYPE_VIRTUAL

Touch device without a physical keyboard that should popup a keyboad


See Also:
Constant Field Values
KEYBOARD_TYPE_HALF_QWERTY
public static final int KEYBOARD_TYPE_HALF_QWERTY

Half QWERTY which needs software assistance for completion


See Also:
Constant Field Values
SMS_NOT_SUPPORTED
public static final int SMS_NOT_SUPPORTED

Used by getSMSSupport to indicate that SMS is not supported


See Also:
Constant Field Values
SMS_SEAMLESS
public static final int SMS_SEAMLESS

Used by getSMSSupport to indicate that SMS is sent in the background without a


compose UI
See Also:
Constant Field Values
SMS_INTERACTIVE
public static final int SMS_INTERACTIVE

Used by getSMSSupport to indicate that SMS triggers the native SMS app which will
show a compose UI
See Also:
Constant Field Values
SMS_BOTH
public static final int SMS_BOTH

Used by getSMSSupport to indicate that SMS can be sent in either seamless or


interactive mode
See Also:

Field Detail

1831

Overview (Codename One API)


Constant Field Values
GALLERY_IMAGE
public static final int GALLERY_IMAGE

Used by openGallery
See Also:
Constant Field Values
GALLERY_VIDEO
public static final int GALLERY_VIDEO

Used by openGallery
See Also:
Constant Field Values
GALLERY_ALL
public static final int GALLERY_ALL

Used by openGallery
See Also:
Constant Field Values
DENSITY_VERY_LOW
public static final int DENSITY_VERY_LOW

Very Low Density 176x220 And Smaller


See Also:
Constant Field Values
DENSITY_LOW
public static final int DENSITY_LOW

Low Density Up To 240x320


See Also:
Constant Field Values
DENSITY_MEDIUM
public static final int DENSITY_MEDIUM

Medium Density Up To 360x480


See Also:
Constant Field Values
DENSITY_HIGH
public static final int DENSITY_HIGH

Hi Density Up To 480x854
See Also:
Constant Field Values
DENSITY_VERY_HIGH
public static final int DENSITY_VERY_HIGH

Very Hi Density Up To 1440x720


See Also:
Constant Field Values
DENSITY_HD
public static final int DENSITY_HD

HD Up To 1920x1080
See Also:
Constant Field Values

Field Detail

1832

Overview (Codename One API)


DENSITY_560
public static final int DENSITY_560

Intermediate density for screens that sit somewhere between HD to 2HD


See Also:
Constant Field Values
DENSITY_2HD
public static final int DENSITY_2HD

Double the HD level density


See Also:
Constant Field Values
DENSITY_4K
public static final int DENSITY_4K

4K level density
See Also:
Constant Field Values
PICKER_TYPE_DATE
public static final int PICKER_TYPE_DATE

Date native picker type, it returns a java.util.Date result.


See Also:
Constant Field Values
PICKER_TYPE_TIME
public static final int PICKER_TYPE_TIME

Time native picker type, it returns an integer with minutes since midnight.
See Also:
Constant Field Values
PICKER_TYPE_DATE_AND_TIME
public static final int PICKER_TYPE_DATE_AND_TIME

Date and time native picker type, it returns a java.util.Date result.


See Also:
Constant Field Values
PICKER_TYPE_STRINGS
public static final int PICKER_TYPE_STRINGS

Strings native picker type, it returns a String result and accepts a String array.
See Also:
Constant Field Values
GAME_FIRE
public static final int GAME_FIRE

Game action for fire


See Also:
Constant Field Values
GAME_LEFT
public static final int GAME_LEFT

Game action for left key


See Also:
Constant Field Values

Field Detail

1833

Overview (Codename One API)


GAME_RIGHT
public static final int GAME_RIGHT

Game action for right key


See Also:
Constant Field Values
GAME_UP
public static final int GAME_UP

Game action for UP key


See Also:
Constant Field Values
GAME_DOWN
public static final int GAME_DOWN

Game action for down key


See Also:
Constant Field Values
MEDIA_KEY_SKIP_FORWARD
public static final int MEDIA_KEY_SKIP_FORWARD

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_SKIP_BACK
public static final int MEDIA_KEY_SKIP_BACK

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_PLAY
public static final int MEDIA_KEY_PLAY

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_STOP
public static final int MEDIA_KEY_STOP

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_PLAY_STOP
public static final int MEDIA_KEY_PLAY_STOP

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_PLAY_PAUSE
public static final int MEDIA_KEY_PLAY_PAUSE

Special case game key used for media playback events


See Also:
Constant Field Values

Field Detail

1834

Overview (Codename One API)


MEDIA_KEY_FAST_FORWARD
public static final int MEDIA_KEY_FAST_FORWARD

Special case game key used for media playback events


See Also:
Constant Field Values
MEDIA_KEY_FAST_BACKWARD
public static final int MEDIA_KEY_FAST_BACKWARD

Special case game key used for media playback events


See Also:
Constant Field Values
KEY_POUND
public static final int KEY_POUND

An attribute that encapsulates '#' int value.


See Also:
Constant Field Values
SHOW_DURING_EDIT_IGNORE
public static final int SHOW_DURING_EDIT_IGNORE

Ignore all calls to show occurring during edit, they are discarded immediately
See Also:
Constant Field Values
SHOW_DURING_EDIT_EXCEPTION
public static final int SHOW_DURING_EDIT_EXCEPTION

If show is called while editing text in the native text box an exception is thrown
See Also:
Constant Field Values
SHOW_DURING_EDIT_ALLOW_DISCARD
public static final int SHOW_DURING_EDIT_ALLOW_DISCARD

Allow show to occur during edit and discard all user input at this moment
See Also:
Constant Field Values
SHOW_DURING_EDIT_ALLOW_SAVE
public static final int SHOW_DURING_EDIT_ALLOW_SAVE

Allow show to occur during edit and save all user input at this moment
See Also:
Constant Field Values
SHOW_DURING_EDIT_SET_AS_NEXT
public static final int SHOW_DURING_EDIT_SET_AS_NEXT

Show will update the current form to which the OK button of the text box will return
See Also:
Constant Field Values
COMMAND_BEHAVIOR_DEFAULT
public static final int COMMAND_BEHAVIOR_DEFAULT

Indicates that the Codename One implementation should decide internally the
command behavior most appropriate for this platform.
See Also:
Constant Field Values

Field Detail

1835

Overview (Codename One API)


COMMAND_BEHAVIOR_SOFTKEY
public static final int COMMAND_BEHAVIOR_SOFTKEY

Indicates the classic Codename One command behavior where the commands are
placed in a list within a dialog. This is the most customizable approach for none touch
devices.
See Also:
Constant Field Values
COMMAND_BEHAVIOR_TOUCH_MENU
public static final int COMMAND_BEHAVIOR_TOUCH_MENU

Indicates the touch menu dialog rendered by Codename One where commands are
placed into a scrollable dialog
See Also:
Constant Field Values
COMMAND_BEHAVIOR_BUTTON_BAR
public static final int COMMAND_BEHAVIOR_BUTTON_BAR

Indicates that commands should be added to an always visible bar at the bottom of
the form.
See Also:
Constant Field Values
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK

Identical to the bar behavior, places the back command within the title bar of the
form/dialg
See Also:
Constant Field Values
COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT
public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT

Places all commands on the right side of the title bar with a uniform size grid layout
See Also:
Constant Field Values
COMMAND_BEHAVIOR_ICS
public static final int COMMAND_BEHAVIOR_ICS

Commands are placed in the same was as they are in the ice cream sandwich
Android OS update where the back button has a theme icon the application icon
appears next to the
See Also:
Constant Field Values
COMMAND_BEHAVIOR_SIDE_NAVIGATION
public static final int COMMAND_BEHAVIOR_SIDE_NAVIGATION

Commands are placed in a side menu similar to Facebook/Google+ apps


See Also:
Constant Field Values
COMMAND_BEHAVIOR_NATIVE
public static final int COMMAND_BEHAVIOR_NATIVE

Indicates that commands should try to add themselves to the native menus
See Also:
Constant Field Values

Field Detail

1836

Overview (Codename One API)

Method Detail
init
public static void init(Object m)

Deprecated. this method is invoked internally do not invoke it!


This is the INTERNAL Display initialization method, it will be removed in future
versions of the API. This method must be called before any Form is shown
Parameters:
m - platform specific object used by the implementation
deinitialize
public static void deinitialize()

Closes down the EDT and Codename One, under normal conditions this method is
completely unnecessary since exiting the application will shut down Codename One.
However, if the application is minimized and the user wishes to free all resources
without exiting the application then this method can be used. Once this method is
used Codename One will no longer work and Display.init(Object) should be invoked
again for any further Codename One call! Notice that minimize (being a Codename
One method) MUST be invoked before invoking this method!
isInitialized
public static boolean isInitialized()

This method returns true if the Display is initialized.


Returns:
true if the EDT is running
getInstance
public static Display getInstance()

Return the Display instance


Returns:
the Display instance
getDragStartPercentage
public 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 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
setFramerate
public void setFramerate(int rate)

Indicates the maximum frames the API will try to draw every second by default this is
set to 10. The advantage of limiting framerate is to allow the CPU to perform other
tasks besides drawing. Notice that when no change is occurring on the screen no
frame is drawn and so a high/low FPS will have no effect then. 10FPS would be very
reasonable for a business application.
Parameters:
rate - the frame rate

Method Detail

1837

Overview (Codename One API)


vibrate
public void vibrate(int duration)

Vibrates the device for the given length of time


Parameters:
duration - length of time to vibrate
flashBacklight
public void flashBacklight(int duration)

Flash the backlight of the device for the given length of time
Parameters:
duration - length of time to flash the backlight
setShowDuringEditBehavior
public void setShowDuringEditBehavior(int showDuringEdit)

Invoking the show() method of a form/dialog while the user is editing text in the native
text box can have several behaviors: SHOW_DURING_EDIT_IGNORE,
SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD,
SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT
Parameters:
showDuringEdit - one of the following: SHOW_DURING_EDIT_IGNORE,
SHOW_DURING_EDIT_EXCEPTION,
SHOW_DURING_EDIT_ALLOW_DISCARD,
SHOW_DURING_EDIT_ALLOW_SAVE,
SHOW_DURING_EDIT_SET_AS_NEXT
getShowDuringEditBehavior
public int getShowDuringEditBehavior()

Returns the status of the show during edit flag


Returns:
one of the following: SHOW_DURING_EDIT_IGNORE,
SHOW_DURING_EDIT_EXCEPTION,
SHOW_DURING_EDIT_ALLOW_DISCARD,
SHOW_DURING_EDIT_ALLOW_SAVE,
SHOW_DURING_EDIT_SET_AS_NEXT
getFrameRate
public int getFrameRate()

Indicates the maximum frames the API will try to draw every second
Returns:
the frame rate
isEdt
public 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:
true if we are currently in the event dispatch thread; otherwise false
callSerially
public void callSerially(Runnable r)

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 - runnable (NOT A THREAD!) that will be invoked on the EDT serial to the
paint and key handling events

Method Detail

1838

Overview (Codename One API)


scheduleBackgroundTask
public void scheduleBackgroundTask(Runnable r)

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
public void callSeriallyAndWait(Runnable r)

Identical to callSerially with the added benefit of waiting for the Runnable method to
complete.
Parameters:
r - runnable (NOT A THREAD!) that will be invoked on the EDT serial to the
paint and key handling events
Throws:
IllegalStateException - if this method is invoked on the event dispatch
thread (e.g. during paint or event handling).
callSeriallyAndWait
public void callSeriallyAndWait(Runnable r,
int timeout)

Identical to callSerially with the added benefit of waiting for the Runnable method to
complete.
Parameters:
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 - if this method is invoked on the event dispatch
thread (e.g. during paint or event handling).
onEditingComplete
public void onEditingComplete(Component c,
String text)

Called by the underlying implementation to indicate that editing in the native system
has completed and changes should propagate into Codename One
Parameters:
c - edited component
text - new text for the component
invokeAndBlock
public void invokeAndBlock(Runnable r,
boolean dropEvents)

Invokes runnable and blocks the current thread, if the current thread is the edt it will
still be blocked however a separate thread would be launched to perform the duties
of the EDT while it is blocked. Once blocking is finished the EDT would be restored to
its original position. This is very similar to the "foxtrot" Swing toolkit and allows coding
"simpler" logic that requires blocking code in the middle of event sensitive areas.
Parameters:
r - runnable (NOT A THREAD!) that will be invoked synchroniously by this
method
dropEvents - indicates if the display should drop all events while this runnable
is running
invokeAndBlock
public void invokeAndBlock(Runnable r)

Invokes runnable and blocks the current thread, if the current thread is the edt it will
still be blocked however a separate thread would be launched to perform the duties
of the EDT while it is blocked. Once blocking is finished the EDT would be restored to
its original position. This is very similar to the "foxtrot" Swing toolkit and allows coding

Method Detail

1839

Overview (Codename One API)


"simpler" logic that requires blocking code in the middle of event sensitive areas.
Parameters:
r - runnable (NOT A THREAD!) that will be invoked synchroniously by this
method
isTouchScreenDevice
public boolean isTouchScreenDevice()

Indicates if this is a touch screen device that will return pen events, defaults to true if
the device has pen events but can be overriden by the developer.
Returns:
true if this device supports touch events
setTouchScreenDevice
public void setTouchScreenDevice(boolean touchScreen)

Indicates if this is a touch screen device that will return pen events, defaults to true if
the device has pen events but can be overriden by the developer.
Parameters:
touchScreen - false if this is not a touch screen device
setNoSleep
public void setNoSleep(boolean noSleep)

Calling this method with noSleep=true will cause the edt to run without sleeping.
Parameters:
noSleep - causes the edt to stop the sleeping periods between 2 cycles
setTransitionYield
public void setTransitionYield(int transitionD)

Indicates whether a delay should exist between calls to flush graphics during
transition. In some devices flushGraphics is asynchronious causing it to be very slow
with our background thread. The solution is to add a short wait allowing the
implementation time to paint the screen. This value is set automatically by default but
can be overriden for some devices.
Parameters:
transitionD - -1 for no delay otherwise delay in milliseconds
editString
public void editString(Component cmp,
int maxSize,
int constraint,
String text)

Encapsulates the editing code which is specific to the platform, some platforms would
allow "in place editing" MIDP does not.
Parameters:
cmp - the TextArea component
maxSize - the maximum size from the text area
constraint - the constraints of the text area
text - the string to edit
editString
public void editString(Component cmp,
int maxSize,
int constraint,
String text,
int initiatingKeycode)

Encapsulates the editing code which is specific to the platform, some platforms would
allow "in place editing" MIDP does not.
Parameters:
cmp - the TextArea component
maxSize - the maximum size from the text area
constraint - the constraints of the text area
text - the string to edit
initiatingKeycode - the keycode used to initiate the edit.

Method Detail

1840

Overview (Codename One API)


stopEditing
public void stopEditing(Component cmp)

Allows us to stop editString on the given text component


Parameters:
cmp - the text field/text area component
minimizeApplication
public 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 boolean isMinimized()

Indicates whether an application is minimized


Returns:
true if the application is minimized
restoreMinimizedApplication
public void restoreMinimizedApplication()

Restore the minimized application if minimization is supported by the platform


keyPressed
public void keyPressed(int keyCode)

Pushes a key press event with the given keycode into Codename One
Parameters:
keyCode - keycode of the key event
keyReleased
public void keyReleased(int keyCode)

Pushes a key release event with the given keycode into Codename One
Parameters:
keyCode - keycode of the key event
pointerDragged
public void pointerDragged(int[] x,
int[] y)

Pushes a pointer drag event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer
pointerHover
public void pointerHover(int[] x,
int[] y)

Pushes a pointer hover event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer
pointerHoverPressed
public void pointerHoverPressed(int[] x,
int[] y)

Pushes a pointer hover release event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer

Method Detail

1841

Overview (Codename One API)


pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Pushes a pointer hover release event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer
pointerPressed
public void pointerPressed(int[] x,
int[] y)

Pushes a pointer press event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer
pointerReleased
public void pointerReleased(int[] x,
int[] y)

Pushes a pointer release event with the given coordinates into Codename One
Parameters:
x - the x position of the pointer
y - the y position of the pointer
sizeChanged
public void sizeChanged(int w,
int h)

Notifies Codename One of display size changes, this method is invoked by the
implementation class and is for internal use
Parameters:
w - the width of the drawing surface
h - the height of the drawing surface
hideNotify
public void hideNotify()

Broadcasts hide notify into Codename One, this method is invoked by the Codename
One implementation to notify Codename One of hideNotify events
showNotify
public void showNotify()

Broadcasts show notify into Codename One, this method is invoked by the
Codename One implementation to notify Codename One of showNotify events
hasDragOccured
public boolean hasDragOccured()

This method should be invoked by components that broadcast events on the


pointerReleased callback. This method will indicate if a drag occured since the
pointer press event, notice that this method will not behave as expected for
multi-touch events.
Returns:
true if a drag has occured since the last pointer pressed
getCurrent
public Form getCurrent()

Return the form currently displayed on the screen or null if no form is currently
displayed.
Returns:
the form currently displayed on the screen or null if no form is currently
displayed

Method Detail

1842

Overview (Codename One API)


numAlphaLevels
public int numAlphaLevels()

Deprecated. this method isn't implemented in most modern devices


Return the number of alpha levels supported by the implementation.
Returns:
the number of alpha levels supported by the implementation
numColors
public int numColors()

Deprecated. this method isn't implemented in most modern devices


Returns the number of colors applicable on the device, note that the API does not
support gray scale devices.
Returns:
the number of colors applicable on the device
getDisplayWidth
public int getDisplayWidth()

Return the width of the display


Returns:
the width of the display
getDisplayHeight
public int getDisplayHeight()

Return the height of the display


Returns:
the height of the display
convertToPixels
public 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
getGameAction
public int getGameAction(int keyCode)

Returns the game action code matching the given key combination
Parameters:
keyCode - key code received from the event
Returns:
game action matching this keycode
getKeyCode
public int getKeyCode(int gameAction)

Deprecated. this method doesn't work properly across device and is mocked up here
mostly for the case of unit testing. Do not use it for anything other than that! Do not
rely on getKeyCode(GAME_*) == keyCodeFromKeyEvent, this will never actually
happen!
Returns the keycode matching the given game action constant (the opposite of
getGameAction). On some devices getKeyCode returns numeric keypad values for
game actions, this breaks the code since we filter these values (to prevent navigation
on '2'). We pick unused negative values for game keys and assign them to game
keys for getKeyCode so they will work with getGameAction.
Parameters:
gameAction - game action constant from this class

Method Detail

1843

Overview (Codename One API)


Returns:
keycode matching this constant
isThirdSoftButton
public boolean isThirdSoftButton()

Indicates whether the 3rd softbutton should be supported on this device


Returns:
true if a third softbutton should be used
setThirdSoftButton
public void setThirdSoftButton(boolean thirdSoftButton)

Indicates whether the 3rd softbutton should be supported on this device


Parameters:
thirdSoftButton - true if a third softbutton should be used
setShowVirtualKeyboard
public void setShowVirtualKeyboard(boolean show)

Displays the virtual keyboard on devices that support manually poping up the vitual
keyboard
Parameters:
show - toggles the virtual keyboards visibility
isVirtualKeyboardShowing
public boolean isVirtualKeyboardShowing()

Indicates if the virtual keyboard is currently showing or not


Returns:
true if the virtual keyboard is showing
getSupportedVirtualKeyboard
public String[] getSupportedVirtualKeyboard()

Returns all platform supported virtual keyboards names


Returns:
all platform supported virtual keyboards names
registerVirtualKeyboard

public void registerVirtualKeyboard(com.codename1.impl.VirtualKeyboardInterface vkb)

Register a virtual keyboard


Parameters:
vkb setDefaultVirtualKeyboard

public void setDefaultVirtualKeyboard(com.codename1.impl.VirtualKeyboardInterface vk

Sets the default virtual keyboard to be used by the platform


Parameters:
vkb - a VirtualKeyboard to be used or null to disable the VirtualKeyboard
getDefaultVirtualKeyboard
public com.codename1.impl.VirtualKeyboardInterface getDefaultVirtualKeyboard()

Get the default virtual keyboard or null if the VirtualKeyboard is disabled


Returns:
the default vkb
getKeyboardType
public int getKeyboardType()

Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN,


KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY,
KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY
Returns:

Method Detail

1844

Overview (Codename One API)


KEYBOARD_TYPE_UNKNOWN
isNativeInputSupported
public boolean isNativeInputSupported()

Indicates whether the device supports native in place editing in which case
lightweight input logic shouldn't be used for input.
Returns:
false by default
isMultiTouch
public boolean isMultiTouch()

Indicates whether the device supports multi-touch events, this is only relevant when
touch events are supported
Returns:
false by default
isClickTouchScreen
public boolean isClickTouchScreen()

Indicates whether the device has a double layer screen thus allowing two stages to
touch events: click and hover. This is true for devices such as the storm but can also
be true for a PC with a mouse pointer floating on top.
A click touch screen will also send pointer hover events to the underlying software
and will only send the standard pointer events on click.
Returns:
false by default
getDragSpeed
public float getDragSpeed(boolean yAxis)

This method returns the dragging speed based on the latest dragged events
Parameters:
yAxis - indicates what axis speed is required
Returns:
the dragging speed
isBidiAlgorithm
public boolean isBidiAlgorithm()

Indicates whether Codename One should consider the bidi RTL algorithm when
drawing text or navigating with the text field cursor.
Returns:
true if the bidi algorithm should be considered
setBidiAlgorithm
public void setBidiAlgorithm(boolean activate)

Indicates whether Codename One should consider the bidi RTL algorithm when
drawing text or navigating with the text field cursor.
Parameters:
activate - set to true to activate the bidi algorithm, false to disable it
convertBidiLogicalToVisual
public String convertBidiLogicalToVisual(String s)

Converts the given string from logical bidi layout to visual bidi layout so it can be
rendered properly on the screen. This method is only necessary for devices/platforms
that don't have "built in" bidi support such as Sony Ericsson devices. See this for
more on visual vs. logical ordering.
Parameters:
s - a "logical" string with RTL characters
Returns:
a "visual" renderable string

Method Detail

1845

Overview (Codename One API)


getCharLocation
public int getCharLocation(String source,
int index)

Returns the index of the given char within the source string, the actual index isn't
necessarily the same when bidi is involved See this for more on visual vs. logical
ordering.
Parameters:
source - the string in which we are looking for the position
index - the "logical" location of the cursor
Returns:
the "visual" location of the cursor
isRTL
public boolean isRTL(char c)

Returns true if the given character is an RTL character


Parameters:
c - character to test
Returns:
true if the charcter is an RTL character
getResourceAsStream
public InputStream getResourceAsStream(Class cls,
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.
Parameters:
cls - class to load the resource from
resource - relative/absolute URL based on the Java convention
Returns:
input stream for the resource or null if not found
addEdtErrorHandler
public void addEdtErrorHandler(ActionListener e)

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
public void removeEdtErrorHandler(ActionListener e)

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
setAllowMinimizing
public void setAllowMinimizing(boolean allowMinimizing)

Allows a Codename One application to minimize without forcing it to the front


whenever a new dialog is poped up
Parameters:
allowMinimizing - value
isAllowMinimizing
public boolean isAllowMinimizing()

Allows a Codename One application to minimize without forcing it to the front


whenever a new dialog is poped up

Method Detail

1846

Overview (Codename One API)


Returns:
allowMinimizing value
shouldRenderSelection
public boolean shouldRenderSelection()

This is an internal state flag relevant only for pureTouch mode (otherwise it will
always be true). A pureTouch mode is stopped if a user switches to using the
trackball/navigation pad and this flag essentially toggles between those two modes.
Returns:
the shouldRenderSelection
shouldRenderSelection
public boolean shouldRenderSelection(Component c)

This is an internal state flag relevant only for pureTouch mode (otherwise it will
always be true). A pureTouch mode is stopped if a user switches to using the
trackball/navigation pad and this flag essentially toggles between those two modes.
Parameters:
c - the component to test against, this prevents a touch outside of the
component that triggers a repaint from painting the component selection
Returns:
the shouldRenderSelection
isPureTouch
public boolean isPureTouch()

A pure touch device has no focus showing when the user is using the touch interface.
Selection only shows when the user actually touches the screen or suddenly switches
to using a keypad/trackball. This sort of interface is common in Android devices
Returns:
the pureTouch flag
setPureTouch
public void setPureTouch(boolean pureTouch)

A pure touch device has no focus showing when the user is using the touch interface.
Selection only shows when the user actually touches the screen or suddenly switches
to using a keypad/trackball. This sort of interface is common in Android devices
Parameters:
pureTouch - the value for pureTouch
isNativeCommands
public boolean isNativeCommands()

Deprecated. use getCommandBehavior() ==


Display.COMMAND_BEHAVIOR_NATIVE
Indicates whether Codename One commands should be mapped to the native menus
Returns:
the nativeCommands status
setNativeCommands
public void setNativeCommands(boolean nativeCommands)

Deprecated. use setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE)


Indicates whether Codename One commands should be mapped to the native menus
Parameters:
nativeCommands - the flag to set
exitApplication
public void exitApplication()

Exits the application...

Method Detail

1847

Overview (Codename One API)


showNativeScreen
public void showNativeScreen(Object nativeFullScreenPeer)

Shows a native Form/Canvas or some other heavyweight native screen


Parameters:
nativeFullScreenPeer - the native screen peer
isAutoFoldVKBOnFormSwitch
public boolean isAutoFoldVKBOnFormSwitch()

Normally Codename One folds the VKB when switching forms this field allows us to
block that behavior.
Returns:
the autoFoldVKBOnFormSwitch
setAutoFoldVKBOnFormSwitch
public void setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)

Normally Codename One folds the VKB when switching forms this field allows us to
block that behavior.
Parameters:
autoFoldVKBOnFormSwitch - the autoFoldVKBOnFormSwitch to set
getCommandBehavior
public int getCommandBehavior()

Indicates the way commands should be added to a form as one of the ocmmand
constants defined in this class
Returns:
the commandBehavior
setCommandBehavior
public void setCommandBehavior(int commandBehavior)

Indicates the way commands should be added to a form as one of the ocmmand
constants defined in this class
Parameters:
commandBehavior - the commandBehavior to set
getProperty
public String getProperty(String key,
String defaultValue)

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:
1. AppName
2. User-Agent
3. AppVersion
4. Platform - Similar to microedition.platform
5. OS - returns what is the underlying platform e.g. - J2ME, RIM, SE...
6. 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

Method Detail

1848

Overview (Codename One API)


setProperty
public void setProperty(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.
Parameters:
key - key the key of the property
value - the value of the property
canExecute
public Boolean canExecute(String url)

Returns true if executing this URL should work, returns false if it will not and null if
this is unknown.
Parameters:
url - the url that would be executed
Returns:
true if executing this URL should work, returns false if it will not and null if this
is unknown
execute
public void execute(String url)

Executes the given URL on the native platform


Parameters:
url - the url to execute
execute
public void execute(String url,
ActionListener response)

Executes the given URL on the native platform, this method is useful if the platform
has the ability to send an event to the app when the execution has ended, currently
this works only for Android platform to invoke other intents.
Parameters:
url - the url to execute
response - a callback from the platform when this execution returned to the
application
getDeviceDensity
public 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
playBuiltinSound
public void playBuiltinSound(String soundIdentifier)

Plays a builtin device sound matching the given identifier, implementations and
themes can offer additional identifiers to the ones that are already built in.
Parameters:
soundIdentifier - the sound identifier which can match one of the common
constants in this class or be a user/implementation defined sound
installBuiltinSound
public void installBuiltinSound(String soundIdentifier,
InputStream data)
throws IOException

Installs a replacement sound as the builtin sound responsible for the given sound
identifier (this will override the system sound if such a sound exists).

Method Detail

1849

Overview (Codename One API)


Parameters:
soundIdentifier - the
data - an input stream

sound string passed to playBuiltinSound


containing platform specific audio file, its usually safe
to assume that wav/mp3 would be supported.
Throws:
IOException - if the stream throws an exception
isBuiltinSoundAvailable
public boolean isBuiltinSoundAvailable(String soundIdentifier)

Indicates whether a user installed or system sound is available


Parameters:
soundIdentifier - the sound string passed to playBuiltinSound
Returns:
true if a sound of this given type is avilable
setBuiltinSoundsEnabled
public void setBuiltinSoundsEnabled(boolean enabled)

Allows muting/unmuting the builtin sounds easily


Parameters:
enabled - indicates whether the sound is muted
isBuiltinSoundsEnabled
public boolean isBuiltinSoundsEnabled()

Allows muting/unmuting the builtin sounds easily


Returns:
true if the sound is *not* muted
createMedia
public Media createMedia(String uri,
boolean isVideo,
Runnable onCompletion)
throws IOException

Creates a sound in the given URI which is partially platform specific. Notice that an
audio is "auto destroyed" on completion and cannot be played twice!
Parameters:
uri - the platform specific location for the sound
onCompletion - invoked when the audio file finishes playing, may be null
Returns:
a handle that can be used to control the playback of the audio
Throws:
IOException - if the URI access fails
createMedia
public Media createMedia(InputStream stream,
String mimeType,
Runnable onCompletion)
throws IOException

Create the sound in the given stream Notice that an audio is "auto destroyed" on
completion and cannot be played twice!
Parameters:
stream - the stream containing the media data
mimeType - the type of the data in the stream
onCompletion - invoked when the audio file finishes playing, may be null
Returns:
a handle that can be used to control the playback of the audio
Throws:
IOException - if the URI access fails
createSoftWeakRef
public Object createSoftWeakRef(Object o)

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

Method Detail

1850

Overview (Codename One API)


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
public Object extractHardRef(Object o)

Extracts the hard reference from the soft/weak reference given


Parameters:
o - the reference returned by createSoftWeakRef
Returns:
the original object submitted or null
hasNativeTheme
public boolean hasNativeTheme()

Indicates if the implemenetation has a native underlying theme


Returns:
true if the implementation has a native theme available
installNativeTheme
public void installNativeTheme()

Installs the native theme, this is only applicable if hasNativeTheme() returned true.
Notice that this method might replace the DefaultLookAndFeel instance and the
default transitions.
copyToClipboard
public void copyToClipboard(Object obj)

Performs a clipboard copy operation, if the native clipboard is supported by the


implementation it would be used
Parameters:
obj - object to copy, while this can be any arbitrary object it is recommended
that only Strings or Codename One image objects be used to copy
getPasteDataFromClipboard
public Object getPasteDataFromClipboard()

Returns the current content of the clipboard


Returns:
can be any object or null see copyToClipboard
isPortrait
public boolean isPortrait()

Returns true if the device is currently in portrait mode


Returns:
true if the device is in portrait mode
canForceOrientation
public 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 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

Method Detail

1851

Overview (Codename One API)


unlockOrientation
public void unlockOrientation()

This is the reverse method for lock orientation allowing orientation lock to be disabled
isTablet
public 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 boolean isDesktop()

Returns true if this is a desktop application


Returns:
true if this is a desktop application
canDial
public boolean canDial()

Returns true if the device has dialing capabilities


Returns:
false if it cannot dial
areMutableImagesFast
public boolean areMutableImagesFast()

On most platforms it is quite fast to draw on a mutable image and then render that
image, however some platforms have much slower mutable images in comparison to
just drawing on the screen. These platforms should return false here and Codename
One will try to use less mutable image related optimizations in transitions and other
operations.
Returns:
true if mutable images are fast on this platform
getLocationManager
public LocationManager getLocationManager()

This method returns the platform Location Manager used for geofencing. This allows
tracking the user location in the background. Usage:
public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();
public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Form hi = new Form("Hi World");

Method Detail

1852

Overview (Codename One API)


hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();

Returns:
LocationManager Object
capturePhoto
public void capturePhoto(ActionListener response)

This method tries to invoke the device native camera to capture images. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The image is saved as a jpeg to a file on the device. use this in
the actionPerformed to retrieve the file path String path = (String) evt.getSource(); if
evt returns null the image capture was cancelled by the user.
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform
captureAudio
public void captureAudio(ActionListener response)

This method tries to invoke the device native hardware to capture audio. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The audio is saved to a file on the device. use this in the
actionPerformed to retrieve the file path String path = (String) evt.getSource();
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform
captureVideo
public void captureVideo(ActionListener response)

This method tries to invoke the device native camera to capture video. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The video is saved to a file on the device. use this in the
actionPerformed to retrieve the file path String path = (String) evt.getSource();
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform
openImageGallery
public void openImageGallery(ActionListener response)

Deprecated. see openGallery instead


Opens the device image gallery The method returns immediately and the response
will be sent asynchronously to the given ActionListener Object use this in the
actionPerformed to retrieve the file path String path = (String) evt.getSource();
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform
openGallery
public void openGallery(ActionListener response,
int type)

Opens the device gallery to pick an image or a video.


The method returns immediately and the response is sent asynchronously to the

Method Detail

1853

Overview (Codename One API)


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) {
{@literal @}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
public String 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

Method Detail

1854

Overview (Codename One API)


getPlatformOverrides
public String[] getPlatformOverrides()

Returns the suffixes for ovr files that should be used when loading a layered resource
file on this platform
Returns:
a string array with the proper order of resource override layers
sendMessage
public void sendMessage(String[] recipients,
String subject,
Message msg)

Send an email using the platform mail client


Parameters:
recipients - array of e-mail addresses
subject - e-mail subject
msg - the Message to send
dial
public void dial(String phoneNumber)

Opens the device Dialer application with the given phone number
Parameters:
phoneNumber getSMSSupport
public 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.
Returns:
one of the SMS_* values
sendSMS
public void sendSMS(String phoneNumber,
String message)
throws IOException

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 void sendSMS(String phoneNumber,
String message,
boolean interactive)
throws IOException

Sends a SMS message to the given phone number


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
Throws:
IOException

notifyStatusBar
public void notifyStatusBar(String tickerText,
String contentTitle,
String contentBody,
boolean vibrate,
boolean flashLights)

Method Detail

1855

Overview (Codename One API)


Deprecated. there is a new version of this method with a slightly improved signature
Place a notification on the device status bar (if device has this functionality). Clicking
the notification might re-start the Application.
Parameters:
tickerText - the ticker text of the Notification
contentTitle - the title of the Notification
contentBody - the content of the Notification
vibrate - enable/disable notification alert
flashLights - enable/disable notification flashing
isNotificationSupported
public boolean isNotificationSupported()

Indicates whether the notify status bar method will present a notification to the user
Returns:
true if the notify status bar method will present a notification to the user
notifyStatusBar
public Object notifyStatusBar(String tickerText,
String contentTitle,
String contentBody,
boolean vibrate,
boolean flashLights,
Hashtable args)

Deprecated. use scheduleLocalNotification instead


Place a notification on the device status bar (if device has this functionality). Clicking
the notification might re-start the Application.
Parameters:
tickerText - the ticker text of the Notification
contentTitle - the title of the Notification
contentBody - the content of the Notification
vibrate - enable/disable notification alert
flashLights - enable/disable notification flashing
args - additional arguments to the notification
Returns:
a platform native object that allows modifying notification state
dismissNotification
public void dismissNotification(Object o)

Removes the notification previously posted with the notify status bar method
Parameters:
o - the object returned from the notifyStatusBar method
isBadgingSupported
public boolean isBadgingSupported()

Returns true if the underlying OS supports numeric badges on icons. Notice this is
only available on iOS and only when push notification is enabled
Returns:
true if the underlying OS supports numeric badges
setBadgeNumber
public void setBadgeNumber(int number)

Sets the number that appears on the application icon in iOS


Parameters:
number - number to show on the icon
isOpenNativeNavigationAppSupported
public boolean isOpenNativeNavigationAppSupported()

Returns true if the underlying OS supports opening the native navigation application
Returns:
true if the underlying OS supports launch of native navigation app

Method Detail

1856

Overview (Codename One API)


openNativeNavigationApp
public void openNativeNavigationApp(double latitude,
double longitude)

Opens the native navigation app in the given coordinate.


Parameters:
latitude longitude getAllContacts
public String[] getAllContacts(boolean withNumbers)

Gets all contacts from the address book of the device


Parameters:
withNumbers - if true returns only contacts that has a number
Returns:
array of contacts unique ids
getAllContacts
public Contact[] getAllContacts(boolean
boolean
boolean
boolean
boolean
boolean

withNumbers,
includesFullName,
includesPicture,
includesNumbers,
includesEmail,
includeAddress)

Notice: this method might be very slow and should be invoked on a separate thread!
It might have platform specific optimizations over getAllContacts followed by looping
over individual contacts but that isn't guaranteed. See isGetAllContactsFast for
information.
Parameters:
withNumbers - if true returns only contacts that has a number
includesFullName - if true try to fetch the full name of the Contact(not just
display name)
includesPicture - if true try to fetch the Contact Picture if exists
includesNumbers - if true try to fetch all Contact numbers
includesEmail - if true try to fetch all Contact Emails
includeAddress - if true try to fetch all Contact Addresses
Returns:
array of the contacts
isGetAllContactsFast
public boolean isGetAllContactsFast()

Indicates if the getAllContacts is platform optimized, notice that the method might still
take seconds or more to run so you should still use a separate thread!
Returns:
true if getAllContacts will perform faster that just getting each contact
getContactById
public Contact getContactById(String id)

Get a Contact according to it's contact id.


Parameters:
id - unique id of the Contact
Returns:
a Contact Object
getContactById
public Contact getContactById(String id,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)

Method Detail

1857

Overview (Codename One API)


This method returns a Contact by the contact id and fills it's data according to the
given flags
Parameters:
id - of the Contact
includesFullName - if true try to fetch the full name of the Contact(not just
display name)
includesPicture - if true try to fetch the Contact Picture if exists
includesNumbers - if true try to fetch all Contact numbers
includesEmail - if true try to fetch all Contact Emails
includeAddress - if true try to fetch all Contact Addresses
Returns:
a Contact Object
isContactsPermissionGranted
public boolean isContactsPermissionGranted()

Some platforms allow the user to block contacts access on a per application basis
(specifically iOS).
Returns:
true if contacts access is allowed or globally available, false otherwise
createContact
public String createContact(String
String
String
String
String
String

firstName,
familyName,
officePhone,
homePhone,
cellPhone,
email)

Create a contact to the device contacts book


Parameters:
firstName - the Contact firstName
familyName - the Contact familyName
officePhone - the Contact work phone or null
homePhone - the Contact home phone or null
cellPhone - the Contact mobile phone or null
email - the Contact email or null
Returns:
the contact id if creation succeeded or null if failed
deleteContact
public boolean deleteContact(String id)

removed a contact from the device contacts book


Parameters:
id - the contact id to remove
Returns:
true if deletion succeeded false otherwise
isNativeVideoPlayerControlsIncluded
public boolean isNativeVideoPlayerControlsIncluded()

Indicates if the native video player includes its own play/pause etc. controls so the
movie player component doesn't need to include them
Returns:
true if the movie player component doesn't need to include such controls
isNativeShareSupported
public boolean isNativeShareSupported()

Indicates if the underlying platform supports sharing capabilities


Returns:
true if the underlying platform handles share.

Method Detail

1858

Overview (Codename One API)


share
public void share(String toShare)

Deprecated. use the method share that accepts an image and mime type
Share the required information using the platform sharing services. a Sharing service
can be: mail, sms, facebook, twitter,... This method is implemented if
isNativeShareSupported() returned true for a specific platform.
Parameters:
toShare - String to share.
share
public void share(String text,
String image,
String mimeType)

Share the required information using the platform sharing services. a Sharing service
can be: mail, sms, facebook, twitter,... This method is implemented if
isNativeShareSupported() returned true for a specific platform.
Parameters:
text - String to share.
image - file path to the image or null
mime - type of the image or null if no image to share
share
public void share(String text,
String image,
String mimeType,
Rectangle sourceRect)

Share the required information using the platform sharing services. a Sharing service
can be: mail, sms, facebook, twitter,... This method is implemented if
isNativeShareSupported() returned true for a specific platform.
Parameters:
text - String to share.
image - file path to the image or null
mimeType - type of the image or null if no image to share
sourceRect - The source rectangle of the button that originated the share
request. This is used on some platforms to provide a hint as to where the
share dialog overlay should pop up. Particularly, on the iPad with iOS 8 and
higher.
getLocalizationManager
public L10NManager getLocalizationManager()

Returns the localization manager instance for this platform


Returns:
an instance of the localization manager
registerPush
public void registerPush(String id,
boolean noFallback)

Deprecated. use the version that doesn't take an id argument this argument is
effectively ignored!
User register to receive push notification
Parameters:
id - the id for the user
noFallback - some devices don't support an efficient push API and will resort
to polling to provide push like functionality. If this flag is set to true no polling
will occur and the error
PushCallback.REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE will
be sent to the push interface.

Method Detail

1859

Overview (Codename One API)


registerPush
public void registerPush(Hashtable metaData,
boolean noFallback)

Register to receive push notification, invoke this method once (ever) to receive push
notifications.
Parameters:
metaData - meta data for push, this is relevant on some platforms such as
google where a push id is necessary,
noFallback - some devices don't support an efficient push API and will resort
to polling to provide push like functionality. If this flag is set to true no polling
will occur and the error
PushCallback.REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE will
be sent to the push interface.
deregisterPush
public void deregisterPush()

Stop receiving push notifications to this client application


createMediaRecorder
public Media createMediaRecorder(String path)
throws IOException

Deprecated.
Creates a Media recorder Object which will record from the device mic to a file in the
given path. The output format will be amr-nb if supported by the platform.
Parameters:
path - a file path to where to store the recording, if the file does not exists it
will be created.
Throws:
IOException

createMediaRecorder
public Media createMediaRecorder(String path,
String mimeType)
throws IOException

Creates a Media recorder Object which will record from the device mic to a file in the
given path.
Parameters:
path - a file path to where to store the recording, if the file does not exists it
will be created.
mimeType - the output mime type that is supported see
getAvailableRecordingMimeTypes()
Throws:
IOException

getImageIO
public ImageIO getImageIO()

Returns the image IO instance that allows scaling image files.


Returns:
the image IO instance or null if image IO isn't supported for the given platform
getMediaRecorderingMimeType
public String getMediaRecorderingMimeType()

Deprecated. see getAvailableRecordingMimeTypes() instead


Gets the recording mime type for the returned Media from the createMediaRecorder
method
Returns:
the recording mime type

Method Detail

1860

Overview (Codename One API)


openOrCreate
public Database openOrCreate(String databaseName)
throws IOException

Opens a database or create one if not exists


Parameters:
databaseName - the name of the database
Returns:
Database Object or null if not supported on the platform
Throws:
IOException - if database cannot be created
delete
public void delete(String databaseName)
throws IOException

Deletes database
Parameters:
databaseName

- the name of the database

Throws:
IOException

- if database cannot be deleted

exists
public boolean exists(String databaseName)

Indicates weather a database exists


Parameters:
databaseName - the name of the database
Returns:
true if database exists
getDatabasePath
public String getDatabasePath(String databaseName)

Returns the file path of the Database if exists and if supported on the platform.
Returns:
the file path of the database or null if not exists
setPollingFrequency
public void setPollingFrequency(int freq)

Sets the frequency for polling the server in case of polling based push notification
Parameters:
freq - the frequency in milliseconds
startThread
public Thread startThread(Runnable r,
String name)

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!
isNativeTitle
public boolean isNativeTitle()

Indicates if the title of the Form is native title(in android ICS devices if the command
behavior is native the ActionBar is used to display the title and the menu)
Returns:
true if platform would like to show the Form title

Method Detail

1861

Overview (Codename One API)


refreshNativeTitle
public void refreshNativeTitle()

if the title is native(e.g the android action bar), notify the native title that is needs to be
refreshed
getCrashReporter
public CrashReport getCrashReporter()

The crash reporter gets invoked when an uncaught exception is intercepted


Returns:
the crashReporter
setCrashReporter
public void setCrashReporter(CrashReport crashReporter)

The crash reporter gets invoked when an uncaught exception is intercepted


Parameters:
crashReporter - the crashReporter to set
getUdid
public String getUdid()

Returns the UDID for devices that support it


Returns:
the UDID or null
getMsisdn
public String getMsisdn()

Returns the MSISDN for devices that expose it


Returns:
the msisdn or null
getInAppPurchase
public Purchase getInAppPurchase()

Returns the native OS purchase implementation if applicable, if unavailable this


method will try to fallback to a custom purchase implementation and failing that will
return null
Returns:
instance of the purchase class or null
getInAppPurchase
public Purchase getInAppPurchase(boolean d)

Deprecated. use the version that accepts no arguments, the physical goods purchase
is always manual payment if applicable
getCodeScanner
public CodeScanner getCodeScanner()

Deprecated. Use the cn1-codescanner cn1lib.


Returns the native implementation of the code scanner or null
Returns:
code scanner instance
getAvailableRecordingMimeTypes
public String[] getAvailableRecordingMimeTypes()

Gets the available recording MimeTypes


isScreenSaverDisableSupported
public boolean isScreenSaverDisableSupported()

Method Detail

1862

Overview (Codename One API)


Checks if the device supports disabling the screen display from dimming, allowing the
developer to keep the screen display on.
setScreenSaverEnabled
public void setScreenSaverEnabled(boolean e)

If isScreenSaverDisableSupported() returns true calling this method will lock the


screen display on
Parameters:
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 boolean hasCamera()

Returns true if the device has camera false otherwise.


isNativePickerTypeSupported
public 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
public Object showNativePicker(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_DATE
Parameters:
type - the picker type constant
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.
isMultiKeyMode
public boolean isMultiKeyMode()

When set to true Codename One allows multiple hardware keys to be pressed at
once, this isn't on by default since it can trigger some complexities with UI navigation
to/from native code
Returns:
the multiKeyMode
setMultiKeyMode
public void setMultiKeyMode(boolean multiKeyMode)

When set to true Codename One allows multiple hardware keys to be pressed at
once, this isn't on by default since it can trigger some complexities with UI navigation
to/from native code
Parameters:
multiKeyMode - the multiKeyMode to set

Method Detail

1863

Overview (Codename One API)


setLongPointerPressInterval
public void setLongPointerPressInterval(int v)

Long pointer press is invoked after the given interval, this allows making long press
events shorter/longer
Parameters:
v - time in milliseconds
getLongPointerPressInterval
public int getLongPointerPressInterval()

Long pointer press is invoked after the given interval, this allows making long press
events shorter/longer
Returns:
time in milliseconds
scheduleLocalNotification
public void scheduleLocalNotification(LocalNotification n,
long firstTime,
int repeat)

Schedules a local notification to occur.


Parameters:
n - The notification to schedule.
firstTime - time in milliseconds when to schedule the notification
repeat - repeat one of the following: REPEAT_NONE,
REPEAT_FIFTEEN_MINUTES, REPEAT_HALF_HOUR, REPEAT_HOUR,
REPEAT_DAY, REPEAT_WEEK
cancelLocalNotification
public void cancelLocalNotification(String notificationId)

Cancels a local notification by ID.


Parameters:
notificationId See Also:
LocalNotification

isSimulator
public 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
createBackgroundMedia
public Media createBackgroundMedia(String uri)
throws IOException

Creates an audio media that can be played in the background.


Parameters:
uri - the uri of the media can start with jar://, file://, http:// (can also use rtsp://
if supported on the platform)
Returns:
Media a Media Object that can be used to control the playback of the media
or null if background playing is not supported on the platform
Throws:
IOException - if creation of media from the given URI has failed
gaussianBlurImage
public Image gaussianBlurImage(Image image,
float radius)

Create a blur image from the given image. The algorithm is gaussian blur https://en.wikipedia.org/wiki/Gaussian_blur
Parameters:

Method Detail

1864

Overview (Codename One API)

image - the image to blur


radius - the radius to be used

in the algorithm

isGaussianBlurSupported
public boolean isGaussianBlurSupported()

Returns true if gaussian blur is supported on this platform


Returns:
true if gaussian blur is supported.

Method Detail

1865

Overview (Codename One API)


com.codename1.ui

Class Dialog
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Form

com.codename1.ui.Dialog
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
Progress, VirtualKeyboard

public class
extends Form

A dialog is a form that occupies a part of the screen and appears as a modal entity to the developer.
Dialogs allow us to prompt users for information and rely on the information being available on the
next line after the show method.
Modality indicates that a dialog will block the calling thread even if the calling thread is the EDT.
Notice that a dialog will not release the block until dispose is called even if show() from another form
is called! Events are still performed thanks to the Display.invokeAndBlock(java.lang.Runnable)
capability of the Display class.
To determine the size of the dialog use the show method that accepts 4 integer values, notice that
these values accept margin from the four sides rather than x, y, width and height values!
It's important to style a Dialog using getDialogStyle() or setDialogUIID(java.lang.String)
methods rather than styling the dialog object directly.
The Dialog class also includes support for popup dialog which is a dialog type that is positioned next
to a component or screen area and points an arrow at that location.
Typical dialog usage looks like this:
final Button show = new Button("Show Dialog");
final Button showPopup = new Button("Show Popup");
cnt.add(show).add(showPopup);
show.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Dialog.show("Dialog Title", "This is the dialog body, it can contain anything...", "OK", "Cancel");
}
});
showPopup.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Dialog d = new Dialog("Popup Title");
TextArea popupBody = new TextArea("This is the body of the popup", 3, 10);
popupBody.setUIID("PopupBody");
popupBody.setEditable(false);
d.setLayout(new BorderLayout());
d.add(BorderLayout.CENTER, popupBody);
d.showPopupDialog(showPopup);
}
});

See this sample for showing a dialog at the bottom of the screen:
Dialog dlg = new Dialog("At Bottom");
dlg.setLayout(new BorderLayout());
// span label accepts the text and the UIID for the dialog body
dlg.add(new SpanLabel("Dialog Body text", "DialogBody"));
int h = Display.getInstance().getDisplayHeight();
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.show(h /8 * 7, 0, 0, 0);

Class Dialog

1866

Overview (Codename One API)

See Also:
Display.invokeAndBlock(java.lang.Runnable)

Field Summary
Modifier and
Type

Field and Description


TYPE_ALARM

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set
TYPE_CONFIRMATION

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set
TYPE_ERROR

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set
TYPE_INFO

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set
TYPE_NONE

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set
TYPE_WARNING

static int

Constant indicating the type of alert to indicate the sound to play or icon if
none are explicitly set

Fields inherited from class com.codename1.ui.Form


focusScrolling

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,

Field Summary

1867

Overview (Codename One API)


DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Dialog()

Constructs a Dialog with a title


Dialog(String title)

Constructs a Dialog with a title

Method Summary
Modifier
and Type
protected
void
void
void
void
void
boolean

Method and Description


actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point rather
than implementing many command instances
addComponent(Component cmp)

Adds Component to the Form's Content Pane


addComponent(int index, Component cmp)

Adds Component to the Form's Content Pane


addComponent(int index, Object constraints, Component cmp)

Adds a Component to the Container


addComponent(Object constraints, Component cmp)

Adds a Component to the Container


animate()

Allows the animation to reduce "repaint" calls when it returns false.

protected autoAdjust(int w, int h)


void
Auto adjust size of the dialog.
dispose()
void

Closes the current form and returns to the previous form, releasing the EDT in
the process
getBlurBackgroundRadius()

float

Container
static
float

Dialog background can be blurred using a Gaussian blur effect, this sets the
radius of the Gaussian blur.
getContentPane()

This method returns the Content pane instance


getDefaultBlurBackgroundRadius()

Dialog background can be blurred using a Gaussian blur effect, this sets the
radius of the Gaussian blur.

static
String

getDefaultDialogPosition()

static
int

getDefaultDialogType()

Container
String

Default screen orientation position for the upcoming dialog.


The default type for dialogs
getDialogComponent()

Returns the container that actually implements the dialog positioning.


getDialogPosition()

Screen orientation position for the upcoming dialog.


getDialogPreferredSize()

Dimension

Style

Returns the preferred size of the dialog, this allows developers to position a
dialog manually in arbitrary positions.
getDialogStyle()

Simple getter to get the Dialog Style


getDialogType()

int

The type of the dialog can be one of TYPE_WARNING, TYPE_INFO,


TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM

String

getDialogUIID()

Fields inherited from class com.codename1.ui.Component

1868

Overview (Codename One API)


Returns the uiid of the dialog
Layout
Boolean
String
Label
Style
void

getLayout()

Returns the layout manager responsible for arranging this container


getPopupDirectionBiasPortrait()

Indicates if we want to enforce directional bias for the popup dialog.


getTitle()

Returns the Form title text


getTitleComponent()

Allows modifying the title attributes beyond style (e.g.


getTitleStyle()

Returns the style of the title


growOrShrink()

Allows a dialog component to grow or shrink to its new preferred size

protected initLaf(UIManager uim)


void
Initialize the default transition
static
boolean

for the dialogs overriding the forms transition

isAutoAdjustDialogSize()

Indicates whether Codename One should try to automatically adjust a showing


dialog size when a screen size change event occurs
isAutoDispose()

boolean

static
boolean

Determines whether the execution of a command on this dialog implicitly


disposes the dialog.
isCommandsAsButtons()

Places commands as buttons at the bottom of the standard static dialogs rather
than as softbuttons.
isDisableStaticDialogScrolling()

static
boolean

Allows a developer to indicate his interest that the dialog should no longer scroll
on its own but rather rely on the scrolling properties of internal scrollable
containers.
isDisposeWhenPointerOutOfBounds()

boolean

void
protected
void

This flag indicates if the dialog should be disposed if a pointer released event
occurred out of the dialog content.
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
onShow()

Allows subclasses to bind functionality that occurs when a specific form or dialog
appears on the screen
placeButtonCommands(Command[] cmds)

void

void
void
void
void
static
void

Deprecated.
this method shouldn't be invoked externally, it should have been private
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
removeAll()

Removes all Components from the Content Pane


removeComponent(Component cmp)

Removes a component from the Form's Content Pane


setAutoAdjustDialogSize(boolean a)

Indicates whether Codename One should try to automatically adjust a showing


dialog size when a screen size change event occurs
setAutoDispose(boolean autoDispose)

void

Determines whether the execution of a command on this dialog implicitly


disposes the dialog.
setBlurBackgroundRadius(float blurBackgroundRadius)

void

static
void

Method Summary

Dialog background can be blurred using a Gaussian blur effect, this sets the
radius of the Gaussian blur.
setCommandsAsButtons(boolean c)

Places commands as buttons at the bottom of the standard static dialogs rather
than as softbuttons.

1869

Overview (Codename One API)


static
void

setDefaultBlurBackgroundRadius(float aDefaultBlurBackgroundRadius)

Dialog background can be blurred using a Gaussian blur effect, this sets the
radius of the Gaussian blur.

static
void

setDefaultDialogPosition(String p)

static
void

setDefaultDialogType(int d)

void
void

Default screen orientation position for the upcoming dialog.


The default type for dialogs
setDialogPosition(String dialogPosition)

Screen orientation position for the upcoming dialog.


setDialogStyle(Style style)

Simple setter to set the Dialog Style


setDialogType(int dialogType)

void

void

The type of the dialog can be one of TYPE_WARNING, TYPE_INFO,


TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
setDialogUIID(String uiid)

Simple setter to set the Dialog uiid


setDisableStaticDialogScrolling(boolean d)

static
void

Allows a developer to indicate his interest that the dialog should no longer scroll
on its own but rather rely on the scrolling properties of internal scrollable
containers.
setDisposeWhenPointerOutOfBounds(boolean disposeWhenPointerOutOfBounds)

void

void
void
void

This flag indicates if the dialog should be disposed if a pointer released event
occurred out of the dialog content.
setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


setPopupDirectionBiasPortrait(Boolean popupDirectionBiasPortrait)

Indicates if we want to enforce directional bias for the popup dialog.


setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


setTimeout(long time)

void

void

Indicates the time (in milliseconds) afterwhich the dialog will be disposed
implicitly
setTitle(String title)

Sets the Form title to the given text


setTitleComponent(Label title)

void

Allows replacing the title with a different title component, thus allowing
developers to create more elaborate title objects.
setTitleComponent(Label title, Transition t)

void

Allows replacing the title with a different title component, thus allowing
developers to create more elaborate title objects.
show()

void

The default version of show modal shows the dialog occupying the center portion
of the screen.
show(int top, int bottom, int left, int right)

Command

This method shows the form as a modal alert allowing us to produce a behavior
of an alert/dialog box.
show(int top, int bottom, int left, int right, boolean includeTitle)

Command

Command

static
Command
static
Command

Method Summary

Deprecated.
use the version that doesn't accept the include title, the includeTitle feature is no
longer supported
show(int top, int bottom, int left, int right, boolean includeTitle,
boolean modal)

Deprecated.
use showAtPosition, the includeTitle flag is no longer supported
show(String title, Component body, Command... cmds)

Shows a modal dialog with the given component as its "body" placed in the
center.
show(String title, Component body, Command[] cmds, int type,
Image icon)

1870

Overview (Codename One API)


Shows a modal dialog with the given component as its "body" placed in the
center.
static
Command

static
Command

static
Command

static
Command
static
Command
static
Command
static
Command
static
boolean
static
boolean
static
boolean

show(String title, Component body, Command[] cmds, int type,


Image icon, long timeout)

Shows a modal dialog with the given component as its "body" placed in the
center.
show(String title, Component body, Command[] cmds, int type,
Image icon, long timeout, Transition transition)

Shows a modal dialog with the given component as its "body" placed in the
center.
show(String title, Component body, Command defaultCommand,
Command[] cmds, int type, Image icon, long timeout,
Transition transition)

Shows a modal dialog with the given component as its "body" placed in the
center.
show(String title, String text, Command[] cmds, int type, Image icon,
long timeout)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, Command[] cmds, int type, Image icon,
long timeout, Transition transition)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, Command defaultCommand, Command[] cmds,
int type, Image icon, long timeout)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, Command defaultCommand, Command[] cmds,
int type, Image icon, long timeout, Transition transition)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, int type, Image icon, String okText,
String cancelText)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, int type, Image icon, String okText,
String cancelText, long timeout)

Shows a modal prompt dialog with the given title and text.
show(String title, String text, String okText, String cancelText)

Shows a modal prompt dialog with the given title and text.
showAtPosition(int top, int bottom, int left, int right, boolean modal)

Command

This method shows the form as a modal alert allowing us to produce a behavior
of an alert/dialog box.
showBack()

void

Command

Displays the current form on the screen, this version of the method is useful for
"back" navigation since it reverses the direction of the transition.
showDialog()

Shows a modal dialog and returns the command pressed within the modal dialog
showModeless()

void

Command

Shows a modeless dialog which is useful for some simpler use cases such as
progress indication etc...
showPacked(String position, boolean modal)

Convenience method to show a dialog sized to match its content.


showPopupDialog(Component c)

Command

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside
its bounds.
showPopupDialog(Rectangle rect)

Command

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside
its bounds.
showStetched(String position, boolean modal)

Command

Command

Method Summary

Deprecated.
due to typo use showStretched instead
showStretched(String position, boolean modal)

Convenience method to show a dialog stretched to one of the sides

1871

Overview (Codename One API)


wasDisposedDueToOutOfBoundsTouch()
boolean

boolean

Returns true if a dialog that was disposed did it because of a pointer out of
bounds
wasDisposedDueToRotation()

Returns true if the dialog was disposed automatically due to device rotation

Methods inherited from class com.codename1.ui.Form


addCommand, addCommand, addCommandListener, addGameKeyListener,
addKeyListener, addOrientationListener, addShowListener,
addSizeChangedListener, deregisterAnimated, dispatchCommand,
findNextFocusHorizontal, findNextFocusVertical, getAnimationManager,
getBackCommand, getClearCommand, getCommand, getCommandCount,
getComponentForm, getComponentIndex, getDefaultCommand,
getDragRegionStatus, getEditOnShow, getFocused, getGlassPane,
getLayeredPane, getLayeredPane, getMenuBar, getMenuStyle, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getScrollAnimationSpeed, getSoftButton, getSoftButtonCount, getTintColor,
getTitleArea, getToolbar, getTransitionInAnimator,
getTransitionOutAnimator, getUIManager, grabAnimationLock, hasMedia,
hideNotify, isAlwaysTensile, isCyclicFocus, isDragRegion, isFocusScrolling,
isFormBottomPaddingEditingMode, isMinimizeOnBack, isScrollable,
isSingleFocusMode, isSmoothScrolling, keyPressed, keyRepeated,
longKeyPress, longPointerPress, onShowCompleted, paint, paintBackground,
paramString, pointerDragged, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, refreshTheme, registerAnimated,
releaseAnimationLock, removeAllCommands, removeAllShowListeners,
removeCommand, removeCommandListener, removeGameKeyListener,
removeKeyListener, removeOrientationListener, removeShowListener,
removeSizeChangedListener, replace, replaceAndWait,
scrollComponentToVisible, setAlwaysTensile, setBackCommand, setBgImage,
setClearCommand, setCyclicFocus, setDefaultCommand, setEditOnShow,
setFocused, setFocusScrolling, setFormBottomPaddingEditingMode,
setGlassPane, setMenuBar, setMenuCellRenderer, setMenuTransitions,
setMinimizeOnBack, setPropertyValue, setRTL, setScrollableX,
setScrollableY, setScrollAnimationSpeed, setSmoothScrolling, setTintColor,
setTitleStyle, setToolbar, setToolBar, setTransitionInAnimator,
setTransitionOutAnimator, setUIManager, setVisible,
shouldSendPointerReleaseToOtherForm, showNotify, sizeChanged

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getGridPosX,
getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled,
isScrollableX, isScrollableY, isSelectableInteraction, iterator,
layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass,
replace, replaceAndWait, replaceAndWait, revalidate, setCellRenderer,
setEnabled, setLeadComponent, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentState, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed,
getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollDimension,

Methods inherited from class com.codename1.ui.Form

1872

Overview (Codename One API)


getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollVisible, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
onScrollX, onScrollY, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerPressed,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setSameHeight, setSameWidth, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString,
unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
TYPE_NONE
public static final int TYPE_NONE

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values
TYPE_ALARM
public static final int TYPE_ALARM

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values
TYPE_CONFIRMATION
public static final int TYPE_CONFIRMATION

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values
TYPE_ERROR
public static final int TYPE_ERROR

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values

Methods inherited from class com.codename1.ui.Component

1873

Overview (Codename One API)


TYPE_INFO
public static final int TYPE_INFO

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values
TYPE_WARNING
public static final int TYPE_WARNING

Constant indicating the type of alert to indicate the sound to play or icon if none are
explicitly set
See Also:
Constant Field Values

Constructor Detail
Dialog
public Dialog(String title)

Constructs a Dialog with a title


Parameters:
title - the title of the dialog
Dialog
public Dialog()

Constructs a Dialog with a title

Method Detail
getContentPane
public Container getContentPane()

Description copied from class: Form


This method returns the Content pane instance
Overrides:
getContentPane in class Form
Returns:
a content pane instance
getLayout
public Layout getLayout()

Returns the layout manager responsible for arranging this container


Overrides:
getLayout in class Form
Returns:
the container layout manager
getTitle
public String getTitle()

Returns the Form title text


Overrides:
getTitle in class Form
Returns:
returns the form title

Field Detail

1874

Overview (Codename One API)


addComponent
public void addComponent(Component cmp)

Adds Component to the Form's Content Pane


Overrides:
addComponent in class Form
Parameters:
cmp - the added param
addComponent
public void addComponent(Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Form
Parameters:
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Form
Parameters:
index - location to insert the Component
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Component cmp)

Adds Component to the Form's Content Pane


Overrides:
addComponent in class Form
Parameters:
index - location to insert the Component
cmp - the added param
removeAll
public void removeAll()

Removes all Components from the Content Pane


Overrides:
removeAll in class Form
removeComponent
public void removeComponent(Component cmp)

Removes a component from the Form's Content Pane


Overrides:
removeComponent in class Form
Parameters:
cmp - the component to be removed

Method Detail

1875

Overview (Codename One API)


getTitleComponent
public Label getTitleComponent()

Allows modifying the title attributes beyond style (e.g. setting icon/alignment etc.)
Overrides:
getTitleComponent in class Form
Returns:
the component representing the title for the form
getTitleStyle
public Style getTitleStyle()

Returns the style of the title


Overrides:
getTitleStyle in class Form
Returns:
the style of the title
setLayout
public void setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


Overrides:
setLayout in class Form
Parameters:
layout - the specified layout manager
setTitle
public void setTitle(String title)

Sets the Form title to the given text


Overrides:
setTitle in class Form
Parameters:
title - the form title
setTitleComponent
public void setTitleComponent(Label title)

Allows replacing the title with a different title component, thus allowing developers to
create more elaborate title objects.
Overrides:
setTitleComponent in class Form
Parameters:
title - new title component
getDialogComponent
public Container getDialogComponent()

Returns the container that actually implements the dialog positioning. This container
is normally not accessible via the Codename One API.
Returns:
internal dialog container useful for various calculations.
setTitleComponent
public void setTitleComponent(Label title,
Transition t)

Allows replacing the title with a different title component, thus allowing developers to
create more elaborate title objects. This version of the method allows special effects
for title replacement such as transitions for title entering
Overrides:
setTitleComponent in class Form
Parameters:
title - new title component
t - transition for title replacement

Method Detail

1876

Overview (Codename One API)


setDialogStyle
public void setDialogStyle(Style style)

Simple setter to set the Dialog Style


Parameters:
style setDialogUIID
public void setDialogUIID(String uiid)

Simple setter to set the Dialog uiid


Parameters:
uiid - the id for the dialog
getDialogUIID
public String getDialogUIID()

Returns the uiid of the dialog


Returns:
the uiid of the dialog
getDialogStyle
public Style getDialogStyle()

Simple getter to get the Dialog Style


Returns:
the style of the dialog
initLaf
protected void initLaf(UIManager uim)

Initialize the default transition for the dialogs overriding the forms transition
Overrides:
initLaf in class Form
Parameters:
laf - the default transition for the dialog
show
public Command show(int top,
int bottom,
int left,
int right,
boolean includeTitle)

Deprecated. use the version that doesn't accept the include title, the includeTitle
feature is no longer supported
This method shows the form as a modal alert allowing us to produce a behavior of an
alert/dialog box. This method will block the calling thread even if the calling thread is
the EDT. Notice that this method will not release the block until dispose is called even
if show() from another form is called!
Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful
for dialogs where you would want the underlying form to "peek" from behind the form.
Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
includeTitle - whether the title should hang in the top of the screen or be
glued onto the content pane
Returns:
the last command pressed by the user if such a command exists

Method Detail

1877

Overview (Codename One API)


show
public Command show(int
int
int
int

top,
bottom,
left,
right)

This method shows the form as a modal alert allowing us to produce a behavior of an
alert/dialog box. This method will block the calling thread even if the calling thread is
the EDT. Notice that this method will not release the block until dispose is called even
if show() from another form is called!
Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful
for dialogs where you would want the underlying form to "peek" from behind the form.
See this sample for showing a dialog at the bottom of the screen:
Dialog dlg = new Dialog("At Bottom");
dlg.setLayout(new BorderLayout());
// span label accepts the text and the UIID for the dialog body
dlg.add(new SpanLabel("Dialog Body text", "DialogBody"));
int h = Display.getInstance().getDisplayHeight();
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.show(h /8 * 7, 0, 0, 0);

Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
Returns:
the last command pressed by the user if such a command exists
show
public Command show(int top,
int bottom,
int left,
int right,
boolean includeTitle,
boolean modal)

Deprecated. use showAtPosition, the includeTitle flag is no longer supported


This method shows the form as a modal alert allowing us to produce a behavior of an
alert/dialog box. This method will block the calling thread even if the calling thread is
the EDT. Notice that this method will not release the block until dispose is called even
if show() from another form is called!
Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful
for dialogs where you would want the underlying form to "peek" from behind the form.
Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
includeTitle - whether the title should hang in the top of the screen or be
glued onto the content pane
modal - indicates the dialog should be modal set to false for modeless dialog
which is useful for some use cases
Returns:
the last command pressed by the user if such a command exists
showAtPosition
public Command showAtPosition(int top,
int bottom,
int left,
int right,
boolean modal)

Method Detail

1878

Overview (Codename One API)


This method shows the form as a modal alert allowing us to produce a behavior of an
alert/dialog box. This method will block the calling thread even if the calling thread is
the EDT. Notice that this method will not release the block until dispose is called even
if show() from another form is called!
Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful
for dialogs where you would want the underlying form to "peek" from behind the form.
Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
modal - indicates the dialog should be modal set to false for modeless dialog
which is useful for some use cases
Returns:
the last command pressed by the user if such a command exists
setTimeout
public void setTimeout(long time)

Indicates the time (in milliseconds) afterwhich the dialog will be disposed implicitly
Parameters:
time - a milliseconds time used to dispose the dialog
show
public static boolean show(String title,
String text,
int type,
Image icon,
String okText,
String cancelText)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for
canceling the dialog
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.
autoAdjust
protected void autoAdjust(int w,
int h)

Auto adjust size of the dialog. This method is triggered from a sizeChanged event.
Parameters:
w - width of the screen
h - height of the screen
show
public static boolean show(String title,
String text,
int type,
Image icon,
String okText,
String cancelText,
long timeout)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog

Method Detail

1879

Overview (Codename One API)


- the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for
canceling the dialog
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.
show
type

public static Command show(String title,


String text,
Command[] cmds,
int type,
Image icon,
long timeout)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
Returns:
the command pressed by the user
show
public static Command show(String title,
String text,
Command defaultCommand,
Command[] cmds,
int type,
Image icon,
long timeout)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
Returns:
the command pressed by the user
show
public static Command show(String title,
String text,
Command[] cmds,
int type,
Image icon,
long timeout,
Transition transition)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;

Method Detail

1880

Overview (Codename One API)


- the text displayed in the dialog
- commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user
show
text
cmds

public static Command show(String title,


String text,
Command defaultCommand,
Command[] cmds,
int type,
Image icon,
long timeout,
Transition transition)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user
show
public static boolean show(String
String
String
String

title,
text,
okText,
cancelText)

Shows a modal prompt dialog with the given title and text.
Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for
canceling the dialog
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.
show
public static Command show(String title,
Component body,
Command... cmds)

Shows a modal dialog with the given component as its "body" placed in the center.
Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will
dispose the form
Returns:
the command pressed by the user

Method Detail

1881

Overview (Codename One API)


show
public static Command show(String title,
Component body,
Command[] cmds,
int type,
Image icon)

Shows a modal dialog with the given component as its "body" placed in the center.
Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
Returns:
the command pressed by the user
show
public static Command show(String title,
Component body,
Command[] cmds,
int type,
Image icon,
long timeout)

Shows a modal dialog with the given component as its "body" placed in the center.
Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
Returns:
the command pressed by the user
show
public static Command show(String title,
Component body,
Command[] cmds,
int type,
Image icon,
long timeout,
Transition transition)

Shows a modal dialog with the given component as its "body" placed in the center.
Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite
time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user

Method Detail

1882

Overview (Codename One API)


placeButtonCommands
public void placeButtonCommands(Command[] cmds)

Deprecated. this method shouldn't be invoked externally, it should have been private
Places the given commands in the dialog command area, this is very useful for touch
devices.
Parameters:
cmds - the commands to place
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Form
Parameters:
keyCode - the key code value to indicate a physical key.
show
public static Command show(String title,
Component body,
Command defaultCommand,
Command[] cmds,
int type,
Image icon,
long timeout,
Transition transition)

Shows a modal dialog with the given component as its "body" placed in the center.
Parameters:
title - title for the dialog
body - component placed in the center of the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will
dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO,
TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 inifinite
time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user
onShow
protected void onShow()

Allows subclasses to bind functionality that occurs when a specific form or dialog
appears on the screen
Overrides:
onShow in class Form
showBack
public void showBack()

Displays the current form on the screen, this version of the method is useful for
"back" navigation since it reverses the direction of the transition.
Overrides:
showBack in class Form
setScrollable
public void setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


Overrides:
setScrollable in class Form
Parameters:

Method Detail

1883

Overview (Codename One API)


scrollable

- whether the component should/could scroll on the X and Y axis

show
public void show()

The default version of show modal shows the dialog occupying the center portion of
the screen.
Overrides:
show in class Form
showModeless
public void showModeless()

Shows a modeless dialog which is useful for some simpler use cases such as
progress indication etc...
showPopupDialog
public Command showPopupDialog(Component c)

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside its
bounds. It can optionally provide an arrow in the theme to point at the context
component. The popup dialog has the PopupDialog style by default.
Parameters:
c - the context component which is used to position the dialog and can also
be pointed at
Returns:
the command that might have been triggered by the user within the dialog if
commands are placed in the dialog
showPopupDialog
public Command showPopupDialog(Rectangle rect)

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside its
bounds. It can optionally provide an arrow in the theme to point at the context
component. The popup dialog has the PopupDialog style by default.
Parameters:
rect - the screen rectangle to which the popup should point
Returns:
the command that might have been triggered by the user within the dialog if
commands are placed in the dialog
showPacked
public Command showPacked(String position,
boolean modal)

Convenience method to show a dialog sized to match its content.


Parameters:
position - one of the values from the BorderLayout class e.g.
BorderLayout.CENTER, BorderLayout.NORTH etc.
modal - whether the dialog should be modal or modaless
Returns:
the command selected if the dialog is modal and disposed via a command
showStretched
public Command showStretched(String position,
boolean modal)

Convenience method to show a dialog stretched to one of the sides


Parameters:
position - one of the values from the BorderLayout class except for center
e.g. BorderLayout.NORTH, BorderLayout.EAST etc.
modal - whether the dialog should be modal or modaless
Returns:
the command selected if the dialog is modal and disposed via a command

Method Detail

1884

Overview (Codename One API)


showStetched
public Command showStetched(String position,
boolean modal)

Deprecated. due to typo use showStretched instead


Convenience method to show a dialog stretched to one of the sides
Parameters:
position - one of the values from the BorderLayout class except for center
e.g. BorderLayout.NORTH, BorderLayout.EAST etc.
modal - whether the dialog should be modal or modaless
Returns:
the command selected if the dialog is modal and disposed via a command
getDialogPreferredSize
public Dimension getDialogPreferredSize()

Returns the preferred size of the dialog, this allows developers to position a dialog
manually in arbitrary positions.
Returns:
the preferred size of this dialog
dispose
public void dispose()

Closes the current form and returns to the previous form, releasing the EDT in the
process
showDialog
public Command showDialog()

Shows a modal dialog and returns the command pressed within the modal dialog
Returns:
last command pressed in the modal dialog
actionCommand
protected void actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point rather than
implementing many command instances
Overrides:
actionCommand in class Form
Parameters:
cmd - the action command
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Form
Returns:
true if a repaint is desired or false if no repaint is necessary
isAutoDispose
public boolean isAutoDispose()

Determines whether the execution of a command on this dialog implicitly disposes


the dialog. This defaults to true which is a sensible default for simple dialogs.
Returns:
true if this dialog disposes on any command

Method Detail

1885

Overview (Codename One API)


setAutoDispose
public void setAutoDispose(boolean autoDispose)

Determines whether the execution of a command on this dialog implicitly disposes


the dialog. This defaults to true which is a sensible default for simple dialogs.
Parameters:
autoDispose - true if this dialog disposes on any command
setDefaultDialogPosition
public static void setDefaultDialogPosition(String p)

Default screen orientation position for the upcoming dialog. By default the dialog will
be shown at hardcoded coordinates, this method allows us to pack the dialog
appropriately in one of the border layout based locations see BorderLayout for futher
details.
Parameters:
p - for dialogs on the sceen using BorderLayout orientation tags
getDefaultDialogPosition
public static String getDefaultDialogPosition()

Default screen orientation position for the upcoming dialog. By default the dialog will
be shown at hardcoded coordinates, this method allows us to pack the dialog
appropriately in one of the border layout based locations see BorderLayout for futher
details.
Returns:
position for dialogs on the sceen using BorderLayout orientation tags
getDialogType
public int getDialogType()

The type of the dialog can be one of TYPE_WARNING, TYPE_INFO,


TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
Returns:
can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR,
TYPE_CONFIRMATION or TYPE_ALARM
setDialogType
public void setDialogType(int dialogType)

The type of the dialog can be one of TYPE_WARNING, TYPE_INFO,


TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
Parameters:
dialogType - can be one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR,
TYPE_CONFIRMATION or TYPE_ALARM
setDefaultDialogType
public static void setDefaultDialogType(int d)

The default type for dialogs


Parameters:
d - the default type for the dialog
getDefaultDialogType
public static int getDefaultDialogType()

The default type for dialogs


Returns:
the default type for the dialog
setAutoAdjustDialogSize
public static void setAutoAdjustDialogSize(boolean a)

Indicates whether Codename One should try to automatically adjust a showing dialog
size when a screen size change event occurs
Parameters:

Method Detail

1886

Overview (Codename One API)


- true to indicate that Codename One should make a "best effort" to resize
the dialog
isAutoAdjustDialogSize
a

public static boolean isAutoAdjustDialogSize()

Indicates whether Codename One should try to automatically adjust a showing dialog
size when a screen size change event occurs
Returns:
true to indicate that Codename One should make a "best effort" to resize the
dialog
setDisableStaticDialogScrolling
public static void setDisableStaticDialogScrolling(boolean d)

Allows a developer to indicate his interest that the dialog should no longer scroll on its
own but rather rely on the scrolling properties of internal scrollable containers. This
flag only affects the static show methods within this class.
Parameters:
d - indicates whether scrolling should be active or not
isDisableStaticDialogScrolling
public static boolean isDisableStaticDialogScrolling()

Allows a developer to indicate his interest that the dialog should no longer scroll on its
own but rather rely on the scrolling properties of internal scrollable containers. This
flag only affects the static show methods within this class.
Returns:
true if scrolling should be activated, false otherwise
setCommandsAsButtons
public static void setCommandsAsButtons(boolean c)

Places commands as buttons at the bottom of the standard static dialogs rather than
as softbuttons. This is especially appropriate for devices such as touch devices and
devices without the common softbuttons (e.g. blackberries). The default value is false
Parameters:
c - true to place commands as buttons and not as softbutton keys
isCommandsAsButtons
public static boolean isCommandsAsButtons()

Places commands as buttons at the bottom of the standard static dialogs rather than
as softbuttons. This is especially appropriate for devices such as touch devices and
devices without the common softbuttons (e.g. blackberries). The default value is false
Returns:
true if commands are placed as buttons and not as softbutton keys
setDisposeWhenPointerOutOfBounds
public void setDisposeWhenPointerOutOfBounds(boolean disposeWhenPointerOutOfBounds)

This flag indicates if the dialog should be disposed if a pointer released event
occurred out of the dialog content.
Parameters:
disposeWhenPointerOutOfBounds isDisposeWhenPointerOutOfBounds
public boolean isDisposeWhenPointerOutOfBounds()

This flag indicates if the dialog should be disposed if a pointer released event
occurred out of the dialog content.
Returns:
true if the dialog should dispose

Method Detail

1887

Overview (Codename One API)


pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Form
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Form
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
wasDisposedDueToOutOfBoundsTouch
public boolean wasDisposedDueToOutOfBoundsTouch()

Returns true if a dialog that was disposed did it because of a pointer out of bounds
Returns:
true when a dialog was disposed due to pointer out of bounds.
getDialogPosition
public String getDialogPosition()

Screen orientation position for the upcoming dialog. By default the dialog will be
shown at hardcoded coordinates, this method allows us to pack the dialog
appropriately in one of the border layout based locations see BorderLayout for futher
details.
Returns:
the dialogPosition
setDialogPosition
public void setDialogPosition(String dialogPosition)

Screen orientation position for the upcoming dialog. By default the dialog will be
shown at hardcoded coordinates, this method allows us to pack the dialog
appropriately in one of the border layout based locations see BorderLayout for futher
details.
Parameters:
dialogPosition - the dialogPosition to set
growOrShrink
public void growOrShrink()

Allows a dialog component to grow or shrink to its new preferred size


getPopupDirectionBiasPortrait
public Boolean getPopupDirectionBiasPortrait()

Indicates if we want to enforce directional bias for the popup dialog. If null this field is
ignored but if its set to a value it biases the system towards a fixed direction for the
popup dialog.
Returns:
the popupDirectionBiasPortrait

Method Detail

1888

Overview (Codename One API)


setPopupDirectionBiasPortrait
public void setPopupDirectionBiasPortrait(Boolean popupDirectionBiasPortrait)

Indicates if we want to enforce directional bias for the popup dialog. If null this field is
ignored but if its set to a value it biases the system towards a fixed direction for the
popup dialog.
Parameters:
popupDirectionBiasPortrait - the popupDirectionBiasPortrait to set
wasDisposedDueToRotation
public boolean wasDisposedDueToRotation()

Returns true if the dialog was disposed automatically due to device rotation
Returns:
the disposedDueToRotation value
getBlurBackgroundRadius
public float getBlurBackgroundRadius()

Dialog background can be blurred using a Gaussian blur effect, this sets the radius of
the Gaussian blur. -1 is a special case value that indicates that no blurring should
take effect and the default tint mode only should be used
Returns:
the blurBackgroundRadius
setBlurBackgroundRadius
public void setBlurBackgroundRadius(float blurBackgroundRadius)

Dialog background can be blurred using a Gaussian blur effect, this sets the radius of
the Gaussian blur. -1 is a special case value that indicates that no blurring should
take effect and the default tint mode only should be used. Notice that this value can
be set using the theme constant: dialogBlurRadiusInt
Parameters:
blurBackgroundRadius - the blurBackgroundRadius to set
getDefaultBlurBackgroundRadius
public static float getDefaultBlurBackgroundRadius()

Dialog background can be blurred using a Gaussian blur effect, this sets the radius of
the Gaussian blur. -1 is a special case value that indicates that no blurring should
take effect and the default tint mode only should be used
Returns:
the defaultBlurBackgroundRadius
setDefaultBlurBackgroundRadius

public static void setDefaultBlurBackgroundRadius(float aDefaultBlurBackgroundRadius

Dialog background can be blurred using a Gaussian blur effect, this sets the radius of
the Gaussian blur. -1 is a special case value that indicates that no blurring should
take effect and the default tint mode only should be used. Notice that this value can
be set using the theme constant: dialogBlurRadiusInt
Parameters:
aDefaultBlurBackgroundRadius - the defaultBlurBackgroundRadius to set

Method Detail

1889

Overview (Codename One API)


com.codename1.ui

Class Container
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>
Direct Known Subclasses:
Ads, BaseSpinner, BrowserComponent, Calendar, ComponentGroup, ContainerList,
EmbeddedContainer, FloatingHint, Form, HTMLComponent, InfiniteContainer,
InteractionDialog, MapComponent, MediaPlayer, MenuBar, MultiButton, OnOffSwitch,
SpanButton, SpanLabel, SwipeableContainer, Table, Tabs, Toolbar, Tree, WebBrowser

public class
extends Component
implements Iterable<Component>

A composite pattern with Component, allows nesting and arranging multiple components using a
pluggable layout manager architecture. Containers can be nested one within the other to form
elaborate UI's. By default Containers use FlowLayout which isn't ideal for most use cases.

Components within the Container MUST be arranged using a layout manager!


This allows the UI to adapt to different resolutions, DPI, orientation changes etc. seamlessly. Invoking
any bounds setting method will produce unpredictable results. To learn about layout managers check
out the relevant section in the developer guide.
A container doesn't implicitly reflow its elements and in that regard follows the direction of
AWT/Swing. As a result the layout can be animated to create a flowing effect for UI changes. This
also provides improved performance as a bonus. See this sample of Container animation:
Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
Button fall = new Button("Fall");
fall.addActionListener((e) -> {
for(int iter = 0 ; iter < 10 ; iter++) {
Label b = new Label ("Label " + iter);
b.setWidth(fall.getWidth());
b.setHeight(fall.getHeight());
b.setY(-fall.getHeight());
hi.add(b);
}
hi.getContentPane().animateLayout(20000);
});
hi.add(fall);

Many components within Codename One (e.g. Tree, Table, MultiButton etc.) derive from Container
instead of Component. This allows such components to provide very rich functionality by building on
top of the existing functionality. Container also provides the lead component functionality that allows

Class Container

1890

Overview (Codename One API)


treating an entire Container hierarchy as a single component. This is discussed in depth within the
developer guide.
See Also:
com.codename1.ui.layouts, Component

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Container()

Constructs a new Container, with a FlowLayout.


Container(Layout layout)

Constructs a new Container with a new layout manager.

Method Summary
Modifier and Type

Method and Description


add(Component cmp)

Container

Simpler version of addComponent that allows chaining the calls for


shorter syntax
add(Image img)

Container

Simpler version of addComponent that allows chaining the calls for


shorter syntax
add(Object constraint, Component cmp)

Container

Simpler version of addComponent that allows chaining the calls for


shorter syntax
add(Object constraint, Image img)

Container

Simpler version of addComponent that allows chaining the calls for


shorter syntax
add(Object constraint, String label)

Container

Simpler version of addComponent that allows chaining the calls for


shorter syntax
add(String label)

Container

void

Simpler version of addComponent that allows chaining the calls for


shorter syntax
addComponent(Component cmp)

Adds a Component to the Container


addComponent(int index, Component cmp)

void

void
void

This method adds the Component at a specific index location in the


Container Components array.
addComponent(int index, Object constraints, Component cmp)

Adds a Component to the Container


addComponent(Object constraints, Component cmp)

Adds a Component to the Container


animateHierarchy(int duration)

void

Field Summary

Animates a pending hierarchy of components into place, this


effectively replaces revalidate with a more visual form of animation

1891

Overview (Codename One API)


animateHierarchyAndWait(int duration)
void

Animates a pending hierarchy of components into place, this


effectively replaces revalidate with a more visual form of animation.
animateHierarchyFade(int duration, int startingOpacity)

void

void

Animates a pending hierarchy of components into place, this


effectively replaces revalidate with a more visual form of animation
animateHierarchyFadeAndWait(int duration,
int startingOpacity)

Animates a pending hierarchy of components into place, this


effectively replaces revalidate with a more visual form of animation.
animateLayout(int duration)

void

Animates a pending layout into place, this effectively replaces


revalidate with a more visual form of animation
See:
animateLayoutAndWait(int duration)

void

Animates a pending layout into place, this effectively replaces


revalidate with a more visual form of animation.
animateLayoutFade(int duration, int startingOpacity)

void

Animates a pending layout into place, this effectively replaces


revalidate with a more visual form of animation
animateLayoutFadeAndWait(int duration, int startingOpacity)

void

Animates a pending layout into place, this effectively replaces


revalidate with a more visual form of animation.
animateUnlayout(int duration, int opacity, Runnable callback)

void

This method is the exact reverse of animateLayout, when completed


it leaves the container in an invalid state.
animateUnlayoutAndWait(int duration, int opacity)

void

This method is the exact reverse of animateLayoutAndWait, when


completed it leaves the container in an invalid state.
applyRTL(boolean rtl)

void

protected Dimension
protected void
void

Invokes apply/setRTL recursively on all the children components of


this container
calcPreferredSize()

Calculates the preferred size based on component content.


cancelRepaints()

remove this component and it's children from the painting queue
clearClientProperties()

Clears all client properties from this Component


contains(Component cmp)

boolean

Returns true if the given component is within the hierarchy of this


container
createAnimateMotion(int start, int destination, int duration)

protected Motion

Creates a motion object for animation, allows subclasses to replace


the motion type used in animations (currently defaults to ease-in).
dragInitiated()

protected void

Invoked on the focus component to let it know that drag has started
on the parent container for the case of a component that doesn't
support scrolling
drop(Component dragged, int x, int y)

void

Performs a drop operation of the component at the given X/Y


location in coordinate space, this method should be overriden by
subclasses to perform all of the logic related to moving a component,
by default this method does nothing and so dragging a component
and dropping it has no effect
encloseIn(Layout l, Component... cmp)

static Container

static Container
Component

Method Summary

Short-hand for enclosing multiple components in a container typically


a box layout
encloseIn(Layout l, Component cmp, Object cons)

Short-hand for enclosing a component within a Container


findFirstFocusable()

1892

Overview (Codename One API)


Finds the first focusable Component on this Container
fireClicked()
protected void

When working in 3 softbutton mode "fire" key (center softbutton) is


sent to this method in order to allow 3 button devices to work
properly.
flushReplace()

void

Deprecated.
this method is no longer used in the new animation framework
forceRevalidate()

void

int

A more powerful form of revalidate that recursively lays out the full
hierarchy
getBottomGap()

Returns the gap to be left for the bottom scrollbar on the X axis.
getClosestComponentTo(int x, int y)

Component

Component

Very useful for touch events or drop events that need approximation
more than accuracy
getComponentAt(int index)

Returns the Component at a given index


getComponentAt(int x, int y)

Component

int
int

Returns a Component that exists in the given x, y coordinates by


traversing component objects and invoking contains
getComponentCount()

Returns the number of components


getComponentIndex(Component cmp)

Returns the Component index in the Container


getGridPosX()

protected int

This method should be implemented correctly by subclasses to make


snap to grid functionality work as expected.
getGridPosY()

protected int

Layout

This method should be implemented correctly by subclasses to make


snap to grid functionality work as expected.
getLayout()

Returns the layout manager responsible for arranging this container


getLayoutHeight()

int

Returns the height for layout manager purposes, this takes scrolling
into consideration unlike the getWidth method.
getLayoutWidth()

int

Returns the width for layout manager purposes, this takes scrolling
into consideration unlike the getWidth method.
getLeadComponent()

Component

Returns the lead component for this hierarchy if such a component is


defined
getLeadParent()

Container

int
int

Returns the lead container thats handling the leading, this is useful
for a container hierarchy where the parent container might not be the
leader
getScrollIncrement()

Gets the Container scroll increment


getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis.
getUIManager()

UIManager

protected void

This method should be used by the Component to retrieve the


correct UIManager to work with
initLaf(UIManager uim)

This method initializes the Component defaults constants


invalidate()

void

Same as setShouldCalcPreferredSize(true) but made accessible for


layout managers

boolean

isEnabled()

Method Summary

1893

Overview (Codename One API)


Indicates whether component is enabled or disabled thus allowing us
to prevent a component from receiving input events and indicate so
visually
boolean
boolean

isScrollableX()

Indicates whether the component should/could scroll on the X axis


isScrollableY()

Indicates whether the component should/could scroll on the Y axis


isSelectableInteraction()

protected boolean

This method allows a component to indicate that it is interested in an


"implicit" select command to appear in the "fire" button when 3
softbuttons are defined in a device.
iterator()

Iterator<Component>

Part of the Iterable interface allowing us to do a for-each loop on


Container
keyPressed(int k)

void

If this Component is focused, the key pressed event will call this
method
keyReleased(int k)

void

void

void

void

If this Component is focused, the key released event will call this
method
layoutContainer()

Performs the layout of the container if a layout is necessary


morph(Component source, Component destination, int duration,
Runnable onCompletion)

Morph is similar to the replace functionality where a component


might be replaced with a component that isn't within the container.
morphAndWait(Component source, Component destination,
int duration)

Morph is similar to the replace functionality where a component


might be replaced with a component that isn't within the container.
paint(Graphics g)

void

This method paints the Component on the screen, it should be


overriden by subclasses to perform custom drawing or invoke the UI
API's to let the PLAF perform the rendering.
paintComponentBackground(Graphics g)

void

Paints the background of the component, invoked with the clipping


region and appropriate scroll translation.
paintGlass(Graphics g)

protected void

protected String

This method can be overriden by a component to draw on top of


itself or its children after the component or the children finished
drawing in a similar way to the glass pane but more refined per
component
paramString()

Returns a string representing the state of this component.


pointerHover(int[] x, int[] y)

void

Invoked for devices where the pointer can hover without actually
clicking the display.
pointerPressed(int x, int y)

void

If this Component is focused, the pointer pressed event will call this
method
refreshTheme(boolean merge)

void

Makes sure the component is up to date with the current theme,


ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!
removeAll()

void

remove all Components from container, notice that removed


component might still have a pending repaint in the queue that won't
be removed.
removeComponent(Component cmp)

void

Method Summary

removes a Component from the Container, notice that removed


component might still have a pending repaint in the queue that won't
be removed.

1894

Overview (Codename One API)


replace(Component current, Component next, Transition t)

This method replaces the current Component with the next


Component.

void

replace(Component current, Component next, Transition t,


Runnable onFinish, int growSpeed)

void

This method replaces the current Component with the next


Component
replaceAndWait(Component current, Component next,
Transition t)

void

This method replaces the current Component with the next


Component.
replaceAndWait(Component current, Component next,
Transition t, boolean dropEvents)

void

This method replaces the current Component with the next


Component.
replaceAndWait(Component current, Component next,
Transition t, int layoutAnimationSpeed)

void

This method replaces the current Component with the next


Component.
revalidate()

Re-layout the container, this is useful when we modify the container


hierarchy and need to redo the layout

void

scrollComponentToVisible(Component c)

Makes sure the component is visible in the scroll if this container is


scrollable

void

setCellRenderer(boolean cellRenderer)

Used as an optimization to mark that this component is currently


being used as a cell renderer

void

setEnabled(boolean enabled)

This method will recursively set all the Container chidrens to be


enabled/disabled.

void

setLayout(Layout layout)

void

Sets the layout manager responsible for arranging this container


setLeadComponent(Component lead)

Sets the lead component for this container, a lead component takes
over the entire component hierarchy and receives all the events for
the container hierarchy.

void

setScrollable(boolean scrollable)

void

The equivalent of calling both setScrollableY and setScrollableX


setScrollableX(boolean scrollableX)

void

Sets whether the component should/could scroll on the X axis


setScrollableY(boolean scrollableY)

void

Sets whether the component should/could scroll on the Y axis


setScrollIncrement(int scrollIncrement)

void

Determines the scroll increment size of this Container.


setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and


preferred size should be recalculated

void

protected void

setShouldLayout(boolean layout)

Flags this container to preform layout


setUIManager(UIManager uiManager)

Allows replacing the UIManager in a component hierarchy to update


the look and feel only to a specific hierarchy

void

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,

Methods inherited from class com.codename1.ui.Component

1895

Overview (Codename One API)


getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Container
public Container(Layout layout)

Constructs a new Container with a new layout manager.


Parameters:
layout - the specified layout manager
Container
public Container()

Constructs a new Container, with a FlowLayout.

Method Detail

Methods inherited from class java.lang.Object

1896

Overview (Codename One API)


encloseIn
public static Container encloseIn(Layout l,
Component cmp,
Object cons)

Short-hand for enclosing a component within a Container


Parameters:
l - the layout
cmp - the component to enclose
cons - the constraint for the component
Returns:
a newly created container containing the given component
encloseIn
public static Container encloseIn(Layout l,
Component... cmp)

Short-hand for enclosing multiple components in a container typically a box layout


Parameters:
l - the layout
cmp - the components to enclose
Returns:
a newly created container containing the given components
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


Overrides:
initLaf in class Component
getUIManager
public UIManager getUIManager()

This method should be used by the Component to retrieve the correct UIManager to
work with
Overrides:
getUIManager in class Component
Returns:
a UIManager instance
add
public Container add(Component cmp)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:
cmp - the component to add
Returns:
this for call chaining
add
public Container add(Object constraint,
Component cmp)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:
constraint - the layout constraint if applicable
cmp - the component to add
Returns:
this for call chaining
add
public Container add(String label)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:

Method Detail

1897

Overview (Codename One API)


- a string that will be wrapped as a label, this is equivalent to calling
add(new Label(l))
Returns:
this for call chaining
add
label

public Container add(Image img)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:
img - an image that will be wrapped as a label, this is equivalent to calling
add(new Label(l))
Returns:
this for call chaining
add
public Container add(Object constraint,
String label)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:
constraint - the layout constraint if applicable
label - a component that will be wrapped as a label, this is equivalent to
calling add(new Label(l))
Returns:
this for call chaining
add
public Container add(Object constraint,
Image img)

Simpler version of addComponent that allows chaining the calls for shorter syntax
Parameters:
constraint - the layout constraint if applicable
img - an image that will be wrapped as a label, this is equivalent to calling
add(new Label(l))
Returns:
this for call chaining
setUIManager
public void setUIManager(UIManager uiManager)

Allows replacing the UIManager in a component hierarchy to update the look and feel
only to a specific hierarchy
Parameters:
uiManager - UIManager instance
setLeadComponent
public void setLeadComponent(Component lead)

Sets the lead component for this container, a lead component takes over the entire
component hierarchy and receives all the events for the container hierarchy.
Parameters:
lead - component that takes over the hierarchy
getLeadComponent
public Component getLeadComponent()

Returns the lead component for this hierarchy if such a component is defined
Returns:
the lead component
getLeadParent
public Container getLeadParent()

Returns the lead container thats handling the leading, this is useful for a container
hierarchy where the parent container might not be the leader

Method Detail

1898

Overview (Codename One API)


Returns:
the lead component
keyPressed
public void keyPressed(int k)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
k - the key code value to indicate a physical key.
keyReleased
public void keyReleased(int k)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
k - the key code value to indicate a physical key.
getLayout
public Layout getLayout()

Returns the layout manager responsible for arranging this container


Returns:
the container layout manager
setLayout
public void setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


Parameters:
layout - the specified layout manager
invalidate
public void invalidate()

Same as setShouldCalcPreferredSize(true) but made accessible for layout managers


setShouldLayout
protected void setShouldLayout(boolean layout)

Flags this container to preform layout


Parameters:
layout setShouldCalcPreferredSize
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and preferred size should
be recalculated
Overrides:
setShouldCalcPreferredSize in class Component
Parameters:
shouldCalcPreferredSize - indicate whether this component need to
recalculate his preferred size
getLayoutWidth
public int getLayoutWidth()

Returns the width for layout manager purposes, this takes scrolling into consideration
unlike the getWidth method.
Returns:
the layout width

Method Detail

1899

Overview (Codename One API)


getLayoutHeight
public int getLayoutHeight()

Returns the height for layout manager purposes, this takes scrolling into
consideration unlike the getWidth method.
Returns:
the layout height
applyRTL
public void applyRTL(boolean rtl)

Invokes apply/setRTL recursively on all the children components of this container


Parameters:
rtl - right to left bidi indication
See Also:
Component.setRTL(boolean)

addComponent
public void addComponent(Component cmp)

Adds a Component to the Container


Parameters:
cmp - the component to be added
addComponent
public void addComponent(Object constraints,
Component cmp)

Adds a Component to the Container


Parameters:
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Object constraints,
Component cmp)

Adds a Component to the Container


Parameters:
index - location to insert the Component
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Component cmp)

This method adds the Component at a specific index location in the Container
Components array.
Parameters:
index - location to insert the Component
cmp - the Component to add
Throws:
ArrayIndexOutOfBoundsException - if index is out of bounds
IllegalArgumentException - if Component is already contained or the cmp is
a Form Component
replaceAndWait
public void replaceAndWait(Component current,
Component next,
Transition t)

Method Detail

1900

Overview (Codename One API)


This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method returns when transition
has finished.
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
replaceAndWait
public void replaceAndWait(Component current,
Component next,
Transition t,
int layoutAnimationSpeed)

This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method returns when transition
has finished.
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
layoutAnimationSpeed - the speed of the layout animation after replace is
completed
replace
public void replace(Component current,
Component next,
Transition t,
Runnable onFinish,
int growSpeed)

This method replaces the current Component with the next Component
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
onFinish - invoked when the replace operation is completed, may be null
growSpeed - after replace is completed the component can gradually
grow/shrink to fill up available room, set this to 0 for immediate growth or any
larger number for gradual animation. -1 indicates a special case where no
validation occurs
replaceAndWait
public void replaceAndWait(Component current,
Component next,
Transition t,
boolean dropEvents)

This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method returns when transition
has finished.
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
dropEvents - indicates if the display should drop all events while this
Component replacing is happening
replace
public void replace(Component current,
Component next,
Transition t)

Method Detail

1901

Overview (Codename One API)


This method replaces the current Component with the next Component. Current
Component must be contained in this Container. This method return immediately.
Parameters:
current - a Component to remove from the Container
next - a Component that replaces the current Component
t - a Transition between the add and removal of the Components a Transition
can be null
isEnabled
public boolean isEnabled()

Indicates whether component is enabled or disabled thus allowing us to prevent a


component from receiving input events and indicate so visually
Overrides:
isEnabled in class Component
Returns:
true if enabled
removeComponent
public void removeComponent(Component cmp)

removes a Component from the Container, notice that removed component might still
have a pending repaint in the queue that won't be removed. Calling form.repaint() will
workaround such an issue.
Parameters:
cmp - the removed component
cancelRepaints
protected void cancelRepaints()

remove this component and it's children from the painting queue
Overrides:
cancelRepaints in class Component
flushReplace
public void flushReplace()

Deprecated. this method is no longer used in the new animation framework


Flushes ongoing replace operations to prevent two concurrent replace operations
from colliding. If there is no ongoing replace nothing will occur
removeAll
public void removeAll()

remove all Components from container, notice that removed component might still
have a pending repaint in the queue that won't be removed. Calling form.repaint() will
workaround such an issue.
revalidate
public void revalidate()

Re-layout the container, this is useful when we modify the container hierarchy and
need to redo the layout
forceRevalidate
public void forceRevalidate()

A more powerful form of revalidate that recursively lays out the full hierarchy
clearClientProperties
public void clearClientProperties()

Clears all client properties from this Component


Overrides:
clearClientProperties in class Component

Method Detail

1902

Overview (Codename One API)


paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
paintGlass
protected void paintGlass(Graphics g)

This method can be overriden by a component to draw on top of itself or its children
after the component or the children finished drawing in a similar way to the glass
pane but more refined per component
Parameters:
g - the graphics context
layoutContainer
public void layoutContainer()

Performs the layout of the container if a layout is necessary


getComponentCount
public int getComponentCount()

Returns the number of components


Returns:
the Component count
getComponentAt
public Component getComponentAt(int index)

Returns the Component at a given index


Parameters:
index - of the Component you wish to get
Returns:
a Component
Throws:
ArrayIndexOutOfBoundsException - if an invalid index was given.
getComponentIndex
public int getComponentIndex(Component cmp)

Returns the Component index in the Container


Parameters:
cmp - the component to search for
Returns:
the Component index in the Container or -1 if not found
contains
public boolean contains(Component cmp)

Returns true if the given component is within the hierarchy of this container
Parameters:
cmp - a Component to check
Returns:
true if this Component contains in this Container

Method Detail

1903

Overview (Codename One API)


scrollComponentToVisible
public void scrollComponentToVisible(Component c)

Makes sure the component is visible in the scroll if this container is scrollable
Parameters:
c - the component that will be scrolling for visibility
getClosestComponentTo
public Component getClosestComponentTo(int x,
int y)

Very useful for touch events or drop events that need approximation more than
accuracy
Parameters:
x - location in container relative coordinates
y - location in container relative coordinates
Returns:
the closest component in the container or null if no component is in the
container
getComponentAt
public Component getComponentAt(int x,
int y)

Returns a Component that exists in the given x, y coordinates by traversing


component objects and invoking contains
Parameters:
x - absolute screen location
y - absolute screen location
Returns:
a Component if found, null otherwise
See Also:
Component.contains(int, int)

pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content

Method Detail

1904

Overview (Codename One API)


paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Overrides:
paramString in class Component
Returns:
a string representation of this component's state
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Component
Parameters:
merge - indicates if the current styles should be merged with the new styles
isScrollableX
public boolean isScrollableX()

Indicates whether the component should/could scroll on the X axis


Overrides:
isScrollableX in class Component
Returns:
whether the component is scrollable on the X axis
isScrollableY
public boolean isScrollableY()

Indicates whether the component should/could scroll on the Y axis


Overrides:
isScrollableY in class Component
Returns:
whether the component is scrollable on the X axis
getSideGap
public int getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis. This method is used by
layout managers to determine the room they should leave for the scrollbar. (note:
side scrollbar rather than left scrollbar is used for a future version that would support
bidi).
Overrides:
getSideGap in class Component
Returns:
the gap to be left for the side scrollbar on the Y axis
getBottomGap
public int getBottomGap()

Returns the gap to be left for the bottom scrollbar on the X axis. This method is used
by layout managers to determine the room they should leave for the scrollbar
Overrides:
getBottomGap in class Component
Returns:
the gap to be left for the bottom scrollbar on the X axis
setScrollableX
public void setScrollableX(boolean scrollableX)

Sets whether the component should/could scroll on the X axis

Method Detail

1905

Overview (Codename One API)


Parameters:
scrollableX

- whether the component should/could scroll on the X axis

setScrollableY
public void setScrollableY(boolean scrollableY)

Sets whether the component should/could scroll on the Y axis


Parameters:
scrollableY - whether the component should/could scroll on the Y axis
setScrollable
public void setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


Parameters:
scrollable - whether the component should/could scroll on the X and Y axis
setCellRenderer
public void setCellRenderer(boolean cellRenderer)

Used as an optimization to mark that this component is currently being used as a cell
renderer
Overrides:
setCellRenderer in class Component
Parameters:
cellRenderer - indicate whether this component is currently being used as a
cell renderer
setScrollIncrement
public void setScrollIncrement(int scrollIncrement)

Determines the scroll increment size of this Container. This value is in use when the
current foucs element within this Container is larger than this Container size.
Parameters:
scrollIncrement - the size in pixels.
getScrollIncrement
public int getScrollIncrement()

Gets the Container scroll increment


Returns:
the scroll increment in pixels.
findFirstFocusable
public Component findFirstFocusable()

Finds the first focusable Component on this Container


Returns:
a focusable Component or null if not exists;
dragInitiated
protected void dragInitiated()

Invoked on the focus component to let it know that drag has started on the parent
container for the case of a component that doesn't support scrolling
Overrides:
dragInitiated in class Component
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component

Method Detail

1906

Overview (Codename One API)


isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction
setEnabled
public void setEnabled(boolean enabled)

This method will recursively set all the Container chidrens to be enabled/disabled. If
the Container is disabled and a child Component changed it's state to be enabled, the
child Component will be treated as an enabled Component.
Overrides:
setEnabled in class Component
Parameters:
enabled getGridPosY
protected int getGridPosY()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid Y position closest to the current
Y position.
Overrides:
getGridPosY in class Component
Returns:
a valid Y position in the grid
paintComponentBackground
public void paintComponentBackground(Graphics g)

Paints the background of the component, invoked with the clipping region and
appropriate scroll translation.
Parameters:
g - the component graphics
getGridPosX
protected int getGridPosX()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid X position closest to the current
X position.
Overrides:
getGridPosX in class Component
Returns:
a valid Y position in the grid
animateHierarchyAndWait
public void animateHierarchyAndWait(int duration)

Animates a pending hierarchy of components into place, this effectively replaces


revalidate with a more visual form of animation. This method waits until the operation
is completed before returning
Parameters:
duration - the duration in milliseconds for the animation
animateHierarchy
public void animateHierarchy(int duration)

Animates a pending hierarchy of components into place, this effectively replaces


revalidate with a more visual form of animation
Parameters:

Method Detail

1907

Overview (Codename One API)


duration - the duration in milliseconds for the animation
animateHierarchyFadeAndWait
public void animateHierarchyFadeAndWait(int duration,
int startingOpacity)

Animates a pending hierarchy of components into place, this effectively replaces


revalidate with a more visual form of animation. This method waits until the operation
is completed before returning
Parameters:
duration - the duration in milliseconds for the animation
startingOpacity - the initial opacity to give to the animated components
animateHierarchyFade
public void animateHierarchyFade(int duration,
int startingOpacity)

Animates a pending hierarchy of components into place, this effectively replaces


revalidate with a more visual form of animation
Parameters:
duration - the duration in milliseconds for the animation
startingOpacity - the initial opacity to give to the animated components
animateLayoutFadeAndWait
public void animateLayoutFadeAndWait(int duration,
int startingOpacity)

Animates a pending layout into place, this effectively replaces revalidate with a more
visual form of animation. This method waits until the operation is completed before
returning
Parameters:
duration - the duration in milliseconds for the animation
startingOpacity - the initial opacity to give to the animated components
animateLayoutFade
public void animateLayoutFade(int duration,
int startingOpacity)

Animates a pending layout into place, this effectively replaces revalidate with a more
visual form of animation
Parameters:
duration - the duration in milliseconds for the animation
startingOpacity - the initial opacity to give to the animated components
animateLayoutAndWait
public void animateLayoutAndWait(int duration)

Animates a pending layout into place, this effectively replaces revalidate with a more
visual form of animation. This method waits until the operation is completed before
returning
Parameters:
duration - the duration in milliseconds for the animation
animateLayout
public void animateLayout(int duration)

Animates a pending layout into place, this effectively replaces revalidate with a more
visual form of animation
See:
Form hi = new Form("Layout Animations", new BoxLayout(BoxLayout.Y_AXIS));
Button fall = new Button("Fall");
fall.addActionListener((e) -> {
for(int iter = 0 ; iter < 10 ; iter++) {
Label b = new Label ("Label " + iter);
b.setWidth(fall.getWidth());
b.setHeight(fall.getHeight());
b.setY(-fall.getHeight());
hi.add(b);
}

Method Detail

1908

Overview (Codename One API)


hi.getContentPane().animateLayout(20000);
});
hi.add(fall);

Parameters:
duration

- the duration in milliseconds for the animation

drop
public void drop(Component dragged,
int x,
int y)

Performs a drop operation of the component at the given X/Y location in coordinate
space, this method should be overriden by subclasses to perform all of the logic
related to moving a component, by default this method does nothing and so dragging
a component and dropping it has no effect
Overrides:
drop in class Component
Parameters:
dragged - the component being dropped
x - the x coordinate of the drop
y - the y coordinate of the drop
createAnimateMotion
protected Motion createAnimateMotion(int start,
int destination,
int duration)

Creates a motion object for animation, allows subclasses to replace the motion type
used in animations (currently defaults to ease-in).
Parameters:
start - start value
destination - destination value
duration - duration of animation
Returns:
motion object
morph
public void morph(Component source,
Component destination,
int duration,
Runnable onCompletion)

Morph is similar to the replace functionality where a component might be replaced


with a component that isn't within the container. However, unlike the replace
functionality which uses a transition and assumes the position of the component (and
is hence quite flexible) morph can move and resize the component. E.g. after
entering text into a text field and pressing submit it can "morph" into a chat bubble
located in a different part of the screen.
It is the responsibility of the caller to remove the source component (if desired) and
revalidate the container when the animation completes.
Parameters:
source - source component assumed to be within this container or one of its
children
destination - the destination component
duration - the time the morph operation should take
onCompletion - invoked when the morphing completes
morphAndWait
public void morphAndWait(Component source,
Component destination,
int duration)

Morph is similar to the replace functionality where a component might be replaced


with a component that isn't within the container. However, unlike the replace
functionality which uses a transition and assumes the position of the component (and
is hence quite flexible) morph can move and resize the component. E.g. after
entering text into a text field and pressing submit it can "morph" into a chat bubble
located in a different part of the screen.

Method Detail

1909

Overview (Codename One API)


It is the responsibility of the caller to remove the source component (if desired) and
revalidate the container when the animation completes.
Parameters:
source - source component assumed to be within this container or one of its
children
destination - the destination component
duration - the time the morph operation should take
animateUnlayout
public void animateUnlayout(int duration,
int opacity,
Runnable callback)

This method is the exact reverse of animateLayout, when completed it leaves the
container in an invalid state. It is useful to invoke this in order to remove a
component, transition to a different form or provide some other interaction. E.g.:
Parameters:
duration - the duration of the animation
opacity - the opacity to which the layout

will reach, allows fading out the


components
callback - if not null will be invoked when unlayouting is complete
animateUnlayoutAndWait
public void animateUnlayoutAndWait(int duration,
int opacity)

This method is the exact reverse of animateLayoutAndWait, when completed it


leaves the container in an invalid state. It is useful to invoke this in order to remove a
component, transition to a different form or provide some other interaction. E.g.:
Parameters:
duration - the duration of the animation
opacity - the opacity to which the layout

will reach, allows fading out the

components
iterator
public Iterator<Component> iterator()

Part of the Iterable interface allowing us to do a for-each loop on Container


Specified by:
iterator in interface Iterable<Component>
Returns:
the iterator of the components

Method Detail

1910

Overview (Codename One API)


com.codename1.ui

Class ComponentGroup
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.ComponentGroup
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A component group is a container that applies the given UIID to a set of components within it and
gives the same UIID with "First"/"Last" prepended to the first and last components. E.g. by default the
GroupElement UIID is applied so the first and last elements would have the
GroupElementFirst/GroupElementLast UIID's applied to them. If a group has only one element the
word "Only" is appended to the element UIID as in GroupElementOnly.
Important!!! A component group does nothing by default unless explicitly activated by the theme by
enabling the ComponentGroupBool constant (by default, this can be customized via the groupFlag
property). This allows logical grouping without changing the UI for themes that don't need grouping.
This container uses box X/Y layout (defaults to Y), other layout managers shouldn't be used since this
container relies on the specific behavior of the box layout.
Check out this sample code:
hi.add("Three Labels").
add(ComponentGroup.enclose(new
add("One Label").
add(ComponentGroup.enclose(new
add("Three Buttons").
add(ComponentGroup.enclose(new
add("One Button").
add(ComponentGroup.enclose(new

Class ComponentGroup

Label("GroupElementFirst UIID"), new Label("GroupElement UIID"), new Label("Gro


Label("GroupElementOnly UIID"))).

Button("ButtonGroupFirst UIID"), new Button("ButtonGroup UIID"), new Button("Bu


Button("ButtonGroupOnly UIID")));

1911

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ComponentGroup()

Default constructor

Method Summary
Modifier and Type

Field Summary

Method and Description

1912

Overview (Codename One API)


static
ComponentGroup
static
ComponentGroup

enclose(Component... cmp)

Shorthand method for wrapping the given components in a vertical


component group
encloseHorizontal(Component... cmp)

Shorthand method for wrapping the given components in a horizontal


component group
getElementUIID()

String

The UIID to apply to the elements within this container


getGroupFlag()

The group flag allows changing the flag that activates this group, from
ComponentGroupBool to any arbitrary flag.

String

getPropertyNames()
String[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder
code
getPropertyTypes()

Class[]

Matches the property names method (see that method for further
details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by
the GUI builder

Object

isForceGroup()
boolean

Component grouping can be an element from the theme but can be


forced manually for a specific group
isHorizontal()

boolean

Indicates that the component group should be horizontal by using the


BoxLayout Y
refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY
INVOKE THIS METHOD IF YOU CHANGED THE THEME!

void

setElementUIID(String elementUIID)

void

The UIID to apply to the elements within this container


setForceGroup(boolean forceGroup)

Component grouping can be an element from the theme but can be


forced manually for a specific group

void

setGroupFlag(String groupFlag)

The group flag allows changing the flag that activates this group, from
ComponentGroupBool to any arbitrary flag.

void

setHorizontal(boolean horizontal)

Indicates that the component group should be horizontal by using the


BoxLayout Y

void

setPropertyValue(String name, Object value)


String

Sets a new value to the given property, returns an error message if


failed and null if successful.

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, removeAll,
removeComponent, replace, replace, replaceAndWait, replaceAndWait,
replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer,

Method Summary

1913

Overview (Codename One API)


setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX,
setScrollableY, setScrollIncrement, setShouldCalcPreferredSize,
setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer,
isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion,
isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHidden,
isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed,
pointerReleased, pointerReleased, putClientProperty, refreshTheme,
refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,
setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,
setScrollY, setSelectCommandText, setSelectedStyle, setSize,
setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled,
setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX,
setY, shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ComponentGroup
public ComponentGroup()

Default constructor

Methods inherited from class com.codename1.ui.Container

1914

Overview (Codename One API)

Method Detail
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Container
Parameters:
merge - indicates if the current styles should be merged with the new styles
isHorizontal
public boolean isHorizontal()

Indicates that the component group should be horizontal by using the BoxLayout Y
Returns:
the horizontal
setHorizontal
public void setHorizontal(boolean horizontal)

Indicates that the component group should be horizontal by using the BoxLayout Y
Parameters:
horizontal - the horizontal to set
getElementUIID
public String getElementUIID()

The UIID to apply to the elements within this container


Returns:
the elementUIID
setElementUIID
public void setElementUIID(String elementUIID)

The UIID to apply to the elements within this container


Parameters:
elementUIID - the elementUIID to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:

Method Detail

1915

Overview (Codename One API)


getPropertyValue

in class Component

Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getGroupFlag
public String getGroupFlag()

The group flag allows changing the flag that activates this group, from
ComponentGroupBool to any arbitrary flag. This allows a developer/designer to
enable grouping for a specific type of components (e.g. for horizontal Toggle Buttons)
yet disable it for vertical lists of components.
Returns:
the groupFlag
setGroupFlag
public void setGroupFlag(String groupFlag)

The group flag allows changing the flag that activates this group, from
ComponentGroupBool to any arbitrary flag. This allows a developer/designer to
enable grouping for a specific type of components (e.g. for horizontal Toggle Buttons)
yet disable it for vertical lists of components.
Parameters:
groupFlag - the groupFlag to set
isForceGroup
public boolean isForceGroup()

Component grouping can be an element from the theme but can be forced manually
for a specific group
Returns:
the forceGroup
setForceGroup
public void setForceGroup(boolean forceGroup)

Component grouping can be an element from the theme but can be forced manually
for a specific group
Parameters:
forceGroup - the forceGroup to set
enclose
public static ComponentGroup enclose(Component... cmp)

Shorthand method for wrapping the given components in a vertical component group
Parameters:
cmp - the components to add into a newly created group
Returns:
the newly created group

Method Detail

1916

Overview (Codename One API)

encloseHorizontal
public static ComponentGroup encloseHorizontal(Component... cmp)

Shorthand method for wrapping the given components in a horizontal component


group
Parameters:
cmp - the components to add into a newly created group
Returns:
the newly created group

Method Detail

1917

Overview (Codename One API)


com.codename1.ui

Class Component
java.lang.Object

com.codename1.ui.Component
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
ChartComponent, Container, ImageViewer, InfiniteProgress, Label, List, PeerComponent,
TextArea

public class
extends Object
implements Animation, StyleListener

The component class is the basis of all UI widgets in Codename One, to arrange multiple components
together we use the Container class which itself "IS A" Component subclass. The Container is a
Component that contains Components effectively allowing us to nest Containers infinitely to build any
type of visual hierarchy we want by nesting Containers.
See Also:
Container

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Class Component

Field and Description


BASELINE

Alignment to the baseline constraint


BOTTOM

Box-orientation constant used to specify the bottom of a box.


BRB_CENTER_OFFSET

Baseline resize behavior constant used to properly align components.


BRB_CONSTANT_ASCENT

Baseline resize behavior constant used to properly align components.


BRB_CONSTANT_DESCENT

Baseline resize behavior constant used to properly align components.


BRB_OTHER

Baseline resize behavior constant used to properly align components.


CENTER

Indicates a Component center alignment


DRAG_REGION_LIKELY_DRAG_X

Used by getDragRegionStatus to indicate likely dragability


DRAG_REGION_LIKELY_DRAG_XY

Used by getDragRegionStatus to indicate likely dragability


DRAG_REGION_LIKELY_DRAG_Y

Used by getDragRegionStatus to indicate likely dragability


DRAG_REGION_NOT_DRAGGABLE

Used by getDragRegionStatus to indicate no dragability


DRAG_REGION_POSSIBLE_DRAG_X

Used by getDragRegionStatus to indicate limited dragability


DRAG_REGION_POSSIBLE_DRAG_XY

Used by getDragRegionStatus to indicate limited dragability


DRAG_REGION_POSSIBLE_DRAG_Y

Used by getDragRegionStatus to indicate limited dragability


LEFT

Box-orientation constant used to specify the left side of a box.

1918

Overview (Codename One API)


RIGHT

static int

Box-orientation constant used to specify the right side of a box.


TOP

static int

Box-orientation constant used to specify the top of a box.

Constructor Summary
Modifier
protected

Constructor and Description


Component()

Creates a new instance of Component

Method Summary
Modifier and Type
void
void

Method and Description


addDragOverListener(ActionListener l)

Broadcasts an event when dragging over a component


addDropListener(ActionListener l)

Binds an action listener to drop events which are invoked when this component i
addFocusListener(FocusListener l)

void

void
void
void

Registers interest in receiving callbacks for focus gained events, a focus event is
accepts the focus.
addPointerDraggedListener(ActionListener l)

Adds a listener to the pointer event


addPointerPressedListener(ActionListener l)

Adds a listener to the pointer event


addPointerReleasedListener(ActionListener l)

Adds a listener to the pointer event


addPullToRefresh(Runnable task)

void

This method adds a refresh task to the Component, the task will be executed if t
beyond a certain height.
addScrollListener(ScrollListener l)

void

boolean
void
protected
Dimension
protected
Dimension
protected void
void
boolean

Registers interest in receiving callbacks for scroll gained events, a scroll event is
is scrolled.
animate()

Allows the animation to reduce "repaint" calls when it returns false.


bindProperty(String prop, BindTarget target)

Binds the given property name to the given bind target


calcPreferredSize()

Calculates the preferred size based on component content.


calcScrollSize()

Method that can be overriden to represent the actual size of the component whe
size for the viewport
cancelRepaints()

remove this component from the painting queue


clearClientProperties()

Clears all client properties from this Component


contains(int x, int y)

Returns true if the given absolute coordinate is contained in the Component


createStyleAnimation(String destUIID, int duration)

ComponentAnimation

Creates an animation that will transform the current component to the styling of t
completed.
deinitialize()

protected void

protected void

Field Summary

Invoked to indicate that the component initialization is being reversed since the c
the container hierarchy.
deinitializeCustomStyle(Style s)

Allows components to create a style of their own, this method cleans up state for

1919

Overview (Codename One API)


protected void

dragEnter(Component dragged)

This callback method indicates that a component drag has just entered this com
dragExit(Component dragged)

protected void

protected void

This callback method provides an indication for a drop target that a drag operatio
component and it should clear all relevant state if such state exists.
dragFinished(int x, int y)

Callback indicating that the drag has finished either via drop or by releasing the c
draggingOver(Component dragged, int x, int y)

protected boolean

This method allows a component to indicate if it is a drop target for the given com
location (in component coordiate space).
dragInitiated()

protected void

Invoked on the focus component to let it know that drag has started on the paren
component that doesn't support scrolling
drawDraggedImage(Graphics g, Image img, int x, int y)

protected void

Draws the given image at x/y, this method can be overriden to draw additional in
negative drop indication
drop(Component dragged, int x, int y)

void

Performs a drop operation of the component at the given X/Y location in coordin
be overriden by subclasses to perform all of the logic related to moving a compo
does nothing and so dragging a component and dropping it has no effect
fireClicked()

protected void

protected void
protected void

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this m
devices to work properly.
focusGained()

Callback allowing a developer to track wheh the component gains focus


focusLost()

Callback allowing a developer to track wheh the component loses focus


getAbsoluteX()

int

Returns the absolute X location based on the component hierarchy, this method
screen for the component rather than a relative location as returned by getX()
getAbsoluteY()

int

Returns the absolute Y location based on the component hierarchy, this method
screen for the component rather than a relative location as returned by getX()
getAllStyles()

Style

AnimationManager

Returns a "meta style" that allows setting styles once to all the different Style obj
will be meaningless and will return 0 values.
getAnimationManager()

Returns the animation manager of the parent form or null if this component isn't
getBaseline(int width, int height)

int

int

The baseline for the component text according to which it should be aligned with
visual look.
getBaselineResizeBehavior()

Returns a constant indicating how the baseline varies with the size of the compo
getBindablePropertyNames()

String[]

Class[]

Returns the names of the properties within this component that can be bound for
names mean that the first one will be the first bound
getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
getBorder()

protected Border

int
Object

Normally returns getStyle().getBorder() but some subclasses might use this to pr


border in runtime e.g.
getBottomGap()

Returns the gap to be left for the bottom scrollbar on the X axis.
getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property

protected
Rectangle

getBounds()

Object

getClientProperty(String key)

Method Summary

Returns the component bounds which is sometimes more convenient than invok

1920

Overview (Codename One API)

Client properties allow the association of meta-data with a component, this is use
construct GUI's on the fly and need to track the connection between the UI and t
String
String
Form
Object

getCloudBoundProperty()

Indicates the property within this component that should be bound to the cloud o
getCloudDestinationProperty()

The destination property of the CloudObject


getComponentForm()

Returns the Component Form or null if this Component is not added yet to a form
getComponentState()

Some components may optionally generate a state which can then be restored u
getDirtyRegion()

Rectangle

gets the Component dirty region, this method is for internal use only and SHOUL
code.
getDisabledStyle()

Style

int
int

Returns the Component Style for the disabled state allowing us to manipulate th
its disabled
getDraggedx()

Gets the current dragged x values when the Component is being dragged
getDraggedy()

Gets the current dragged y values when the Component is being dragged
getDragImage()

protected Image

This method returns an image representing the dragged component, it can be ov


customize the look of the image, the image will be overlaid on top of the form du
getDragRegionStatus(int x, int y)

protected int

protected float

Indicates if the section within the X/Y area is a "drag region" where we expect pe
case we can instantly start dragging making perceived performance faster.
getDragSpeed(boolean vertical)

This method returns the dragging speed based on the latest dragged events
getGridPosX()

protected int

This method should be implemented correctly by subclasses to make snap to gr


expected.
getGridPosY()

protected int

int

This method should be implemented correctly by subclasses to make snap to gr


expected.
getHeight()

Returns the component height


getLabelForComponent()

Label

String
Component
Component
Component
Component
Container
int
Dimension
int
Style

Method Summary

Allows us to indicate the label associated with this component thus providing vis
component e.g.
getName()

A component name allows us to easily identify the component within a dynamic


getNextFocusDown()

Allows us to determine which component will receive focus next when traversing
getNextFocusLeft()

Allows us to determine which component will receive focus next when traversing
getNextFocusRight()

Allows us to determine which component will receive focus next when traversing
getNextFocusUp()

Allows us to determine which component will receive focus next when traversing
getParent()

Returns the container in which this component is contained


getPreferredH()

Helper method to retrieve the preferred height of the component.


getPreferredSize()

Returns the Component Preferred Size, there is no guarantee the Component w


getPreferredW()

Helper method to retrieve the preferred width of the component.


getPressedStyle()

1921

Overview (Codename One API)

Returns the Component Style for the pressed state allowing us to manipulate the
is pressed
getPropertyNames()
String[]

A component may expose mutable property names for a UI designer to manipula


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
Component[]
Component[]
Component

This method is here to workaround an XMLVM array type bug where property ty
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Obje
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI b
getSameHeight()

Returns the array of components that have an equal height


getSameWidth()

Returns the array of components that have an equal width


getScrollable()

Returns the scrollable parent of this component


getScrollAnimationSpeed()

int

Scroll animation speed in milliseconds allowing a developer to slow down or acc


mode
getScrollDimension()

Dimension

int
int

Returns the Components dimension in scrolling, this is very similar to the preferr
represents actual scrolling limits.
getScrollOpacity()

This method is used internally by the look and feel to implement the fading scroll
getScrollOpacityChangeSpeed()

Indicates the decrement units for the scroll opacity


getScrollX()

int

Indicates the X position of the scrolling, this number is relative to the component
would indicate the x position of the component.
getScrollY()

int

String

Indicates the Y position of the scrolling, this number is relative to the component
would indicate the x position of the component.
getSelectCommandText()

Allows determining the text for the select command used in the 3rd softbutton m
getSelectedRect()

Rectangle

Returns the component bounds with absolute screen coordinates, for componen
selection behavior and are not containers (currently only List) this method allows
selection itself which is useful for things such as the popup dialog and similar UI'
position of the selection externally
getSelectedStyle()

Style

int

Returns the Component Style for the selected state allowing us to manipulate th
owns focus
getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis.
getStyle()

Style

int
String
UIManager
Style

Method Summary

Returns the current Component Style allowing code to draw the current compon
getUnselected/Pressed/DisabledStyle() and not this method since it will return di
component state.
getTensileLength()

Recommended length for the tensile, -1 for default


getUIID()

Unique identifier for a component.


getUIManager()

This method should be used by the Component to retrieve the correct UIManage
getUnselectedStyle()

Returns the Component Style for the unselected mode allowing us to manipulate

1922

Overview (Codename One API)


protected
Rectangle
int
int
int

getVisibleBounds()

Returns the component bounds for scrolling which might differ from the getBoun
getWidth()

Returns the component width


getX()

Returns the current component x location relatively to its parent container


getY()

Returns the component y location relatively to its parent container


growShrink(int duration)

void

boolean
boolean
protected void

Grows or shrinks this component to its new preferred size, this method essential
preferred size has changed and creates a "growing" effect that lasts for the dura
handlesInput()

Prevents key events from being grabbed for focus traversal.


hasFocus()

Returns true if the component has focus


initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready fo
initCustomStyle(Style s)

protected void

protected void
protected void

Allows components to create a style of their own, this method binds the listener t
painter
initLaf(UIManager uim)

This method initializes the Component defaults constants


installDefaultPainter(Style s)

Allows subclasses to create their own custom style types and install the backgro
isAlwaysTensile()

boolean

boolean

Enable the tensile drag to work even when a component doesn't have a scroll sh
needs to be set to true)
isCellRenderer()

Used as an optimization to mark that this component is currently being used as a


isDragActivated()

protected boolean

Indicates whether we are in the middle of a drag operation, this method allows d
released events to know when this is a drag operation.
isDragAndDropOperation(int x, int y)

protected boolean

boolean

This method allows a developer to define only a specific portion of a component


returns true if the component is defined as "draggable"
isDraggable()

Indicates whether this component can be dragged in a drag and drop operation r
isDragRegion(int x, int y)

protected boolean

Deprecated.
replaced with getDragRegionStatus
isDropTarget()

boolean

Indicates whether this component can receive dropped components into it, notic
component or container the parents will be checked recursively to find a valid dro
isEnabled()

boolean

Indicates whether component is enabled or disabled thus allowing us to prevent


input events and indicate so visually
isFlatten()

boolean

boolean

Makes the component effectively opaque by blending the backgrounds into an im


underlying components is only drawn once when this component is repainted.
isFocusable()

Returns true if this component can receive focus and is enabled


isGrabsPointerEvents()

boolean

boolean
boolean
protected boolean

Method Summary

This property is useful for blocking in z-order touch events, sometimes we might
specific component without making it focusable.
isHidden()

Returns true if the component was explicitly hidden by the user


isHideInPortrait()

Indicates that this component and all its children should be hidden when the dev
isInClippingRegion(Graphics g)

1923

Overview (Codename One API)


isInitialized()
protected boolean

boolean
protected boolean
boolean
boolean
boolean

Indicates if the component is in the initialized state, a component is initialized wh


was invoked.
isRTL()

Is the component a bidi RTL component


isScrollable()

Indicates whether the component should/could scroll by default a component is n


isScrollableX()

Indicates whether the component should/could scroll on the X axis


isScrollableY()

Indicates whether the component should/could scroll on the Y axis


isScrollVisible()

Indicate whether this component scroll is visible


isSelectableInteraction()

protected boolean

boolean
boolean

This method allows a component to indicate that it is interested in an "implicit" se


"fire" button when 3 softbuttons are defined in a device.
isSmoothScrolling()

Indicates that scrolling through the component should work as an animation


isSnapToGrid()

Indicates whether scrolling this component should jump to a specific location in a


isStickyDrag()

protected boolean

boolean
protected boolean

Returns true if the component is interested in receiving drag/pointer release even


exceeded its boundaries.
isTactileTouch()

Indicates whether the component should "trigger" tactile touch when pressed by
isTactileTouch(int x, int y)

Elaborate components might not provide tactile feedback for all their areas (e.g.
isTensileDragEnabled()

boolean

boolean
void
void
void
protected void
protected void

Indicates whether tensile drag (dragging beyond the boundry of the component a
for this component.
isVisible()

Returns whether the component is visible or not


keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
laidOut()

This is a callback method to inform the Component when it's been laidout on the
longKeyPress(int keyCode)

If this Component is focused this method is invoked when the user presses and
longPointerPress(int x, int y)

void

If this Component is focused this method is invoked when the user presses and
Component
onScrollX(int scrollX)

protected void

This method can be overriden to receive scroll events, unlike overriding setScrol
scrolling.
onScrollY(int scrollY)

protected void

This method can be overriden to receive scroll events, unlike overriding setScrol
scrolling.
paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden by subc
drawing or invoke the UI API's to let the PLAF perform the rendering.
paintBackground(Graphics g)

protected void

void

Method Summary

This method paints the Component background, it should be overriden by subcla


background drawing.
paintBackgrounds(Graphics g)

This method paints all the parents Components Background.

1924

Overview (Codename One API)


protected void
protected void

paintBorder(Graphics g)

Draws the component border if such a border exists.


paintBorderBackground(Graphics g)

Draws the component border background if such a border exists.


paintComponent(Graphics g)

void

Paints this component as a root by going to all the parent components and settin
based on coordinates and scroll status.
paintComponent(Graphics g, boolean background)

void

Paints this component as a root by going to all the parent components and settin
based on coordinates and scroll status.
paintLock(boolean hardLock)

Image

void
protected void

This method locks the component so it will always paint the given image instead
logic.
paintLockRelease()

Releases the paint lock image to allow paint to work as usual, see paintLock(boo
paintScrollbars(Graphics g)

Paints the UI for the scrollbars on the component, this will be invoked only for sc
paintScrollbarX(Graphics g)

protected void

Paints the UI for the scrollbar on the X axis, this method allows component subc
a scrollbar
paintScrollbarY(Graphics g)

protected void

protected String

Paints the UI for the scrollbar on the Y axis, this method allows component subc
a scrollbar
paramString()

Returns a string representing the state of this component.


pinch(float scale)

protected boolean

void
void
void
void
void
void
void
void
void

Invoked by subclasses interested in handling pinch to zoom events, if true is retu


be broadcast
pointerDragged(int[] x, int[] y)

If this Component is focused, the pointer dragged event will call this method
pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerHover(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the disp
pointerHoverPressed(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the disp
pointerHoverReleased(int[] x, int[] y)

Invoked for devices where the pointer can hover without actually clicking the disp
pointerPressed(int[] x, int[] y)

If this Component is focused, the pointer pressed event will call this method
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int[] x, int[] y)

If this Component is focused, the pointer released event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
putClientProperty(String key, Object value)

void

Client properties allow the association of meta-data with a component, this is use
construct GUI's on the fly and need to track the connection between the UI and t
refreshTheme()

void

Makes sure the component is up to date with the current theme, ONLY INVOKE
CHANGED THE THEME!
refreshTheme(boolean merge)

void

protected void
void

Method Summary

Makes sure the component is up to date with the current theme, ONLY INVOKE
CHANGED THE THEME!
refreshTheme(String id, boolean merge)

Makes sure the component is up to date with the given UIID


removeDragOverListener(ActionListener l)

Removes an action listener to drag over events

1925

Overview (Codename One API)


void
void
void
void
void
void
void
void

removeDropListener(ActionListener l)

Removes an action listener to drop events which are invoked when this compon
removeFocusListener(FocusListener l)

Deregisters interest in receiving callbacks for focus gained events


removePointerDraggedListener(ActionListener l)

Removes the listener from the pointer event


removePointerPressedListener(ActionListener l)

Removes the listener from the pointer event


removePointerReleasedListener(ActionListener l)

Removes the listener from the pointer event


removeScrollListener(ScrollListener l)

Deregisters interest in receiving callbacks for scroll gained events


repaint()

Repaint this Component, the repaint call causes a callback of the paint method o
repaint(int x, int y, int w, int h)

Repaints a specific region within the component


requestFocus()

void

protected void
void
protected void

Changes the current component to the focused component, will work only for a c
parent form.
resetFocusable()

Restores the state of the focusable flag to its default state

scrollRectToVisible(int x, int y, int width, int height, Component coor

Makes sure the component is visible in the scroll if this container is scrollable
scrollRectToVisible(Rectangle rect, Component coordinateSpace)

Makes sure the component is visible in the scroll if this container is scrollable
setAlwaysTensile(boolean alwaysTensile)

void

Enable the tensile drag to work even when a component doesn't have a scroll sh
needs to be set to true)
setBoundPropertyValue(String prop, Object value)

void

void
void
void
void

Sets the value of a bound property within this component, notice that this method
change event when invoked to prevent recursion!
setCellRenderer(boolean cellRenderer)

Used as an optimization to mark that this component is currently being used as a


setCloudBoundProperty(String cloudBoundProperty)

Indicates the property within this component that should be bound to the cloud o
setCloudDestinationProperty(String cloudDestinationProperty)

The destination property of the CloudObject


setComponentState(Object state)

If getComponentState returned a value the setter can update the value and resto
setDirtyRegion(Rectangle dirty)

void

void
void

sets the Component dirty region, this method is for internal use only and SHOUL
code.
setDisabledStyle(Style style)

Changes the Component disalbed Style by replacing the Component Style with t
setDraggable(boolean draggable)

Indicates whether this component can be dragged in a drag and drop operation r
setDropTarget(boolean dropTarget)

void

Indicates whether this component can receive dropped components into it, notic
component or container the parents will be checked recursively to find a valid dro
setEnabled(boolean enabled)

void

Indicates whether component is enabled or disabled thus allowing us to prevent


input events and indicate so visually
setFlatten(boolean flatten)

void

Makes the component effectively opaque by blending the backgrounds into an im


underlying components is only drawn once when this component is repainted.
setFocus(boolean focused)

void

Method Summary

Deprecated.
this method shouldn't be invoked by user code, use requestFocus() instead

1926

Overview (Codename One API)


void

setFocusable(boolean focusable)

A simple setter to determine if this Component can get focused


setGrabsPointerEvents(boolean grabsPointerEvents)

void

void

This property is useful for blocking in z-order touch events, sometimes we might
specific component without making it focusable.
setHandlesInput(boolean handlesInput)

Prevents key events from being grabbed for focus traversal.


setHeight(int height)

void

void
void
void

Sets the Component height, this method is exposed for the purpose of external l
be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
setHidden(boolean b)

Makes the components preferred size equal 0 when hidden and restores it to the
setHidden(boolean b, boolean changeMargin)

Makes the components preferred size equal 0 when hidden and restores it to the
setHideInPortrait(boolean hideInPortrait)

Indicates that this component and all its children should be hidden when the dev
setInitialized(boolean initialized)

protected void

Indicates if the component is in the initialized state, a component is initialized wh


was invoked.
setIsScrollVisible(boolean isScrollVisible)

void

Deprecated.
replaced by setScrollVisible to match the JavaBeans spec
setLabelForComponent(Label componentLabel)

void

void
void

Allows us to indicate the label associated with this component thus providing vis
component e.g.
setName(String name)

A component name allows us to easily identify the component within a dynamic


setNextFocusDown(Component nextFocusDown)

Allows us to determine which component will receive focus next when traversing
setNextFocusLeft(Component nextFocusLeft)

void

void

Allows us to determine which component will receive focus next when traversing
doesn't affect the general focus behavior.
setNextFocusRight(Component nextFocusRight)

Allows us to determine which component will receive focus next when traversing
setNextFocusUp(Component nextFocusUp)

void

Allows us to determine which component will receive focus next when traversing
doesn't affect the general focus behavior.
setPreferredH(int preferredH)

void

Deprecated.
this method shouldn't be used, use sameWidth/Height, padding, margin or overr
similar functionality
setPreferredSize(Dimension d)

void

Deprecated.
this method shouldn't be used, use sameWidth/Height, padding, margin or overr
similar functionality
setPreferredW(int preferredW)

void

Deprecated.
this method shouldn't be used, use sameWidth/Height, padding, margin or overr
similar functionality
setPressedStyle(Style style)

void

String
void

Sets the Component Style for the pressed state allowing us to manipulate the loo
pressed
setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and nu
setRTL(boolean rtl)

Is the component a bidi RTL component


setSameHeight(Component... c)

static void

Method Summary

Places all of these components in the same height group, to remove a compone
method with that component only.

1927

Overview (Codename One API)


setSameWidth(Component... c)
static void

Places all of these components in the same width group, to remove a componen
method with that component only.
setScrollAnimationSpeed(int animationSpeed)

void

void
void
void

Scroll animation speed in milliseconds allowing a developer to slow down or acc


mode
setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)

Indicates the decrement units for the scroll opacity


setScrollSize(Dimension d)

Set the size for the scroll area


setScrollVisible(boolean isScrollVisible)

Set whether this component scroll is visible


setScrollX(int scrollX)

protected void

Indicates the X position of the scrolling, this number is relative to the component
would indicate the x position of the component.
setScrollY(int scrollY)

protected void

void
void
void

Indicates the X position of the scrolling, this number is relative to the component
would indicate the x position of the component.
setSelectCommandText(String selectText)

Allows determining the text for the select command used in the 3rd softbutton m
setSelectedStyle(Style style)

Changes the Component selected Style by replacing the Component Style with t
setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and preferred size sho
setSize(Dimension d)

void

void
void
void

Sets the Component size, this method is exposed for the purpose of external lay
be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
setSmoothScrolling(boolean smoothScrolling)

Indicates that scrolling through the component should work as an animation


setSnapToGrid(boolean snapToGrid)

Indicates whether scrolling this component should jump to a specific location in a


setTactileTouch(boolean tactileTouch)

Indicates whether the component should "trigger" tactile touch when pressed by
setTensileDragEnabled(boolean tensileDragEnabled)

void

void
void
void
void

Indicates whether tensile drag (dragging beyond the boundry of the component a
for this component.
setTensileLength(int tensileLength)

Recommended length for the tensile, -1 for default


setUIID(String id)

This method sets the Component the Unique identifier.


setUnselectedStyle(Style style)

Changes the Component Style by replacing the Component Style with the given
setVisible(boolean visible)

Toggles visibility of the component


setWidth(int width)

void

Sets the Component width, this method is exposed for the purpose of external la
be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
setX(int x)

void

Sets the Component x location relative to the parent container, this method is ex
external layout managers and should not be invoked directly.
setY(int y)

void

Sets the Component y location relative to the parent container, this method is ex
external layout managers and should not be invoked directly.
shouldBlockSideSwipe()

protected boolean

A component that might need side swipe such as the slider could block it from be
purpose when on top of said component.

void

styleChanged(String propertyName, Style source)

Method Summary

1928

Overview (Codename One API)


Invoked to indicate a change in a propertyName of a Style
toString()

String

Overriden to return a useful value for debugging purposes


unbindProperty(String prop, BindTarget target)

void

Removes a bind target from the given property name

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
DRAG_REGION_NOT_DRAGGABLE
public static final int DRAG_REGION_NOT_DRAGGABLE

Used by getDragRegionStatus to indicate no dragability


See Also:
Constant Field Values
DRAG_REGION_POSSIBLE_DRAG_X
public static final int DRAG_REGION_POSSIBLE_DRAG_X

Used by getDragRegionStatus to indicate limited dragability


See Also:
Constant Field Values
DRAG_REGION_POSSIBLE_DRAG_Y
public static final int DRAG_REGION_POSSIBLE_DRAG_Y

Used by getDragRegionStatus to indicate limited dragability


See Also:
Constant Field Values
DRAG_REGION_POSSIBLE_DRAG_XY
public static final int DRAG_REGION_POSSIBLE_DRAG_XY

Used by getDragRegionStatus to indicate limited dragability


See Also:
Constant Field Values
DRAG_REGION_LIKELY_DRAG_X
public static final int DRAG_REGION_LIKELY_DRAG_X

Used by getDragRegionStatus to indicate likely dragability


See Also:
Constant Field Values
DRAG_REGION_LIKELY_DRAG_Y
public static final int DRAG_REGION_LIKELY_DRAG_Y

Used by getDragRegionStatus to indicate likely dragability


See Also:
Constant Field Values
DRAG_REGION_LIKELY_DRAG_XY
public static final int DRAG_REGION_LIKELY_DRAG_XY

Used by getDragRegionStatus to indicate likely dragability


See Also:
Constant Field Values

Methods inherited from class java.lang.Object

1929

Overview (Codename One API)


BRB_CONSTANT_ASCENT
public static final int BRB_CONSTANT_ASCENT

Baseline resize behavior constant used to properly align components. Indicates as


the size of the component changes the baseline remains a fixed distance from the top
of the component.
See Also:
getBaselineResizeBehavior(), Constant Field Values
BRB_CONSTANT_DESCENT
public static final int BRB_CONSTANT_DESCENT

Baseline resize behavior constant used to properly align components. Indicates as


the size of the component changes the baseline remains a fixed distance from the
bottom of the component.
See Also:
getBaselineResizeBehavior(), Constant Field Values
BRB_CENTER_OFFSET
public static final int BRB_CENTER_OFFSET

Baseline resize behavior constant used to properly align components. Indicates as


the size of the component changes the baseline remains a fixed distance from the
center of the component.
See Also:
getBaselineResizeBehavior(), Constant Field Values
BRB_OTHER
public static final int BRB_OTHER

Baseline resize behavior constant used to properly align components. Indicates as


the size of the component changes the baseline can not be determined using one of
the other constants.
See Also:
getBaselineResizeBehavior(), Constant Field Values
CENTER
public static final int CENTER

Indicates a Component center alignment


See Also:
Constant Field Values
TOP
public static final int TOP

Box-orientation constant used to specify the top of a box.


See Also:
Constant Field Values
LEFT
public static final int LEFT

Box-orientation constant used to specify the left side of a box.


See Also:
Constant Field Values
BOTTOM
public static final int BOTTOM

Box-orientation constant used to specify the bottom of a box.


See Also:
Constant Field Values

Field Detail

1930

Overview (Codename One API)


RIGHT
public static final int RIGHT

Box-orientation constant used to specify the right side of a box.


See Also:
Constant Field Values
BASELINE
public static final int BASELINE

Alignment to the baseline constraint


See Also:
Constant Field Values

Constructor Detail
Component
protected Component()

Creates a new instance of Component

Method Detail
setSameWidth
public static void setSameWidth(Component... c)

Places all of these components in the same width group, to remove a component
from the group invoke this method with that component only.
Parameters:
c - the components to group together, this will override all previous width
grouping
getAllStyles
public Style getAllStyles()

Returns a "meta style" that allows setting styles once to all the different Style objects,
the getters for this style will be meaningless and will return 0 values. Usage:
Painter p = new Painter(cmp) {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
int r = Math.min(rect.getWidth(), rect.getHeight())/2;
int x = rect.getX() + rect.getWidth()/2 - r;
int y = rect.getY() + rect.getHeight()/2 - r;
switch (style) {
case CircleButtonStrokedDark:
case CircleButtonStrokedLight: {
if (cmp.getStyle().getBgTransparency() != 0) {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha <0) {
alpha = 0xff;
}
g.setColor(cmp.getStyle().getBgColor());
g.setAlpha(alpha);
g.fillArc(x, y, 2*r-1, 2*r-1, 0, 360);
g.setAlpha(0xff);
}
g.setColor(cmp.getStyle().getFgColor());
g.drawArc(x, y, 2*r-1, 2*r-1, 0, 360);
break;
}
case CircleButtonFilledDark:
case CircleButtonFilledLight:
case CircleButtonTransparentDark:
case CircleButtonTransparentLight: {
int alpha = cmp.getStyle().getBgTransparency();
if (alpha < 0) {
alpha = 0xff;
}
g.setAlpha(alpha);

Field Detail

1931

Overview (Codename One API)


g.setColor(cmp.getStyle().getBgColor());
g.fillArc(x, y, 2*r, 2*r, 0, 360);
g.setAlpha(0xff);
break;
}
}
g.setAntiAliased(antiAliased);
}
};
cmp.getAllStyles().setBgPainter(p);

Returns:
a unified style object for the purpose of setting on object object instances
getSameWidth
public Component[] getSameWidth()

Returns the array of components that have an equal width


Returns:
components in the same width group
setSameHeight
public static void setSameHeight(Component... c)

Places all of these components in the same height group, to remove a component
from the group invoke this method with that component only.
Parameters:
c - the components to group together, this will override all previous height
grouping
getSameHeight
public Component[] getSameHeight()

Returns the array of components that have an equal height


Returns:
components in the same height group
initLaf
protected void initLaf(UIManager uim)

This method initializes the Component defaults constants


getUIManager
public UIManager getUIManager()

This method should be used by the Component to retrieve the correct UIManager to
work with
Returns:
a UIManager instance
getX
public int getX()

Returns the current component x location relatively to its parent container


Returns:
the current x coordinate of the components origin
getY
public int getY()

Returns the component y location relatively to its parent container


Returns:
the current y coordinate of the components origin
isVisible
public boolean isVisible()

Returns whether the component is visible or not


Returns:

Method Detail

1932

Overview (Codename One API)


true if component is visible; otherwise false
getClientProperty
public Object getClientProperty(String key)

Client properties allow the association of meta-data with a component, this is useful
for some applications that construct GUI's on the fly and need to track the connection
between the UI and the data.
Parameters:
key - the key used for putClientProperty
Returns:
the value set to putClientProperty or null if no value is set to the property
clearClientProperties
public void clearClientProperties()

Clears all client properties from this Component


putClientProperty
public void putClientProperty(String key,
Object value)

Client properties allow the association of meta-data with a component, this is useful
for some applications that construct GUI's on the fly and need to track the connection
between the UI and the data. Setting the value to null will remove the client property
from the component.
Parameters:
key - arbitrary key for the property
value - the value assigned to the given client property
getDirtyRegion
public final Rectangle getDirtyRegion()

gets the Component dirty region, this method is for internal use only and SHOULD
NOT be invoked by user code. Use repaint(int,int,int,int)
Returns:
returns the region that needs repainting or null for the whole component
setDirtyRegion
public final void setDirtyRegion(Rectangle dirty)

sets the Component dirty region, this method is for internal use only and SHOULD
NOT be invoked by user code. Use repaint(int,int,int,int)
Parameters:
dirty - the region that needs repainting or null for the whole component
setVisible
public void setVisible(boolean visible)

Toggles visibility of the component


Parameters:
visible - true if component is visible; otherwise false
getWidth
public int getWidth()

Returns the component width


Returns:
the component width
getHeight
public int getHeight()

Returns the component height


Returns:
the component height

Method Detail

1933

Overview (Codename One API)


setX
public void setX(int x)

Sets the Component x location relative to the parent container, this method is
exposed for the purpose of external layout managers and should not be invoked
directly.
Parameters:
x - the current x coordinate of the components origin
setY
public void setY(int y)

Sets the Component y location relative to the parent container, this method is
exposed for the purpose of external layout managers and should not be invoked
directly.
Parameters:
y - the current y coordinate of the components origin
isDragRegion
protected boolean isDragRegion(int x,
int y)

Deprecated. replaced with getDragRegionStatus


Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag and never actually "press" in which case we can instantly start dragging
making perceived performance faster. This is invoked by the implementation code to
optimize drag start behavior
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
true if the touch is in a region specifically designated as a "drag region"
getDragRegionStatus
protected int getDragRegionStatus(int x,
int y)

Indicates if the section within the X/Y area is a "drag region" where we expect people
to drag or press in which case we can instantly start dragging making perceived
performance faster. This is invoked by the implementation code to optimize drag start
behavior
Parameters:
x - x location for the touch
y - y location for the touch
Returns:
one of the DRAG_REGION_* values
getBaseline
public int getBaseline(int width,
int height)

The baseline for the component text according to which it should be aligned with
other components for best visual look.
Parameters:
width - the component width
height - the component height
Returns:
baseline value from the top of the component
getBaselineResizeBehavior
public int getBaselineResizeBehavior()

Returns a constant indicating how the baseline varies with the size of the component.
Returns:
one of BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT,
BRB_CENTER_OFFSET or BRB_OTHER

Method Detail

1934

Overview (Codename One API)


setPreferredSize
public void setPreferredSize(Dimension d)

Deprecated. this method shouldn't be used, use sameWidth/Height, padding, margin


or override calcPeferredSize to reach similar functionality
Sets the Component Preferred Size, there is no guarantee the Component will be
sized at its Preferred Size. The final size of the component may be smaller than its
preferred size or even larger than the size.
The Layout manager can take this value into consideration, but there is no guarantee
or requirement.
Parameters:
d - the component dimension
getPreferredSize
public Dimension getPreferredSize()

Returns the Component Preferred Size, there is no guarantee the Component will be
sized at its Preferred Size. The final size of the component may be smaller than its
preferred size or even larger than the size.
The Layout manager can take this value into consideration, but there is no guarantee
or requirement.
Returns:
the component preferred size
getScrollDimension
public Dimension getScrollDimension()

Returns the Components dimension in scrolling, this is very similar to the preferred
size aspect only it represents actual scrolling limits.
Returns:
the component actual size with all scrolling
calcScrollSize
protected Dimension calcScrollSize()

Method that can be overriden to represent the actual size of the component when it
differs from the desireable size for the viewport
Returns:
scroll size, by default this is the same as the preferred size
setScrollSize
public void setScrollSize(Dimension d)

Set the size for the scroll area


Parameters:
d - dimension of the scroll area
setPreferredW
public void setPreferredW(int preferredW)

Deprecated. this method shouldn't be used, use sameWidth/Height, padding, margin


or override calcPeferredSize to reach similar functionality
Helper method to set the preferred width of the component.
Parameters:
preferredW - the preferred width of the component
See Also:
setPreferredSize(com.codename1.ui.geom.Dimension)

setPreferredH
public void setPreferredH(int preferredH)

Deprecated. this method shouldn't be used, use sameWidth/Height, padding, margin


or override calcPeferredSize to reach similar functionality
Helper method to set the preferred height of the component.
Parameters:
preferredH - the preferred height of the component

Method Detail

1935

Overview (Codename One API)


See Also:
setPreferredSize(com.codename1.ui.geom.Dimension)

getPreferredW
public int getPreferredW()

Helper method to retrieve the preferred width of the component.


Returns:
preferred width of the component
See Also:
getPreferredSize()

getPreferredH
public int getPreferredH()

Helper method to retrieve the preferred height of the component.


Returns:
preferred height of the component
See Also:
getPreferredSize()

setWidth
public void setWidth(int width)

Sets the Component width, this method is exposed for the purpose of external layout
managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
Parameters:
width - the width of the component
See Also:
setPreferredSize(com.codename1.ui.geom.Dimension)

setHeight
public void setHeight(int height)

Sets the Component height, this method is exposed for the purpose of external layout
managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
Parameters:
height - the height of the component
See Also:
setPreferredSize(com.codename1.ui.geom.Dimension)

setSize
public void setSize(Dimension d)

Sets the Component size, this method is exposed for the purpose of external layout
managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
Parameters:
d - the component dimension
See Also:
setPreferredSize(com.codename1.ui.geom.Dimension)

getUIID
public String getUIID()

Unique identifier for a component. This id is used to retrieve a suitable Style.


Returns:
unique string identifying this component for the style sheet
setUIID
public void setUIID(String id)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized
Parameters:
id - UIID unique identifier for component type

Method Detail

1936

Overview (Codename One API)


getParent
public Container getParent()

Returns the container in which this component is contained


Returns:
the parent container in which this component is contained
addFocusListener
public void addFocusListener(FocusListener l)

Registers interest in receiving callbacks for focus gained events, a focus event is
invoked when the component accepts the focus. A special case exists for the Form
which sends a focus even for every selection within the form.
Parameters:
l - listener interface implementing the observable pattern
removeFocusListener
public void removeFocusListener(FocusListener l)

Deregisters interest in receiving callbacks for focus gained events


Parameters:
l - listener interface implementing the observable pattern
addScrollListener
public void addScrollListener(ScrollListener l)

Registers interest in receiving callbacks for scroll gained events, a scroll event is
invoked when the component is scrolled.
Parameters:
l - listener interface implementing the observable pattern
removeScrollListener
public void removeScrollListener(ScrollListener l)

Deregisters interest in receiving callbacks for scroll gained events


Parameters:
l - listener interface implementing the observable pattern
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Returns:
true if this is a selectable interaction
setSelectCommandText
public void setSelectCommandText(String selectText)

Allows determining the text for the select command used in the 3rd softbutton mode.
Parameters:
selectText - text for the interaction with the softkey
getSelectCommandText
public String getSelectCommandText()

Allows determining the text for the select command used in the 3rd softbutton mode.
Returns:

Method Detail

1937

Overview (Codename One API)


text for the interaction with the softkey
setLabelForComponent
public void setLabelForComponent(Label componentLabel)

Allows us to indicate the label associated with this component thus providing visual
feedback related for this component e.g. starting the ticker when the component
receives focus.
Parameters:
componentLabel - a label associated with this component
getLabelForComponent
public Label getLabelForComponent()

Allows us to indicate the label associated with this component thus providing visual
feedback related for this component e.g. starting the ticker when the component
receives focus.
Returns:
the label associated with this component
focusGained
protected void focusGained()

Callback allowing a developer to track wheh the component gains focus


focusLost
protected void focusLost()

Callback allowing a developer to track wheh the component loses focus


paintBackgrounds
public void paintBackgrounds(Graphics g)

This method paints all the parents Components Background.


Parameters:
g - the graphics object
getAbsoluteX
public int getAbsoluteX()

Returns the absolute X location based on the component hierarchy, this method
calculates a location on the screen for the component rather than a relative location
as returned by getX()
Returns:
the absolute x location of the component
See Also:
getX()

getAbsoluteY
public int getAbsoluteY()

Returns the absolute Y location based on the component hierarchy, this method
calculates a location on the screen for the component rather than a relative location
as returned by getX()
Returns:
the absolute y location of the component
See Also:
getY()

isInClippingRegion
protected boolean isInClippingRegion(Graphics g)

paintScrollbars
protected void paintScrollbars(Graphics g)

Paints the UI for the scrollbars on the component, this will be invoked only for
scrollable components. This method invokes the appropriate X/Y versions to do all

Method Detail

1938

Overview (Codename One API)


the work.
Parameters:
g - the component graphics
paintScrollbarX
protected void paintScrollbarX(Graphics g)

Paints the UI for the scrollbar on the X axis, this method allows component
subclasses to customize the look of a scrollbar
Parameters:
g - the component graphics
getScrollOpacity
public int getScrollOpacity()

This method is used internally by the look and feel to implement the fading scrollbar
behavior.
Returns:
the opacity of the scrollbar
getSelectedRect
public Rectangle getSelectedRect()

Returns the component bounds with absolute screen coordinates, for components
that include an internal selection behavior and are not containers (currently only List)
this method allows returning the position of the selection itself which is useful for
things such as the popup dialog and similar UI's that need to reference the position of
the selection externally
Returns:
the bounds of the component with absolute screen coordinates
paintScrollbarY
protected void paintScrollbarY(Graphics g)

Paints the UI for the scrollbar on the Y axis, this method allows component
subclasses to customize the look of a scrollbar
Parameters:
g - the component graphics
paintComponent
public final void paintComponent(Graphics g)

Paints this component as a root by going to all the parent components and setting the
absolute translation based on coordinates and scroll status. Restores translation
when the painting is finished.
One of the uses of this method is to create a "screenshot" as is demonstrated in the
code below that creates an image for sharing on social media
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");

Parameters:
g - the graphics to paint this Component on

Method Detail

1939

Overview (Codename One API)


paintComponent
public final void paintComponent(Graphics g,
boolean background)

Paints this component as a root by going to all the parent components and setting the
absolute translation based on coordinates and scroll status. Restores translation
when the painting is finished.
One of the uses of this method is to create a "screenshot" as is demonstrated in the
code below that creates an image for sharing on social media
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");

Parameters:
g - the graphics to paint this Component on
background - if true paints all parents background
getBorder
protected Border getBorder()

Normally returns getStyle().getBorder() but some subclasses might use this to


programmatically replace the border in runtime e.g. for a pressed border effect
Returns:
the border that is drawn according to the current component state
getScrollable
public Component getScrollable()

Returns the scrollable parent of this component


Returns:
the component itself or its parent which is scrollable
paintBackground
protected void paintBackground(Graphics g)

This method paints the Component background, it should be overriden by subclasses


to perform custom background drawing.
Parameters:
g - the component graphics
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Parameters:
g - the component graphics
isScrollable
protected boolean isScrollable()

Indicates whether the component should/could scroll by default a component is not


scrollable.

Method Detail

1940

Overview (Codename One API)


Returns:
whether the component is scrollable
isScrollableX
public boolean isScrollableX()

Indicates whether the component should/could scroll on the X axis


Returns:
whether the component is scrollable on the X axis
isScrollableY
public boolean isScrollableY()

Indicates whether the component should/could scroll on the Y axis


Returns:
whether the component is scrollable on the X axis
getScrollX
public int getScrollX()

Indicates the X position of the scrolling, this number is relative to the component
position and so a position of 0 would indicate the x position of the component.
Returns:
the X position of the scrolling
getScrollY
public int getScrollY()

Indicates the Y position of the scrolling, this number is relative to the component
position and so a position of 0 would indicate the x position of the component.
Returns:
the Y position of the scrolling
onScrollX
protected void onScrollX(int scrollX)

This method can be overriden to receive scroll events, unlike overriding setScrollX it
will receive all calls for scrolling. Normally you should not override this method and try
to find a more creative solution since scrolling is very specific to platform behavior.
Parameters:
scrollX - the X position of the scrolling
onScrollY
protected void onScrollY(int scrollY)

This method can be overriden to receive scroll events, unlike overriding setScrollY it
will receive all calls for scrolling. Normally you should not override this method and try
to find a more creative solution since scrolling is very specific to platform behavior.
Parameters:
scrollY - the Y position of the scrolling
setScrollX
protected void setScrollX(int scrollX)

Indicates the X position of the scrolling, this number is relative to the component
position and so a position of 0 would indicate the x position of the component.
Parameters:
scrollX - the X position of the scrolling
setScrollY
protected void setScrollY(int scrollY)

Indicates the X position of the scrolling, this number is relative to the component
position and so a position of 0 would indicate the x position of the component.
Parameters:
scrollY - the Y position of the scrolling

Method Detail

1941

Overview (Codename One API)


getDraggedx
public int getDraggedx()

Gets the current dragged x values when the Component is being dragged
Returns:
dragged x value
getDraggedy
public int getDraggedy()

Gets the current dragged y values when the Component is being dragged
Returns:
dragged y value
getBottomGap
public int getBottomGap()

Returns the gap to be left for the bottom scrollbar on the X axis. This method is used
by layout managers to determine the room they should leave for the scrollbar
Returns:
the gap to be left for the bottom scrollbar on the X axis
getSideGap
public int getSideGap()

Returns the gap to be left for the side scrollbar on the Y axis. This method is used by
layout managers to determine the room they should leave for the scrollbar. (note:
side scrollbar rather than left scrollbar is used for a future version that would support
bidi).
Returns:
the gap to be left for the side scrollbar on the Y axis
contains
public boolean contains(int x,
int y)

Returns true if the given absolute coordinate is contained in the Component


Parameters:
x - the given absolute x coordinate
y - the given absolute y coordinate
Returns:
true if the given absolute coordinate is contained in the Component;
otherwise false
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Returns:
the calculated preferred size based on component content
getBounds
protected Rectangle getBounds()

Returns the component bounds which is sometimes more convenient than invoking
getX/Y/Width/Height. Bounds are relative to parent container.
Changing values within the bounds can lead to unpredicted behavior.
Returns:
the component bounds
See Also:
getX(), getY()

Method Detail

1942

Overview (Codename One API)


getVisibleBounds
protected Rectangle getVisibleBounds()

Returns the component bounds for scrolling which might differ from the getBounds for
large components e.g. list.
Returns:
the component bounds
See Also:
getX(), getY()
isFocusable
public boolean isFocusable()

Returns true if this component can receive focus and is enabled


Returns:
true if this component can receive focus; otherwise false
resetFocusable
protected void resetFocusable()

Restores the state of the focusable flag to its default state


setFocusable
public void setFocusable(boolean focusable)

A simple setter to determine if this Component can get focused


Parameters:
focusable - indicate whether this component can get focused
setShouldCalcPreferredSize
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize)

Indicates the values within the component have changed and preferred size should
be recalculated
Parameters:
shouldCalcPreferredSize - indicate whether this component need to
recalculate his preferred size
handlesInput
public boolean handlesInput()

Prevents key events from being grabbed for focus traversal. E.g. a list component
might use the arrow keys for internal navigation so it will switch this flag to true in
order to prevent the focus manager from moving to the next component.
Returns:
true if key events are being used for focus traversal ; otherwise false
setHandlesInput
public void setHandlesInput(boolean handlesInput)

Prevents key events from being grabbed for focus traversal. E.g. a list component
might use the arrow keys for internal navigation so it will switch this flag to true in
order to prevent the focus manager from moving to the next component.
Parameters:
handlesInput - indicates whether key events can be grabbed for focus
traversal
hasFocus
public boolean hasFocus()

Returns true if the component has focus


Returns:
true if the component has focus; otherwise false
See Also:
requestFocus()

Method Detail

1943

Overview (Codename One API)


setFocus
public void setFocus(boolean focused)

Deprecated. this method shouldn't be invoked by user code, use requestFocus()


instead
This flag doesn't really give focus, its a state that determines what colors from the
Style should be used when painting the component. Actual focus is determined by
the parent form
Parameters:
focused - sets the state that determines what colors from the Style should be
used when painting a focused component
See Also:
requestFocus()

getComponentForm
public Form getComponentForm()

Returns the Component Form or null if this Component is not added yet to a form
Returns:
the Component Form
repaint
public void repaint()

Repaint this Component, the repaint call causes a callback of the paint method on the
event dispatch thread.
See Also:
Display

repaint
public void repaint(int
int
int
int

x,
y,
w,
h)

Repaints a specific region within the component


Parameters:
x - boundary of the region to repaint in absolute screen coordinates not
component coordinates
y - boundary of the region to repaint in absolute screen coordinates not
component coordinates
w - boundary of the region to repaint
h - boundary of the region to repaint
longKeyPress
protected void longKeyPress(int keyCode)

If this Component is focused this method is invoked when the user presses and holds
the key
Parameters:
keyCode - the key code value to indicate a physical key.
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Parameters:
keyCode - the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

1944

Overview (Codename One API)


keyRepeated
public void keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
Parameters:
keyCode - the key code value to indicate a physical key.
getAnimationManager
public AnimationManager getAnimationManager()

Returns the animation manager of the parent form or null if this component isn't
currently associated with a form
Returns:
the animation manager instance
getScrollAnimationSpeed
public int getScrollAnimationSpeed()

Scroll animation speed in milliseconds allowing a developer to slow down or


accelerate the smooth animation mode
Returns:
scroll animation speed in milliseconds
createStyleAnimation
public ComponentAnimation createStyleAnimation(String destUIID,
int duration)

Creates an animation that will transform the current component to the styling of the
destination UIID when completed. Notice that fonts will only animate within the
truetype and native familiy and we recommend that you don't shift
weight/typeface/style as this might diminish the effect.
Important: Only unselected styles are animated but once the animation completes all
styles are applied.
Parameters:
destUIID - the UIID to which this component will gradually shift
duration - the duration of the animation or the number of steps
Returns:
an animation component that can either be stepped or played
setScrollAnimationSpeed
public void setScrollAnimationSpeed(int animationSpeed)

Scroll animation speed in milliseconds allowing a developer to slow down or


accelerate the smooth animation mode
Parameters:
animationSpeed - scroll animation speed in milliseconds
isSmoothScrolling
public boolean isSmoothScrolling()

Indicates that scrolling through the component should work as an animation


Returns:
whether this component use smooth scrolling
setSmoothScrolling
public void setSmoothScrolling(boolean smoothScrolling)

Indicates that scrolling through the component should work as an animation


Parameters:
smoothScrolling - indicates if a component uses smooth scrolling
pointerHover
public void pointerHover(int[] x,
int[] y)

Method Detail

1945

Overview (Codename One API)


Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverPressed
public void pointerHoverPressed(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pinch
protected boolean pinch(float scale)

Invoked by subclasses interested in handling pinch to zoom events, if true is returned


other drag events will not be broadcast
Parameters:
scale - the scaling of the pinch operation a number larger than 1 means
scaling up and smaller than 1 means scaling down. It is recommended that
code would threshold the number (so a change between 1.0 and 1.02
shouldn't necessarily trigger zoom). Notice that this number is relevant to
current zoom levels and unaware of them so you should also enforce limits of
maximum/minimum zoom levels.
Returns:
false by default
pointerDragged
public void pointerDragged(int[] x,
int[] y)

If this Component is focused, the pointer dragged event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
getDragImage
protected Image getDragImage()

This method returns an image representing the dragged component, it can be


overriden by subclasses to customize the look of the image, the image will be
overlaid on top of the form during a drag and drop operation
Returns:
an image
dragInitiated
protected void dragInitiated()

Invoked on the focus component to let it know that drag has started on the parent
container for the case of a component that doesn't support scrolling

Method Detail

1946

Overview (Codename One API)


drawDraggedImage
protected void drawDraggedImage(Graphics g,
Image img,
int x,
int y)

Draws the given image at x/y, this method can be overriden to draw additional
information such as positive or negative drop indication
Parameters:
g - the graphics context
img - the image
x - x position
y - y position
draggingOver
protected boolean draggingOver(Component dragged,
int x,
int y)

This method allows a component to indicate if it is a drop target for the given
component at the given x/y location (in component coordiate space). This method
can also update the drop tagets appearance to indicate the drop location.
Parameters:
dragged - the component being dragged
x - the x location over the component
y - the y location over the component
Returns:
true if a drop at this location will be successful
dragEnter
protected void dragEnter(Component dragged)

This callback method indicates that a component drag has just entered this
component
Parameters:
dragged - the component being dragged
dragExit
protected void dragExit(Component dragged)

This callback method provides an indication for a drop target that a drag operation is
exiting the bounds of this component and it should clear all relevant state if such state
exists. E.g. if a component provides drop indication visuaization in draggingOver this
visualization should be cleared..
Parameters:
dragged - the component being dragged
drop
public void drop(Component dragged,
int x,
int y)

Performs a drop operation of the component at the given X/Y location in coordinate
space, this method should be overriden by subclasses to perform all of the logic
related to moving a component, by default this method does nothing and so dragging
a component and dropping it has no effect
Parameters:
dragged - the component being dropped
x - the x coordinate of the drop
y - the y coordinate of the drop
addPullToRefresh
public void addPullToRefresh(Runnable task)

This method adds a refresh task to the Component, the task will be executed if the
user has pulled the scroll beyond a certain height.
Parameters:

Method Detail

1947

Overview (Codename One API)


task - the refresh task to execute.
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
isStickyDrag
protected boolean isStickyDrag()

Returns true if the component is interested in receiving drag/pointer release events


even after the gesture exceeded its boundaries. This is useful for spinners etc. where
the motion might continue beyond the size of the component
Returns:
false by default
pointerPressed
public void pointerPressed(int[] x,
int[] y)

If this Component is focused, the pointer pressed event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
isDragAndDropOperation
protected boolean isDragAndDropOperation(int x,
int y)

This method allows a developer to define only a specific portion of a component as


draggable by default it returns true if the component is defined as "draggable"
Parameters:
x - the x coordinate relative to the component
y - the y coordinate relative to the component
Returns:
true if a press in this point might indicate the desire to begin a drag operation
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int[] x,
int[] y)

If this Component is focused, the pointer released event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
longPointerPress
public void longPointerPress(int x,
int y)

If this Component is focused this method is invoked when the user presses and holds
the pointer on the Component

Method Detail

1948

Overview (Codename One API)


pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
setTensileDragEnabled
public void setTensileDragEnabled(boolean tensileDragEnabled)

Indicates whether tensile drag (dragging beyond the boundry of the component and
snapping back) is enabled for this component.
Parameters:
tensileDragEnabled - true to enable tensile drag
isTensileDragEnabled
public boolean isTensileDragEnabled()

Indicates whether tensile drag (dragging beyond the boundry of the component and
snapping back) is enabled for this component.
Returns:
true when tensile drag is enabled
addDropListener
public void addDropListener(ActionListener l)

Binds an action listener to drop events which are invoked when this component is
dropped on a target
Parameters:
l - the callback
removeDropListener
public void removeDropListener(ActionListener l)

Removes an action listener to drop events which are invoked when this component is
dropped on a target
Parameters:
l - the callback
addDragOverListener
public void addDragOverListener(ActionListener l)

Broadcasts an event when dragging over a component


Parameters:
l - the listener
removeDragOverListener
public void removeDragOverListener(ActionListener l)

Removes an action listener to drag over events


Parameters:
l - the callback
dragFinished
protected void dragFinished(int x,
int y)

Callback indicating that the drag has finished either via drop or by releasing the
component
Parameters:
x - the x location
y - the y location

Method Detail

1949

Overview (Codename One API)


addPointerPressedListener
public void addPointerPressedListener(ActionListener l)

Adds a listener to the pointer event


Parameters:
l - callback to receive pointer events
removePointerPressedListener
public void removePointerPressedListener(ActionListener l)

Removes the listener from the pointer event


Parameters:
l - callback to remove
addPointerReleasedListener
public void addPointerReleasedListener(ActionListener l)

Adds a listener to the pointer event


Parameters:
l - callback to receive pointer events
removePointerReleasedListener
public void removePointerReleasedListener(ActionListener l)

Removes the listener from the pointer event


Parameters:
l - callback to remove
addPointerDraggedListener
public void addPointerDraggedListener(ActionListener l)

Adds a listener to the pointer event


Parameters:
l - callback to receive pointer events
removePointerDraggedListener
public void removePointerDraggedListener(ActionListener l)

Removes the listener from the pointer event


Parameters:
l - callback to remove
getDragSpeed
protected float getDragSpeed(boolean vertical)

This method returns the dragging speed based on the latest dragged events
Parameters:
vertical - indicates what axis speed is required
Returns:
the dragging speed
getStyle
public Style getStyle()

Returns the current Component Style allowing code to draw the current component,
you should normally use getUnselected/Pressed/DisabledStyle() and not this method
since it will return different values based on component state.
Returns:
the component Style object
getPressedStyle
public Style getPressedStyle()

Returns the Component Style for the pressed state allowing us to manipulate the look
of the component when it is pressed
Returns:

Method Detail

1950

Overview (Codename One API)


the component Style object
setPressedStyle
public void setPressedStyle(Style style)

Sets the Component Style for the pressed state allowing us to manipulate the look of
the component when it is pressed
Parameters:
style - the component Style object
getUnselectedStyle
public Style getUnselectedStyle()

Returns the Component Style for the unselected mode allowing us to manipulate the
look of the component
Returns:
the component Style object
getSelectedStyle
public Style getSelectedStyle()

Returns the Component Style for the selected state allowing us to manipulate the
look of the component when it owns focus
Returns:
the component Style object
getDisabledStyle
public Style getDisabledStyle()

Returns the Component Style for the disabled state allowing us to manipulate the
look of the component when its disabled
Returns:
the component Style object
setUnselectedStyle
public void setUnselectedStyle(Style style)

Changes the Component Style by replacing the Component Style with the given Style
Parameters:
style - the component Style object
setSelectedStyle
public void setSelectedStyle(Style style)

Changes the Component selected Style by replacing the Component Style with the
given Style
Parameters:
style - the component Style object
setDisabledStyle
public void setDisabledStyle(Style style)

Changes the Component disalbed Style by replacing the Component Style with the
given Style
Parameters:
style - the component Style object
installDefaultPainter
protected void installDefaultPainter(Style s)

Allows subclasses to create their own custom style types and install the background
painter into them
Parameters:
s - the custom style

Method Detail

1951

Overview (Codename One API)


requestFocus
public void requestFocus()

Changes the current component to the focused component, will work only for a
component that belongs to a parent form.
toString
public String toString()

Overriden to return a useful value for debugging purposes


Overrides:
toString in class Object
Returns:
a string representation of this component
paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Returns:
a string representation of this component's state
refreshTheme
public void refreshTheme()

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Parameters:
merge - indicates if the current styles should be merged with the new styles
refreshTheme
protected void refreshTheme(String id,
boolean merge)

Makes sure the component is up to date with the given UIID


Parameters:
id - The Style Id to update the Component with
merge - indicates if the current styles should be merged with the new styles
isDragActivated
protected boolean isDragActivated()

Indicates whether we are in the middle of a drag operation, this method allows
developers overriding the pointer released events to know when this is a drag
operation.
Returns:
true if we are in the middle of a drag; otherwise false
getGridPosY
protected int getGridPosY()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid Y position closest to the current
Y position.
Returns:
a valid Y position in the grid

Method Detail

1952

Overview (Codename One API)


getGridPosX
protected int getGridPosX()

This method should be implemented correctly by subclasses to make snap to grid


functionality work as expected. Returns the ideal grid X position closest to the current
X position.
Returns:
a valid Y position in the grid
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Returns:
true if a repaint is desired or false if no repaint is necessary
scrollRectToVisible
protected void scrollRectToVisible(Rectangle rect,
Component coordinateSpace)

Makes sure the component is visible in the scroll if this container is scrollable
Parameters:
rect - the rectangle that need to be visible
coordinateSpace - the component according to whose coordinates rect is
defined. Rect's x/y are relative to that component (they are not absolute).
scrollRectToVisible
public void scrollRectToVisible(int x,
int y,
int width,
int height,
Component coordinateSpace)

Makes sure the component is visible in the scroll if this container is scrollable
Parameters:
xywidth height coordinateSpace - the component according to whose coordinates rect is
defined. Rect's x/y are relative to that component (they are not absolute).
paintBorder
protected void paintBorder(Graphics g)

Draws the component border if such a border exists. The border unlike the content of
the component will not be affected by scrolling for a scrollable component.
Parameters:
g - graphics context on which the border is painted
paintBorderBackground
protected void paintBorderBackground(Graphics g)

Draws the component border background if such a border exists.


Parameters:
g - graphics context on which the border is painted
setCellRenderer
public void setCellRenderer(boolean cellRenderer)

Used as an optimization to mark that this component is currently being used as a cell
renderer
Parameters:

Method Detail

1953

Overview (Codename One API)


cellRenderer

- indicate whether this component is currently being used as a

cell renderer
isCellRenderer
public boolean isCellRenderer()

Used as an optimization to mark that this component is currently being used as a cell
renderer
Returns:
true is this component is currently being used as a cell renderer
isScrollVisible
public boolean isScrollVisible()

Indicate whether this component scroll is visible


Returns:
true is this component scroll is visible; otherwise false
setScrollVisible
public void setScrollVisible(boolean isScrollVisible)

Set whether this component scroll is visible


Parameters:
isScrollVisible - Indicate whether this component scroll is visible
setIsScrollVisible
public void setIsScrollVisible(boolean isScrollVisible)

Deprecated. replaced by setScrollVisible to match the JavaBeans spec


Set whether this component scroll is visible
Parameters:
isScrollVisible - Indicate whether this component scroll is visible
laidOut
protected void laidOut()

This is a callback method to inform the Component when it's been laidout on the
parent Container
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
isInitialized
protected boolean isInitialized()

Indicates if the component is in the initialized state, a component is initialized when


its initComponent() method was invoked. The initMethod is invoked before showing
the component to the user.
Returns:
true if the component is in the initialized state
setInitialized
protected void setInitialized(boolean initialized)

Indicates if the component is in the initialized state, a component is initialized when


its initComponent() method was invoked. The initMethod is invoked before showing

Method Detail

1954

Overview (Codename One API)


the component to the user.
Parameters:
initialized - Indicates if the component is in the initialized state
styleChanged
public void styleChanged(String propertyName,
Style source)

Invoked to indicate a change in a propertyName of a Style


Specified by:
styleChanged in interface StyleListener
Parameters:
propertyName - the property name that was changed
source - The changed Style object
getNextFocusDown
public Component getNextFocusDown()

Allows us to determine which component will receive focus next when traversing with
the down key
Returns:
the next focus component
setNextFocusDown
public void setNextFocusDown(Component nextFocusDown)

Allows us to determine which component will receive focus next when traversing with
the down key
Parameters:
nextFocusDown - the next focus component
getNextFocusUp
public Component getNextFocusUp()

Allows us to determine which component will receive focus next when traversing with
the up key.
Returns:
the nxt focus component
setNextFocusUp
public void setNextFocusUp(Component nextFocusUp)

Allows us to determine which component will receive focus next when traversing with
the up key, this method doesn't affect the general focus behavior.
Parameters:
nextFocusUp - next focus component
getNextFocusLeft
public Component getNextFocusLeft()

Allows us to determine which component will receive focus next when traversing with
the left key.
Returns:
the next focus component
setNextFocusLeft
public void setNextFocusLeft(Component nextFocusLeft)

Allows us to determine which component will receive focus next when traversing with
the left key, this method doesn't affect the general focus behavior.
Parameters:
nextFocusLeft - the next focus component
getNextFocusRight
public Component getNextFocusRight()

Method Detail

1955

Overview (Codename One API)


Allows us to determine which component will receive focus next when traversing with
the right key
Returns:
the next focus component
setNextFocusRight
public void setNextFocusRight(Component nextFocusRight)

Allows us to determine which component will receive focus next when traversing with
the right key
Parameters:
nextFocusRight - the next focus component
isEnabled
public boolean isEnabled()

Indicates whether component is enabled or disabled thus allowing us to prevent a


component from receiving input events and indicate so visually
Returns:
true if enabled
setEnabled
public void setEnabled(boolean enabled)

Indicates whether component is enabled or disabled thus allowing us to prevent a


component from receiving input events and indicate so visually
Parameters:
enabled - true to enable false to disable
getName
public String getName()

A component name allows us to easily identify the component within a dynamic UI.
Returns:
name of the component
setName
public void setName(String name)

A component name allows us to easily identify the component within a dynamic UI.
Parameters:
name - a name for the component
initCustomStyle
protected void initCustomStyle(Style s)

Allows components to create a style of their own, this method binds the listener to the
style and installs a bg painter
Parameters:
s - style to initialize
deinitializeCustomStyle
protected void deinitializeCustomStyle(Style s)

Allows components to create a style of their own, this method cleans up state for the
given style
Parameters:
s - style no longer used
isRTL
public boolean isRTL()

Is the component a bidi RTL component


Returns:
true if the component is working in a right to left mode

Method Detail

1956

Overview (Codename One API)


setRTL
public void setRTL(boolean rtl)

Is the component a bidi RTL component


Parameters:
rtl - true if the component should work in a right to left mode
isTactileTouch
protected boolean isTactileTouch(int x,
int y)

Elaborate components might not provide tactile feedback for all their areas (e.g. Lists)
this method defaults to returning the value of isTactileTouch
Parameters:
x - the x position
y - the y position
Returns:
True if the device should vibrate
isTactileTouch
public boolean isTactileTouch()

Indicates whether the component should "trigger" tactile touch when pressed by the
user in a touch screen UI.
Returns:
the tactileTouch
setTactileTouch
public void setTactileTouch(boolean tactileTouch)

Indicates whether the component should "trigger" tactile touch when pressed by the
user in a touch screen UI.
Parameters:
tactileTouch - true to trigger vibration when the component is pressed
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Parameters:

Method Detail

1957

Overview (Codename One API)


name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
paintLockRelease
public void paintLockRelease()

Releases the paint lock image to allow paint to work as usual, see
paintLock(boolean) for details
paintLock
public Image paintLock(boolean hardLock)

This method locks the component so it will always paint the given image instead of
running through its paint logic. This is useful when running transitions that might be
quite expensive on the device. A lock should be released using paintLockRelease(), it
is implicitly released when a component is deinitialized although a component doesn't
need to be initialized to be locked!
If the component is not opaque null is always returned!
Duplicate calls to this method won't produce duplicate locks, in case of a soft lock the
return value will always be null.
Parameters:
- indicates whether the lock uses a hard or a soft reference to the
image
Returns:
the image in case of a hard lock
isSnapToGrid
hardLock

public boolean isSnapToGrid()

Indicates whether scrolling this component should jump to a specific location in a grid
Returns:
the snapToGrid
setSnapToGrid
public void setSnapToGrid(boolean snapToGrid)

Indicates whether scrolling this component should jump to a specific location in a grid
Parameters:
snapToGrid - the snapToGrid to set
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from being
used for some other purpose when on top of said component.
isFlatten
public boolean isFlatten()

Makes the component effectively opaque by blending the backgrounds into an image
in memory so the layer of underlying components is only drawn once when this

Method Detail

1958

Overview (Codename One API)


component is repainted. This does have a significant memory overhead.
Returns:
the flatten property
setFlatten
public void setFlatten(boolean flatten)

Makes the component effectively opaque by blending the backgrounds into an image
in memory so the layer of underlying components is only drawn once when this
component is repainted. This does have a significant memory overhead.
Parameters:
flatten - the flatten value
getTensileLength
public int getTensileLength()

Recommended length for the tensile, -1 for default


Returns:
Recommended length for the tensile, -1 for default
setTensileLength
public void setTensileLength(int tensileLength)

Recommended length for the tensile, -1 for default


Parameters:
tensileLength - length for tensile drag
isGrabsPointerEvents
public boolean isGrabsPointerEvents()

This property is useful for blocking in z-order touch events, sometimes we might want
to grab touch events in a specific component without making it focusable.
Returns:
the grabsPointerEvents
setGrabsPointerEvents
public void setGrabsPointerEvents(boolean grabsPointerEvents)

This property is useful for blocking in z-order touch events, sometimes we might want
to grab touch events in a specific component without making it focusable.
Parameters:
grabsPointerEvents - the grabsPointerEvents to set
getScrollOpacityChangeSpeed
public int getScrollOpacityChangeSpeed()

Indicates the decrement units for the scroll opacity


Returns:
the scrollOpacityChangeSpeed
setScrollOpacityChangeSpeed
public void setScrollOpacityChangeSpeed(int scrollOpacityChangeSpeed)

Indicates the decrement units for the scroll opacity


Parameters:
scrollOpacityChangeSpeed - the scrollOpacityChangeSpeed to set
growShrink
public void growShrink(int duration)

Grows or shrinks this component to its new preferred size, this method essentially
takes a component whose preferred size has changed and creates a "growing" effect
that lasts for the duration. Notice that some components (such as text areas) don't
report proper preferred size untill they are laid out once. Hence the first time around a
text area (or container containing a text area) will not produce the expected effect.
This can be solved by invoking revalidate before the call to this method only the first
time around!

Method Detail

1959

Overview (Codename One API)


Parameters:
duration

- the duration in milliseconds for the grow/shrink animation

isAlwaysTensile
public boolean isAlwaysTensile()

Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Returns:
the alwaysTensile
setAlwaysTensile
public void setAlwaysTensile(boolean alwaysTensile)

Enable the tensile drag to work even when a component doesn't have a scroll
showable (scrollable flag still needs to be set to true)
Parameters:
alwaysTensile - the alwaysTensile to set
isDraggable
public boolean isDraggable()

Indicates whether this component can be dragged in a drag and drop operation rather
than scroll the parent
Returns:
the draggable state
setDraggable
public void setDraggable(boolean draggable)

Indicates whether this component can be dragged in a drag and drop operation rather
than scroll the parent
Parameters:
draggable - the draggable to set
isDropTarget
public boolean isDropTarget()

Indicates whether this component can receive dropped components into it, notice that
when dropping on a component or container the parents will be checked recursively
to find a valid drop target
Returns:
the dropTarget state
setDropTarget
public void setDropTarget(boolean dropTarget)

Indicates whether this component can receive dropped components into it, notice that
when dropping on a component or container the parents will be checked recursively
to find a valid drop target
Parameters:
dropTarget - the dropTarget to set
isHideInPortrait
public boolean isHideInPortrait()

Indicates that this component and all its children should be hidden when the device is
switched to portrait mode
Returns:
the hideInPortrait
setHideInPortrait
public void setHideInPortrait(boolean hideInPortrait)

Indicates that this component and all its children should be hidden when the device is
switched to portrait mode
Parameters:

Method Detail

1960

Overview (Codename One API)


hideInPortrait

- set to true in order to hide when in portrait

cancelRepaints
protected void cancelRepaints()

remove this component from the painting queue


getBindablePropertyNames
public String[] getBindablePropertyNames()

Returns the names of the properties within this component that can be bound for
persistence, the order of these names mean that the first one will be the first bound
Returns:
a string array of property names or null
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
Returns:
the class for binding
bindProperty
public void bindProperty(String prop,
BindTarget target)

Binds the given property name to the given bind target


Parameters:
prop - the property name
target - the target binder
unbindProperty
public void unbindProperty(String prop,
BindTarget target)

Removes a bind target from the given property name


Parameters:
prop - the property names
target - the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


Parameters:
prop - the property
Returns:
the value for the property
setBoundPropertyValue
public void setBoundPropertyValue(String prop,
Object value)

Sets the value of a bound property within this component, notice that this method
MUST NOT fire the property change event when invoked to prevent recursion!
Parameters:
prop - the property whose value should be set
value - the value
getCloudBoundProperty
public String getCloudBoundProperty()

Indicates the property within this component that should be bound to the cloud object
Returns:
the cloudBoundProperty

Method Detail

1961

Overview (Codename One API)


setCloudBoundProperty
public void setCloudBoundProperty(String cloudBoundProperty)

Indicates the property within this component that should be bound to the cloud object
Parameters:
cloudBoundProperty - the cloudBoundProperty to set
getCloudDestinationProperty
public String getCloudDestinationProperty()

The destination property of the CloudObject


Returns:
the cloudDestinationProperty
setCloudDestinationProperty
public void setCloudDestinationProperty(String cloudDestinationProperty)

The destination property of the CloudObject


Parameters:
cloudDestinationProperty - the cloudDestinationProperty to set
getComponentState
public Object getComponentState()

Some components may optionally generate a state which can then be restored using
setCompnentState(). This method is used by the UIBuilder.
Returns:
the component state or null for undefined state.
setHidden
public void setHidden(boolean b,
boolean changeMargin)

Makes the components preferred size equal 0 when hidden and restores it to the
default size when not. This method also optionally sets the margin to 0 so the
component will be truly hidden
Parameters:
b - true to hide the component and false to show it
changeMargin - indicates margin should be set to 0
setHidden
public void setHidden(boolean b)

Makes the components preferred size equal 0 when hidden and restores it to the
default size when not. Also toggles the UIID to "Container" and back to allow
padding/margin to be removed. Since the visible flag just hides the component
without "removing" the space it occupies this is the flag that can be used to truly hide
a component within the UI.
Parameters:
b - true to hide the component and false to show it
isHidden
public boolean isHidden()

Returns true if the component was explicitly hidden by the user


Returns:
true if the component is hidden, notice that the hidden property and visible
property have different meanings in the API!
setComponentState
public void setComponentState(Object state)

If getComponentState returned a value the setter can update the value and restore
the prior state.
Parameters:
state - the non-null state

Method Detail

1962

Overview (Codename One API)


com.codename1.ui

Class Command
java.lang.Object

com.codename1.ui.Command
All Implemented Interfaces:
ActionListener
Direct Known Subclasses:
NavigationCommand, ShareService

public class
extends Object
implements ActionListener

The Command class provides a useful extension to the ActionListener interface in cases where the
same functionality may be accessed by several controls.

Constructor Summary
Constructor and Description
Command(String command)

Creates a new instance of Command


Command(String command, Image icon)

Creates a new instance of Command


Command(String command, Image icon, int id)

Creates a new instance of Command


Command(String command, int id)

Creates a new instance of Command

Method Summary
Modifier
and Type
void

Method and Description


actionPerformed(ActionEvent evt)

This method is called when the soft button/Menu item is clicked


create(String name, Image icon, ActionListener ev)

static
Command

boolean

Creates a new command instance that encapsulates the action listener and
details, the main value of this approach is in our ability to write commands using
the shorthand lambda syntax of Java 8.
equals(Object obj)

compare two commands


getClientProperty(String key)

Object

String

The client properties are a useful way to associate meta-data with a command
without subclassing
getCommandName()

gets the Command Name


getDisabledIcon()

Image

Image
int
Image

Class Command

Indicates the icon that is displayed on the button when the button is in the
disabled state
getIcon()

Returns the icon representing the command


getId()

Return the command ID


getPressedIcon()

1963

Overview (Codename One API)


Indicates the icon that is displayed on the button when the button is in pressed
state
getRolloverIcon()

Indicates the icon that is displayed on the button when the button is in rolled
over state

Image

hashCode()

int

Allows storing commands in a vector/hashtable


isDisposesDialog()

boolean

boolean

Indicates whether this command causes the dialog to dispose implicitly, defaults
to true
isEnabled()

Allows disabling/enabling the command


putClientProperty(String key, Object value)

The client properties are a useful way to associate meta-data with a command
without sub classing

void

setCommandName(String command)

void

sets the Command name


setDisabledIcon(Image disabledIcon)

Indicates the icon that is displayed on the button when the button is in the
disabled state

void

setDisposesDialog(boolean disposesDialog)

Indicates whether this command causes the dialog to dispose implicitly, defaults
to true

void

setEnabled(boolean enabled)

void

Allows disabling/enabling the command


setIcon(Image icon)

void

Sets the icon for the command


setPressedIcon(Image pressedIcon)

Indicates the icon that is displayed on the button when the button is in pressed
state

void

setRolloverIcon(Image rolloverIcon)

Indicates the icon that is displayed on the button when the button is in rolled
over state

void

String

toString()

Returns a string representation of the object

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
Command
public Command(String command)

Creates a new instance of Command


Parameters:
command - the string that will be placed on the Soft buttons\Menu
Command
public Command(String command,
Image icon)

Creates a new instance of Command


Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command

Method Summary

1964

Overview (Codename One API)


Command
public Command(String command,
int id)

Creates a new instance of Command


Parameters:
command - the string that will be placed on the Soft buttons\Menu
id - user defined ID for a command simplifying switch statement code
working with a command
Command
public Command(String command,
Image icon,
int id)

Creates a new instance of Command


Parameters:
command - the string that will be placed on the Soft buttons\Menu
icon - the icon representing the command
id - user defined ID for a command simplifying switch statement code
working with a command

Method Detail
getId
public int getId()

Return the command ID


Returns:
the command ID
getCommandName
public String getCommandName()

gets the Command Name


Returns:
the Command name
setCommandName
public void setCommandName(String command)

sets the Command name


Parameters:
command getIcon
public Image getIcon()

Returns the icon representing the command


Returns:
an icon representing the command
setIcon
public void setIcon(Image icon)

Sets the icon for the command


Parameters:
icon - the new icon
toString
public String toString()

Returns a string representation of the object


Overrides:

Constructor Detail

1965

Overview (Codename One API)


toString in class Object
Returns:
Returns a string representation of the object
getPressedIcon
public Image getPressedIcon()

Indicates the icon that is displayed on the button when the button is in pressed state
Returns:
icon used
getDisabledIcon
public Image getDisabledIcon()

Indicates the icon that is displayed on the button when the button is in the disabled
state
Returns:
icon used
getRolloverIcon
public Image getRolloverIcon()

Indicates the icon that is displayed on the button when the button is in rolled over
state
Returns:
icon used
setRolloverIcon
public void setRolloverIcon(Image rolloverIcon)

Indicates the icon that is displayed on the button when the button is in rolled over
state
Parameters:
rolloverIcon - icon to use
setPressedIcon
public void setPressedIcon(Image pressedIcon)

Indicates the icon that is displayed on the button when the button is in pressed state
Parameters:
pressedIcon - icon used
setDisabledIcon
public void setDisabledIcon(Image disabledIcon)

Indicates the icon that is displayed on the button when the button is in the disabled
state
Parameters:
disabledIcon - icon used
equals
public boolean equals(Object obj)

compare two commands


Overrides:
equals in class Object
Parameters:
obj - a Command Object to compare
Returns:
true if the obj has the same command name
hashCode
public int hashCode()

Allows storing commands in a vector/hashtable


Overrides:
hashCode in class Object

Method Detail

1966

Overview (Codename One API)


Returns:
unique hashcode for the command class
actionPerformed
public void actionPerformed(ActionEvent evt)

This method is called when the soft button/Menu item is clicked


Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - the Event Object
setDisposesDialog
public void setDisposesDialog(boolean disposesDialog)

Indicates whether this command causes the dialog to dispose implicitly, defaults to
true
isDisposesDialog
public boolean isDisposesDialog()

Indicates whether this command causes the dialog to dispose implicitly, defaults to
true
isEnabled
public boolean isEnabled()

Allows disabling/enabling the command


Returns:
the enabled
setEnabled
public void setEnabled(boolean enabled)

Allows disabling/enabling the command


Parameters:
enabled - the enabled to set
getClientProperty
public Object getClientProperty(String key)

The client properties are a useful way to associate meta-data with a command
without subclassing
Parameters:
key - an arbitrary user key
Returns:
an arbitrary user object
putClientProperty
public void putClientProperty(String key,
Object value)

The client properties are a useful way to associate meta-data with a command
without sub classing
Parameters:
key - an arbitrary user key
value - an arbitrary user object, null to remove
create
public static Command create(String name,
Image icon,
ActionListener ev)

Creates a new command instance that encapsulates the action listener and details,
the main value of this approach is in our ability to write commands using the
shorthand lambda syntax of Java 8.
Parameters:

Method Detail

1967

Overview (Codename One API)


name - the name/title of the command
icon - the icon for the command
ev - the even handler

Returns:
a newly created Command instance

Method Detail

1968

Overview (Codename One API)


com.codename1.ui

Class ComboBox<T>
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.List<T>

com.codename1.ui.ComboBox<T>
All Implemented Interfaces:
Animation, StyleListener

public class
extends List<T>

A ComboBox is a list that allows only one selection at a time, when a user clicks the ComboBox a popup
button with the full list of elements allows the selection of a single element. The ComboBox is driven by
the list model and allows all the renderer features of the List as well.
The ComboBox is notoriously hard to style properly as it relies on a complex dynamic of popup renderer
and instantly visible renderer. The UIID for the ComboBox is "ComboBox" however if you set it to
something else all the other UIID's will also change their prefix. E.g. the "ComboBoxPopup" UIID will
become "MyNewUIIDPopup".
The combo box defines the following UIID's by default:
ComboBox
ComboBoxItem
ComboBoxFocus
PopupContentPane
PopupItem
PopupFocus
This class also defines theme constants that allow some native themes to manipulate its behavior
e.g.:
popupTitleBool - shows the "label for" value as the title of the popup dialog
popupCancelBodyBool - Adds a cancel button into the popup dialog
centeredPopupBool - shows the popup dialog in the center of the screen instead of under the
popup
otherPopupRendererBool - Uses a different list cell render for the popup than the one used
for the ComboBox itself. When this is false PopupItem & PopupFocus become irrelevant. Notice
that the Android native theme defines this to true.
iOS doesn't use combo boxes as part of its UI paradigm. Its available there mostly in web
applications and feels unnatural in iOS which is why we recommend using the Picker class.
The sample code below uses the GenericListCellRenderer to create a richer ComboBox UI.
public void showComboForm() {
Form hi = new Form("ComboBox", new BoxLayout(BoxLayout.Y_AXIS));
ComboBox<Map<String, Object>> combo = new ComboBox<> (
createListEntry("A Game of Thrones", "1996"),
createListEntry("A Clash Of Kings", "1998"),
createListEntry("A Storm Of Swords", "2000"),
createListEntry("A Feast For Crows", "2005"),
createListEntry("A Dance With Dragons", "2011"),
createListEntry("The Winds of Winter", "2016 (please, please, please)"),
createListEntry("A Dream of Spring", "Ugh"));
combo.setRenderer(new GenericListCellRenderer<>(new MultiButton(), new MultiButton()));
hi.show();
}
private Map<String, Object> createListEntry(String name, String date) {
Map<String, Object> entry = new HashMap<>();
entry.put("Line1", name);
entry.put("Line2", date);
return entry;
}

Class ComboBox<T>

1969

Overview (Codename One API)

See Also:
List

Field Summary

Fields inherited from class com.codename1.ui.List


FIXED_CENTER, FIXED_LEAD, FIXED_NONE, FIXED_NONE_CYCLIC,
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE, FIXED_TRAIL, HORIZONTAL, VERTICAL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ComboBox()

Constructs an empty combo box


ComboBox(ListModel<T> model)

Creates a new instance of ComboBox


ComboBox(Object... items)

Creates a new instance of ComboBox


ComboBox(Vector<T> items)

Creates a new instance of ComboBox

Method Summary
Modifier
and Type

Field Summary

Method and Description

protected
Dimension

calcPreferredSize()

protected
Dialog

createPopupDialog(List<T> l)

protected
List<T>

createPopupList()

protected
void

fireClicked()

Calculates the preferred size based on component content.


Subclasses can override this method to change the creation of the dialog
Creates the list object used within the popup dialog.

1970

Overview (Codename One API)


When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly.
getBaseline(int width, int height)
int

int

The baseline for the component text according to which it should be aligned
with other components for best visual look.
getOrientation()

Returns the list orientation


getSelectedRect()

Rectangle

protected
Rectangle

Returns the component bounds with absolute screen coordinates, for


components that include an internal selection behavior and are not containers
(currently only List) this method allows returning the position of the selection
itself which is useful for things such as the popup dialog and similar UI's that
need to reference the position of the selection externally
getVisibleBounds()

Returns the component bounds for scrolling which might differ from the
getBounds for large components e.g.
isActAsSpinnerDialog()

boolean

When this flag is active the combo box acts as a button that opens a dialog that
looks like a spinner this allows creating user interfaces for touch devices where
a spinner UI approach is more common than a combo box paradigm.
isDefaultActAsSpinnerDialog()

static
boolean

static
boolean

When this flag is active the combo box acts as a button that opens a dialog that
looks like a spinner this allows creating user interfaces for touch devices where
a spinner UI approach is more common than a combo box paradigm.
isDefaultIncludeSelectCancel()

Indicates whethe the soft buttons for select/cancel should appear for the combo
box by default
isIncludeSelectCancel()

boolean

void
protected
void

Indicates whethe the soft buttons for select/cancel should appear for the combo
box
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
laidOut()

This is a callback method to inform the Component when it's been laidout on
the parent Container
paint(Graphics g)

void

void

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF
perform the rendering.
pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerHover(int[] x, int[] y)

void

Invoked for devices where the pointer can hover without actually clicking the
display.
pointerHoverReleased(int[] x, int[] y)

void

void
void

Invoked for devices where the pointer can hover without actually clicking the
display.
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
setActAsSpinnerDialog(boolean actAsSpinnerDialog)

void

When this flag is active the combo box acts as a button that opens a dialog that
looks like a spinner this allows creating user interfaces for touch devices where
a spinner UI approach is more common than a combo box paradigm.
setDefaultActAsSpinnerDialog(boolean aDefaultActAsSpinnerDialog)

static
void

When this flag is active the combo box acts as a button that opens a dialog that
looks like a spinner this allows creating user interfaces for touch devices where
a spinner UI approach is more common than a combo box paradigm.
setDefaultIncludeSelectCancel(boolean aDefaultIncludeSelectCancel)

Method Summary

1971

Overview (Codename One API)


Indicates whethe the soft buttons for select/cancel should appear for the combo
box by default

static
void

setIncludeSelectCancel(boolean includeSelectCancel)

Indicates whethe the soft buttons for select/cancel should appear for the combo
box

void

setSelectedIndex(int selection)

Sets the current selected offset in the list, by default this implementation will
scroll the list to the selection if the selection is outside of the screen

void

setSelectedIndex(int selection, boolean scroll)

void

Sets the current selected offset in the list


setUIID(String uiid)

void

This method sets the Component the Unique identifier.

protected
Command

showPopupDialog(Dialog popupDialog, List l)

Shows the popup dialog for the combo box and returns the resulting command.

Methods inherited from class com.codename1.ui.List


addActionListener, addItem, addSelectionListener, animate, fireActionEvent,
fireActionEvent, getActionListeners, getCurrentSelected,
getDragRegionStatus, getFixedSelection, getGridPosX, getGridPosY, getHint,
getHintIcon, getItemGap, getListeners, getListSizeCalculationSampleCount,
getMaxElementHeight, getMinElementHeight, getModel, getRenderer,
getRenderingPrototype, getSelectedIndex, getSelectedItem, getSideGap,
initLaf, isCommandList, isDefaultFireOnClick,
isDefaultIgnoreFocusComponentWhenUnfocused,
isIgnoreFocusComponentWhenUnfocused, isLongPointerPressActionEnabled,
isMutableRendererBackgrounds, isNumericKeyActions, isScrollableX,
isScrollableY, isSelectableInteraction, isTactileTouch, keyPressed,
listSelectionChanged, longPointerPress, modelChanged, paramString,
refreshTheme, removeActionListener, removeSelectionListener,
scrollRectToVisible, setCommandList, setDefaultFireOnClick,
setDefaultIgnoreFocusComponentWhenUnfocused, setFireOnClick,
setFixedSelection, setHandlesInput, setHint, setHint, setHintIcon,
setIgnoreFocusComponentWhenUnfocused, setInputOnFocus, setItemGap,
setListCellRenderer, setListSizeCalculationSampleCount,
setLongPointerPressActionEnabled, setMaxElementHeight, setMinElementHeight,
setModel, setMutableRendererBackgrounds, setNumericKeyActions,
setOrientation, setPaintFocusBehindList, setRenderer,
setRenderingPrototype, setScrollToSelected, setSelectedItem,
setShouldCalcPreferredSize, shouldRenderSelection, size

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitialize, deinitializeCustomStyle,
dragEnter, dragExit, dragFinished, draggingOver, dragInitiated,
drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedStyle, getStyle, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getWidth, getX, getY, growShrink, handlesInput,
hasFocus, initComponent, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, longKeyPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,

Methods inherited from class com.codename1.ui.List

1972

Overview (Codename One API)


paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ComboBox
public ComboBox(Vector<T> items)

Creates a new instance of ComboBox


Parameters:
items - set of items placed into the combo box model
ComboBox
public ComboBox(Object... items)

Creates a new instance of ComboBox


Parameters:
items - set of items placed into the combo box model
ComboBox
public ComboBox()

Constructs an empty combo box


ComboBox
public ComboBox(ListModel<T> model)

Creates a new instance of ComboBox


Parameters:
model - the model for the combo box elements and selection

Method Detail
isDefaultActAsSpinnerDialog
public static boolean isDefaultActAsSpinnerDialog()

When this flag is active the combo box acts as a button that opens a dialog that looks
like a spinner this allows creating user interfaces for touch devices where a spinner
UI approach is more common than a combo box paradigm.
Returns:
the defaultActAsSpinnerDialog

Methods inherited from class com.codename1.ui.Component

1973

Overview (Codename One API)


setDefaultActAsSpinnerDialog
public static void setDefaultActAsSpinnerDialog(boolean aDefaultActAsSpinnerDialog)

When this flag is active the combo box acts as a button that opens a dialog that looks
like a spinner this allows creating user interfaces for touch devices where a spinner
UI approach is more common than a combo box paradigm.
Parameters:
aDefaultActAsSpinnerDialog - the defaultActAsSpinnerDialog to set
setUIID
public void setUIID(String uiid)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized
Overrides:
setUIID in class Component
Parameters:
uiid - UIID unique identifier for component type
getBaseline
public int getBaseline(int width,
int height)

The baseline for the component text according to which it should be aligned with
other components for best visual look.
Overrides:
getBaseline in class Component
Parameters:
width - the component width
height - the component height
Returns:
baseline value from the top of the component
laidOut
protected void laidOut()

This is a callback method to inform the Component when it's been laidout on the
parent Container
Overrides:
laidOut in class List<T>
getSelectedRect
public Rectangle getSelectedRect()

Returns the component bounds with absolute screen coordinates, for components
that include an internal selection behavior and are not containers (currently only List)
this method allows returning the position of the selection itself which is useful for
things such as the popup dialog and similar UI's that need to reference the position of
the selection externally
Overrides:
getSelectedRect in class List<T>
Returns:
the bounds of the component with absolute screen coordinates
getVisibleBounds
protected Rectangle getVisibleBounds()

Returns the component bounds for scrolling which might differ from the getBounds for
large components e.g. list.
Overrides:
getVisibleBounds in class List<T>
Returns:
the component bounds
See Also:
Component.getX(), Component.getY()

Method Detail

1974

Overview (Codename One API)


setSelectedIndex
public void setSelectedIndex(int selection)

Sets the current selected offset in the list, by default this implementation will scroll the
list to the selection if the selection is outside of the screen
Overrides:
setSelectedIndex in class List<T>
Parameters:
selection - the current selected offset in the list
setSelectedIndex
public void setSelectedIndex(int selection,
boolean scroll)

Sets the current selected offset in the list


Overrides:
setSelectedIndex in class List<T>
Parameters:
selection - the current selected offset in the list
scroll - indicates whether scrolling to selection should occur if the selection
is outside of view
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class List<T>
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class List<T>
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
createPopupDialog
protected Dialog createPopupDialog(List<T> l)

Subclasses can override this method to change the creation of the dialog
Parameters:
l - the list of the popup
Returns:
a dialog instance
showPopupDialog
protected Command showPopupDialog(Dialog popupDialog,
List l)

Shows the popup dialog for the combo box and returns the resulting command. This
method can be overriden by subclasses to modify the behavior of the class.
Parameters:
popupDialog - the popup dialog
l - the list within
Returns:
the selected command

Method Detail

1975

Overview (Codename One API)


fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class List<T>
createPopupList
protected List<T> createPopupList()

Creates the list object used within the popup dialog. This method allows subclasses
to customize the list creation for the popup dialog shown when the combo box is
pressed.
Returns:
a newly created list object used when the user presses the combo box.
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class List<T>
Parameters:
keyCode - the key code value to indicate a physical key.
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class List<T>
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class List<T>
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class List<T>
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform

Method Detail

1976

Overview (Codename One API)


the rendering.
Specified by:
paint

in interface Animation

Overrides:
paint in class List<T>
Parameters:
g - the component graphics
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class List<T>
Returns:
the calculated preferred size based on component content
getOrientation
public int getOrientation()

Returns the list orientation


Overrides:
getOrientation in class List<T>
Returns:
the list orientation HORIZONTAL or VERTICAL
See Also:
List.HORIZONTAL, List.VERTICAL
isIncludeSelectCancel
public boolean isIncludeSelectCancel()

Indicates whethe the soft buttons for select/cancel should appear for the combo box
Returns:
true if the soft buttons for select/cancel should appear for the combo box
setIncludeSelectCancel
public void setIncludeSelectCancel(boolean includeSelectCancel)

Indicates whethe the soft buttons for select/cancel should appear for the combo box
Parameters:
includeSelectCancel - the new value
isDefaultIncludeSelectCancel
public static boolean isDefaultIncludeSelectCancel()

Indicates whethe the soft buttons for select/cancel should appear for the combo box
by default
Returns:
true if the soft buttons for select/cancel should appear for the combo box
setDefaultIncludeSelectCancel

public static void setDefaultIncludeSelectCancel(boolean aDefaultIncludeSelectCancel

Indicates whethe the soft buttons for select/cancel should appear for the combo box
by default
Parameters:
aDefaultIncludeSelectCancel - the new value
isActAsSpinnerDialog
public boolean isActAsSpinnerDialog()

When this flag is active the combo box acts as a button that opens a dialog that looks
like a spinner this allows creating user interfaces for touch devices where a spinner
UI approach is more common than a combo box paradigm.
Returns:
the actAsSpinnerDialog

Method Detail

1977

Overview (Codename One API)


setActAsSpinnerDialog
public void setActAsSpinnerDialog(boolean actAsSpinnerDialog)

When this flag is active the combo box acts as a button that opens a dialog that looks
like a spinner this allows creating user interfaces for touch devices where a spinner
UI approach is more common than a combo box paradigm.
Parameters:
actAsSpinnerDialog - the actAsSpinnerDialog to set

Method Detail

1978

Overview (Codename One API)


com.codename1.ui

Class CheckBox
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.ui.CheckBox
All Implemented Interfaces:
Animation, StyleListener

public class
extends Button

CheckBox is a button that can be selected or deselected and displays its state to the user. Check out
RadioButton for a more exclusive selection approach. Both components support a toggle button mode
using the Button.setToggle(boolean) API.
CheckBox cb1 = new CheckBox("CheckBox No Icon");
cb1.setSelected(true);
CheckBox cb2 = new CheckBox("CheckBox With Icon", icon);
CheckBox cb3 = new CheckBox("CheckBox Opposite True", icon);
CheckBox cb4 = new CheckBox("CheckBox Opposite False", icon);
cb3.setOppositeSide(true);
cb4.setOppositeSide(false);
RadioButton rb1 = new RadioButton("Radio 1");
RadioButton rb2 = new RadioButton("Radio 2");
RadioButton rb3 = new RadioButton("Radio 3", icon);
new ButtonGroup(rb1, rb2, rb3);
rb2.setSelected(true);
hi.add(cb1).add(cb2).add(cb3).add(cb4).add(rb1).add(rb2).add(rb3);

Field Summary

Class CheckBox

1979

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.Button

STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
CheckBox()

Constructs a checkbox with no text


CheckBox(Image icon)

Constructs a checkbox with the given icon


CheckBox(String text)

Constructs a checkbox with the given text


CheckBox(String text, Image icon)

Constructs a checkbox with the given text and icon

Method Summary
Modifier and
Type
void
protected
Dimension
static
CheckBox
static
CheckBox
static
CheckBox

Method and Description


bindProperty(String prop, BindTarget target)

Binds the given property name to the given bind target


calcPreferredSize()

Calculates the preferred size based on component content.


createToggle(Image icon)

Shorthand for creating the check box setting the icon/text and making it into a
toggle button
createToggle(String text)

Shorthand for creating the check box setting the icon/text and making it into a
toggle button
createToggle(String text, Image icon)

Shorthand for creating the check box setting the icon/text and making it into a
toggle button
getBindablePropertyNames()

String[]

Class[]
Object
boolean
boolean

Returns the names of the properties within this component that can be bound
for persistence, the order of these names mean that the first one will be the
first bound
getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


isOppositeSide()

Places the check box on the opposite side at the far end
isSelected()

Return true if the checkbox is selected


paint(Graphics g)

void

protected
String

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF
perform the rendering.
paramString()

Returns a string representing the state of this component.

Fields inherited from class com.codename1.ui.Button

1980

Overview (Codename One API)


refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY
INVOKE THIS METHOD IF YOU CHANGED THE THEME!

void

released(int x, int y)

void

Invoked to change the state of the button to the released state


setBoundPropertyValue(String prop, Object value)

Sets the value of a bound property within this component, notice that this
method MUST NOT fire the property change event when invoked to prevent
recursion!

void

setOppositeSide(boolean oppositeSide)

void

Places the check box on the opposite side at the far end
setSelected(boolean selected)

void

Selects the current checkbox


unbindProperty(String prop, BindTarget target)

void

Removes a bind target from the given property name

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, dragInitiated, fireClicked, getActionListeners,
getBorder, getCommand, getDisabledIcon, getIconFromState, getListeners,
getPressedIcon, getReleaseRadius, getRolloverIcon, getRolloverPressedIcon,
getState, isAutoRelease, isSelectableInteraction, isToggle, keyPressed,
keyReleased, keyRepeated, pointerDragged, pointerHover,
pointerHoverReleased, pointerPressed, pointerReleased, pressed, released,
removeActionListener, resetFocusable, setAlignment, setAutoRelease,
setCommand, setDisabledIcon, setPressedIcon, setReleaseRadius,
setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


getAlignment, getBaseline, getBaselineResizeBehavior, getGap, getIcon,
getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, setDefaultTickerEnabled,
setEndsWith3Points, setGap, setIcon, setLegacyRenderer, setMask,
setMaskName, setPropertyValue, setShiftMillimeters, setShiftText,
setShouldLocalize, setShowEvenIfBlank, setText, setTextPosition,
setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker,
startTicker, stopTicker

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,

Method Summary

1981

Overview (Codename One API)


longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
CheckBox
public CheckBox(String text)

Constructs a checkbox with the given text


Parameters:
text - to display next to the checkbox
CheckBox
public CheckBox()

Constructs a checkbox with no text


CheckBox
public CheckBox(Image icon)

Constructs a checkbox with the given icon


Parameters:
icon - icon to display next to the checkbox
CheckBox
public CheckBox(String text,
Image icon)

Constructs a checkbox with the given text and icon


Parameters:
text - to display next to the checkbox
icon - icon to display next to the text

Method Detail
isSelected
public boolean isSelected()

Return true if the checkbox is selected

Methods inherited from class com.codename1.ui.Component

1982

Overview (Codename One API)


Overrides:
isSelected in class Button
Returns:
true if the checkbox is selected
setSelected
public void setSelected(boolean selected)

Selects the current checkbox


Parameters:
selected - value for selection
released
public void released(int x,
int y)

Invoked to change the state of the button to the released state


Overrides:
released in class Button
Parameters:
x - the x position if a touch event triggered this, -1 if this isn't relevant
y - the y position if a touch event triggered this, -1 if this isn't relevant
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Label
Parameters:
g - the component graphics
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Button
Returns:
the calculated preferred size based on component content
paramString
protected String paramString()

Returns a string representing the state of this component. This method is intended to
be used only for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be empty but may
not be null.
Overrides:
paramString in class Label
Returns:
a string representation of this component's state
refreshTheme
public void refreshTheme(boolean merge)

Makes sure the component is up to date with the current theme, ONLY INVOKE THIS
METHOD IF YOU CHANGED THE THEME!
Overrides:
refreshTheme in class Component
Parameters:
merge - indicates if the current styles should be merged with the new styles

Method Detail

1983

Overview (Codename One API)


isOppositeSide
public boolean isOppositeSide()

Places the check box on the opposite side at the far end
Overrides:
isOppositeSide in class Button
Returns:
the oppositeSide
setOppositeSide
public void setOppositeSide(boolean oppositeSide)

Places the check box on the opposite side at the far end
Parameters:
oppositeSide - the oppositeSide to set
getBindablePropertyNames
public String[] getBindablePropertyNames()

Returns the names of the properties within this component that can be bound for
persistence, the order of these names mean that the first one will be the first bound
Overrides:
getBindablePropertyNames in class Label
Returns:
a string array of property names or null
getBindablePropertyTypes
public Class[] getBindablePropertyTypes()

Returns the types of the properties that are bindable within this component
Overrides:
getBindablePropertyTypes in class Label
Returns:
the class for binding
bindProperty
public void bindProperty(String prop,
BindTarget target)

Binds the given property name to the given bind target


Overrides:
bindProperty in class Label
Parameters:
prop - the property name
target - the target binder
unbindProperty
public void unbindProperty(String prop,
BindTarget target)

Removes a bind target from the given property name


Overrides:
unbindProperty in class Label
Parameters:
prop - the property names
target - the target binder
getBoundPropertyValue
public Object getBoundPropertyValue(String prop)

Allows the binding code to extract the value of the property


Overrides:
getBoundPropertyValue in class Label
Parameters:
prop - the property
Returns:

Method Detail

1984

Overview (Codename One API)


the value for the property
setBoundPropertyValue
public void setBoundPropertyValue(String prop,
Object value)

Sets the value of a bound property within this component, notice that this method
MUST NOT fire the property change event when invoked to prevent recursion!
Overrides:
setBoundPropertyValue in class Label
Parameters:
prop - the property whose value should be set
value - the value
createToggle
public static CheckBox createToggle(String text,
Image icon)

Shorthand for creating the check box setting the icon/text and making it into a toggle
button
Parameters:
text - the text for the button
icon - the icon for the button
Returns:
a check box
createToggle
public static CheckBox createToggle(String text)

Shorthand for creating the check box setting the icon/text and making it into a toggle
button
Parameters:
text - the text for the button
Returns:
a check box
createToggle
public static CheckBox createToggle(Image icon)

Shorthand for creating the check box setting the icon/text and making it into a toggle
button
Parameters:
icon - the icon for the button
Returns:
a check box

Method Detail

1985

Overview (Codename One API)


com.codename1.ui

Class Calendar
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Calendar
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

Date widget for selecting a date/time value.


To localize strings for month names use the values "Calendar.Month" using the 3 first characters of
the month name in the resource localization e.g. "Calendar.Jan", "Calendar.Feb" etc...
To localize strings for day names use the values "Calendar.Day" in the resource localization e.g.
"Calendar.Sunday", "Calendar.Monday" etc...
Note that we recommend using the Picker class which is superior when running on the device for
most use cases.
Form hi = new Form("Calendar", new BorderLayout());
Calendar cld = new Calendar();
cld.addActionListener((e) -> Log.p("You picked: " + new Date(cld.getSelectedDay())));
hi.add(BorderLayout.CENTER, cld);

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,

Class Calendar

1986

Overview (Codename One API)


DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Calendar()

Constructs a calendar with the current date and time


Calendar(long time)

Creates a new instance of Calendar set to the given date based on time since epoch (the
java.util.Date convention)
Calendar(long time, TimeZone tmz)

Creates a new instance of Calendar set to the given date based on time since epoch (the
java.util.Date convention)

Method Summary
Modifier
and Type
void
void

Method and Description


addActionListener(ActionListener l)

Fires when a change is made to the month view of this component


addDataChangeListener(DataChangedListener l)

Allows tracking selection changes in the calendar in real time

protected
Button

createDay()

protected
Label

createDayTitle(int day)

Date
Date
Style
Style
long
TimeZone

This method creates the Day Button Component for the Month View
This method creates the Day title Component for the Month View
getCurrentDate()

Returns the currently viewed date (as opposed to the selected date)
getDate()

Return the date object matching the current selection


getMonthViewSelectedStyle()

Gets the selected style of the month view component within the calendar
getMonthViewUnSelectedStyle()

Gets the un selected style of the month view component within the calendar
getSelectedDay()

Returns the time for the current calendar.


getTimeZone()

Gets the Calendar timezone


isChangesSelectedDateEnabled()

boolean

void
void

This flag determines if selected date can be changed by selecting an


alternative date
removeActionListener(ActionListener l)

Fires when a change is made to the month view of this component


removeDataChangeListener(DataChangedListener l)

Allows tracking selection changes in the calendar in real time


setChangesSelectedDateEnabled(boolean changesSelectedDateEnabled)

void

This flag determines if selected date can be changed by selecting an


alternative date
setCurrentDate(Date d)

void

void
void
void

Sets the Calendar view on the given date, only the the month and year are
being considered.
setDate(Date d)

Sets the current date in the view and the selected date to be the same.
setMonthViewSelectedStyle(Style s)

Sets the selected style of the month view component within the calendar
setMonthViewUnSelectedStyle(Style s)

Sets the un selected style of the month view component within the calendar

Fields inherited from class com.codename1.ui.Component

1987

Overview (Codename One API)


setSelectedDate(Date d)

void

This method sets the Calendar selected day


setTimeZone(TimeZone tmz)

Sets the Calendar timezone, if not specified Calendar will use the default
timezone

void

setYearRange(int minYear, int maxYear)

void

Sets the Calendar min and max years

protected
void
protected
void

updateButtonDayDate(Button dayButton, int currentMonth, int day)

This method updates the Button day.


updateButtonDayDate(Button dayButton, int year, int currentMonth,
int day)

This method updates the Button day.

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,

Method Summary

1988

Overview (Codename One API)


removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Calendar
public Calendar(long time)

Creates a new instance of Calendar set to the given date based on time since epoch
(the java.util.Date convention)
Parameters:
time - time since epoch
Calendar
public Calendar()

Constructs a calendar with the current date and time


Calendar
public Calendar(long time,
TimeZone tmz)

Creates a new instance of Calendar set to the given date based on time since epoch
(the java.util.Date convention)
Parameters:
time - time since epoch
tmz - a reference timezone

Method Detail
getSelectedDay
public long getSelectedDay()

Returns the time for the current calendar.


Returns:
the time for the current calendar.
getDate
public Date getDate()

Return the date object matching the current selection


Returns:
the date object matching the current selection

Methods inherited from class com.codename1.ui.Component

1989

Overview (Codename One API)


setDate
public void setDate(Date d)

Sets the current date in the view and the selected date to be the same.
Parameters:
d - new date
setYearRange
public void setYearRange(int minYear,
int maxYear)

Sets the Calendar min and max years


Parameters:
minYear - the min year
maxYear - the max year
setSelectedDate
public void setSelectedDate(Date d)

This method sets the Calendar selected day


Parameters:
d - the selected day
setCurrentDate
public void setCurrentDate(Date d)

Sets the Calendar view on the given date, only the the month and year are being
considered.
Parameters:
d - the date to set the calendar view on.
getCurrentDate
public Date getCurrentDate()

Returns the currently viewed date (as opposed to the selected date)
Returns:
the currently viewed date
setTimeZone
public void setTimeZone(TimeZone tmz)

Sets the Calendar timezone, if not specified Calendar will use the default timezone
Parameters:
tmz - the timezone
getTimeZone
public TimeZone getTimeZone()

Gets the Calendar timezone


Returns:
Calendar TimeZone
setMonthViewSelectedStyle
public void setMonthViewSelectedStyle(Style s)

Sets the selected style of the month view component within the calendar
Parameters:
s - style for the month view
setMonthViewUnSelectedStyle
public void setMonthViewUnSelectedStyle(Style s)

Sets the un selected style of the month view component within the calendar
Parameters:
s - style for the month view

Method Detail

1990

Overview (Codename One API)


getMonthViewSelectedStyle
public Style getMonthViewSelectedStyle()

Gets the selected style of the month view component within the calendar
Returns:
the style of the month view
getMonthViewUnSelectedStyle
public Style getMonthViewUnSelectedStyle()

Gets the un selected style of the month view component within the calendar
Returns:
the style of the month view
addActionListener
public void addActionListener(ActionListener l)

Fires when a change is made to the month view of this component


Parameters:
l - listener to add
removeActionListener
public void removeActionListener(ActionListener l)

Fires when a change is made to the month view of this component


Parameters:
l - listener to remove
addDataChangeListener
public void addDataChangeListener(DataChangedListener l)

Allows tracking selection changes in the calendar in real time


Parameters:
l - listener to add
removeDataChangeListener
public void removeDataChangeListener(DataChangedListener l)

Allows tracking selection changes in the calendar in real time


Parameters:
l - listener to remove
setChangesSelectedDateEnabled
public void setChangesSelectedDateEnabled(boolean changesSelectedDateEnabled)

This flag determines if selected date can be changed by selecting an alternative date
Parameters:
changesSelectedDateEnabled - if true pressing on a date will cause the
selected date to be changed to the pressed one
isChangesSelectedDateEnabled
public boolean isChangesSelectedDateEnabled()

This flag determines if selected date can be changed by selecting an alternative date
Returns:
true if enabled
createDay
protected Button createDay()

This method creates the Day Button Component for the Month View
Returns:
a Button that corresponds to the Days Components

Method Detail

1991

Overview (Codename One API)


createDayTitle
protected Label createDayTitle(int day)

This method creates the Day title Component for the Month View
Parameters:
day - the relevant day values are 0-6 where 0 is sunday.
Returns:
a Label that corresponds to the relevant Day
updateButtonDayDate
protected void updateButtonDayDate(Button dayButton,
int year,
int currentMonth,
int day)

This method updates the Button day.


Parameters:
dayButton - the button to be updated
day - the new button day
updateButtonDayDate
protected void updateButtonDayDate(Button dayButton,
int currentMonth,
int day)

This method updates the Button day.


Parameters:
dayButton - the button to be updated
day - the new button day

Method Detail

1992

Overview (Codename One API)


com.codename1.ui

Class ButtonGroup
java.lang.Object

com.codename1.ui.ButtonGroup

public class
extends Object

This class is used to create a multiple-exclusion scope for RadioButton. Creating a set of RadioButton
components with the same ButtonGroup object means that only one RadioButton can be selected
among those within the specific ButtonGroup.
CheckBox cb1 = new CheckBox("CheckBox No Icon");
cb1.setSelected(true);
CheckBox cb2 = new CheckBox("CheckBox With Icon", icon);
CheckBox cb3 = new CheckBox("CheckBox Opposite True", icon);
CheckBox cb4 = new CheckBox("CheckBox Opposite False", icon);
cb3.setOppositeSide(true);
cb4.setOppositeSide(false);
RadioButton rb1 = new RadioButton("Radio 1");
RadioButton rb2 = new RadioButton("Radio 2");
RadioButton rb3 = new RadioButton("Radio 3", icon);
new ButtonGroup(rb1, rb2, rb3);
rb2.setSelected(true);
hi.add(cb1).add(cb2).add(cb3).add(cb4).add(rb1).add(rb2).add(rb3);

Constructor Summary
Constructor and Description
ButtonGroup()

Creates a new instance of ButtonsGroup


ButtonGroup(RadioButton... rb)

Adds all the radio buttons to the group

Class ButtonGroup

1993

Overview (Codename One API)


Method

Summary

Modifier and
Type

Method and Description


add(RadioButton rb)

void

Adds a RadioButton to the group


addAll(RadioButton... rb)

void

Adds the RadioButtons to the group


clearSelection()

Clears the selection such that none of the buttons in the ButtonGroup are
selected.

void

getButtonCount()

int

Returns the number of buttons in the group.

RadioButton

getRadioButton(int index)

Returns the radio button at the given group index


getSelectedIndex()

int

Return the index of the selected button within the group

boolean

isSelected()

Returns whether a radio button in the group is selected.


remove(RadioButton rb)

void

removes a RadioButton from the group


setSelected(int index)

void

Sets the selected Radio button by index


setSelected(RadioButton rb)

void

Selects the given radio button

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ButtonGroup
public ButtonGroup()

Creates a new instance of ButtonsGroup


ButtonGroup
public ButtonGroup(RadioButton... rb)

Adds all the radio buttons to the group


Parameters:
rb

Method Detail
addAll
public void addAll(RadioButton... rb)

Adds the RadioButtons to the group


Parameters:
rb - a RadioButtons to add

Method Summary

1994

Overview (Codename One API)


add
public void add(RadioButton rb)

Adds a RadioButton to the group


Parameters:
rb - a RadioButton to add
remove
public void remove(RadioButton rb)

removes a RadioButton from the group


Parameters:
rb - a RadioButton to remove
clearSelection
public void clearSelection()

Clears the selection such that none of the buttons in the ButtonGroup are selected.
getButtonCount
public int getButtonCount()

Returns the number of buttons in the group.


Returns:
number of radio buttons in the group
isSelected
public boolean isSelected()

Returns whether a radio button in the group is selected.


Returns:
true if a selection was made in the radio button group
getSelectedIndex
public int getSelectedIndex()

Return the index of the selected button within the group


Returns:
the index of the selected button within the group
getRadioButton
public RadioButton getRadioButton(int index)

Returns the radio button at the given group index


Parameters:
index - offset within the group starting with 0 and no larger than
getButtonCount()
Returns:
the radio button instance
setSelected
public void setSelected(RadioButton rb)

Selects the given radio button


Parameters:
rb - the radio button to set as selected
setSelected
public void setSelected(int index)

Sets the selected Radio button by index


Parameters:
index - the index of the radio button to mark as selected

Method Detail

1995

Overview (Codename One API)


com.codename1.ui

Class Button
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
CheckBox, LikeButton, Picker, RadioButton, ScaleImageButton, ShareButton

public class
extends Label

Button is the base class for several UI widgets allowing clickability. It has 3 states: rollover, pressed
and the default state. Button can also have an ActionListener that react when the Button is clicked
or handle actions via a Command.
Button has the "Button" UIID by default.
Here is trivial usage of the Button API:
Form hi = new Form("Button");
Button b = new Button("My Button");
hi.add(b);
b.addActionListener((e) -> Log.p("Clicked"));

This code shows a common use case of making a button look like a hyperlink
Form hi = new Form("Button");
Button b = new Button("Link Button");
b.getAllStyles().setBorder(Border.createEmpty());
b.getAllStyles().setTextDecoration(Style.TEXT_DECORATION_UNDERLINE);
hi.add(b);
b.addActionListener((e) -> Log.p("Clicked"));

Class Button

1996

Overview (Codename One API)


Field

Summary

Modifier and
Type

Field and Description


STATE_DEFAULT

Indicates the default state of a button which is neither pressed nor


focused

static int

STATE_PRESSED

static int

Indicates the pressed state of a button


STATE_ROLLOVER

Indicates the rollover state of a button which is equivalent to focused for


most uses

static int

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Button()

Constructs a button with an empty string for its text.


Button(Command cmd)

Allows binding a command to a button for ease of use


Button(Image icon)

Constructs a button with the specified image.


Button(String text)

Constructs a button with the specified text.


Button(String text, Image icon)

Constructor a button with text and image

Method Summary
Modifier and
Type
void
boolean
protected
Dimension
protected
void
protected
void

Method and Description


addActionListener(ActionListener l)

Adds a listener to the button which will cause an event to dispatch on click
animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


dragInitiated()

Invoked on the focus component to let it know that drag has started on the
parent container for the case of a component that doesn't support scrolling
fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly.
getActionListeners()

Vector

protected
Border

Field Summary

Deprecated.
use getListeners instead
getBorder()

Normally returns getStyle().getBorder() but some subclasses might use this to


programmatically replace the border in runtime e.g.

1997

Overview (Codename One API)


Command

getCommand()

This method return the Button Command if exists


getDisabledIcon()

Image

Image
Collection

Indicates the icon that is displayed on the button when the button is in the
disabled state
getIconFromState()

Returns the icon for the button based on its current state
getListeners()

Returns a collection containing the action listeners for this button


getPressedIcon()

Image

int

Indicates the icon that is displayed on the button when the button is in
pressed state
getReleaseRadius()

Indicates a radius in which a pointer release will still have effect.


getRolloverIcon()

Image

Indicates the icon that is displayed on the button when the button is in rolled
over state
getRolloverPressedIcon()

Image

int
boolean
boolean

Indicates the icon that is displayed on the button when the button is in
pressed state and is selected.
getState()

Returns the button state


isAutoRelease()

Returns if this is an auto released Button.


isOppositeSide()

Places the check box or radio button on the opposite side at the far end
isSelectableInteraction()

protected
boolean

boolean
boolean
void
void
void
void

This method allows a component to indicate that it is interested in an "implicit"


select command to appear in the "fire" button when 3 softbuttons are defined
in a device.
isSelected()

Returns true if the button is selected for toggle buttons,


isToggle()

Toggle button mode is only relevant for checkboxes/radio buttons.


keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerHover(int[] x, int[] y)

void

Invoked for devices where the pointer can hover without actually clicking the
display.
pointerHoverReleased(int[] x, int[] y)

void

void
void
void
void
void

Method Summary

Invoked for devices where the pointer can hover without actually clicking the
display.
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

If this Component is focused, the pointer released event will call this method
pressed()

Invoked to change the state of the button to the pressed state


released()

Invoked to change the state of the button to the released state


released(int x, int y)

Invoked to change the state of the button to the released state

1998

Overview (Codename One API)


removeActionListener(ActionListener l)

void

Removes the given action listener from the button

protected
void

resetFocusable()

Restores the state of the focusable flag to its default state


setAlignment(int align)

Deprecated.
use the Style alignment instead

void

setAutoRelease(boolean autoRelease)

Sets the auto released mode of this button, by default it's not an auto
released Button

void

setCommand(Command cmd)

void

Applies the given command to this button


setDisabledIcon(Image disabledIcon)

Indicates the icon that is displayed on the button when the button is in the
disabled state

void

setPressedIcon(Image pressedIcon)

Indicates the icon that is displayed on the button when the button is in
pressed state

void

setReleaseRadius(int releaseRadius)

void

Indicates a radius in which a pointer release will still have effect.


setRolloverIcon(Image rolloverIcon)

Indicates the icon that is displayed on the button when the button is in rolled
over state

void

setRolloverPressedIcon(Image rolloverPressedIcon)

Indicates the icon that is displayed on the button when the button is in
pressed state and is selected.

void

setToggle(boolean toggle)

void

Toggle button mode is only relevant for checkboxes/radio buttons.

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getIcon, getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setIcon, setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setText, setTextPosition, setTickerEnabled, setVerticalAlignment,
shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,

Methods inherited from class com.codename1.ui.Label

1999

Overview (Codename One API)

isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,


isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
STATE_ROLLOVER
public static final int STATE_ROLLOVER

Indicates the rollover state of a button which is equivalent to focused for most uses
See Also:
Constant Field Values
STATE_PRESSED
public static final int STATE_PRESSED

Indicates the pressed state of a button


See Also:
Constant Field Values
STATE_DEFAULT
public static final int STATE_DEFAULT

Indicates the default state of a button which is neither pressed nor focused
See Also:
Constant Field Values

Constructor Detail
Button
public Button()

Constructs a button with an empty string for its text.

Methods inherited from class com.codename1.ui.Component

2000

Overview (Codename One API)


Button
public Button(String text)

Constructs a button with the specified text.


Parameters:
text - label appearing on the button
Button
public Button(Command cmd)

Allows binding a command to a button for ease of use


Parameters:
cmd - command whose text would be used for the button and would recive
action events from the button
Button
public Button(Image icon)

Constructs a button with the specified image.


Parameters:
icon - appearing on the button
Button
public Button(String text,
Image icon)

Constructor a button with text and image


Parameters:
text - label appearing on the button
icon - image appearing on the button

Method Detail
setCommand
public void setCommand(Command cmd)

Applies the given command to this button


Parameters:
cmd - the command on the button
resetFocusable
protected void resetFocusable()

Restores the state of the focusable flag to its default state


Overrides:
resetFocusable in class Component
getState
public int getState()

Returns the button state


Returns:
One of STATE_ROLLOVER, STATE_DEAFULT, STATE_PRESSED
getPressedIcon
public Image getPressedIcon()

Indicates the icon that is displayed on the button when the button is in pressed state
Returns:
icon used
See Also:
STATE_PRESSED

Constructor Detail

2001

Overview (Codename One API)


getRolloverPressedIcon
public Image getRolloverPressedIcon()

Indicates the icon that is displayed on the button when the button is in pressed state
and is selected. This is ONLY applicable to toggle buttons
Returns:
icon used
setRolloverPressedIcon
public void setRolloverPressedIcon(Image rolloverPressedIcon)

Indicates the icon that is displayed on the button when the button is in pressed state
and is selected. This is ONLY applicable to toggle buttons
Parameters:
rolloverPressedIcon - icon used
getDisabledIcon
public Image getDisabledIcon()

Indicates the icon that is displayed on the button when the button is in the disabled
state
Returns:
icon used
getRolloverIcon
public Image getRolloverIcon()

Indicates the icon that is displayed on the button when the button is in rolled over
state
Returns:
icon used
See Also:
STATE_ROLLOVER

setRolloverIcon
public void setRolloverIcon(Image rolloverIcon)

Indicates the icon that is displayed on the button when the button is in rolled over
state
Parameters:
rolloverIcon - icon to use
See Also:
STATE_ROLLOVER

setPressedIcon
public void setPressedIcon(Image pressedIcon)

Indicates the icon that is displayed on the button when the button is in pressed state
Parameters:
pressedIcon - icon used
See Also:
STATE_PRESSED

setDisabledIcon
public void setDisabledIcon(Image disabledIcon)

Indicates the icon that is displayed on the button when the button is in the disabled
state
Parameters:
disabledIcon - icon used
addActionListener
public void addActionListener(ActionListener l)

Adds a listener to the button which will cause an event to dispatch on click
Parameters:

Method Detail

2002

Overview (Codename One API)


l - implementation of the action listener interface
removeActionListener
public void removeActionListener(ActionListener l)

Removes the given action listener from the button


Parameters:
l - implementation of the action listener interface
getActionListeners
public Vector getActionListeners()

Deprecated. use getListeners instead


Returns a vector containing the action listeners for this button
Returns:
the action listeners
getListeners
public Collection getListeners()

Returns a collection containing the action listeners for this button


Returns:
the action listeners
getIconFromState
public Image getIconFromState()

Returns the icon for the button based on its current state
Returns:
the button icon based on its current state
pressed
public void pressed()

Invoked to change the state of the button to the pressed state


released
public void released()

Invoked to change the state of the button to the released state


released
public void released(int x,
int y)

Invoked to change the state of the button to the released state


Parameters:
x - the x position if a touch event triggered this, -1 if this isn't relevant
y - the y position if a touch event triggered this, -1 if this isn't relevant
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
keyReleased
public void keyReleased(int keyCode)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

Method Detail

2003

Overview (Codename One API)


keyRepeated
public void keyRepeated(int keyCode)

If this Component is focused, the key repeat event will call this method.
Overrides:
keyRepeated in class Component
Parameters:
keyCode - the key code value to indicate a physical key.
fireClicked
protected void fireClicked()

When working in 3 softbutton mode "fire" key (center softbutton) is sent to this
method in order to allow 3 button devices to work properly. When overriding this
method you should also override isSelectableInteraction to indicate that a command
is placed appropriately on top of the fire key for 3 soft button phones.
Overrides:
fireClicked in class Component
isSelectableInteraction
protected boolean isSelectableInteraction()

This method allows a component to indicate that it is interested in an "implicit" select


command to appear in the "fire" button when 3 softbuttons are defined in a device.
Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction
pointerHover
public void pointerHover(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerHoverReleased
public void pointerHoverReleased(int[] x,
int[] y)

Invoked for devices where the pointer can hover without actually clicking the display.
This is true for PC mouse pointer as well as some devices such as the BB storm.
Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

Method Detail

2004

Overview (Codename One API)


pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
dragInitiated
protected void dragInitiated()

Invoked on the focus component to let it know that drag has started on the parent
container for the case of a component that doesn't support scrolling
Overrides:
dragInitiated in class Component
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Label
Returns:
the calculated preferred size based on component content
getBorder
protected Border getBorder()

Normally returns getStyle().getBorder() but some subclasses might use this to


programmatically replace the border in runtime e.g. for a pressed border effect
Overrides:
getBorder in class Component
Returns:
the border that is drawn according to the current component state
getCommand
public Command getCommand()

This method return the Button Command if exists


Returns:
Command Object or null if a Command not exists
isSelected
public boolean isSelected()

Returns true if the button is selected for toggle buttons,


Returns:
true if the button is selected

Method Detail

2005

Overview (Codename One API)


setAlignment
public void setAlignment(int align)

Deprecated. use the Style alignment instead


Sets the Alignment of the Label to one of: CENTER, LEFT, RIGHT
Overrides:
setAlignment in class Label
Parameters:
align - alignment value
See Also:
Component.CENTER, Component.LEFT, Component.RIGHT
isToggle
public boolean isToggle()

Toggle button mode is only relevant for checkboxes/radio buttons. When pressed a
toggle button stays pressed and when pressed again it moves to releleased state.
Returns:
the toggle
setToggle
public void setToggle(boolean toggle)

Toggle button mode is only relevant for checkboxes/radio buttons. When pressed a
toggle button stays pressed and when pressed again it moves to releleased state.
Setting toggle implicitly changes the UIID to "ToggleButton"
Parameters:
toggle - the toggle to set
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Label
Returns:
true if a repaint is desired or false if no repaint is necessary
isOppositeSide
public boolean isOppositeSide()

Places the check box or radio button on the opposite side at the far end
Returns:
the oppositeSide
getReleaseRadius
public int getReleaseRadius()

Indicates a radius in which a pointer release will still have effect. Notice that this only
applies to pointer release events and not to pointer press events
Returns:
the releaseRadius
setReleaseRadius
public void setReleaseRadius(int releaseRadius)

Indicates a radius in which a pointer release will still have effect. Notice that this only
applies to pointer release events and not to pointer press events
Parameters:
releaseRadius - the releaseRadius to set

Method Detail

2006

Overview (Codename One API)


isAutoRelease
public boolean isAutoRelease()

Returns if this is an auto released Button. Auto released Buttons will are been
disarmed when a drag is happening within the Button.
Returns:
true if it's an auto released Button.
setAutoRelease
public void setAutoRelease(boolean autoRelease)

Sets the auto released mode of this button, by default it's not an auto released Button

Method Detail

2007

Overview (Codename One API)


com.codename1.ui

Class BrowserComponent
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.BrowserComponent
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

The browser component is an interface to an embeddable native platform browser on platforms that
support embedding the native browser in place, if you need wide compatibility and flexibility you
should check out the HTMLComponent which provides a lightweight 100% cross platform web
component.
This component will only work on platforms that support embedding a native browser which exclude
earlier versions of Blackberry devices and J2ME devices.
Its recommended that you place this component in a fixed position (none scrollable) on the screen
without other focusable components to prevent confusion between focus authority and allow the
component to scroll itself rather than CodenameOne making that decision for it.
On Android this component might show a native progress indicator dialog. You can disable that
functionality using the call.
The following code shows the basic usage of the BrowserComponent:
Form hi = new Form("Browser", new BorderLayout());
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://www.codenameone.com/");
hi.add(BorderLayout.CENTER, browser);

Class BrowserComponent

2008

Overview (Codename One API)

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Field Summary

2009

Overview (Codename One API)


Constructor

Summary
Constructor and Description

BrowserComponent()

This constructor will work as expected when a browser component is supported, see
isNativeBrowserSupported()

Method Summary
Modifier and Type

Method and Description


addWebEventListener(String type, ActionListener listener)

void

void
void
void
void

Adds a listener to the given event type name, event type names are
platform specific but some must be fired for all platforms and will invoke
the action listener when the appropriate event loads
back()

Navigates back in the history


clearHistory()

Clears navigation history


destroy()

Release native resources of this Browser Component


execute(String javaScript)

Executes the given JavaScript string within the current context


executeAndReturnString(String javaScript)

String

Executes the given JavaScript and returns a result string from the
underlying platform where applicable
exposeInJavaScript(Object o, String name)

void

Deprecated.
this doesn't work in most platforms see issue 459 for details, use the
setBrowserNavigationCallback method instead
fireWebEvent(String type, ActionEvent ev)

void

void

Used internally by the implementation to fire an event from the native


browser widget
forward()

Navigates forward in the history


getBrowserNavigationCallback()

BrowserNavigationCallback

String
String
boolean
boolean

The browser navigation callback interface allows handling a case where


a URL invocation can be delegated to Java code.
getTitle()

The page title


getURL()

The page URL


hasBack()

Indicates whether back is currently available


hasForward()

Indicates whether forward is currently available


isNativeBrowserSupported()

static boolean

Returns true if the platform supports embedding a native browser


component
isNativeScrollingEnabled()

boolean

This method is unreliable and is only here for consistency with


setNativeScrollingEnabled.
isPinchToZoomEnabled()

boolean

void

Constructor Summary

This method is unreliable and is only here for consistency with


setPinchToZoomEnabled, it will not return whether the platform supports
pinch since this is very hard to detect properly.
reload()

Reload the current page

2010

Overview (Codename One API)


removeWebEventListener(String type, ActionListener listener)

void

Removes the listener, see addWebEventListener for details

setBrowserNavigationCallback(BrowserNavigationCallback callback)

Set the browser navigation callback which allows handling a case where
a URL invocation can be delegated to Java code.

void

setNativeScrollingEnabled(boolean b)

This flag allows disabling the native browser scrolling on platforms that
support it

void

setPage(String html, String baseUrl)

void

Shows the given HTML in the native viewer


setPinchToZoomEnabled(boolean e)

void

Some platforms require that you enable pinch to zoom explicitly.


setProperty(String key, Object value)

This method allows customizing the properties of a web view in various


ways including platform specific settings.

void

setURL(String url)

void

Sets the page URL, jar: URL's must be supported by the implementation
setURLHierarchy(String url)

void

Sets the page URL while respecting the hierarchy of the html
stop()

void

Cancel the loading of the current page

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,

Method Summary

2011

Overview (Codename One API)


isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
BrowserComponent
public BrowserComponent()

This constructor will work as expected when a browser component is supported, see
isNativeBrowserSupported()

Method Detail
setBrowserNavigationCallback
public void setBrowserNavigationCallback(BrowserNavigationCallback callback)

Set the browser navigation callback which allows handling a case where a URL
invocation can be delegated to Java code. This allows binding Java side functionality
to JavaScript functionality in the same way PhoneGap/Cordova work
Parameters:
callback - the callback interface
getBrowserNavigationCallback
public BrowserNavigationCallback getBrowserNavigationCallback()

The browser navigation callback interface allows handling a case where a URL
invocation can be delegated to Java code. This allows binding Java side functionality
to JavaScript functionality in the same way PhoneGap/Cordova work
Returns:
the callback interface
isNativeBrowserSupported
public static boolean isNativeBrowserSupported()

Returns true if the platform supports embedding a native browser component

Methods inherited from class com.codename1.ui.Component

2012

Overview (Codename One API)


Returns:
true if native browsing is supported
setProperty
public void setProperty(String key,
Object value)

This method allows customizing the properties of a web view in various ways
including platform specific settings. When a property isn't supported by a specific
platform it is just ignored.
Parameters:
key - see the documentation with the CodenameOne Implementation for
further details
value - see the documentation with the CodenameOne Implementation for
further details
getTitle
public String getTitle()

The page title


Returns:
the title
getURL
public String getURL()

The page URL


Returns:
the URL
setURL
public void setURL(String url)

Sets the page URL, jar: URL's must be supported by the implementation
Parameters:
url - the URL
setURLHierarchy
public void setURLHierarchy(String url)
throws IOException

Sets the page URL while respecting the hierarchy of the html
Parameters:
url - the URL
Throws:
IOException

reload
public void reload()

Reload the current page


hasBack
public boolean hasBack()

Indicates whether back is currently available


Returns:
true if back should work
hasForward
public boolean hasForward()

Indicates whether forward is currently available


Returns:
true if forward should work

Method Detail

2013

Overview (Codename One API)


back
public void back()

Navigates back in the history


forward
public void forward()

Navigates forward in the history


clearHistory
public void clearHistory()

Clears navigation history


setPinchToZoomEnabled
public void setPinchToZoomEnabled(boolean e)

Some platforms require that you enable pinch to zoom explicitly. This method has no
effect if pinch to zoom isn't supported by the platform
Parameters:
e - true to enable pinch to zoom, false to disable it
isPinchToZoomEnabled
public boolean isPinchToZoomEnabled()

This method is unreliable and is only here for consistency with


setPinchToZoomEnabled, it will not return whether the platform supports pinch since
this is very hard to detect properly.
Returns:
the last value for setPinchToZoomEnabled
setNativeScrollingEnabled
public void setNativeScrollingEnabled(boolean b)

This flag allows disabling the native browser scrolling on platforms that support it
Parameters:
b - true to enable native scrolling, notice that non-native scrolling might be
problematic
isNativeScrollingEnabled
public boolean isNativeScrollingEnabled()

This method is unreliable and is only here for consistency with


setNativeScrollingEnabled.
Returns:
the last value for setNativeScrollingEnabled
setPage
public void setPage(String html,
String baseUrl)

Shows the given HTML in the native viewer


Parameters:
html - HTML web page
baseUrl - base URL to associate with the HTML
addWebEventListener
public void addWebEventListener(String type,
ActionListener listener)

Adds a listener to the given event type name, event type names are platform specific
but some must be fired for all platforms and will invoke the action listener when the
appropriate event loads
Parameters:
type - platform specific but must support: onStart, onLoad, onError

Method Detail

2014

Overview (Codename One API)


listener - callback for the event
removeWebEventListener
public void removeWebEventListener(String type,
ActionListener listener)

Removes the listener, see addWebEventListener for details


Parameters:
type - see addWebEventListener for details
listener - see addWebEventListener for details
stop
public void stop()

Cancel the loading of the current page


destroy
public void destroy()

Release native resources of this Browser Component


fireWebEvent
public void fireWebEvent(String type,
ActionEvent ev)

Used internally by the implementation to fire an event from the native browser widget
Parameters:
type - the type of the event
ev - the event
execute
public void execute(String javaScript)

Executes the given JavaScript string within the current context


Parameters:
javaScript - the JavaScript string
executeAndReturnString
public String executeAndReturnString(String javaScript)

Executes the given JavaScript and returns a result string from the underlying platform
where applicable
Parameters:
javaScript - the JavaScript code to execute
Returns:
the string returned from the Javascript call
exposeInJavaScript
public void exposeInJavaScript(Object o,
String name)

Deprecated. this doesn't work in most platforms see issue 459 for details, use the
setBrowserNavigationCallback method instead
Allows exposing the given object to JavaScript code so the JavaScript code can
invoke methods and access fields on the given object. Notice that on RIM devices
which don't support reflection this object must implement the propriatery Scriptable
interface
http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/script/Scriptable.html
Parameters:
o - the object to invoke, notice all public fields and methods would be
exposed to JavaScript
name - the name to expose within JavaScript

Method Detail

2015

Overview (Codename One API)


com.codename1.ui

Class AutoCompleteTextField
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.TextArea

com.codename1.ui.TextField

com.codename1.ui.AutoCompleteTextField
All Implemented Interfaces:
Animation, StyleListener

public class
extends TextField

An editable TextField with completion suggestions that show up in a drop down menu while the user
types in text.
This class uses the "TextField" UIID by default as well as "AutoCompletePopup" & "AutoCompleteList"
for the popup list details.
The sample below shows the more trivial use case for this widget:
Form hi = new Form("Auto Complete", new BoxLayout(BoxLayout.Y_AXIS));
AutoCompleteTextField ac = new AutoCompleteTextField("Short", "Shock", "Sholder", "Shrek");
ac.setMinimumElementsShownInPopup(5);
hi.add(ac);

Field Summary

Class AutoCompleteTextField

2016

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.TextArea

ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD,


NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, URL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
AutoCompleteTextField()

The default constructor is useful for cases of filter subclasses overriding the
getSuggestionModel value as well as for the GUI builder
AutoCompleteTextField(ListModel<String> listModel)

Constructor with completion suggestions, filtering is automatic in this case


AutoCompleteTextField(String... completion)

Constructor with completion suggestions

Method Summary
Modifier and Type
void

Method and Description


addListListener(ActionListener a)

Adds an action listener that fires an event when an entry in the auto-complete li
deinitialize()

protected void

protected boolean
String[]
int

Invoked to indicate that the component initialization is being reversed since the
the container hierarchy.
filter(String text)

Subclasses can override this method to perform more elaborate filter operations
getCompletion()

Returns the completion values


getMinimumElementsShownInPopup()

The number of elements shown for the auto complete popup


getMinimumLength()

int

Indicates the minimum length of text in the field in order for a popup to show the
shown immediately for all text length if the number is 2 a popup will only appear
or more.
getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipu


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
protected
ListModel<String>
protected void
boolean

This method is here to workaround an XMLVM array type bug where property ty
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Obj
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
getSuggestionModel()

Returns the list model to show within the completion list


initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready f
isStartsWithMode()

When enabled this makes the filter check that the string starts with rather than w

Fields inherited from class com.codename1.ui.TextArea

2017

Overview (Codename One API)


keyPressed(int k)

void

If this Component is focused, the key pressed event will call this method
keyReleased(int k)

void

If this Component is focused, the key released event will call this method
removeListListener(ActionListener a)

void

Removes an action listener that fires an event when an entry in the auto-comple
setCompletion(String... completion)

void

Sets the completion values


setCompletionRenderer(ListCellRenderer completionRenderer)

void

Sets a custom renderer to the completion suggestions list.


setMinimumElementsShownInPopup(int minimumElementsShownInPopup)

void

The number of elements shown for the auto complete popup


setMinimumLength(int minimumLength)

Indicates the minimum length of text in the field in order for a popup to show the
shown immediately for all text length if the number is 2 a popup will only appear
or more.

void

setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and n
setStartsWithMode(boolean startsWithMode)

void

When enabled this makes the filter check that the string starts with rather than w
setText(String text)

void

Sets the text within this text area

protected void

updateFilterList()

In a case of an asynchronous filter this method can be invoked to refresh the co

Methods inherited from class com.codename1.ui.TextField


addDataChangeListener, addInputMode, animate, calcPreferredSize, clear,
commitChange, create, create, create, create, createSymbolTable,
deleteChar, fireClicked, fireDataChanged, fireDoneEvent, getCharPerKeyCode,
getCommitTimeout, getCursorBlinkTimeOff, getCursorBlinkTimeOn,
getCursorPosition, getCursorX, getCursorY, getDefaultChangeInputModeKey,
getDefaultInputModeOrder, getDefaultSymbolDialogKey, getDoneListener,
getInputMode, getInputModeOrder, getLongClickDuration,
getLongClickInputMode, getSymbolTable, insertChars, installCommands,
isChangeInputMode, isClearKey, isCursorPositionCycle, isEditingEndTrigger,
isEditingTrigger, isEnableInputScroll, isImmediateInputMode,
isLeftAndRightEditingTrigger, isOverwriteMode, isPendingCommit,
isQwertyAutoDetect, isQwertyDevice, isQwertyInput, isReplaceMenu,
isReplaceMenuDefault, isSelectableInteraction, isSymbolDialogKey,
isUseNativeTextInput, isUseSoftkeys, keyRepeated, longKeyPress, paint,
pointerReleased, removeCommands, removeDataChangeListener, setAlignment,
setClearText, setCommitTimeout, setCursorBlinkTimeOff,
setCursorBlinkTimeOn, setCursorPosition, setDefaultChangeInputModeKey,
setDefaultInputModeOrder, setDefaultSymbolDialogKey, setDoneListener,
setEditable, setEnableInputScroll, setInputMode, setInputModeOrder,
setLeftAndRightEditingTrigger, setOverwriteMode, setQwertyAutoDetect,
setQwertyDevice, setQwertyInput, setReplaceMenu, setReplaceMenuDefault,
setSymbolTable, setT9Text, setUseNativeTextInput, setUseSoftkeys,
showSymbolDialog, validChar

Methods inherited from class com.codename1.ui.TextArea


addActionListener, autoDetectWidestChar, bindProperty, calcScrollSize,
getAbsoluteAlignment, getActualRows, getAlignment, getAsInt,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getColumns, getConstraint, getDefaultValign, getGrowLimit, getHint,
getHintIcon, getHintLabel, getLines, getLinesToScroll, getMaxSize, getRows,
getRowsGap, getStyle, getText, getTextAt, getUnsupportedChars,
getVerticalAlignment, getWidestChar, initLaf, isAutoDegradeMaxSize,
isEditable, isEditing, isEndsWith3Points, isEnterKey, isGrowByContent,
isScrollableY, isSingleLineTextArea, isUseStringWidth, pointerHover,
pointerHoverReleased, preprocess, removeActionListener,
setAutoDegradeMaxSize, setBoundPropertyValue, setColumns, setConstraint,
setDefaultMaxSize, setDefaultValign, setEndsWith3Points, setGrowByContent,
setGrowLimit, setHint, setHint, setHintIcon, setLinesToScroll, setMaxSize,
setRows, setRowsGap, setSingleLineTextArea, setUnsupportedChars,
setUseStringWidth, setVerticalAlignment, setWidestChar, setWidth,
startEditing, startEditingAsync, stopEditing, unbindProperty

Method Summary

2018

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
cancelRepaints, clearClientProperties, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
dragInitiated, drawDraggedImage, drop, focusGained, focusLost,
getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline,
getBaselineResizeBehavior, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, laidOut, longPointerPress,
onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder,
paintBorderBackground, paintComponent, paintComponent, paintLock,
paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY,
paramString, pinch, pointerDragged, pointerDragged, pointerHoverPressed,
pointerPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe,
styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
AutoCompleteTextField
public AutoCompleteTextField(String... completion)

Constructor with completion suggestions


Parameters:
completion - a String array of suggestion for completion
AutoCompleteTextField
public AutoCompleteTextField(ListModel<String> listModel)

Constructor with completion suggestions, filtering is automatic in this case


Parameters:

Methods inherited from class com.codename1.ui.Component

2019

Overview (Codename One API)


listModel - a list model containing potential string suggestions
AutoCompleteTextField
public AutoCompleteTextField()

The default constructor is useful for cases of filter subclasses overriding the
getSuggestionModel value as well as for the GUI builder

Method Detail
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class TextField
setText
public void setText(String text)

Sets the text within this text area


Overrides:
setText in class TextField
Parameters:
text - new value for the text area
updateFilterList
protected void updateFilterList()

In a case of an asynchronous filter this method can be invoked to refresh the


completion list
filter
protected boolean filter(String text)

Subclasses can override this method to perform more elaborate filter operations
Parameters:
text - the text to filter
Returns:
true if the filter has changed the list, false if it hasn't or is working
asynchronously
getSuggestionModel
protected ListModel<String> getSuggestionModel()

Returns the list model to show within the completion list


Returns:
the list model can be anything
setCompletionRenderer
public void setCompletionRenderer(ListCellRenderer completionRenderer)

Sets a custom renderer to the completion suggestions list.


Parameters:

Constructor Detail

2020

Overview (Codename One API)


completionRenderer

- a ListCellRenderer for the suggestions List

keyPressed
public void keyPressed(int k)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class TextField
Parameters:
k - the key code value to indicate a physical key.
keyReleased
public void keyReleased(int k)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class TextField
Parameters:
k - the key code value to indicate a physical key.
addListListener
public void addListListener(ActionListener a)

Adds an action listener that fires an event when an entry in the auto-complete list is
selected. Notice that this method will only take effect when the popup is reshown, if it
is invoked when a popup is already showing it will have no effect.
Parameters:
a - the listener
removeListListener
public void removeListListener(ActionListener a)

Removes an action listener that fires an event when an entry in the auto-complete list
is selected. Notice that this method will only take effect when the popup is reshown, if
it is invoked when a popup is already showing it will have no effect.
Parameters:
a - the listener
getMinimumLength
public int getMinimumLength()

Indicates the minimum length of text in the field in order for a popup to show the
default is 0 where a popup is shown immediately for all text length if the number is 2
a popup will only appear when there are two characters or more.
Returns:
the minimumLength
setMinimumLength
public void setMinimumLength(int minimumLength)

Indicates the minimum length of text in the field in order for a popup to show the
default is 0 where a popup is shown immediately for all text length if the number is 2
a popup will only appear when there are two characters or more.
Parameters:
minimumLength - the minimumLength to set
getMinimumElementsShownInPopup
public int getMinimumElementsShownInPopup()

The number of elements shown for the auto complete popup


Returns:
the minimumElementsShownInPopup
setMinimumElementsShownInPopup
public void setMinimumElementsShownInPopup(int minimumElementsShownInPopup)

The number of elements shown for the auto complete popup

Method Detail

2021

Overview (Codename One API)


Parameters:
minimumElementsShownInPopup

- the minimumElementsShownInPopup to set

getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setCompletion
public void setCompletion(String... completion)

Sets the completion values


Parameters:
completion - the completion values
getCompletion
public String[] getCompletion()

Returns the completion values


Returns:
array of completion entries
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.

Method Detail

2022

Overview (Codename One API)


Overrides:
setPropertyValue

in class Component

Parameters:
name - the name of the property
value - new value for the property

Returns:
error message or null
isStartsWithMode
public boolean isStartsWithMode()

When enabled this makes the filter check that the string starts with rather than within
the index
Returns:
the startsWithMode
setStartsWithMode
public void setStartsWithMode(boolean startsWithMode)

When enabled this makes the filter check that the string starts with rather than within
the index
Parameters:
startsWithMode - the startsWithMode to set

Method Detail

2023

Overview (Codename One API)


com.codename1.ui

Class AnimationManager
java.lang.Object

com.codename1.ui.AnimationManager

public final class


extends Object

Animation manager concentrates all of the animations for a given form into a single place that allows
us to manage all mutations to a Form in a way the prevents collisions between mutations. The one
type of animation that isn't handled by this class is the form level transition, replace transitions are
handled by this class.

Method Summary
Modifier
and Type

Method and Description


addAnimation(ComponentAnimation an)

void

Adds the animation to the end to the animation queue


addAnimation(ComponentAnimation an, Runnable callback)

void

Adds the animation to the end to the animation queue


addAnimationAndBlock(ComponentAnimation an)

Adds the animation to the end of the animation queue and blocks the current
thread until the animation completes

void

flushAnimation(Runnable r)

void

Invokes the runnable when all animations have completed

boolean

isAnimating()

Returns true if an animation is currently in progress


onTitleScrollAnimation(ComponentAnimation... cna)

void

Performs a step animation as the user scrolls down/up the page e.g.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
isAnimating
public boolean isAnimating()

Returns true if an animation is currently in progress


Returns:
true if an animation is currently in progress
addAnimation
public void addAnimation(ComponentAnimation an)

Adds the animation to the end to the animation queue


Parameters:
an - the animation object

Class AnimationManager

2024

Overview (Codename One API)


addAnimationAndBlock
public void addAnimationAndBlock(ComponentAnimation an)

Adds the animation to the end of the animation queue and blocks the current thread
until the animation completes
Parameters:
an - the animation to perform
addAnimation
public void addAnimation(ComponentAnimation an,
Runnable callback)

Adds the animation to the end to the animation queue


Parameters:
an - the animation object
callback - invoked when the animation completes
onTitleScrollAnimation
public void onTitleScrollAnimation(ComponentAnimation... cna)

Performs a step animation as the user scrolls down/up the page e.g. slowly
converting a title UIID from a big visual representation to a smaller title for easier
navigation then back again when scrolling up
Parameters:
cna - the animation to bind to the scroll event
flushAnimation
public void flushAnimation(Runnable r)

Invokes the runnable when all animations have completed


Parameters:
r - the runnable that will be invoked after the animations

Method Detail

2025

Overview (Codename One API)


com.codename1.testing

Interface UnitTest
All Known Implementing Classes:
AbstractTest

public interface

A Codename One unit test interface, you would normally like to derive from AbstractTest which is less
verbose and contains many helper methods.

Method Summary
Modifier and
Type

Method and Description


cleanup()

void

Cleanup after a test case executed


getTimeoutMillis()

Returns the time in milliseconds after which the test should be


automatically failed.

int

prepare()

void

Prepares the unit test for execution

boolean
boolean

runTest()

Runs a unit test, if it returns true it passed.


shouldExecuteOnEDT()

Returns true to indicate that the test expects to be executed on the EDT

Method Detail
runTest
boolean runTest()
throws Exception

Runs a unit test, if it returns true it passed. If it threw an exception or returned false it
failed.
Returns:
whether it passed
Throws:
Exception - thrown if it failed
prepare
void prepare()

Prepares the unit test for execution


cleanup
void cleanup()

Cleanup after a test case executed


getTimeoutMillis
int getTimeoutMillis()

Returns the time in milliseconds after which the test should be automatically failed.
Returns:
time in milliseconds

Interface UnitTest

2026

Overview (Codename One API)


shouldExecuteOnEDT
boolean shouldExecuteOnEDT()

Returns true to indicate that the test expects to be executed on the EDT
Returns:
whether the test should execute on the EDT or the testing thread

Method Detail

2027

Overview (Codename One API)


com.codename1.testing

Class TestUtils
java.lang.Object

com.codename1.testing.TestUtils

public class
extends Object

Various utility classes to automate UI testing

Method Summary
Modifier and
Type
static void
static void

static void

Method and Description


assertArrayEqual(byte[] expected, byte[] actual)

Asserts that the given byte arrays are equal


assertArrayEqual(byte[] expected, byte[] actual, String errorMessage)

Asserts that the given byte arrays are equal


assertArrayEqual(double[] expected, double[] actual,
double maxRelativeError)

Asserts that the given double arrays are equal


static void

assertArrayEqual(double[] expected, double[] actual,


double maxRelativeError, String errorMessage)

Asserts that the given double arrays are equal


static void

assertArrayEqual(float[] expected, float[] actual,


double maxRelativeError)

Asserts that the given float arrays are equal


static void

assertArrayEqual(float[] expected, float[] actual,


double maxRelativeError, String errorMessage)

Asserts that the given double arrays are equal


static void
static void

static void

assertArrayEqual(int[] expected, int[] actual)

Asserts that the given int arrays are equal


assertArrayEqual(int[] expected, int[] actual, String errorMessage)

Asserts that the given int arrays are equal


assertArrayEqual(long[] expected, long[] actual,
double maxRelativeError)

Asserts that the given long arrays are equal


static void

assertArrayEqual(long[] expected, long[] actual,


double maxRelativeError, String errorMessage)

Asserts that the given long arrays are equal


static void

static void

assertArrayEqual(Object[] expected, Object[] actual)

Asserts that the given object arrays are equal


assertArrayEqual(Object[] expected, Object[] actual,
String errorMessage)

Asserts that the given object arrays are equal


static void

static void

assertArrayEqual(short[] expected, short[] actual)

Asserts that the given short arrays are equal


assertArrayEqual(short[] expected, short[] actual,
String errorMessage)

Asserts that the given short arrays are equal


static void
static void
static void

Class TestUtils

assertBool(boolean b)

Assertions allow for simpler test code


assertBool(boolean b, String errorMessage)

Assertions allow for simpler test code


assertEqual(byte expected, byte actual)

2028

Overview (Codename One API)


Asserts that the given bytes are equal
static void
static void

static void

assertEqual(byte expected, byte actual, String errorMessage)

Asserts that the given bytes are equal


assertEqual(double expected, double actual, double maxRelativeError)

Asserts that the given doubles are equal


assertEqual(double expected, double actual, double maxRelativeError,
String errorMessage)

Asserts that the given doubles are equal


static void

static void

assertEqual(float expected, float actual, double maxRelativeError)

Asserts that the given floats are equal


assertEqual(float expected, float actual, double maxRelativeError,
String errorMessage)

Asserts that the given floats are equal


static void
static void
static void
static void

assertEqual(int expected, int actual)

Asserts that the given ints are equal


assertEqual(int expected, int actual, String errorMessage)

Asserts that the given ints are equal


assertEqual(long expected, long actual)

Asserts that the given longs are equal


assertEqual(long expected, long actual, String errorMessage)

Asserts that the given longs are equal


assertEqual(Object expected, Object actual)

static void

Asserts that the given objects are equal using the first object's .equal()
method
assertEqual(Object expected, Object actual, String errorMessage)

static void

static void
static void
static void

static void

Asserts that the given objects are equal using the first object's .equal()
method
assertEqual(short expected, short actual)

Asserts that the given shorts are equal


assertEqual(short expected, short actual, String errorMessage)

Asserts that the given shorts are equal


assertException(RuntimeException exception, Runnable expression)

Asserts that a certain exception is raised


assertException(RuntimeException exception, Runnable expression,
String errorMessage)

Asserts that a certain exception is raised


static void
static void
static void
static void
static void
static void
static void
static void
static void

static void

assertFalse(boolean value)

Asserts that the given expression evaluates to false


assertFalse(boolean value, String errorMessage)

Asserts that the given expression evaluates to false


assertLabel(int[] path, String text)

Asserts that we have a label with the given text baring the given name
assertLabel(String text)

Asserts that we have a label with the given text baring the given name
assertLabel(String name, String text)

Asserts that we have a label with the given text baring the given name
assertNoException(Runnable expression)

Asserts that no exception is raised


assertNoException(Runnable expression, String errorMessage)

Asserts that no exception is raised


assertNotEqual(byte expected, byte actual)

Asserts that the given bytes are not equal


assertNotEqual(byte expected, byte actual, String errorMessage)

Asserts that the given bytes are not equal


assertNotEqual(double expected, double actual,
double minRelativeError)

Asserts that the given doubles are not equal


static void

Method Summary

assertNotEqual(double expected, double actual,


double minRelativeError, String errorMessage)

2029

Overview (Codename One API)


Asserts that the given doubles are not equal
static void
static void
static void

static void

assertNotEqual(int expected, int actual)

Asserts that the given ints are not equal


assertNotEqual(int expected, int actual, String errorMessage)

Asserts that the given ints are not equal


assertNotEqual(long expected, long actual, double minRelativeError)

Asserts that the given longs are not equal


assertNotEqual(long expected, long actual, double minRelativeError,
String errorMessage)

Asserts that the given longs are not equal


assertNotEqual(Object expected, Object actual)
static void

Asserts that the given objects are not equal using the first object's .equal()
method
assertNotEqual(Object expected, Object actual, String errorMessage)

static void

static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void

Method Summary

Asserts that the given objects are not equal using the first object's .equal()
method
assertNotEqual(short expected, short actual)

Asserts that the given shorts are not equal


assertNotEqual(short expected, short actual, String errorMessage)

Asserts that the given shorts are not equal


assertNotNull(Object object)

Asserts that the given expression does not evaluate to null


assertNotNull(Object object, String errorMessage)

Asserts that the given expression does not evaluate to null


assertNotSame(Object expected, Object actual)

Asserts that the given parameters do not reference the same object
assertNotSame(Object expected, Object actual, String errorMessage)

Asserts that the given parameters do not reference the same object
assertNull(Object object)

Asserts that the given expression evaluates to null


assertNull(Object object, String errorMessage)

Asserts that the given expression evaluates to null


assertSame(Object expected, Object actual)

Asserts that the given parameters reference the same object


assertSame(Object expected, Object actual, String errorMessage)

Asserts that the given parameters reference the same object


assertTextArea(int[] path, String text)

Asserts that we have a label with the given text baring the given name
assertTextArea(String text)

Asserts that we have a label with the given text baring the given name
assertTextArea(String name, String text)

Asserts that we have a label with the given text baring the given name
assertTitle(String title)

Verifies the current title is the same otherwise throws an exception


assertTrue(boolean value)

Asserts that the given expression evaluates to true


assertTrue(boolean value, String errorMessage)

Asserts that the given expression evaluates to true


clickButtonByLabel(String text)

Clicks the button with the given label


clickButtonByName(String name)

Clicks the button with the given label


clickButtonByPath(int[] path)

Clicks the button with the given component path


clickMenuItem(String name)

Executes a menu command with the given name


ensureVisible(Component c)

Scrolls to show the component in case it is invisible currently

2030

Overview (Codename One API)


static void
static void
static void
static void
static
Component
static
Label
static
TextArea
static void
static void
static
Component

ensureVisible(int[] path)

Scrolls to show the component in case it is invisible currently


ensureVisible(String componentName)

Scrolls to show the component in case it is invisible currently


fail()

An assertion that always fails a test.


fail(String errorMessage)

An assertion that always fails a test.


findByName(String componentName)

Finds a component with the given name, works even with UI's that weren't
created with the GUI builder
findLabelText(String text)

Finds a component with the given name, works even with UI's that weren't
created with the GUI builder
findTextAreaText(String text)

Finds a component with the given name, works even with UI's that weren't
created with the GUI builder
gameKeyPress(int gameKey)

Simulates a game key press


gameKeyRelease(int gameKey)

Simulates a game key release


getComponentByPath(int[] path)

Gets the component from the current form based on its path.
goBack()

static void

static void
static void
static void
static void

Executes the back command for the current form, similarly to pressing the
back button
keyPress(int keyCode)

Simulates a device key press


keyRelease(int keyCode)

Simulates a device key release


log(String t)

Log to the test log


log(Throwable t)

Log to the test log


pointerDrag(float x, float y, int[] path)

static void

A component drag on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
pointerDrag(float x, float y, String componentName)

static void

A component drag on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
pointerPress(float x, float y, int[] path)

static void

A component press on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
pointerPress(float x, float y, String componentName)

static void

A component press on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
pointerRelease(float x, float y, int[] path)

static void

A component release on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
pointerRelease(float x, float y, String componentName)

static void

static
boolean

Method Summary

A component release on a given named component at x/y where x and y are


NOT pixels but rather a number between 0 to 1 representing the percentage
within the component where the event took place.
screenshotTest(String screenshotName)

2031

Overview (Codename One API)


The screenshot test takes a screenshot of the screen and compares it to a
prior screenshot, if both are 100% identical the test passes.
static void
static void
static void
static void
static void

selectInList(int[] path, int offset)

Selects the given offset in a list


selectInList(String listName, int offset)

Selects the given offset in a list


setText(int[] path, String text)

Sets the text for the given component


setText(String name, String text)

Sets the text for the given component


setVerboseMode(boolean v)

Activates/deactivates the verbose test mode


waitFor(int millis)

static void

Waits for the given number of milliseconds even if the waiting is on the EDT
thread
waitForFormName(String name)

static void

Waits for a form change and if no form change occurred after a given timeout
then fail the test
waitForFormTitle(String title)

static void

Waits for a form change and if no form change occurred after a given timeout
then fail the test

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
setVerboseMode
public static void setVerboseMode(boolean v)

Activates/deactivates the verbose test mode


Parameters:
v - true for verbosity
waitFor
public static void waitFor(int millis)

Waits for the given number of milliseconds even if the waiting is on the EDT thread
Parameters:
millis - the number of milliseconds to wait
findByName
public static Component findByName(String componentName)

Finds a component with the given name, works even with UI's that weren't created
with the GUI builder
Parameters:
componentName - the name of the component to find
Returns:
the component with the given name within the tree
selectInList
public static void selectInList(String listName,
int offset)

Selects the given offset in a list


Parameters:
listName - the name of the list component
offset - the offset to select

Methods inherited from class java.lang.Object

2032

Overview (Codename One API)


selectInList
public static void selectInList(int[] path,
int offset)

Selects the given offset in a list


Parameters:
listName - the name of the list component
offset - the offset to select
findLabelText
public static Label findLabelText(String text)

Finds a component with the given name, works even with UI's that weren't created
with the GUI builder
Parameters:
text - the text of the label/button
Returns:
the component with the given label text within the tree
clickButtonByLabel
public static void clickButtonByLabel(String text)

Clicks the button with the given label


Parameters:
text - the text on the button
clickButtonByName
public static void clickButtonByName(String name)

Clicks the button with the given label


Parameters:
name - the name of the button
clickButtonByPath
public static void clickButtonByPath(int[] path)

Clicks the button with the given component path


Parameters:
path - the path
goBack
public static void goBack()

Executes the back command for the current form, similarly to pressing the back
button
clickMenuItem
public static void clickMenuItem(String name)

Executes a menu command with the given name


Parameters:
name - the name of the command
ensureVisible
public static void ensureVisible(Component c)

Scrolls to show the component in case it is invisible currently


Parameters:
c - the component
ensureVisible
public static void ensureVisible(String componentName)

Scrolls to show the component in case it is invisible currently


Parameters:
componentName - the component

Method Detail

2033

Overview (Codename One API)


ensureVisible
public static void ensureVisible(int[] path)

Scrolls to show the component in case it is invisible currently


Parameters:
path - the path to the component
waitForFormTitle
public static void waitForFormTitle(String title)

Waits for a form change and if no form change occurred after a given timeout then fail
the test
Parameters:
title - the title of the form to wait for
waitForFormName
public static void waitForFormName(String name)

Waits for a form change and if no form change occurred after a given timeout then fail
the test
Parameters:
name - the name of the form to wait for
screenshotTest
public static boolean screenshotTest(String screenshotName)

The screenshot test takes a screenshot of the screen and compares it to a prior
screenshot, if both are 100% identical the test passes. If not the test fails.
If this is the first time the test is run then the screenshot is taken and saved under the
given name in the devices storage. The test passes for this case but a warning is
printed to the console. The name will have .png appended to it so it will be identified.
This test will only work on devices that support the ImageIO API with PNG file format.
Parameters:
screenshotName - the name to use for the storage, must be unique!
Returns:
true if the screenshots are identical or no prior screenshot exists or if the test
can't be run on this device. False if a screenshot exists and it isn't 100%
identical.
log
public static void log(String t)

Log to the test log


Parameters:
t - the string to log
log
public static void log(Throwable t)

Log to the test log


Parameters:
t - exception to log
keyPress
public static void keyPress(int keyCode)

Simulates a device key press


Parameters:
keyCode - the keycode
keyRelease
public static void keyRelease(int keyCode)

Simulates a device key release


Parameters:
keyCode - the keycode

Method Detail

2034

Overview (Codename One API)


gameKeyPress
public static void gameKeyPress(int gameKey)

Simulates a game key press


Parameters:
gameKey - the game key (arrows etc.)
gameKeyRelease
public static void gameKeyRelease(int gameKey)

Simulates a game key release


Parameters:
gameKey - the game key (arrows etc.)
pointerPress
public static void pointerPress(float x,
float y,
String componentName)

A component press on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1
y - the offset within the component as a number between 0 and 1
componentName - the name of the component
pointerRelease
public static void pointerRelease(float x,
float y,
String componentName)

A component release on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1
y - the offset within the component as a number between 0 and 1
componentName - the name of the component
pointerDrag
public static void pointerDrag(float x,
float y,
String componentName)

A component drag on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1
y - the offset within the component as a number between 0 and 1
componentName - the name of the component
pointerPress
public static void pointerPress(float x,
float y,
int[] path)

A component press on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1

Method Detail

2035

Overview (Codename One API)


y - the offset within the component
path - the path to the component

as a number between 0 and 1

pointerRelease
public static void pointerRelease(float x,
float y,
int[] path)

A component release on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1
y - the offset within the component as a number between 0 and 1
path - the path to the component
pointerDrag
public static void pointerDrag(float x,
float y,
int[] path)

A component drag on a given named component at x/y where x and y are NOT
pixels but rather a number between 0 to 1 representing the percentage within the
component where the event took place. E.g. For a 100x100 component a press within
10,5 would be 0.1f, 0.05f.
Parameters:
x - the offset within the component as a number between 0 and 1
y - the offset within the component as a number between 0 and 1
path - the path to the component
getComponentByPath
public static Component getComponentByPath(int[] path)

Gets the component from the current form based on its path. A path is a set of offsets
starting from the content pane and moving inwards so a path of { 0, 3 } would mean
that the first component within the Content pane (by index) is a Container whose 3rd
component (again by index) is the component we want.
Parameters:
path - an array
Returns:
a component
setText
public static void setText(String name,
String text)

Sets the text for the given component


Parameters:
name - the name of the component
text - the text to set
setText
public static void setText(int[] path,
String text)

Sets the text for the given component


Parameters:
path - the path to the component
text - the text to set
assertBool
public static void assertBool(boolean b)

Assertions allow for simpler test code


Parameters:
b - must be true, otherwise an exception is thrown thus failing the test

Method Detail

2036

Overview (Codename One API)


assertBool
public static void assertBool(boolean b,
String errorMessage)

Assertions allow for simpler test code


Parameters:
b - must be true, otherwise an exception is thrown thus failing the test
fail
public static void fail()

An assertion that always fails a test.


fail
public static void fail(String errorMessage)

An assertion that always fails a test.


Parameters:
errorMessage - is a string describing the failure
assertTrue
public static void assertTrue(boolean value)

Asserts that the given expression evaluates to true


assertTrue
public static void assertTrue(boolean value,
String errorMessage)

Asserts that the given expression evaluates to true


Parameters:
errorMessage - is a string describing the failure
assertFalse
public static void assertFalse(boolean value)

Asserts that the given expression evaluates to false


assertFalse
public static void assertFalse(boolean value,
String errorMessage)

Asserts that the given expression evaluates to false


Parameters:
errorMessage - is a string describing the failure
assertNull
public static void assertNull(Object object)

Asserts that the given expression evaluates to null


assertNull
public static void assertNull(Object object,
String errorMessage)

Asserts that the given expression evaluates to null


Parameters:
errorMessage - is a string describing the failure
assertNotNull
public static void assertNotNull(Object object)

Asserts that the given expression does not evaluate to null

Method Detail

2037

Overview (Codename One API)


assertNotNull
public static void assertNotNull(Object object,
String errorMessage)

Asserts that the given expression does not evaluate to null


Parameters:
errorMessage - is a string describing the failure
assertSame
public static void assertSame(Object expected,
Object actual)

Asserts that the given parameters reference the same object


assertSame
public static void assertSame(Object expected,
Object actual,
String errorMessage)

Asserts that the given parameters reference the same object


Parameters:
errorMessage - is a string describing the failure
assertNotSame
public static void assertNotSame(Object expected,
Object actual)

Asserts that the given parameters do not reference the same object
assertNotSame
public static void assertNotSame(Object expected,
Object actual,
String errorMessage)

Asserts that the given parameters do not reference the same object
Parameters:
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(byte expected,
byte actual)

Asserts that the given bytes are equal


assertEqual
public static void assertEqual(byte expected,
byte actual,
String errorMessage)

Asserts that the given bytes are equal


Parameters:
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(short expected,
short actual)

Asserts that the given shorts are equal


assertEqual
public static void assertEqual(short expected,
short actual,
String errorMessage)

Asserts that the given shorts are equal


Parameters:
errorMessage - is a string describing the failure

Method Detail

2038

Overview (Codename One API)


assertEqual
public static void assertEqual(int expected,
int actual)

Asserts that the given ints are equal


assertEqual
public static void assertEqual(int expected,
int actual,
String errorMessage)

Asserts that the given ints are equal


Parameters:
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(long expected,
long actual)

Asserts that the given longs are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
assertEqual
public static void assertEqual(long expected,
long actual,
String errorMessage)

Asserts that the given longs are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(float expected,
float actual,
double maxRelativeError)

Asserts that the given floats are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(float expected,
float actual,
double maxRelativeError,
String errorMessage)

Asserts that the given floats are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(double expected,
double actual,
double maxRelativeError)

Asserts that the given doubles are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure

Method Detail

2039

Overview (Codename One API)


assertEqual
public static void assertEqual(double
double
double
String

expected,
actual,
maxRelativeError,
errorMessage)

Asserts that the given doubles are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertEqual
public static void assertEqual(Object expected,
Object actual)

Asserts that the given objects are equal using the first object's .equal() method
assertEqual
public static void assertEqual(Object expected,
Object actual,
String errorMessage)

Asserts that the given objects are equal using the first object's .equal() method
Parameters:
errorMessage - is a string describing the failure
assertNotEqual
public static void assertNotEqual(byte expected,
byte actual)

Asserts that the given bytes are not equal


assertNotEqual
public static void assertNotEqual(byte expected,
byte actual,
String errorMessage)

Asserts that the given bytes are not equal


Parameters:
errorMessage - is a string describing the failure
assertNotEqual
public static void assertNotEqual(short expected,
short actual)

Asserts that the given shorts are not equal


assertNotEqual
public static void assertNotEqual(short expected,
short actual,
String errorMessage)

Asserts that the given shorts are not equal


Parameters:
errorMessage - is a string describing the failure
assertNotEqual
public static void assertNotEqual(int expected,
int actual)

Asserts that the given ints are not equal


assertNotEqual
public static void assertNotEqual(int expected,
int actual,
String errorMessage)

Asserts that the given ints are not equal

Method Detail

2040

Overview (Codename One API)


Parameters:
errorMessage

- is a string describing the failure

assertNotEqual
public static void assertNotEqual(long expected,
long actual,
double minRelativeError)

Asserts that the given longs are not equal


assertNotEqual
public static void assertNotEqual(long expected,
long actual,
double minRelativeError,
String errorMessage)

Asserts that the given longs are not equal


Parameters:
minRelativeError - is the minimum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertNotEqual
public static void assertNotEqual(double expected,
double actual,
double minRelativeError)

Asserts that the given doubles are not equal


Parameters:
minRelativeError - is the minimum allowed error, a value of 1 represents a
1% error.
assertNotEqual
public static void assertNotEqual(double
double
double
String

expected,
actual,
minRelativeError,
errorMessage)

Asserts that the given doubles are not equal


Parameters:
minRelativeError - is the minimum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertNotEqual
public static void assertNotEqual(Object expected,
Object actual)

Asserts that the given objects are not equal using the first object's .equal() method
assertNotEqual
public static void assertNotEqual(Object expected,
Object actual,
String errorMessage)

Asserts that the given objects are not equal using the first object's .equal() method
Parameters:
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(byte[] expected,
byte[] actual)

Asserts that the given byte arrays are equal


assertArrayEqual
public static void assertArrayEqual(byte[] expected,
byte[] actual,
String errorMessage)

Method Detail

2041

Overview (Codename One API)


Asserts that the given byte arrays are equal
Parameters:
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(short[] expected,
short[] actual)

Asserts that the given short arrays are equal


assertArrayEqual
public static void assertArrayEqual(short[] expected,
short[] actual,
String errorMessage)

Asserts that the given short arrays are equal


Parameters:
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(int[] expected,
int[] actual)

Asserts that the given int arrays are equal


assertArrayEqual
public static void assertArrayEqual(int[] expected,
int[] actual,
String errorMessage)

Asserts that the given int arrays are equal


Parameters:
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(long[] expected,
long[] actual,
double maxRelativeError)

Asserts that the given long arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
assertArrayEqual
public static void assertArrayEqual(long[]
long[]
double
String

expected,
actual,
maxRelativeError,
errorMessage)

Asserts that the given long arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(float[] expected,
float[] actual,
double maxRelativeError)

Asserts that the given float arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.

Method Detail

2042

Overview (Codename One API)


assertArrayEqual
public static void assertArrayEqual(float[] expected,
float[] actual,
double maxRelativeError,
String errorMessage)

Asserts that the given double arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(double[] expected,
double[] actual,
double maxRelativeError)

Asserts that the given double arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
assertArrayEqual
public static void assertArrayEqual(double[] expected,
double[] actual,
double maxRelativeError,
String errorMessage)

Asserts that the given double arrays are equal


Parameters:
maxRelativeError - is the maximum allowed error, a value of 1 represents a
1% error.
errorMessage - is a string describing the failure
assertArrayEqual
public static void assertArrayEqual(Object[] expected,
Object[] actual)

Asserts that the given object arrays are equal


assertArrayEqual
public static void assertArrayEqual(Object[] expected,
Object[] actual,
String errorMessage)

Asserts that the given object arrays are equal


Parameters:
errorMessage - is a string describing the failure
assertException
public static void assertException(RuntimeException exception,
Runnable expression)

Asserts that a certain exception is raised


Parameters:
exception expression assertException
public static void assertException(RuntimeException exception,
Runnable expression,
String errorMessage)

Asserts that a certain exception is raised


Parameters:
exception expression errorMessage -

Method Detail

2043

Overview (Codename One API)


assertNoException
public static void assertNoException(Runnable expression)

Asserts that no exception is raised


Parameters:
expression assertNoException
public static void assertNoException(Runnable expression,
String errorMessage)

Asserts that no exception is raised


Parameters:
expression errorMessage assertTitle
public static void assertTitle(String title)

Verifies the current title is the same otherwise throws an exception


Parameters:
title - the tile to verify
assertLabel
public static void assertLabel(String name,
String text)

Asserts that we have a label with the given text baring the given name
Parameters:
name - the name of the label
text - the text of the label
assertLabel
public static void assertLabel(int[] path,
String text)

Asserts that we have a label with the given text baring the given name
Parameters:
path - the path of the label
text - the text of the label
assertLabel
public static void assertLabel(String text)

Asserts that we have a label with the given text baring the given name
Parameters:
text - the text of the label
assertTextArea
public static void assertTextArea(String name,
String text)

Asserts that we have a label with the given text baring the given name
Parameters:
name - the name of the label
text - the text of the label
assertTextArea
public static void assertTextArea(int[] path,
String text)

Asserts that we have a label with the given text baring the given name
Parameters:
path - the path to the text area
text - the text of the label

Method Detail

2044

Overview (Codename One API)


assertTextArea
public static void assertTextArea(String text)

Asserts that we have a label with the given text baring the given name
Parameters:
text - the text of the label
findTextAreaText
public static TextArea findTextAreaText(String text)

Finds a component with the given name, works even with UI's that weren't created
with the GUI builder
Parameters:
text - the text of the label/button
Returns:
the component with the given TextArea text within the tree

Method Detail

2045

Overview (Codename One API)


com.codename1.testing

Class TestReporting
java.lang.Object

com.codename1.testing.TestReporting
Direct Known Subclasses:
JUnitXMLReporting

public class
extends Object

Test reports can be overriden to provide custom test reporting options you can replace the test
reporter on the device by sending the build argument
build.testReporter='com.x.MyTestReporterClass'.

Constructor Summary
Constructor and Description
TestReporting()

Method Summary
Modifier and Type

Method and Description


finishedTestCase(UnitTest test, boolean passed)

void

Invoked when a unit test has completed

static
TestReporting

getInstance()

Gets the test reporting instance


logException(Throwable err)

void

Indicates an error from the current test case


logMessage(String message)

void

Indicates a message from the current test case

static void

setInstance(TestReporting i)

Sets the test reporting instance to a subclass of this class.


startingTestCase(UnitTest test)

void

Invoked when a unit test is started


testExecutionFinished()

Callback to indicate the test execution has finished allowing for a report
to be generated if appropriate

void

writeReport(OutputStream os)

void

Writes a test report to the given stream

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
TestReporting
public TestReporting()

Class TestReporting

2046

Overview (Codename One API)


Method

Detail

getInstance
public static TestReporting getInstance()

Gets the test reporting instance


setInstance
public static void setInstance(TestReporting i)

Sets the test reporting instance to a subclass of this class.


Parameters:
i - the new instance
startingTestCase
public void startingTestCase(UnitTest test)

Invoked when a unit test is started


Parameters:
test - the test case
logMessage
public void logMessage(String message)

Indicates a message from the current test case


Parameters:
message - the message
logException
public void logException(Throwable err)

Indicates an error from the current test case


Parameters:
err - the error message
finishedTestCase
public void finishedTestCase(UnitTest test,
boolean passed)

Invoked when a unit test has completed


Parameters:
test - the test case
passed - true if the test passed and false otherwise
writeReport
public void writeReport(OutputStream os)
throws IOException

Writes a test report to the given stream


Parameters:
os - the destination stream
Throws:
IOException

testExecutionFinished
public void testExecutionFinished()

Callback to indicate the test execution has finished allowing for a report to be
generated if appropriate

Method Detail

2047

Overview (Codename One API)


com.codename1.testing

Class JUnitXMLReporting
java.lang.Object

com.codename1.testing.TestReporting

com.codename1.testing.JUnitXMLReporting

public class
extends TestReporting

Produces test reporting in the format of JUnit XML for compatibility with tools that consume JUnit test
case results see http://code.google.com/p/codenameone/issues/detail?id=446 for more details.

Constructor Summary
Constructor and Description
JUnitXMLReporting()

Method Summary
Modifier and
Type

Method and Description


finishedTestCase(UnitTest test, boolean passed)

void

Invoked when a unit test has completed


logException(Throwable err)

void

Indicates an error from the current test case


logMessage(String message)

void

Indicates a message from the current test case


startingTestCase(UnitTest test)

void

Invoked when a unit test is started


testExecutionFinished()

Callback to indicate the test execution has finished allowing for a report to
be generated if appropriate

void

writeReport(OutputStream os)

void

Writes a test report to the given stream

Methods inherited from


class com.codename1.testing.TestReporting
getInstance, setInstance

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
JUnitXMLReporting
public JUnitXMLReporting()

Class JUnitXMLReporting

2048

Overview (Codename One API)


Method

Detail

startingTestCase
public void startingTestCase(UnitTest test)

Invoked when a unit test is started


Overrides:
startingTestCase in class TestReporting
Parameters:
test - the test case
logMessage
public void logMessage(String message)

Indicates a message from the current test case


Overrides:
logMessage in class TestReporting
Parameters:
message - the message
logException
public void logException(Throwable err)

Indicates an error from the current test case


Overrides:
logException in class TestReporting
Parameters:
err - the error message
finishedTestCase
public void finishedTestCase(UnitTest test,
boolean passed)

Invoked when a unit test has completed


Overrides:
finishedTestCase in class TestReporting
Parameters:
test - the test case
passed - true if the test passed and false otherwise
writeReport
public void writeReport(OutputStream os)
throws IOException

Writes a test report to the given stream


Overrides:
writeReport in class TestReporting
Parameters:
os - the destination stream
Throws:
IOException

testExecutionFinished
public void testExecutionFinished()

Callback to indicate the test execution has finished allowing for a report to be
generated if appropriate
Overrides:
testExecutionFinished in class TestReporting

Method Detail

2049

Overview (Codename One API)


com.codename1.testing

Class DeviceRunner
java.lang.Object

com.codename1.testing.DeviceRunner

public abstract class


extends Object

Runs the test cases from the test build of the app, notice that this class is abstract since device/app
specific code can exist in the implementation

Constructor Summary
Constructor and Description
DeviceRunner()

Method Summary
Modifier and
Type

Method and Description


runTest(String testClassName)

void

Runs the given test case


runTests()

void

Run all the test cases

protected
abstract void
protected
abstract void

startApplicationInstance()

This method starts a new application instance


stopApplicationInstance()

This method should cleanup the application so the next test case can
run on a clean application instance

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DeviceRunner
public DeviceRunner()

Method Detail
runTests
public void runTests()

Run all the test cases


startApplicationInstance
protected abstract void startApplicationInstance()

This method starts a new application instance

Class DeviceRunner

2050

Overview (Codename One API)


stopApplicationInstance
protected abstract void stopApplicationInstance()

This method should cleanup the application so the next test case can run on a clean
application instance
runTest
public void runTest(String testClassName)

Runs the given test case


Parameters:
testClassName - the class name of the test case

Method Detail

2051

Overview (Codename One API)


com.codename1.testing

Class AbstractTest
java.lang.Object

com.codename1.testing.AbstractTest
All Implemented Interfaces:
UnitTest

public abstract class


extends Object
implements UnitTest

A unit test class that simplifies the process of writing test cases for Codename One.

Constructor Summary
Constructor and Description
AbstractTest()

Method Summary
Modifier and
Type
void

void

Method and Description


assertArrayEqual(byte[] expected, byte[] actual)

This method just invokes the test utils method, it is here for convenience
assertArrayEqual(byte[] expected, byte[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
void

assertArrayEqual(double[] expected, double[] actual,


double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertArrayEqual(double[] expected, double[] actual,


double maxRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void

assertArrayEqual(float[] expected, float[] actual,


double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertArrayEqual(float[] expected, float[] actual,


double maxRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void
void

void

assertArrayEqual(int[] expected, int[] actual)

This method just invokes the test utils method, it is here for convenience
assertArrayEqual(int[] expected, int[] actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertArrayEqual(long[] expected, long[] actual,
long maxRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertArrayEqual(long[] expected, long[] actual,


long maxRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void

void

assertArrayEqual(Object[] expected, Object[] actual)

This method just invokes the test utils method, it is here for convenience
assertArrayEqual(Object[] expected, Object[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience

Class AbstractTest

2052

Overview (Codename One API)


void

void

assertArrayEqual(short[] expected, short[] actual)

This method just invokes the test utils method, it is here for convenience
assertArrayEqual(short[] expected, short[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
void
void
void
void

void

assertBool(boolean b)

This method just invokes the test utils method, it is here for convenience
assertBool(boolean b, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertEqual(byte expected, byte actual)

This method just invokes the test utils method, it is here for convenience
assertEqual(byte expected, byte actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertEqual(double expected, double actual,
double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertEqual(double expected, double actual,


double maxRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void

void

assertEqual(float expected, float actual, double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
assertEqual(float expected, float actual, double maxRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
void
void
void
void
void
void
void
void
void

void

assertEqual(int expected, int actual)

This method just invokes the test utils method, it is here for convenience
assertEqual(int expected, int actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertEqual(long expected, long actual)

This method just invokes the test utils method, it is here for convenience
assertEqual(long expected, long actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertEqual(Object expected, Object actual)

This method just invokes the test utils method, it is here for convenience
assertEqual(Object expected, Object actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertEqual(short expected, short actual)

This method just invokes the test utils method, it is here for convenience
assertEqual(short expected, short actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertException(RuntimeException exception, Runnable expression)

This method just invokes the test utils method, it is here for convenience
assertException(RuntimeException exception, Runnable expression,
String message)

This method just invokes the test utils method, it is here for convenience
void
void
void
void
void
void
void

Method Summary

assertFalse(boolean value)

This method just invokes the test utils method, it is here for convenience
assertFalse(boolean value, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertLabel(int[] path, String text)

This method just invokes the test utils method, it is here for convenience
assertLabel(String text)

This method just invokes the test utils method, it is here for convenience
assertLabel(String name, String text)

This method just invokes the test utils method, it is here for convenience
assertNoException(Runnable expression)

This method just invokes the test utils method, it is here for convenience
assertNoException(Runnable expression, String message)

This method just invokes the test utils method, it is here for convenience

2053

Overview (Codename One API)


void
void

void

assertNotEqual(byte expected, byte actual)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(byte expected, byte actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(double expected, double actual,
double minRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertNotEqual(double expected, double actual,


double minRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void

assertNotEqual(float expected, float actual,


double minRelativeError)

This method just invokes the test utils method, it is here for convenience
void

assertNotEqual(float expected, float actual,


double minRelativeError, String errorMessage)

This method just invokes the test utils method, it is here for convenience
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

Method Summary

assertNotEqual(int expected, int actual)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(int expected, int actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(long expected, long actual)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(long expected, long actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(Object expected, Object actual)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(Object expected, Object actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(short expected, short actual)

This method just invokes the test utils method, it is here for convenience
assertNotEqual(short expected, short actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotNull(Object object)

This method just invokes the test utils method, it is here for convenience
assertNotNull(Object object, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNotSame(Object expected, Object actual)

This method just invokes the test utils method, it is here for convenience
assertNotSame(Object expected, Object actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertNull(Object object)

This method just invokes the test utils method, it is here for convenience
assertNull(Object object, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertSame(Object expected, Object actual)

This method just invokes the test utils method, it is here for convenience
assertSame(Object expected, Object actual, String errorMessage)

This method just invokes the test utils method, it is here for convenience
assertTextArea(int[] path, String text)

This method just invokes the test utils method, it is here for convenience
assertTextArea(String text)

This method just invokes the test utils method, it is here for convenience
assertTextArea(String name, String text)

This method just invokes the test utils method, it is here for convenience
assertTitle(String title)

This method just invokes the test utils method, it is here for convenience
assertTrue(boolean value)

This method just invokes the test utils method, it is here for convenience
assertTrue(boolean value, String errorMessage)

2054

Overview (Codename One API)


This method just invokes the test utils method, it is here for convenience
void
void
void
void
void
void
void
void
void
void
Component
Label
TextArea
void
void
Component

cleanup()

Cleanup after a test case executed


clickButtonByLabel(String text)

This method just invokes the test utils method, it is here for convenience
clickButtonByName(String name)

This method just invokes the test utils method, it is here for convenience
clickButtonByPath(int[] path)

This method just invokes the test utils method, it is here for convenience
clickMenuItem(String name)

This method just invokes the test utils method, it is here for convenience
ensureVisible(Component c)

This method just invokes the test utils method, it is here for convenience
ensureVisible(int[] c)

This method just invokes the test utils method, it is here for convenience
ensureVisible(String c)

This method just invokes the test utils method, it is here for convenience
fail()

This method just invokes the test utils method, it is here for convenience
fail(String errorMessage)

This method just invokes the test utils method, it is here for convenience
findByName(String componentName)

This method just invokes the test utils method, it is here for convenience
findLabelText(String text)

This method just invokes the test utils method, it is here for convenience
findTextAreaText(String text)

This method just invokes the test utils method, it is here for convenience
gameKeyPress(int gameKey)

This method just invokes the test utils method, it is here for convenience
gameKeyRelease(int gameKey)

This method just invokes the test utils method, it is here for convenience
getComponentByPath(int[] path)

This method just invokes the test utils method, it is here for convenience
getTimeoutMillis()

int

void
void
void
void
void
void
void
void
void
void

Method Summary

Defaults to two minutes.


Returns the time in milliseconds after which the test should be automatically
failed.
goBack()

This method just invokes the test utils method, it is here for convenience
keyPress(int keyCode)

This method just invokes the test utils method, it is here for convenience
keyRelease(int keyCode)

This method just invokes the test utils method, it is here for convenience
log(String t)

This method just invokes the test utils method, it is here for convenience
log(Throwable t)

This method just invokes the test utils method, it is here for convenience
pointerDrag(float x, float y, int[] path)

This method just invokes the test utils method, it is here for convenience
pointerDrag(float x, float y, String componentName)

This method just invokes the test utils method, it is here for convenience
pointerPress(float x, float y, int[] path)

This method just invokes the test utils method, it is here for convenience
pointerPress(float x, float y, String componentName)

This method just invokes the test utils method, it is here for convenience
pointerRelease(float x, float y, int[] path)

This method just invokes the test utils method, it is here for convenience

2055

Overview (Codename One API)


pointerRelease(float x, float y, String componentName)

void

This method just invokes the test utils method, it is here for convenience
prepare()

void

Prepares the unit test for execution

boolean

screenshotTest(String screenshotName)

This method just invokes the test utils method, it is here for convenience
selectInList(int[] path, int offset)

void

This method just invokes the test utils method, it is here for convenience
selectInList(String listName, int offset)

void

This method just invokes the test utils method, it is here for convenience
setText(int[] path, String text)

void

This method just invokes the test utils method, it is here for convenience
setText(String name, String text)

void

This method just invokes the test utils method, it is here for convenience
setVerboseMode(boolean v)

void

This method just invokes the test utils method, it is here for convenience

boolean

shouldExecuteOnEDT()

Returns false, default tests run in their own thread.


waitFor(int millis)

void

This method just invokes the test utils method, it is here for convenience
waitForFormName(String name)

void

This method just invokes the test utils method, it is here for convenience
waitForFormTitle(String title)

void

This method just invokes the test utils method, it is here for convenience

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.codename1.testing.UnitTest


runTest

Constructor Detail
AbstractTest
public AbstractTest()

Method Detail
prepare
public void prepare()

Prepares the unit test for execution


Specified by:
prepare in interface UnitTest
cleanup
public void cleanup()

Cleanup after a test case executed


Specified by:
cleanup in interface UnitTest

Methods inherited from class java.lang.Object

2056

Overview (Codename One API)


getTimeoutMillis
public int getTimeoutMillis()

Defaults to two minutes.


Returns the time in milliseconds after which the test should be automatically failed.
Specified by:
getTimeoutMillis in interface UnitTest
Returns:
time in milliseconds
shouldExecuteOnEDT
public boolean shouldExecuteOnEDT()

Returns false, default tests run in their own thread. Returns true to indicate that the
test expects to be executed on the EDT
Specified by:
shouldExecuteOnEDT in interface UnitTest
Returns:
whether the test should execute on the EDT or the testing thread
assertBool
public void assertBool(boolean b)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertBool
public void assertBool(boolean b,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

fail
public void fail()

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

fail
public void fail(String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertTrue
public void assertTrue(boolean value)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertTrue
public void assertTrue(boolean value,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2057

Overview (Codename One API)


assertFalse
public void assertFalse(boolean value)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertFalse
public void assertFalse(boolean value,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNull
public void assertNull(Object object)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNull
public void assertNull(Object object,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotNull
public void assertNotNull(Object object)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotNull
public void assertNotNull(Object object,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertSame
public void assertSame(Object expected,
Object actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertSame
public void assertSame(Object expected,
Object actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotSame
public void assertNotSame(Object expected,
Object actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2058

Overview (Codename One API)


assertNotSame
public void assertNotSame(Object expected,
Object actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(byte expected,
byte actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(byte expected,
byte actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(short expected,
short actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(short expected,
short actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(int expected,
int actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(int expected,
int actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(long expected,
long actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2059

Overview (Codename One API)


assertEqual
public void assertEqual(long expected,
long actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(float expected,
float actual,
double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(float expected,
float actual,
double maxRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(double expected,
double actual,
double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(double
double
double
String

expected,
actual,
maxRelativeError,
errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(Object expected,
Object actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertEqual
public void assertEqual(Object expected,
Object actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(byte expected,
byte actual)

This method just invokes the test utils method, it is here for convenience
See Also:

Method Detail

2060

Overview (Codename One API)


TestUtils

assertNotEqual
public void assertNotEqual(byte expected,
byte actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(short expected,
short actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(short expected,
short actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(int expected,
int actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(int expected,
int actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(long expected,
long actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(long expected,
long actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(float expected,
float actual,
double minRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2061

Overview (Codename One API)


assertNotEqual
public void assertNotEqual(float expected,
float actual,
double minRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(double expected,
double actual,
double minRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(double
double
double
String

expected,
actual,
minRelativeError,
errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(Object expected,
Object actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNotEqual
public void assertNotEqual(Object expected,
Object actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(byte[] expected,
byte[] actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(byte[] expected,
byte[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(short[] expected,
short[] actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2062

Overview (Codename One API)


assertArrayEqual
public void assertArrayEqual(short[] expected,
short[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(int[] expected,
int[] actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(int[] expected,
int[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(long[] expected,
long[] actual,
long maxRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(long[] expected,
long[] actual,
long maxRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(float[] expected,
float[] actual,
double maxRelativeError)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(float[] expected,
float[] actual,
double maxRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(double[] expected,
double[] actual,
double maxRelativeError)

This method just invokes the test utils method, it is here for convenience

Method Detail

2063

Overview (Codename One API)


See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(double[] expected,
double[] actual,
double maxRelativeError,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(Object[] expected,
Object[] actual)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertArrayEqual
public void assertArrayEqual(Object[] expected,
Object[] actual,
String errorMessage)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertException
public void assertException(RuntimeException exception,
Runnable expression)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertException
public void assertException(RuntimeException exception,
Runnable expression,
String message)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNoException
public void assertNoException(Runnable expression)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertNoException
public void assertNoException(Runnable expression,
String message)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

waitFor
public void waitFor(int millis)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2064

Overview (Codename One API)


findByName
public Component findByName(String componentName)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

findLabelText
public Label findLabelText(String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

clickButtonByLabel
public void clickButtonByLabel(String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

clickButtonByName
public void clickButtonByName(String name)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

clickButtonByPath
public void clickButtonByPath(int[] path)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

goBack
public void goBack()

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

clickMenuItem
public void clickMenuItem(String name)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

ensureVisible
public void ensureVisible(Component c)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

ensureVisible
public void ensureVisible(int[] c)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

ensureVisible
public void ensureVisible(String c)

This method just invokes the test utils method, it is here for convenience
See Also:

Method Detail

2065

Overview (Codename One API)


TestUtils

waitForFormTitle
public void waitForFormTitle(String title)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

waitForFormName
public void waitForFormName(String name)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

log
public void log(String t)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

log
public void log(Throwable t)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

screenshotTest
public boolean screenshotTest(String screenshotName)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

keyPress
public void keyPress(int keyCode)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

keyRelease
public void keyRelease(int keyCode)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

gameKeyPress
public void gameKeyPress(int gameKey)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

gameKeyRelease
public void gameKeyRelease(int gameKey)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerPress
public void pointerPress(float x,
float y,
String componentName)

Method Detail

2066

Overview (Codename One API)


This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerRelease
public void pointerRelease(float x,
float y,
String componentName)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerDrag
public void pointerDrag(float x,
float y,
String componentName)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerPress
public void pointerPress(float x,
float y,
int[] path)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerRelease
public void pointerRelease(float x,
float y,
int[] path)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

pointerDrag
public void pointerDrag(float x,
float y,
int[] path)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

getComponentByPath
public Component getComponentByPath(int[] path)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

setText
public void setText(String name,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

setText
public void setText(int[] path,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:

Method Detail

2067

Overview (Codename One API)


TestUtils

assertTitle
public void assertTitle(String title)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertLabel
public void assertLabel(String name,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertLabel
public void assertLabel(String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertLabel
public void assertLabel(int[] path,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertTextArea
public void assertTextArea(String name,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertTextArea
public void assertTextArea(int[] path,
String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

assertTextArea
public void assertTextArea(String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

findTextAreaText
public TextArea findTextAreaText(String text)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

setVerboseMode
public void setVerboseMode(boolean v)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2068

Overview (Codename One API)


selectInList
public void selectInList(String listName,
int offset)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

selectInList
public void selectInList(int[] path,
int offset)

This method just invokes the test utils method, it is here for convenience
See Also:
TestUtils

Method Detail

2069

Overview (Codename One API)


com.codename1.system

Interface URLCallback

public interface

In platforms that support opening an application via URL this interface can be implemented by the
main class to support such functionality. Notice that build argument must also include some
information, for more details check out this issue:
http://code.google.com/p/codenameone/issues/detail?id=379

Method Summary
Modifier and
Type

Method and Description


shouldApplicationHandleURL(String url, String caller)

boolean

Indicates whether the application should handle the given URL, defaults
to true

Method Detail
shouldApplicationHandleURL
boolean shouldApplicationHandleURL(String url,
String caller)

Indicates whether the application should handle the given URL, defaults to true
Parameters:
url - the URL to handle
caller - the invoking application
Returns:
true to handle the URL, false otherwise

Interface URLCallback

2070

Overview (Codename One API)


com.codename1.system

Class NativeLookup
java.lang.Object

com.codename1.system.NativeLookup

public class
extends Object

Creates an instance of the native interface which will call the underlying platform using the convention
documented in the package docs. To understand more about native interfaces you can check out this
quick "How Do I?" tutorial.
Alternatively you can dig deeper into this tutorial for integrating 3rd party native libraries.

Method Summary
Modifier and Type
static
NativeInterface
static void

Method and Description


create(Class c)

Creates an instance of the given native interface and returns it for


user callbacks.
register(Class ni, Class cls)

Do NOT invoke this method.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
create
public static NativeInterface create(Class c)

Creates an instance of the given native interface and returns it for user callbacks.
Parameters:
c - the class of the NativeInterface sub interface
Returns:
an instance of that interface that can be invoked or null if the native interface
isn't present on the underlying platform (e.g. simulator platform).
register
public static void register(Class ni,
Class cls)

Do NOT invoke this method. This method is invoked internally by the stub to register
the implementation class that matches a specific interface type.
Parameters:
ni - the native interface
cls - the stub class matching said interface

Method Detail

2071

Overview (Codename One API)


com.codename1.system

Interface NativeInterface

public interface

This is a marker interface that should be extended by a user interface in order to indicate that said
interface is implemented in native code. To understand more about native interfaces you can check
out this quick "How Do I?" tutorial.
Alternatively you can dig deeper into this tutorial for integrating 3rd party native libraries.

Method Summary
Modifier and
Type

Method and Description


isSupported()

boolean

Indicates whether this native interface is supported on the current


platform

Method Detail
isSupported
boolean isSupported()

Indicates whether this native interface is supported on the current platform


Returns:
true if the native interface is supported on the given platform

Method Detail

2072

Overview (Codename One API)


com.codename1.system

Class DefaultCrashReporter
java.lang.Object

com.codename1.system.DefaultCrashReporter
All Implemented Interfaces:
CrashReport

public class
extends Object
implements CrashReport

A default implementation of the crash reporter that instantly sends the crash data to the server.

Method Summary
Modifier and Type

Method and Description


exception(Throwable t)

void

Callback for an exception that was not handled by the developer

static String
static String
static String
static String
static void
static void
static void
static void
static void

getCheckboxText()

The text for the user prompt dialog


getDontSendButtonText()

The text for the user prompt dialog


getErrorText()

The text for the user prompt dialog


getSendButtonText()

The text for the user prompt dialog


init(boolean promptUser, int frequency)

Installs a crash reporter within the system


setCheckboxText(String aCheckboxText)

The text for the user prompt dialog


setDontSendButtonText(String aDontSendButtonText)

The text for the user prompt dialog


setErrorText(String aErrorText)

The text for the user prompt dialog


setSendButtonText(String aSendButtonText)

The text for the user prompt dialog

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
getErrorText
public static String getErrorText()

The text for the user prompt dialog


Returns:
the errorText

Method Detail

2073

Overview (Codename One API)


setErrorText
public static void setErrorText(String aErrorText)

The text for the user prompt dialog


Parameters:
aErrorText - the errorText to set
getSendButtonText
public static String getSendButtonText()

The text for the user prompt dialog


Returns:
the sendButtonText
setSendButtonText
public static void setSendButtonText(String aSendButtonText)

The text for the user prompt dialog


Parameters:
aSendButtonText - the sendButtonText to set
getDontSendButtonText
public static String getDontSendButtonText()

The text for the user prompt dialog


Returns:
the dontSendButtonText
setDontSendButtonText
public static void setDontSendButtonText(String aDontSendButtonText)

The text for the user prompt dialog


Parameters:
aDontSendButtonText - the dontSendButtonText to set
getCheckboxText
public static String getCheckboxText()

The text for the user prompt dialog


Returns:
the checkboxText
setCheckboxText
public static void setCheckboxText(String aCheckboxText)

The text for the user prompt dialog


Parameters:
aCheckboxText - the checkboxText to set
init
public static void init(boolean promptUser,
int frequency)

Installs a crash reporter within the system


Parameters:
promptUser - indicates whether the user should be prompted on crash
reporting
frequency - the frequency with which we send the log to the server in debug
mode in minutes frequency must be at least 1. Any lower level automatically
disables this feature
exception
public void exception(Throwable t)

Callback for an exception that was not handled by the developer


Specified by:

Method Detail

2074

Overview (Codename One API)


exception in interface CrashReport
Parameters:
t - the exception

Method Detail

2075

Overview (Codename One API)


com.codename1.system

Interface CrashReport
All Known Implementing Classes:
DefaultCrashReporter

public interface

Invoked to indicate that an exception occurred, it is up to the developer to decide whether to send the
device log to the server by invoking Log.sendLog(). Notice that sending a log only works for paid
accounts. This interface should be registered with the Display class.
Notice that exceptions will only be reported for threads created by Codename One using the API's
within the Display class, this will not work for exceptions within threads that are created by the new
Thread() API.

Method Summary
Modifier and Type

exception(Throwable t)

void

Method and Description


Callback for an exception that was not handled by the developer

Method Detail
exception
void exception(Throwable t)

Callback for an exception that was not handled by the developer


Parameters:
t - the exception

Interface CrashReport

2076

Overview (Codename One API)


com.codename1.social

Class LoginCallback
java.lang.Object

com.codename1.social.LoginCallback

public abstract class


extends Object

This class is used to indicate whether login was successful or not, it is an abstract class rather than
an interface in order to allow additional features in the future.

Constructor Summary
Constructor and Description
LoginCallback()

Method Summary
Modifier and Type

Method and Description


loginFailed(String errorMessage)

void

Indicates that logging in to the social network has failed


loginSuccessful()

void

Indicates that logging in to the social network has been successful

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
LoginCallback
public LoginCallback()

Method Detail
loginSuccessful
public void loginSuccessful()

Indicates that logging in to the social network has been successful


loginFailed
public void loginFailed(String errorMessage)

Indicates that logging in to the social network has failed


Parameters:
errorMessage - the error message corresponding to this

Method Detail

2077

Overview (Codename One API)


com.codename1.social

Class Login
java.lang.Object

com.codename1.social.Login
Direct Known Subclasses:
FacebookConnect, GoogleConnect

public abstract class


extends Object

The Login abstract base class is used to simplify Oauth2 authentications services. Services can
override the default Oauth2 web login and offers the native login experience.

Constructor Summary
Constructor and Description
Login()

Method Summary
Modifier and
Type
protected
Oauth2
void
void
AccessToken
abstract
boolean
boolean
boolean
void
void
void

Method and Description


createOauth2()

Creates the oauth2 to be used to login in case no native login is available


for this service.
doLogin()

Logs in the user.


doLogout()

Logs out the current user


getAccessToken()

The AccessToken of this service


isNativeLoginSupported()

Returns true if this service supports native login.


isUserLoggedIn()

Indicates if the user is currently logged in


nativeIsLoggedIn()

Indicates if the user is currently logged in.


nativelogin()

Logs in the current user natively.


nativeLogout()

Logs out the current user natively.


setAccessToken(AccessToken token)

Sets the Login access token


setCallback(LoginCallback lc)

void

void
void
void

Method Detail

Sets the login callback that will receive event callback notification from the
API
setClientId(String id)

The client id (appid) which asks to connect


setClientSecret(String secret)

The client secret


setOauth2URL(String oauth2URL)

The oauth2 URL

2078

Overview (Codename One API)


setRedirectURI(String URI)

void

The redirect URI


setScope(String scope)

void

The authentication scope


validateToken()

This method tries to validate the last access token if exists, if the last token
is not valid anymore it will try to login the user in order to get a fresh token
The method blocks until a valid token has been granted

void

protected
abstract
boolean

validateToken(String token)

Returns true if the previous granted access token is still valid otherwise
false.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Login
public Login()

Method Detail
doLogin
public void doLogin()

Logs in the user. If the service has a native login it will try to use that, otherwise an
Oauth2 web login will be used.
doLogout
public void doLogout()

Logs out the current user


isUserLoggedIn
public boolean isUserLoggedIn()

Indicates if the user is currently logged in


Returns:
true if logged in
nativeIsLoggedIn
public boolean nativeIsLoggedIn()

Indicates if the user is currently logged in. Subclasses that uses a native sdk to
login/logout should override this method.
Returns:
true if logged in
nativelogin
public void nativelogin()

Logs in the current user natively. Subclasses that uses a native sdk to login/logout
should override this method.
nativeLogout
public void nativeLogout()

Logs out the current user natively. Subclasses that uses a native sdk to login/logout
should override this method.

Method Summary

2079

Overview (Codename One API)


isNativeLoginSupported
public abstract boolean isNativeLoginSupported()

Returns true if this service supports native login. If implementation returns true here,
the nativelogin, nativelogout, nativeIsLoggedIn should be implemented
Returns:
true if the service supports native login
getAccessToken
public AccessToken getAccessToken()

The AccessToken of this service


Returns:
the token
validateToken
public void validateToken()
throws IOException

This method tries to validate the last access token if exists, if the last token is not
valid anymore it will try to login the user in order to get a fresh token The method
blocks until a valid token has been granted
Throws:
IOException

validateToken
protected abstract boolean validateToken(String token)

Returns true if the previous granted access token is still valid otherwise false.
Parameters:
token - the access token to check
Returns:
true of the token is valid
setAccessToken
public void setAccessToken(AccessToken token)

Sets the Login access token


setCallback
public void setCallback(LoginCallback lc)

Sets the login callback that will receive event callback notification from the API
Parameters:
lc - the login callback or null to remove the existing login callback
setClientId
public void setClientId(String id)

The client id (appid) which asks to connect


Parameters:
clientId setClientSecret
public void setClientSecret(String secret)

The client secret


Parameters:
clientSecret

setRedirectURI
public void setRedirectURI(String URI)

The redirect URI


Parameters:
redirectURI

Method Detail

2080

Overview (Codename One API)


setScope
public void setScope(String scope)

The authentication scope


setOauth2URL
public void setOauth2URL(String oauth2URL)

The oauth2 URL


createOauth2
protected Oauth2 createOauth2()

Creates the oauth2 to be used to login in case no native login is available for this
service.
Returns:
the Oauth2 to be used to login if no native login available and on the
simulator

Method Detail

2081

Overview (Codename One API)


com.codename1.social

Class GoogleConnect
java.lang.Object

com.codename1.social.Login

com.codename1.social.GoogleConnect

public class
extends Login

The GoogleConnect Login class allows the sign in with google functionality. The GoogleConnect
requires to create a corresponding google cloud project. To enable the GoogleConnect to sign-in on
the Simulator create a corresponding web login - https://developers.google.com/+/web/signin/ To
enable the GoogleConnect to sign-in on Android Follow step 1 from here https://developers.google.com/+/mobile/android/getting-started To enable the GoogleConnect to
sign-in on iOS follow step 1 from here - https://developers.google.com/+/mobile/ios/getting-started

Method Summary
Modifier and Type

Method and Description


createOauth2()

protected Oauth2

Creates the oauth2 to be used to login in case no native login is


available for this service.

static
GoogleConnect

getInstance()

boolean

Gets the GoogleConnect singleton instance .


isNativeLoginSupported()

Returns true if this service supports native login.


validateToken(String token)

protected boolean

Returns true if the previous granted access token is still valid


otherwise false.

Methods inherited from class com.codename1.social.Login


doLogin, doLogout, getAccessToken, isUserLoggedIn, nativeIsLoggedIn,
nativelogin, nativeLogout, setAccessToken, setCallback, setClientId,
setClientSecret, setOauth2URL, setRedirectURI, setScope, validateToken

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
getInstance
public static GoogleConnect getInstance()

Gets the GoogleConnect singleton instance .


Returns:
the GoogleConnect instance
isNativeLoginSupported
public boolean isNativeLoginSupported()

Description copied from class: Login


Returns true if this service supports native login. If implementation returns true here,
the nativelogin, nativelogout, nativeIsLoggedIn should be implemented

Class GoogleConnect

2082

Overview (Codename One API)


Specified by:
isNativeLoginSupported in class Login
Returns:
true if the service supports native login
createOauth2
protected Oauth2 createOauth2()

Description copied from class: Login


Creates the oauth2 to be used to login in case no native login is available for this
service.
Overrides:
createOauth2 in class Login
Returns:
the Oauth2 to be used to login if no native login available and on the
simulator
validateToken
protected boolean validateToken(String token)

Description copied from class: Login


Returns true if the previous granted access token is still valid otherwise false.
Specified by:
validateToken in class Login
Parameters:
token - the access token to check
Returns:
true of the token is valid

Method Detail

2083

Overview (Codename One API)


com.codename1.social

Class FacebookConnect
java.lang.Object

com.codename1.social.Login

com.codename1.social.FacebookConnect

public class
extends Login

Invokes the native bundled facebook SDK to login/logout of facebook, notice that in order for this to
work server build arguments must indicate that you are using the facebook sdk! To accomplish this
just define: facebook.appId=YourAppId in your build arguments. In order to obtain the app ID you
need to create a native Android/iOS application and generate the right app id.

Method Summary
Modifier and Type

Method and Description


askPublishPermissions(LoginCallback lc)

void

Asks for publish permissions, this call might suspend the application
which might trigger repeated invocations of stop()/start().
createOauth2()

protected Oauth2

void
AccessToken
static
FacebookConnect

Creates the oauth2 to be used to login in case no native login is


available for this service.
doLogout()

Logs out the current user from facebook


getAccessToken()

The facebook token that can be used to access facebook functionality


getInstance()

Gets the FacebookConnect singleton instance .


getToken()

String

boolean

Deprecated.
use getAccessToken instead
hasPublishPermissions()

Returns true if the current session already has publish permissions


inviteFriends(String appLinkUrl, String previewImageUrl)

void

void

boolean

Opens and invite dialog to invite friends to the app


https://developers.facebook.com/docs/app-invites
inviteFriends(String appLinkUrl, String previewImageUrl,
Callback cb)

Opens and invite dialog to invite friends to the app


https://developers.facebook.com/docs/app-invites
isFacebookSDKSupported()

Indicates whether the native platform supports native facebook login


isInviteFriendsSupported()

boolean

Returns true if inviteFriends is implemented, it is supported on iOS and


Android
isLoggedIn()

boolean

boolean

Deprecated.
use isUserLoggedIn() instead
isNativeLoginSupported()

Returns true if this service supports native login.


login()

void

Deprecated.
use doLogin

void

logout()

Class FacebookConnect

2084

Overview (Codename One API)


Deprecated.
use doLogout instead
boolean

nativeIsLoggedIn()

Indicates if the user is currently logged in.


nativelogin()

void

Logs in the current user natively.


nativeLogout()

void

Logs out the current user natively.


validateToken(String token)

protected boolean

Returns true if the previous granted access token is still valid otherwise
false.

Methods inherited from class com.codename1.social.Login


doLogin, isUserLoggedIn, setAccessToken, setCallback, setClientId,
setClientSecret, setOauth2URL, setRedirectURI, setScope, validateToken

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
getInstance
public static FacebookConnect getInstance()

Gets the FacebookConnect singleton instance .


Returns:
the FacebookConnect instance
isFacebookSDKSupported
public boolean isFacebookSDKSupported()

Indicates whether the native platform supports native facebook login


Returns:
true if supported
login
public void login()

Deprecated. use doLogin


Logs into facebook, notice that this call might suspend the application which might
trigger repeated invocations of stop()/start() etc. This is due to the facebook SDK
spawning a separate process to perform the login then returning to the application.
Once logged in the facebook credentials will be available.
doLogout
public void doLogout()

Logs out the current user from facebook


Overrides:
doLogout in class Login
getAccessToken
public AccessToken getAccessToken()

The facebook token that can be used to access facebook functionality


Overrides:
getAccessToken in class Login
Returns:
the token

Method Summary

2085

Overview (Codename One API)


isLoggedIn
public boolean isLoggedIn()

Deprecated. use isUserLoggedIn() instead


Indicates if the user is currently logged in
Returns:
true if logged in
getToken
public String getToken()

Deprecated. use getAccessToken instead


The facebook token that can be used to access facebook functionality
Returns:
the token
logout
public void logout()

Deprecated. use doLogout instead


Logs out the current user from facebook
askPublishPermissions
public void askPublishPermissions(LoginCallback lc)

Asks for publish permissions, this call might suspend the application which might
trigger repeated invocations of stop()/start().
hasPublishPermissions
public boolean hasPublishPermissions()

Returns true if the current session already has publish permissions


Returns:
isNativeLoginSupported
public boolean isNativeLoginSupported()

Description copied from class: Login


Returns true if this service supports native login. If implementation returns true here,
the nativelogin, nativelogout, nativeIsLoggedIn should be implemented
Specified by:
isNativeLoginSupported in class Login
Returns:
true if the service supports native login
createOauth2
protected Oauth2 createOauth2()

Description copied from class: Login


Creates the oauth2 to be used to login in case no native login is available for this
service.
Overrides:
createOauth2 in class Login
Returns:
the Oauth2 to be used to login if no native login available and on the
simulator
nativelogin
public void nativelogin()

Description copied from class: Login


Logs in the current user natively. Subclasses that uses a native sdk to login/logout
should override this method.
Overrides:
nativelogin in class Login

Method Detail

2086

Overview (Codename One API)


nativeLogout
public void nativeLogout()

Description copied from class: Login


Logs out the current user natively. Subclasses that uses a native sdk to login/logout
should override this method.
Overrides:
nativeLogout in class Login
nativeIsLoggedIn
public boolean nativeIsLoggedIn()

Description copied from class: Login


Indicates if the user is currently logged in. Subclasses that uses a native sdk to
login/logout should override this method.
Overrides:
nativeIsLoggedIn in class Login
Returns:
true if logged in
inviteFriends
public void inviteFriends(String appLinkUrl,
String previewImageUrl)

Opens and invite dialog to invite friends to the app


https://developers.facebook.com/docs/app-invites
Parameters:
appLinkUrl - App Link for what should be opened when the recipient clicks
on the install/play button on the app invite page.
previewImageUrl - url to an image to be used in the invite, can be null
inviteFriends
public void inviteFriends(String appLinkUrl,
String previewImageUrl,
Callback cb)

Opens and invite dialog to invite friends to the app


https://developers.facebook.com/docs/app-invites
Parameters:
appLinkUrl - App Link for what should be opened when the recipient clicks
on the install/play button on the app invite page.
previewImageUrl - url to an image to be used in the invite, can be null
cb - a Callback to be used when we need to know if the Facebook invite was
successful. If the invite was successful the onSucess method will be called If
the user canceled the onError method will be called with error code -1. If an
error occurred the onError method will be called with error code 0.
isInviteFriendsSupported
public boolean isInviteFriendsSupported()

Returns true if inviteFriends is implemented, it is supported on iOS and Android


Returns:
true if inviteFriends is implemented
validateToken
protected boolean validateToken(String token)

Description copied from class: Login


Returns true if the previous granted access token is still valid otherwise false.
Specified by:
validateToken in class Login
Parameters:
token - the access token to check
Returns:
true of the token is valid

Method Detail

2087

Overview (Codename One API)


com.codename1.share

Class ShareService
java.lang.Object

com.codename1.ui.Command

com.codename1.share.ShareService
All Implemented Interfaces:
ActionListener
Direct Known Subclasses:
EmailShare, FacebookShare, SMSShare

public abstract class


extends Command

This is an abstract sharing service.

Constructor Summary
Constructor and Description
ShareService(String name, Image icon)

Constructor with the service name and icon

Method Summary
Modifier
and Type

Method and Description


actionPerformed(ActionEvent evt)

void

This method is called when the soft button/Menu item is clicked

abstract
boolean

canShareImage()

The implementing service needs to declare if it is capable to share an image


finish()

void

Once the share service has finished sharing it should call the finish method
getOriginal()

Form

Gets the original Form


setImage(String image, String mime)

Sets the image to share, this is done by the ShareButton and shouldn't be used
by the developers

void

setMessage(String message)

Sets the message to share, this is done by the ShareButton and shouldn't be
used by the developers

void

setOriginalForm(Form original)

void

Sets the Original Form (this is the Form of the share button)

abstract
void

share(String text)

This is the sharing method which should be implemented by the service.


share(String text, String image, String imageMimeType)

This is the image sharing method which should be implemented by the service,
if the service returned true on the canShareImage() method Notice not all
services are able to share text and image together, in this case the image
sharing will be preferred by these services

void

Methods inherited from class com.codename1.ui.Command


create, equals, getClientProperty, getCommandName, getDisabledIcon,
getIcon, getId, getPressedIcon, getRolloverIcon, hashCode,
isDisposesDialog, isEnabled, putClientProperty, setCommandName,
setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setPressedIcon,

Class ShareService

2088

Overview (Codename One API)


setRolloverIcon, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
ShareService
public ShareService(String name,
Image icon)

Constructor with the service name and icon


Parameters:
name - the service name
icon - the service icon

Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)

This method is called when the soft button/Menu item is clicked


Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class Command
Parameters:
evt - the Event Object
share
public abstract void share(String text)

This is the sharing method which should be implemented by the service.


Parameters:
text - text to share
share
public void share(String text,
String image,
String imageMimeType)

This is the image sharing method which should be implemented by the service, if the
service returned true on the canShareImage() method Notice not all services are able
to share text and image together, in this case the image sharing will be preferred by
these services
Parameters:
text - text to share
image - image to share
canShareImage
public abstract boolean canShareImage()

The implementing service needs to declare if it is capable to share an image


Returns:
true if the service can share images
setMessage
public void setMessage(String message)

Sets the message to share, this is done by the ShareButton and shouldn't be used by
the developers

Methods inherited from class com.codename1.ui.Command

2089

Overview (Codename One API)


Parameters:
message

setImage
public void setImage(String image,
String mime)

Sets the image to share, this is done by the ShareButton and shouldn't be used by
the developers
Parameters:
image - the file path to the image
mime - the image mime type e.g. image/png, image/jpeg
setOriginalForm
public void setOriginalForm(Form original)

Sets the Original Form (this is the Form of the share button)
getOriginal
public Form getOriginal()

Gets the original Form


finish
public void finish()

Once the share service has finished sharing it should call the finish method

Method Detail

2090

Overview (Codename One API)


com.codename1.share

Class SMSShare
java.lang.Object

com.codename1.ui.Command

com.codename1.share.ShareService

com.codename1.share.SMSShare
All Implemented Interfaces:
ActionListener

public class
extends ShareService

SMS Sharing service

Constructor Summary
Constructor and Description
SMSShare()

Default Constructor

Method Summary
Modifier and
Type

Method and Description


canShareImage()

boolean

The implementing service needs to declare if it is capable to share an


image
share(String toShare)

void

This is the sharing method which should be implemented by the service.

Methods inherited from class com.codename1.share.ShareService


actionPerformed, finish, getOriginal, setImage, setMessage,
setOriginalForm, share

Methods inherited from class com.codename1.ui.Command


create, equals, getClientProperty, getCommandName, getDisabledIcon,
getIcon, getId, getPressedIcon, getRolloverIcon, hashCode,
isDisposesDialog, isEnabled, putClientProperty, setCommandName,
setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setPressedIcon,
setRolloverIcon, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
SMSShare
public SMSShare()

Default Constructor

Class SMSShare

2091

Overview (Codename One API)


Method

Detail

share
public void share(String toShare)

This is the sharing method which should be implemented by the service.


Specified by:
share in class ShareService
Parameters:
toShare - text to share
canShareImage
public boolean canShareImage()

The implementing service needs to declare if it is capable to share an image


Specified by:
canShareImage in class ShareService
Returns:
true if the service can share images

Method Detail

2092

Overview (Codename One API)


com.codename1.share

Class FacebookShare
java.lang.Object

com.codename1.ui.Command

com.codename1.share.ShareService

com.codename1.share.FacebookShare
All Implemented Interfaces:
ActionListener

public class
extends ShareService

Facebook sharing service

Constructor Summary
Constructor and Description
FacebookShare()

Default Constructor

Method Summary
Modifier
and Type

Method and Description


actionPerformed(ActionEvent evt)

void

This method is called when the soft button/Menu item is clicked

boolean

canShareImage()

The implementing service needs to declare if it is capable to share an image


share(String toShare)

void

This is the sharing method which should be implemented by the service.


share(String text, String image, String mime)

This is the image sharing method which should be implemented by the service, if
the service returned true on the canShareImage() method Notice not all services
are able to share text and image together, in this case the image sharing will be
preferred by these services

void

Methods inherited from class com.codename1.share.ShareService


finish, getOriginal, setImage, setMessage, setOriginalForm

Methods inherited from class com.codename1.ui.Command


create, equals, getClientProperty, getCommandName, getDisabledIcon,
getIcon, getId, getPressedIcon, getRolloverIcon, hashCode,
isDisposesDialog, isEnabled, putClientProperty, setCommandName,
setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setPressedIcon,
setRolloverIcon, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class FacebookShare

2093

Overview (Codename One API)

Constructor

Detail

FacebookShare
public FacebookShare()

Default Constructor

Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)

This method is called when the soft button/Menu item is clicked


Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class ShareService
Parameters:
evt - the Event Object
share
public void share(String text,
String image,
String mime)

This is the image sharing method which should be implemented by the service, if the
service returned true on the canShareImage() method Notice not all services are able
to share text and image together, in this case the image sharing will be preferred by
these services
Overrides:
share in class ShareService
Parameters:
text - text to share
image - image to share
share
public void share(String toShare)

This is the sharing method which should be implemented by the service.


Specified by:
share in class ShareService
Parameters:
toShare - text to share
canShareImage
public boolean canShareImage()

The implementing service needs to declare if it is capable to share an image


Specified by:
canShareImage in class ShareService
Returns:
true if the service can share images

Constructor Detail

2094

Overview (Codename One API)


com.codename1.share

Class EmailShare
java.lang.Object

com.codename1.ui.Command

com.codename1.share.ShareService

com.codename1.share.EmailShare
All Implemented Interfaces:
ActionListener

public class
extends ShareService

Email sharing service.

Constructor Summary
Constructor and Description
EmailShare()

Default Constructor

Method Summary
Modifier
and Type
boolean

Method and Description


canShareImage()

The implementing service needs to declare if it is capable to share an image


share(String toShare)

void

This is the sharing method which should be implemented by the service.


share(String toShare, String image, String mimeType)

This is the image sharing method which should be implemented by the service,
if the service returned true on the canShareImage() method Notice not all
services are able to share text and image together, in this case the image
sharing will be preferred by these services

void

Methods inherited from class com.codename1.share.ShareService


actionPerformed, finish, getOriginal, setImage, setMessage, setOriginalForm

Methods inherited from class com.codename1.ui.Command


create, equals, getClientProperty, getCommandName, getDisabledIcon,
getIcon, getId, getPressedIcon, getRolloverIcon, hashCode,
isDisposesDialog, isEnabled, putClientProperty, setCommandName,
setDisabledIcon, setDisposesDialog, setEnabled, setIcon, setPressedIcon,
setRolloverIcon, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Method Detail

2095

Overview (Codename One API)


EmailShare
public EmailShare()

Default Constructor

Method Detail
share
public void share(String toShare,
String image,
String mimeType)

This is the image sharing method which should be implemented by the service, if the
service returned true on the canShareImage() method Notice not all services are able
to share text and image together, in this case the image sharing will be preferred by
these services
Overrides:
share in class ShareService
Parameters:
toShare - text to share
image - image to share
share
public void share(String toShare)

This is the sharing method which should be implemented by the service.


Specified by:
share in class ShareService
Parameters:
toShare - text to share
canShareImage
public boolean canShareImage()

The implementing service needs to declare if it is capable to share an image


Specified by:
canShareImage in class ShareService
Returns:
true if the service can share images

Constructor Detail

2096

Overview (Codename One API)


com.codename1.push

Interface PushCallback

public interface

This callback interface is invoked when a push notification is received by the application. If the main
class of the application implements push callback it will receive push notification calls from the
system. Notice that its very possible that a separate instance of the main class will be created to
perform the push!

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int

Field and Description


REGISTRATION_ACCOUNT_MISSING

Error code returned when sending a push notification


REGISTRATION_AUTHENTICATION_FAILED

Error code returned when sending a push notification


REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE

Error code returned when sending a push notification


REGISTRATION_INVALID_SENDER

Error code returned when sending a push notification


REGISTRATION_PHONE_REGISTRATION_ERROR

Error code returned when sending a push notification


REGISTRATION_TOO_MANY_REGISTRATIONS

Error code returned when sending a push notification

Method Summary
Modifier and
Type

Method and Description


push(String value)

void

Invoked when the push notification occurs


pushRegistrationError(String error, int errorCode)

Invoked to indicate an error occurred during registration for push


notification

void

registeredForPush(String deviceId)

Invoked when push registration is complete to pass the device ID to the


application.

void

Field Detail
REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE
static final int REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE

Error code returned when sending a push notification


See Also:
Constant Field Values
REGISTRATION_ACCOUNT_MISSING
static final int REGISTRATION_ACCOUNT_MISSING

Error code returned when sending a push notification


See Also:

Method Detail

2097

Overview (Codename One API)


Constant Field Values
REGISTRATION_AUTHENTICATION_FAILED
static final int REGISTRATION_AUTHENTICATION_FAILED

Error code returned when sending a push notification


See Also:
Constant Field Values
REGISTRATION_TOO_MANY_REGISTRATIONS
static final int REGISTRATION_TOO_MANY_REGISTRATIONS

Error code returned when sending a push notification


See Also:
Constant Field Values
REGISTRATION_INVALID_SENDER
static final int REGISTRATION_INVALID_SENDER

Error code returned when sending a push notification


See Also:
Constant Field Values
REGISTRATION_PHONE_REGISTRATION_ERROR
static final int REGISTRATION_PHONE_REGISTRATION_ERROR

Error code returned when sending a push notification


See Also:
Constant Field Values

Method Detail
push
void push(String value)

Invoked when the push notification occurs


Parameters:
value - the value of the push notification
registeredForPush
void registeredForPush(String deviceId)

Invoked when push registration is complete to pass the device ID to the application.
Parameters:
deviceId - OS native push id you should not use this value and instead use
Push.getPushKey()

See Also:
Push.getPushKey()

pushRegistrationError
void pushRegistrationError(String error,
int errorCode)

Invoked to indicate an error occurred during registration for push notification


Parameters:
error - descriptive error string
errorCode - an error code

Field Detail

2098

Overview (Codename One API)


com.codename1.push

Class Push
java.lang.Object

com.codename1.push.Push

public class
extends Object

Utility class for sending a push message to a different device through the Codename One push
servers.

Field Summary
Modifier and Type
static String

Field and Description


GOOGLE_PUSH_KEY

Key for the hashtable argument when pushing to the google play store

Constructor Summary
Constructor and Description
Push()

Method Summary
Modifier
and Type

Method and Description


getDeviceKey()

static
String

static
String

static
boolean

static
boolean

static
boolean

static
boolean

Method Detail

Deprecated.
this method sends a push using the old push servers which will be retired, you
need to switch to getPushKey()
getPushKey()

Returns the push device key if the device was previously successfully registered
for push otherwise returns null
sendPushMessage(String body, String deviceKey, boolean production,
String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword)

Deprecated.
this method sends a push using the old push servers which will be retired, you
need to switch to the equivalent method that accepts a push token
sendPushMessage(String token, String body, boolean production,
String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword, int pushType, String... deviceKey)

Sends a push message and returns true if server delivery succeeded, notice
that the push message isn't guaranteed to reach all devices.
sendPushMessage(String body, String deviceKey, boolean production,
String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword, String bbUrl, String bbApp,
String bbPass, String bbPort)

Deprecated.
this method sends a push using the old push servers which will be retired, you
need to switch to the equivalent method that accepts a push token
sendPushMessage(String token, String body, String deviceKey,
boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword)

2099

Overview (Codename One API)


Sends a push message and returns true if server delivery succeeded, notice
that the push message isn't guaranteed to reach all devices.

static
boolean

sendPushMessage(String token, String body, String deviceKey,


boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword, String bbUrl, String bbApp,
String bbPass, String bbPort)

Sends a push message and returns true if server delivery succeeded, notice
that the push message isn't guaranteed to reach all devices.

static
void

static
void

static
void

static
void

sendPushMessageAsync(String body, String deviceKey,


boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword)

Deprecated.
this method sends a push using the old push servers which will be retired, you
need to switch to the equivalent method that accepts a push token
sendPushMessageAsync(String body, String deviceKey,
boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword, String bbUrl, String bbApp,
String bbPass, String bbPort)

Deprecated.
this method sends a push using the old push servers which will be retired, you
need to switch to the equivalent method that accepts a push token
sendPushMessageAsync(String token, String body, String deviceKey,
boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword)

Sends a push message and returns true if server delivery succeeded, notice
that the push message isn't guaranteed to reach all devices.
sendPushMessageAsync(String token, String body, String deviceKey,
boolean production, String googleAuthKey, String iosCertificateURL,
String iosCertificatePassword, String bbUrl, String bbApp,
String bbPass, String bbPort)

Sends a push message and returns true if server delivery succeeded, notice
that the push message isn't guaranteed to reach all devices.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
GOOGLE_PUSH_KEY
public static final String GOOGLE_PUSH_KEY

Key for the hashtable argument when pushing to the google play store
See Also:
Constant Field Values

Constructor Detail
Push
public Push()

Method Detail
sendPushMessage
public static boolean sendPushMessage(String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword)

Method Summary

2100

Overview (Codename One API)


Deprecated. this method sends a push using the old push servers which will be
retired, you need to switch to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices.
Parameters:
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
Returns:
true if the message reached the Codename One server successfully, this
makes no guarantee of delivery.
sendPushMessage
public static boolean sendPushMessage(String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword,
String bbUrl,
String bbApp,
String bbPass,
String bbPort)

Deprecated. this method sends a push using the old push servers which will be
retired, you need to switch to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices.
Parameters:
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
bbUrl - the URL to which the push should be submitted when sending a
blackberry push for evaluation use https://pushapi.eval.blackberry.com for
production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbApp - the application id to authenticate on push for RIM devices
bbPass - the application password credentials authenticate on push for RIM
devices
bbPort - the port of the blackberry push
Returns:
true if the message reached the Codename One server successfully, this
makes no guarantee of delivery.
sendPushMessageAsync
public static void sendPushMessageAsync(String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword)

Deprecated. this method sends a push using the old push servers which will be
retired, you need to switch to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices.
Parameters:
body - the body of the message

Method Detail

2101

Overview (Codename One API)


deviceKey

- an optional parameter (can be null) when sending to a specific

device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this

applications push capabilities.


iosCertificatePassword - the password for the push certificate
sendPushMessageAsync
public static void sendPushMessageAsync(String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword,
String bbUrl,
String bbApp,
String bbPass,
String bbPort)

Deprecated. this method sends a push using the old push servers which will be
retired, you need to switch to the equivalent method that accepts a push token
Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices.
Parameters:
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
bbUrl - the URL to which the push should be submitted when sending a
blackberry push for evaluation use https://pushapi.eval.blackberry.com for
production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbApp - the application id to authenticate on push for RIM devices
bbPass - the application password credentials authenticate on push for RIM
devices
bbPort - the port of the blackberry push
getDeviceKey
public static String getDeviceKey()

Deprecated. this method sends a push using the old push servers which will be
retired, you need to switch to getPushKey()
Returns the push device key if the device was previously successfully registered for
push otherwise returns null
Returns:
the device key that can be used to push to this specific device.
getPushKey
public static String getPushKey()

Returns the push device key if the device was previously successfully registered for
push otherwise returns null
Returns:
the device key that can be used to push to this specific device.
sendPushMessage
public static boolean sendPushMessage(String token,
String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword)

Method Detail

2102

Overview (Codename One API)


Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices. This method uses the new push
servers
Parameters:
token - the authorization token from the account settings in the
CodenameOne website, this is used to associate push quotas with your app
body - the body of the message
deviceKey - the device key that will receive the push message (can't be null!)
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
Returns:
true if the message reached the Codename One server successfully, this
makes no guarantee of delivery.
sendPushMessage
public static boolean sendPushMessage(String token,
String body,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword,
int pushType,
String... deviceKey)

Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices. This method uses the new push
servers
Parameters:
token - the authorization token from the account settings in the
CodenameOne website, this is used to associate push quotas with your app
body - the body of the message
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
pushType - the type for the push in the server, this is useful for sending
hidden pushes (type 2) should default to 0 or 1
deviceKey - set of devices that should receive the push
Returns:
true if the message reached the Codename One server successfully, this
makes no guarantee of delivery.
sendPushMessage
public static boolean sendPushMessage(String token,
String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword,
String bbUrl,
String bbApp,
String bbPass,
String bbPort)

Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices. This method uses the new push
servers
Parameters:
token - the authorization token from the account settings in the
CodenameOne website, this is used to associate push quotas with your app
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment

Method Detail

2103

Overview (Codename One API)


googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate

for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
bbUrl - the URL to which the push should be submitted when sending a
blackberry push for evaluation use https://pushapi.eval.blackberry.com for
production you will need to apply at https://cp310.pushapi.na.blackberry.com
bbApp - the application id to authenticate on push for RIM devices
bbPass - the application password credentials authenticate on push for RIM
devices
bbPort - the port of the blackberry push
Returns:
true if the message reached the Codename One server successfully, this
makes no guarantee of delivery.
sendPushMessageAsync
public static void sendPushMessageAsync(String token,
String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword)

Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices. This method uses the new push
servers
Parameters:
token - the authorization token from the account settings in the
CodenameOne website, this is used to associate push quotas with your app
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
sendPushMessageAsync
public static void sendPushMessageAsync(String token,
String body,
String deviceKey,
boolean production,
String googleAuthKey,
String iosCertificateURL,
String iosCertificatePassword,
String bbUrl,
String bbApp,
String bbPass,
String bbPort)

Sends a push message and returns true if server delivery succeeded, notice that the
push message isn't guaranteed to reach all devices. This method uses the new push
servers
Parameters:
token - the authorization token from the account settings in the
CodenameOne website, this is used to associate push quotas with your app
body - the body of the message
deviceKey - an optional parameter (can be null) when sending to a specific
device
production - whether pushing to production or test/sandbox environment
googleAuthKey - authorization key from the google play store
iosCertificateURL - a URL where you host the iOS certificate for this
applications push capabilities.
iosCertificatePassword - the password for the push certificate
bbUrl - the URL to which the push should be submitted when sending a
blackberry push for evaluation use https://pushapi.eval.blackberry.com for
production you will need to apply at https://cp310.pushapi.na.blackberry.com

Method Detail

2104

Overview (Codename One API)


bbApp - the application id to authenticate on push for RIM devices
bbPass - the application password credentials authenticate on push

for RIM

devices
bbPort - the port of the blackberry push

Method Detail

2105

Overview (Codename One API)


com.codename1.processing

Class Result
java.lang.Object

com.codename1.processing.Result

public class
extends Object

An evaluator for a very small expression language to extract primitive types from structured
information. This implementation is layered over the com.codename1.io.JSONParser and
com.codename1.xml.XMLParser classes. This expression language allows applications to extract
information from structured data returned by web services with minimal effort. The expression
language works a lot like a very small subset of XPath - the expression syntax uses the / character for
sub-elements and square brackets for arrays. Some sample expressions:
Simple expression, get the title of the first photo element.
/photos/photo[1]/title
Globally find the first name of a person with a last name of 'Coolman'.
//person[lastname='Coolman']/firstName
Get the latitude value of the second last result element.
/results[last()-1]/geometry/bounds/northeast/lat
Get the names of players from Germany
/tournament/player[@nationality='Germany']/name
Get the purchase order numbers of any order with a lineitem worth over $5
//order/lineitem[price > 5]/../@ponum
etc

Field Summary
Modifier and Type Field and Description
static char

ARRAY_END

static char

ARRAY_START

static String

JSON

static char

SEPARATOR

static String

XML

Method Summary
Modifier and
Type
boolean
static Result

Method and Description


equals(Object other)

Indicates whether some other object is "equal to" this one.


fromContent(Element content)

Create an evaluator object from a parsed XML DOM.


fromContent(InputStream content, String format)

static Result

Class Result

Create an evaluator object from a structured content document (XML,


JSON, etc) input stream.

2106

Overview (Codename One API)


static Result

fromContent(Map content)

Create an evaluator object from parsed JSON content DOM.


fromContent(Reader content, String format)

static Result

Create an evaluator object from a structured content document (XML,


JSON, etc) input stream.
fromContent(String content, String format)

static Result

Create an evaluator object from a structured content document (XML,


JSON, etc) as a string.
get(String path)

Object

Get the object value from the requested path.


getAsArray(String path)

List

Get a List of values from the requested path.

boolean
boolean[]

getAsBoolean(String path)

Get a boolean value from the requested path.


getAsBooleanArray(String path)

Get an array of values from the requested path.


getAsDouble(String path)

double

Get a double value from the requested path.

double[]

getAsDoubleArray(String path)

Get an array of values from the requested path.


getAsInteger(String path)

int

Get an integer value from the requested path.


getAsIntegerArray(String path)

int[]

Get an array of values from the requested path.


getAsLong(String path)

long

Get an long value from the requested path.


getAsLongArray(String path)

long[]

Get an array of values from the requested path.


getAsString(String path)

String

Get a string value from the requested path.

String[]

getAsStringArray(String path)

Get an array of string values from the requested path.


getSizeOfArray(String path)

int

Get the size of an array at the requested path.


hashCode()

int

Returns a hashcode value for the object.

void

mapNamespaceAlias(String namespaceURI, String alias)


toString()

String

Convert the object to a formatted structured content document.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Field Detail
JSON
public static final String JSON

See Also:
Constant Field Values
XML
public static final String XML

See Also:
Constant Field Values

Method Summary

2107

Overview (Codename One API)


SEPARATOR
public static final char SEPARATOR

See Also:
Constant Field Values
ARRAY_START
public static final char ARRAY_START

See Also:
Constant Field Values
ARRAY_END
public static final char ARRAY_END

See Also:
Constant Field Values

Method Detail
fromContent
public static Result fromContent(String content,
String format)
throws IllegalArgumentException

Create an evaluator object from a structured content document (XML, JSON, etc) as
a string.
Parameters:
content - structured content document as a string.
format - an identifier for the type of content passed (ie. xml, json, etc).
Returns:
Result a result evaluator object
Throws:
IllegalArgumentException - thrown if null content or format is passed.
fromContent
public static Result fromContent(InputStream content,
String format)
throws IllegalArgumentException,
IOException

Create an evaluator object from a structured content document (XML, JSON, etc)
input stream. Normally you would use this method within a content request
implementation, for example:
ConnectionRequest request = new ConnectionRequest() {
protected void readResponse(InputStream input) throws IOException {
Result evaluator = Result.fromContent(input, Result.JSON);
// ... evaluate the result here
}
// ... etc
};

Parameters:
content - structured content document as a string.
format - an identifier for the type of content passed

(ie. xml, json, etc).


Returns:
Result a result evaluator object
Throws:
IllegalArgumentException - thrown if null content or format is passed.
IOException

Field Detail

2108

Overview (Codename One API)


fromContent
public static Result fromContent(Reader content,
String format)
throws IllegalArgumentException,
IOException

Create an evaluator object from a structured content document (XML, JSON, etc)
input stream. Normally you would use this method within a content request
implementation, for example:
ConnectionRequest request = new ConnectionRequest() {
protected void readResponse(InputStream input) throws IOException {
Result evaluator = Result.fromContent(input, Result.JSON);
// ... evaluate the result here
}
// ... etc
};

Parameters:
content - structured content document as a string.
format - an identifier for the type of content passed

(ie. xml, json, etc).


Returns:
Result a result evaluator object
Throws:
IllegalArgumentException - thrown if null content or format is passed.
IOException

fromContent
public static Result fromContent(Element content)
throws IllegalArgumentException

Create an evaluator object from a parsed XML DOM.


Parameters:
content - a parsed XML DOM.
Returns:
Result a result evaluator object
Throws:
IllegalArgumentException - thrown if null content is passed.
fromContent
public static Result fromContent(Map content)
throws IllegalArgumentException

Create an evaluator object from parsed JSON content DOM.


Parameters:
content - JSON content input stream
Returns:
Result a result evaluator object
Throws:
IllegalArgumentException

hashCode
public int hashCode()

Returns a hashcode value for the object.


Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals
public boolean equals(Object other)

Indicates whether some other object is "equal to" this one.


Overrides:
equals in class Object
See Also:

Method Detail

2109

Overview (Codename One API)


Object.equals(Object)

toString
public String toString()

Convert the object to a formatted structured content document. For example, an XML
or JSON document.
Overrides:
toString in class Object
Returns:
a structured content document as a string
getAsBoolean
public boolean getAsBoolean(String path)
throws IllegalArgumentException

Get a boolean value from the requested path. For example: JSON
{
"settings" : [
{
"toggle" : "true",
... etc
}

Expression
boolean value = result.getAsBoolean("/settings[0]/toggle");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
getAsInteger
public int getAsInteger(String path)
throws IllegalArgumentException

Get an integer value from the requested path. For example: JSON
{
"settings"
{
"connection"
{
"max_retries" : "20",
... etc
}
}

Expression
int value = result.getAsInteger("//connection/max_retries");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalException - on error traversing the document, ie. traversing into an
array without using subscripts.
IllegalArgumentException

Method Detail

2110

Overview (Codename One API)


getAsLong
public long getAsLong(String path)
throws IllegalArgumentException

Get an long value from the requested path. For example: JSON
{
"settings"
{
"connection"
{
"timeout_milliseconds" : "100000",
... etc
}
}

Expression
long value = result.getAsLong("/settings/connection/timeout_milliseconds");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
getAsDouble
public double getAsDouble(String path)
throws IllegalArgumentException

Get a double value from the requested path. For example: JSON
{
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 42.94959820,
"lng" : -81.24873959999999
},
"southwest" : {
"lat" : 42.94830,
"lng" : -81.24901740000001
}
},
"location" : {
"lat" : 42.94886990,
"lng" : -81.24876030
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 42.95029808029150,
"lng" : -81.24752951970851
},
"southwest" : {
"lat" : 42.94760011970850,
"lng" : -81.25022748029151
}
}
// etc

Expression
double
double
double
double

Method Detail

neBoundsLat = result.getAsDouble("//bounds/northeast/lat");
neBoundsLong = result.getAsDouble("//bounds/northeast/lng");
swBoundsLat = result.getAsDouble("//bounds/southwest/lat");
swBoundsLong = result.getAsDouble("//bounds/southwest/lng");

2111

Overview (Codename One API)


double memberDiscount = result.getAsDouble("pricing.members.members");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
getAsString
public String getAsString(String path)
throws IllegalArgumentException

Get a string value from the requested path. For example: JSON
{
"profile"
{
"location"
{
"city" : "London",
"region" : "Ontario",
"country" : "Canada",
... etc
},
}

Expression
String city = result.getAsDouble("//city");
String province = result.getAsDouble("//location//region");
String country = result.getAsDouble("profile//location//country");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
get
public Object get(String path)
throws IllegalArgumentException

Get the object value from the requested path. This method may return a Map, List,
String, or null.
Parameters:
path Returns:
the object at the given path, or null.
Throws:
IllegalArgumentException

getSizeOfArray
public int getSizeOfArray(String path)
throws IllegalArgumentException

Get the size of an array at the requested path. For example: JSON
{
"results" : [
{
"address_components" : [
{
"long_name" : "921-989",
"short_name" : "921-989",

Method Detail

2112

Overview (Codename One API)


"types" : [ "street_number" ]
},
{
"long_name" : "Country Club Crescent",
"short_name" : "Country Club Crescent",
"types" : [ "route" ]
},
{
"long_name" : "Ontario",
"short_name" : "ON",
"types" : [ "administrative_area_level_1", "political" ]
},
... etc
}
}

Expression
int size = result.getSizeOfArray("/results[0]/address_components");
int size2 = result.getSizeOfArray("results");
int size3 = result.getSizeOfArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
getAsStringArray
public String[] getAsStringArray(String path)
throws IllegalArgumentException

Get an array of string values from the requested path. For example: JSON
{
"results" : [
{
"address_components" : [
{
"long_name" : "921-989",
"short_name" : "921-989",
"types" : [ "street_number" ]
},
{
"long_name" : "Country Club Crescent",
"short_name" : "Country Club Crescent",
"types" : [ "route" ]
},
{
"long_name" : "Ontario",
"short_name" : "ON",
"types" : [ "administrative_area_level_1", "political" ]
},
... etc
}
}

Expression
String types[] = result
.getAsStringArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:

Method Detail

2113

Overview (Codename One API)


- on error traversing the document, ie. traversing
into an array without using subscripts.
getAsIntegerArray
IllegalArgumentException

public int[] getAsIntegerArray(String path)


throws IllegalArgumentException

Get an array of values from the requested path. For example: JSON
{
"results" : [
{
"address_components" : [
{
"long_name" : "921-989",
"short_name" : "921-989",
"types" : [ "street_number" ]
},
{
"long_name" : "Country Club Crescent",
"short_name" : "Country Club Crescent",
"types" : [ "route" ]
},
{
"long_name" : "Ontario",
"short_name" : "ON",
"types" : [ "administrative_area_level_1", "political" ]
},
... etc
}
}

Expression
String types[] = result
.getAsStringArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
NumberFormatException - if the value at path can not be converted to an
integer.
getAsLongArray
public long[] getAsLongArray(String path)
throws IllegalArgumentException

Get an array of values from the requested path.


String types[] = result
.getAsStringArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
NumberFormatException - if the value at path can not be converted to an long.

Method Detail

2114

Overview (Codename One API)


getAsDoubleArray
public double[] getAsDoubleArray(String path)
throws IllegalArgumentException

Get an array of values from the requested path.


String types[] = result
.getAsStringArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
NumberFormatException - if the value at path can not be converted to an
double.
getAsBooleanArray
public boolean[] getAsBooleanArray(String path)
throws IllegalArgumentException

Get an array of values from the requested path.


String types[] = result
.getAsStringArray("/results[0]/address_components[2]/types");

Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
getAsArray
public List getAsArray(String path)
throws IllegalArgumentException

Get a List of values from the requested path. For example: JSON
{
"results" : [
{
"address_components" : [
{
"long_name" : "921-989",
"short_name" : "921-989",
"types" : [ "street_number" ]
},
{
"long_name" : "Country Club Crescent",
"short_name" : "Country Club Crescent",
"types" : [ "route" ]
},
... etc
}
}

Expression
List addressComponents = result.getAsList("/results[0]/address_components");
result = Result.fromContent(addressComponents);
String longName = result.getAsString("[1]/long_name");

Method Detail

2115

Overview (Codename One API)


Parameters:
path - Path expression to evaluate
Returns:
the value at the requested path
Throws:
IllegalArgumentException - on error traversing the document, ie. traversing
into an array without using subscripts.
mapNamespaceAlias
public void mapNamespaceAlias(String namespaceURI,
String alias)

Method Detail

2116

Overview (Codename One API)


com.codename1.payment

Interface RestoreCallback

public interface

Callback interface that the main class must implement in order for the restore option of
in-app-purchasing to work. Once the main class implements this interface the methods within it are
invoked to indicate the various restore states.

Method Summary
Modifier and
Type

Method and Description


itemRestored(String sku)

void

Indicates a the given SKU was restored by a user.


restoreRequestComplete()
Indicates that a Purchase.restore()

void

request was completed without

errors.
restoreRequestError(String message)
Indicates that a Purchase.restore() request

void

was completed with errors.

Method Detail
itemRestored
void itemRestored(String sku)

Indicates a the given SKU was restored by a user. When restoring multiple SKU's at
once multiple calls to this method will be performed.
Parameters:
sku - the sku purchased
restoreRequestComplete
void restoreRequestComplete()

Indicates that a Purchase.restore() request was completed without errors. It doesn't


mean that any particular products were restored, only that the request completed.
After a call to Purchase.restore(), either this or
restoreRequestError(java.lang.String) will be called at some point.
restoreRequestError
void restoreRequestError(String message)

Indicates that a Purchase.restore() request was completed with errors. It doesn't


mean that any particular products were restored, only that the request completed.
After a call to Purchase.restore(), either this or restoreRequestComplete() will be
called at some point.
Parameters:
message - The error message.

Interface RestoreCallback

2117

Overview (Codename One API)


com.codename1.payment

Interface PurchaseCallback

public interface

Callback interface that the main class must implement in order for in-app-purchasing to work. Once
the main class implements this interface the methods within it are invoked to indicate the various
purchase states.

Method Summary
Modifier and
Type

Method and Description


itemPurchased(String sku)

void

Indicates a the given SKU was purchased by a user.


itemPurchaseError(String sku, String errorMessage)

void

Callback indicating a the given SKU purchase failed


itemRefunded(String sku)

void

Invoked if a refund was granted for a purchase


paymentFailed(String paymentCode, String failureReason)

void

Indicates that a manual payment has failed


paymentSucceeded(String paymentCode, double amount,
String currency)

void

Indicates that a manual payment has passed


subscriptionCanceled(String sku)

void

Invoked when a subscription SKU is canceled


subscriptionStarted(String sku)

void

Invoked when a subscription SKU is started

Method Detail
itemPurchased
void itemPurchased(String sku)

Indicates a the given SKU was purchased by a user. When purchasing multiple
SKU's at once multiple calls to this method will be performed.
Parameters:
sku - the sku purchased
itemPurchaseError
void itemPurchaseError(String sku,
String errorMessage)

Callback indicating a the given SKU purchase failed


Parameters:
sku - the id
itemRefunded
void itemRefunded(String sku)

Invoked if a refund was granted for a purchase


Parameters:
sku - the sku purchased

Method Detail

2118

Overview (Codename One API)


subscriptionStarted
void subscriptionStarted(String sku)

Invoked when a subscription SKU is started


Parameters:
sku - the sku purchased
subscriptionCanceled
void subscriptionCanceled(String sku)

Invoked when a subscription SKU is canceled


Parameters:
sku - the sku purchased
paymentFailed
void paymentFailed(String paymentCode,
String failureReason)

Indicates that a manual payment has failed


Parameters:
paymentCode - the transaction id of the payment
paymentSucceeded
void paymentSucceeded(String paymentCode,
double amount,
String currency)

Indicates that a manual payment has passed


Parameters:
paymentCode - the transaction id of the payment

Method Detail

2119

Overview (Codename One API)


com.codename1.payment

Class Purchase
java.lang.Object

com.codename1.payment.Purchase

public abstract class


extends Object

Represents the status of in-app-purchase goods, this class provides information about products
purchased by a user as well as the ability to purchase additional products. There are generally two
types of payment systems: Manual and managed. In manual payments we pay a specific amount in a
specific currency while with managed payment systems we work against a product catalog defined in
the server.
In-app-purchase API's rely on managed server based products, other payment systems use the
manual approach. An application dealing with virtual goods must support both since not all devices
feature in-app-purchase API's. An application dealing with physical goods & services must use the
latter according to the TOS of current in-app-purchase solutions.

Constructor Summary
Constructor and Description
Purchase()

Method Summary
Modifier and
Type

Method and Description


getInAppPurchase()

static
Purchase

static
Purchase
Product[]

Returns the native OS purchase implementation if applicable, if unavailable


this method will try to fallback to a custom purchase implementation and
failing that will return null
getInAppPurchase(boolean d)

Deprecated.
use the version that takes no arguments
getProducts(String[] skus)

Returns the product list for the given SKU array


isItemListingSupported()

boolean

Indicates whether the payment platform supports things such as "item listing"
or requires that items be coded into the system.
isManagedPaymentSupported()

boolean

Indicates whether the purchasing platform supports managed payments which


work by picking products that are handled by the servers/OS of the platform
vendor.
isManualPaymentSupported()

boolean

boolean
boolean
boolean
boolean

Class Purchase

Indicates whether the purchasing platform supports manual payments which


are just payments of a specific amount of money.
isRefundable(String sku)

Indicates whether refunding is possible when the SKU is purchased


isRestoreSupported()

Indicates whether a purchase restore button is supported by the OS


isSubscriptionSupported()

Returns true if the subscription API is supported in this platform


isUnsubscribeSupported()

2120

Overview (Codename One API)


Some platforms support subscribing but don't support unsubscribe
pay(double amount, String currency)

Performs payment of a specific amount based on the manual payment API,


notice that this doesn't use the in-app-purchase functionality of the device!

String

pay(double amount, String currency, String invoiceNumber)

Performs payment of a specific amount based on the manual payment API,


notice that this doesn't use the in-app-purchase functionality of the device!

String

purchase(String sku)

void

Begins the purchase process for the given SKU


refund(String sku)

void

Tries to refund the given SKU if applicable in the current market/product


restore()

Restores purchases if applicable, this will only work if isRestoreSupported()


returns true

void

subscribe(String sku)

void

Begins subscribe process for the given subscription SKU


unsubscribe(String sku)

void

Cancels the subscription to a given SKU


wasPurchased(String sku)

boolean

Returns true if the given SKU was purchased in the past, notice this method
might not work as expected for Unmanaged/consumable products which can
be purchased multiple times.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Purchase
public Purchase()

Method Detail
isManualPaymentSupported
public boolean isManualPaymentSupported()

Indicates whether the purchasing platform supports manual payments which are just
payments of a specific amount of money.
Returns:
true if manual payments are supported
isManagedPaymentSupported
public boolean isManagedPaymentSupported()

Indicates whether the purchasing platform supports managed payments which work
by picking products that are handled by the servers/OS of the platform vendor.
Returns:
true if managed payments are supported
pay
public String pay(double amount,
String currency)

Performs payment of a specific amount based on the manual payment API, notice
that this doesn't use the in-app-purchase functionality of the device!
Parameters:
amount - the amount to pay

Method Summary

2121

Overview (Codename One API)


currency - the three letter currency type
Returns:
a token representing the pending transaction which will be matched when
receiving a callback from the platform or a null if the payment has failed or
was canceled
Throws:
RuntimeException - This method is a part of the manual payments API and
will fail if isManualPaymentSupported() returns false
pay
public String pay(double amount,
String currency,
String invoiceNumber)

Performs payment of a specific amount based on the manual payment API, notice
that this doesn't use the in-app-purchase functionality of the device!
Parameters:
amount - the amount to pay
currency - the three letter currency type
invoiceNumber - application specific invoice number
Returns:
a token representing the pending transaction which will be matched when
receiving a callback from the platform or a null if the payment has failed or
was canceled
Throws:
RuntimeException - This method is a part of the manual payments API and
will fail if isManualPaymentSupported() returns false
isItemListingSupported
public boolean isItemListingSupported()

Indicates whether the payment platform supports things such as "item listing" or
requires that items be coded into the system. iOS provides listing and pricing where
Android expects developers to redirect into the Play application for application details.
Returns:
true if the OS supports this behavior
getProducts
public Product[] getProducts(String[] skus)

Returns the product list for the given SKU array


Parameters:
sku - the ids for the specific products
Returns:
the product instances
Throws:
RuntimeException - This method is a part of the managed payments API and
will fail if isManagedPaymentSupported() returns false
RuntimeException - This method works only if isItemListingSupported()
returns true
wasPurchased
public boolean wasPurchased(String sku)

Returns true if the given SKU was purchased in the past, notice this method might
not work as expected for Unmanaged/consumable products which can be purchased
multiple times. In addition, this will only return true if the product was purchased (or
has been restored) on the current device.
Parameters:
sku - the id of the product
Returns:
true if the product was purchased
Throws:
RuntimeException - This method is a part of the managed payments API and
will fail if isManagedPaymentSupported() returns false

Method Detail

2122

Overview (Codename One API)


purchase
public void purchase(String sku)

Begins the purchase process for the given SKU


Parameters:
sku - the SKU with which to perform the purchase process
Throws:
RuntimeException - This method is a part of the managed payments API and
will fail if isManagedPaymentSupported() returns false
subscribe
public void subscribe(String sku)

Begins subscribe process for the given subscription SKU


Parameters:
sku - the SKU with which to perform the purchase process
Throws:
RuntimeException - This method is a part of the managed payments API and
will fail if isManagedPaymentSupported() returns false
unsubscribe
public void unsubscribe(String sku)

Cancels the subscription to a given SKU


Parameters:
sku - the SKU with which to perform the purchase process
Throws:
RuntimeException - This method is a part of the managed payments API and
will fail if isManagedPaymentSupported() returns false
isRefundable
public boolean isRefundable(String sku)

Indicates whether refunding is possible when the SKU is purchased


Parameters:
sku - the sku
Returns:
true if the SKU can be refunded
refund
public void refund(String sku)

Tries to refund the given SKU if applicable in the current market/product


Parameters:
sku - the id for the product
getInAppPurchase
public static Purchase getInAppPurchase()

Returns the native OS purchase implementation if applicable, if unavailable this


method will try to fallback to a custom purchase implementation and failing that will
return null
Returns:
instance of the purchase class or null
getInAppPurchase
public static Purchase getInAppPurchase(boolean d)

Deprecated. use the version that takes no arguments


isSubscriptionSupported
public boolean isSubscriptionSupported()

Returns true if the subscription API is supported in this platform


Returns:
true if the subscription API is supported in this platform

Method Detail

2123

Overview (Codename One API)


isUnsubscribeSupported
public boolean isUnsubscribeSupported()

Some platforms support subscribing but don't support unsubscribe


Returns:
true if the subscription API allows for unsubscribe
isRestoreSupported
public boolean isRestoreSupported()

Indicates whether a purchase restore button is supported by the OS


Returns:
true if you can invoke the restore method
restore
public void restore()

Restores purchases if applicable, this will only work if isRestoreSupported() returns


true

Method Detail

2124

Overview (Codename One API)


com.codename1.payment

Class Product
java.lang.Object

com.codename1.payment.Product

public class
extends Object

Represents a product within the system

Constructor Summary
Constructor and Description
Product()

Method Summary
Modifier and Type

Method and Description

String

getDescription()

String

getDisplayName()

String

getLocalizedPrice()

String

getSku()

void

setDescription(String description)

void

setDisplayName(String displayName)

void

setLocalizedPrice(String localizedPrice)

void

setSku(String sku)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Product
public Product()

Method Detail
getDisplayName
public String getDisplayName()

Returns:
the displayName
setDisplayName
public void setDisplayName(String displayName)

Parameters:

Class Product

2125

Overview (Codename One API)


displayName

- the displayName to set

getDescription
public String getDescription()

Returns:
the description
setDescription
public void setDescription(String description)

Parameters:
description

- the description to set

getLocalizedPrice
public String getLocalizedPrice()

Returns:
the localizedPrice
setLocalizedPrice
public void setLocalizedPrice(String localizedPrice)

Parameters:
localizedPrice

- the localizedPrice to set

getSku
public String getSku()

Returns:
the sku
setSku
public void setSku(String sku)

Parameters:
sku - the sku to set

Method Detail

2126

Overview (Codename One API)


com.codename1.notifications

Interface LocalNotificationCallback

public interface

An interface that can be implemented by the application's main class (i.e. the class with start(),
stop() etc..) to respond to local notifications. This interface only works when it is implemented by the
main class. It will never be called otherwise.
IMPORTANT: THIS CALLBACK IS CALLED OFF THE EDT. ANY UPDATES TO THE UI WILL NEED
TO OCCUR INSIDE A callSerially() block.
See Also:
LocalNotification

Method Summary
Modifier and
Type

Method and Description


localNotificationReceived(String notificationId)

void

Callback method that is called when a local notification is received AND the
application is active.

Method Detail
localNotificationReceived
void localNotificationReceived(String notificationId)

Callback method that is called when a local notification is received AND the
application is active. This won't necessarily be called when the notification is
received. If the app is in the background, for example, the notification will manifest
itself as a message to the user's task bar (or equivalent). If the user then clicks on the
notification message, the app will be activated, and this callback method will be
called.
IMPORTANT: THIS CALLBACK IS CALLED OFF THE EDT. ANY UPDATES TO
THE UI WILL NEED TO OCCUR INSIDE A callSerially() block.
Parameters:
notificationId

- The notification ID of the notification that was received.

See Also:
LocalNotification

Interface LocalNotificationCallback

2127

Overview (Codename One API)


com.codename1.notifications

Class LocalNotification
java.lang.Object

com.codename1.notifications.LocalNotification

public class
extends Object

Local notifications are user notifications that are scheduled by the app itself. They are very similar to
push notifications, except that they originate locally, rather than remotely.
They enable an app that isnt running in the foreground to let its users know it has information for
them. The information could be a message, an impending calendar event, or new data on a remote
server. They can display an alert message or they can badge the app icon. They can also play a
sound when the alert or badge number is shown.
When users are notified that the app has a message, event, or other data for them, they can launch
the app and see the details. They can also choose to ignore the notification, in which case the app is
not activated.
This class encapsulates a single notification (though the notification can be repeating).

Usage

LocalNotification n = new LocalNotification();


n.setId("hello"); // An ID for the notification.
n.setAlertBody("Some content"); // A description to be displayed for the notification
n.setAlertTitle("Hello World"); // Title to be displayed for notification
Display.getInstance().sendLocalNotification(n, System.currentTimeMillis() + 10000, LocalNotificat

See Also:
Display.scheduleLocalNotification(LocalNotification n, long firstTime, int repeat),
Display.cancelLocalNotification(java.lang.String id)

Field Summary
Modifier and
Type

Field and Description


REPEAT_DAY

static int

Constant used in #setRepeatType(int) to indicate that this notification


should be repeated every day.
REPEAT_HOUR

static int

Constant used in #setRepeatType(int) to indicate that this notification


should be repeated every hour.
REPEAT_MINUTE

static int

Constant used in #setRepeatType(int) to indicate that this notification


should be repeated every 1 minute.
REPEAT_NONE

static int

Constant used in #setRepeatType(int) to indicate that this notification


should not be repeated.
REPEAT_WEEK

static int

Method Detail

Constant used in #setRepeatType(int) to indicate that this notification


should be repeated every week.

2128

Overview (Codename One API)


Constructor

Summary

Constructor and Description


LocalNotification()

Creates a new local notification

Method Summary
Modifier
and Type
String
String
String
String

Method and Description


getAlertBody()

Gets the alert body to be displayed for this notification.


getAlertImage()

Gets the notification image


getAlertSound()

Gets the alert sound to be sounded when the notification arrives.


getAlertTitle()

Gets the alert title to be displayed for this notification.


getBadgeNumber()

int

Gets the badge number to set for this notification.

String

getId()

Gets the ID of the notification.


setAlertBody(String alertBody)

void

Sets the alert body to be displayed for this notification.


setAlertImage(String image)

Sets an image to be displayed on the platform notifications bar, if the


underlying platform supports image displaying otherwise the image will be
ignored.

void

setAlertSound(String alertSound)

void

Sets the alert sound to be sounded when the notification arrives.


setAlertTitle(String alertTitle)

void

Sets the alert title to be displayed for this notification.


setBadgeNumber(int badgeNumber)

void

Gets the badge number to set for this notification.


setId(String id)

void

Sets the ID of the notification.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
REPEAT_NONE
public static final int REPEAT_NONE

Constant used in #setRepeatType(int) to indicate that this notification should not be


repeated.
See Also:
Constant Field Values
REPEAT_MINUTE
public static final int REPEAT_MINUTE

Constant used in #setRepeatType(int) to indicate that this notification should be


repeated every 1 minute.

Constructor Summary

2129

Overview (Codename One API)


See Also:
Constant Field Values
REPEAT_HOUR
public static final int REPEAT_HOUR

Constant used in #setRepeatType(int) to indicate that this notification should be


repeated every hour.
See Also:
Constant Field Values
REPEAT_DAY
public static final int REPEAT_DAY

Constant used in #setRepeatType(int) to indicate that this notification should be


repeated every day.
See Also:
Constant Field Values
REPEAT_WEEK
public static final int REPEAT_WEEK

Constant used in #setRepeatType(int) to indicate that this notification should be


repeated every week.
See Also:
Constant Field Values

Constructor Detail
LocalNotification
public LocalNotification()

Creates a new local notification

Method Detail
getBadgeNumber
public int getBadgeNumber()

Gets the badge number to set for this notification.


Returns:
the badgeNumber
setBadgeNumber
public void setBadgeNumber(int badgeNumber)

Gets the badge number to set for this notification.


Parameters:
badgeNumber - the badgeNumber to set
getAlertBody
public String getAlertBody()

Gets the alert body to be displayed for this notification.


Returns:
the alertBody
setAlertBody
public void setAlertBody(String alertBody)

Sets the alert body to be displayed for this notification.


Parameters:

Field Detail

2130

Overview (Codename One API)


alertBody

- the alertBody to set

getAlertTitle
public String getAlertTitle()

Gets the alert title to be displayed for this notification.


Returns:
the alertTitle
setAlertTitle
public void setAlertTitle(String alertTitle)

Sets the alert title to be displayed for this notification.


Parameters:
alertTitle - the alertTitle to set
getAlertSound
public String getAlertSound()

Gets the alert sound to be sounded when the notification arrives. This should refer to
a sound file that is bundled in the default package of your app.
Returns:
the alertSound
setAlertSound
public void setAlertSound(String alertSound)

Sets the alert sound to be sounded when the notification arrives. This should refer to
a sound file that is bundled in the default package of your app. The name of the file
must start with the "notification_sound" prefix.
LocalNotification n = new LocalNotification();
n.setAlertSound("/notification_sound_bells.mp3");

Parameters:
alertSound

- the alertSound to set

getId
public String getId()

Gets the ID of the notification. The ID is the only information that is passed to
so you
can use it as a lookup key to retrieve the rest of the information as required from
storage or some other mechanism. The ID can also be used to cancel the notification
later using Display.cancelLocalNotification(java.lang.String)
Returns:
the id
setId
LocalNotificationCallback.localNotificationReceived(java.lang.String)

public void setId(String id)

Sets the ID of the notification. The ID is the only information that is passed to
so you
can use it as a lookup key to retrieve the rest of the information as required from
storage or some other mechanism. The ID can also be used to cancel the notification
later using Display.cancelLocalNotification(java.lang.String)
Parameters:
id - the id to set
getAlertImage
LocalNotificationCallback.localNotificationReceived(java.lang.String)

public String getAlertImage()

Gets the notification image


Returns:
image path

Method Detail

2131

Overview (Codename One API)


setAlertImage
public void setAlertImage(String image)

Sets an image to be displayed on the platform notifications bar, if the underlying


platform supports image displaying otherwise the image will be ignored.
Parameters:
image - a path to the image, the image needs to be placed in the app root.

Method Detail

2132

Overview (Codename One API)


com.codename1.messaging

Class Message
java.lang.Object

com.codename1.messaging.Message

public class
extends Object

Represents a message to be sent using underlying platform e-mail client.

Field Summary
Modifier and Type Field and Description
static String

MIME_HTML

static String

MIME_IMAGE_JPG

static String

MIME_IMAGE_PNG

static String

MIME_TEXT

Constructor Summary
Constructor and Description
Message(String content)

Constructor with the message body content

Method Summary
Modifier and Type
String
String

Method and Description


getAttachment()

Gets the message attachment file path


getAttachmentMimeType()

Gets the attachment mime type


getAttachments()

Map<String,String>

String
String

Returns the attachment map which can be used to add multiple


attachments.
getContent()

Gets the message content


getMimeType()

Gets the message mime type


isCloudMessageFailSilently()

boolean

static void

void

boolean

Class Message

Indicates whether the cloud message should produce an error dialog


if sending failed
sendMessage(String[] recipients, String subject, Message msg)

Send an email using the platform mail client


sendMessageViaCloud(String sender, String recipient,
String recipientName, String subject, String plainTextBody)

Send an email message using the Codename One cloud to send the
message, notice that this API will only work for pro accounts
sendMessageViaCloudSync(String sender, String recipient,
String recipientName, String subject, String plainTextBody)

Send an email message using the Codename One cloud to send the
message, notice that this API will only work for pro accounts

2133

Overview (Codename One API)


setAttachment(String fileUri)

void

Sets the message attachment if exists


setAttachmentMimeType(String mimeType)

void

Sets the attachment mime type.


setCloudMessageFailSilently(boolean cloudMessageFailSilently)

Indicates whether the cloud message should produce an error dialog


if sending failed

void

setMimeType(String mimeType)

void

Sets the message mime type.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
MIME_TEXT
public static final String MIME_TEXT

See Also:
Constant Field Values
MIME_HTML
public static final String MIME_HTML

See Also:
Constant Field Values
MIME_IMAGE_JPG
public static final String MIME_IMAGE_JPG

See Also:
Constant Field Values
MIME_IMAGE_PNG
public static final String MIME_IMAGE_PNG

See Also:
Constant Field Values

Constructor Detail
Message
public Message(String content)

Constructor with the message body content


Parameters:
content - the message content

Method Detail
getContent
public String getContent()

Gets the message content


Returns:
content

Method Summary

2134

Overview (Codename One API)


setAttachment
public void setAttachment(String fileUri)

Sets the message attachment if exists


Parameters:
fileUri - the file to attach to the message
getAttachments
public Map<String,String> getAttachments()

Returns the attachment map which can be used to add multiple attachments. The
path needs to point at a full absolute file URI within FileSystemStorage, it will not
work with Storage files!
Returns:
a map of full file paths to mime type that can be used to add attachments
setMimeType
public void setMimeType(String mimeType)

Sets the message mime type.


Parameters:
mimeType getMimeType
public String getMimeType()

Gets the message mime type


Returns:
the mime type
setAttachmentMimeType
public void setAttachmentMimeType(String mimeType)

Sets the attachment mime type.


Parameters:
mimeType getAttachmentMimeType
public String getAttachmentMimeType()

Gets the attachment mime type


Returns:
getAttachment
public String getAttachment()

Gets the message attachment file path


Returns:
the file path of the attachment
sendMessage
public static void sendMessage(String[] recipients,
String subject,
Message msg)

Send an email using the platform mail client


Parameters:
recipients - array of e-mail addresses
subject - e-mail subject
msg - the Message to send
sendMessageViaCloud
public void sendMessageViaCloud(String
String
String
String
String

Method Detail

sender,
recipient,
recipientName,
subject,
plainTextBody)

2135

Overview (Codename One API)


Send an email message using the Codename One cloud to send the message, notice
that this API will only work for pro accounts
Parameters:
sender - the name of the sender, notice all email will arrive from Codename
One to avoid spam issues
recipient - the email for the recipient
recipientName - the display name for the recipient
subject - e-mail subject
plainTextBody - when sending an HTML message you should also attach a
plain text fallback message, this is redundant if the email is a plain text
message to begin with
sendMessageViaCloudSync
public boolean sendMessageViaCloudSync(String
String
String
String
String

sender,
recipient,
recipientName,
subject,
plainTextBody)

Send an email message using the Codename One cloud to send the message, notice
that this API will only work for pro accounts
Parameters:
sender - the name of the sender, notice all email will arrive from Codename
One to avoid spam issues
recipient - the email for the recipient
recipientName - the display name for the recipient
subject - e-mail subject
plainTextBody - when sending an HTML message you should also attach a
plain text fallback message, this is redundant if the email is a plain text
message to begin with
Returns:
true if sending succeeded
isCloudMessageFailSilently
public boolean isCloudMessageFailSilently()

Indicates whether the cloud message should produce an error dialog if sending failed
Returns:
the cloudMessageFailSilently
setCloudMessageFailSilently
public void setCloudMessageFailSilently(boolean cloudMessageFailSilently)

Indicates whether the cloud message should produce an error dialog if sending failed
Parameters:
cloudMessageFailSilently - the cloudMessageFailSilently to set

Method Detail

2136

Overview (Codename One API)


com.codename1.media

Class MediaManager
java.lang.Object

com.codename1.media.MediaManager

public class
extends Object

Allow us to create objects using String URI's or with a stream to the media data.
Notice that the underlying platforms contains the actual codecs, therefore you need to play common
media file types such as mp3, mp4 to successfully play them across devices on all target platforms.
The simulator can't accurately reproduce the behavior of this class in all devices/cases.
The sample code below demonstrates simple video playback.
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) {
{@literal @}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();

Class MediaManager

2137

Overview (Codename One API)

Constructor

Summary

Constructor and Description


MediaManager()

Method Summary
Modifier and
Type
static Media

Method and Description


createBackgroundMedia(String uri)

Creates an audio media that can be played in the background.


createMedia(InputStream stream, String mimeType)

static Media

static Media

static Media
static Media

Creates the Media in the given stream Notice that a Media is "auto
destroyed" on completion and cannot be played twice!
createMedia(InputStream stream, String mimeType,
Runnable onCompletion)

Creates the Media in the given stream Notice that a Media is "auto
destroyed" on completion and cannot be played twice!
createMedia(String uri, boolean isVideo)

Creates a Media from a given URI


createMedia(String uri, boolean isVideo, Runnable onCompletion)

Creates a Media from a given URI


createMediaRecorder(String path)

static Media

Deprecated.
see createMediaRecorder(String path, String mimeType) instead
createMediaRecorder(String path, String mimeType)

static Media

Creates a Media recorder Object which will record from the device mic to a
file in the given path.

static
String[]

getAvailableRecordingMimeTypes()

Gets the available recording MimeTypes


getMediaRecorderingMimeType()

static String

Deprecated.
see getAvailableRecordingMimeTypes() instead

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MediaManager
public MediaManager()

Method Detail
createBackgroundMedia
public static Media createBackgroundMedia(String uri)
throws IOException

Creates an audio media that can be played in the background.


Parameters:
uri - the uri of the media can start with jar://, file://, http:// (can also use rtsp://
if supported on the platform)
Returns:
Media a Media Object that can be used to control the playback of the media

Constructor Summary

2138

Overview (Codename One API)


Throws:
IOException

- if creation of media from the given URI has failed

createMedia
public static Media createMedia(String uri,
boolean isVideo)
throws IOException

Creates a Media from a given URI


Parameters:
uri - the uri of the media can start with file://, http:// (can also use rtsp://
although may not be supported on all target platforms)
isVideo - a boolean flag to indicate if this is a video media
Returns:
Media a Media Object that can be used to control the playback of the media
Throws:
IOException - if creation of media from the given URI has failed
createMedia
public static Media createMedia(InputStream stream,
String mimeType)
throws IOException

Creates the Media in the given stream Notice that a Media is "auto destroyed" on
completion and cannot be played twice!
Parameters:
stream - the stream containing the media data
mimeType - the type of the data in the stream
Returns:
Media a Media Object that can be used to control the playback of the media
Throws:
IOException - if the creation of the Media has failed
createMedia
public static Media createMedia(String uri,
boolean isVideo,
Runnable onCompletion)
throws IOException

Creates a Media from a given URI


Parameters:
uri - the uri of the media can start with file://, http:// (can also use rtsp://
although may not be supported on all target platforms)
isVideo - a boolean flag to indicate if this is a video media
onCompletion - a Runnable to be called when the media has finished
Returns:
Media a Media Object that can be used to control the playback of the media
Throws:
IOException - if creation of media from given URI failed
createMedia
public static Media createMedia(InputStream stream,
String mimeType,
Runnable onCompletion)
throws IOException

Creates the Media in the given stream Notice that a Media is "auto destroyed" on
completion and cannot be played twice!
Parameters:
stream - the stream containing the media data
mimeType - the type of the data in the stream
onCompletion - a Runnable to be called when the media has finished
Returns:
Media a Media Object that can be used to control the playback of the media
Throws:
IOException - if the URI access fails

Method Detail

2139

Overview (Codename One API)


createMediaRecorder
public static Media createMediaRecorder(String path)
throws IOException

Deprecated. see createMediaRecorder(String path, String mimeType) instead


Creates a Media recorder Object which will record from the device mic to a file in the
given path. The output format will be amr-nb if supported by the platform.
Parameters:
path - a file path to where to store the recording, if the file does not exists it
will be created.
Throws:
IOException

getMediaRecorderingMimeType
public static String getMediaRecorderingMimeType()

Deprecated. see getAvailableRecordingMimeTypes() instead


Gets the recording mime type for the returned Media from the createMediaRecorder
method
Returns:
the recording mime type
getAvailableRecordingMimeTypes
public static String[] getAvailableRecordingMimeTypes()

Gets the available recording MimeTypes


createMediaRecorder
public static Media createMediaRecorder(String path,
String mimeType)
throws IOException

Creates a Media recorder Object which will record from the device mic to a file in the
given path.
Parameters:
path - a file path to where to store the recording, if the file does not exists it
will be created.
mimeType - the output mime type that is supported see
getAvailableRecordingMimeTypes()
Throws:
IllegalArgumentException - if given mime-type is not supported
IOException - id failed to create a Media object

Method Detail

2140

Overview (Codename One API)


com.codename1.media

Interface Media

public interface

Media control interface allows for media playback, recording. To get an instance of this interface
(implemented by the native port) see the MediaManager class.
See Also:
MediaManager

Field Summary
Modifier
and Type

Field and Description


VARIABLE_BACKGROUND_ALBUM_COVER

static
String

Write only variable that can be used with setVariable to pass the album cover
Image to the native layer so the currently playing media title will be displayed in
the lock screen where applicable
VARIABLE_BACKGROUND_ARTIST

static
String

Write only variable that can be used with setVariable to pass the artist name to
the native layer so the currently playing media title will be displayed in the lock
screen where applicable
VARIABLE_BACKGROUND_DURATION

static
String

Write only variable that can be used with setVariable to pass the duration for the
media as a Long object to the native layer so the currently playing media title
will be displayed in the lock screen where applicable
VARIABLE_BACKGROUND_POSITION

static
String

Write only variable that can be used with setVariable to pass the position in the
media (Long object) to the native layer so the currently playing media title will
be displayed in the lock screen where applicable
VARIABLE_BACKGROUND_SUPPORTED

static
String

Read only variable that can be used with getVariable to query whether the
native layer supports displaying the currently playing media information in the
lock screen.
VARIABLE_BACKGROUND_TITLE

static
String

Write only variable that can be used with setVariable to pass a title for the
native layer so the currently playing media title will be displayed in the lock
screen where applicable

Method Summary
Modifier
and Type

Method and Description


cleanup()

void

int
int
Object
Component
int

Interface Media

Stops the audio playback and cleans up the resources related to it


immediately.
getDuration()

Returns the length in seconds of the audio file or -1 if not known


getTime()

Returns the time in seconds in the audio file or -1 if not known


getVariable(String key)

Allows querying platform specific information from the media object


getVideoComponent()

Gets the VideoComponent of this Video.


getVolume()

2141

Overview (Codename One API)


Returns the media playback volume in percentage
boolean
boolean
boolean
boolean

isFullScreen()

This method returns true if this video is in full screen mode.


isNativePlayerMode()

Returns true if this Video Media is in Native player mode.


isPlaying()

Returns true if the media is currently playing


isVideo()

This method returns true if this is a Video Media


pause()

void

Pauses the playback of the audio file


play()

void

Starts playing the audio file


prepare()

void

Optional call that allows the caller to prepare the upcoming media player.
setFullScreen(boolean fullScreen)

Sets the Media to be displayed full screen, make sure the


getVideoComponent() is called on the Video Component is added to the
current Form

void

setNativePlayerMode(boolean nativePlayer)

By calling this the Media (if it's a Video) will be played full screen on the native
Player of the device.

void

setTime(int time)

void

Sets the position in the audio file or doesn't effect if not supported
setVariable(String key, Object value)

void

Allows for platform specific enhancements for media playback


setVolume(int vol)

void

Sets the media playback volume in percentage

Field Detail
VARIABLE_BACKGROUND_TITLE
static final String VARIABLE_BACKGROUND_TITLE

Write only variable that can be used with setVariable to pass a title for the native
layer so the currently playing media title will be displayed in the lock screen where
applicable
See Also:
Constant Field Values
VARIABLE_BACKGROUND_ARTIST
static final String VARIABLE_BACKGROUND_ARTIST

Write only variable that can be used with setVariable to pass the artist name to the
native layer so the currently playing media title will be displayed in the lock screen
where applicable
See Also:
Constant Field Values
VARIABLE_BACKGROUND_DURATION
static final String VARIABLE_BACKGROUND_DURATION

Write only variable that can be used with setVariable to pass the duration for the
media as a Long object to the native layer so the currently playing media title will be
displayed in the lock screen where applicable
See Also:
Constant Field Values

Method Summary

2142

Overview (Codename One API)


VARIABLE_BACKGROUND_ALBUM_COVER
static final String VARIABLE_BACKGROUND_ALBUM_COVER

Write only variable that can be used with setVariable to pass the album cover Image
to the native layer so the currently playing media title will be displayed in the lock
screen where applicable
See Also:
Constant Field Values
VARIABLE_BACKGROUND_POSITION
static final String VARIABLE_BACKGROUND_POSITION

Write only variable that can be used with setVariable to pass the position in the media
(Long object) to the native layer so the currently playing media title will be displayed
in the lock screen where applicable
See Also:
Constant Field Values
VARIABLE_BACKGROUND_SUPPORTED
static final String VARIABLE_BACKGROUND_SUPPORTED

Read only variable that can be used with getVariable to query whether the native
layer supports displaying the currently playing media information in the lock screen.
This will return null or Boolean.TRUE.
See Also:
Constant Field Values

Method Detail
play
void play()

Starts playing the audio file


pause
void pause()

Pauses the playback of the audio file


prepare
void prepare()

Optional call that allows the caller to prepare the upcoming media player. This is
useful when streaming multiple streams one after another.
cleanup
void cleanup()

Stops the audio playback and cleans up the resources related to it immediately.
getTime
int getTime()

Returns the time in seconds in the audio file or -1 if not known


Returns:
time in milli seconds
setTime
void setTime(int time)

Sets the position in the audio file or doesn't effect if not supported
Parameters:
time - in milli seconds

Field Detail

2143

Overview (Codename One API)


getDuration
int getDuration()

Returns the length in seconds of the audio file or -1 if not known


Returns:
time in milli seconds
setVolume
void setVolume(int vol)

Sets the media playback volume in percentage


Parameters:
vol - the volume for media playback
getVolume
int getVolume()

Returns the media playback volume in percentage


Returns:
the volume percentage
isPlaying
boolean isPlaying()

Returns true if the media is currently playing


Returns:
true if playing
getVideoComponent
Component getVideoComponent()

Gets the VideoComponent of this Video.


Returns:
a Component of the video to be placed on a Form or null if this Media is not a
Video
isVideo
boolean isVideo()

This method returns true if this is a Video Media


Returns:
true if video
isFullScreen
boolean isFullScreen()

This method returns true if this video is in full screen mode.


Returns:
true if full screen
setFullScreen
void setFullScreen(boolean fullScreen)

Sets the Media to be displayed full screen, make sure the getVideoComponent() is
called on the Video Component is added to the current Form
Parameters:
fullScreen setNativePlayerMode
void setNativePlayerMode(boolean nativePlayer)

By calling this the Media (if it's a Video) will be played full screen on the native Player
of the device. Native playing assumes getVideoComponent() hasn't been called on
this Media unexpected behaviour may occur if getVideoComponent() has been called
and the Component is placed on a Form. Some platforms such as BlackBerry is able
to play video only on the native player on those platforms isNativePlayerMode() will

Method Detail

2144

Overview (Codename One API)


always return true
isNativePlayerMode
boolean isNativePlayerMode()

Returns true if this Video Media is in Native player mode. Some platforms such as
BlackBerry is able to play video only on the native player on those platforms
isNativePlayerMode() will always return true If Media supports native playing by
calling to play() the video will start playing in the native player in full screen.
Returns:
true if the player is in native mode
setVariable
void setVariable(String key,
Object value)

Allows for platform specific enhancements for media playback


Parameters:
key - the key to set to the media that is platform specific
value - the value
getVariable
Object getVariable(String key)

Allows querying platform specific information from the media object


Parameters:
key - the key query
Returns:
the value or null

Method Detail

2145

Overview (Codename One API)


com.codename1.maps.providers

Class TiledProvider
java.lang.Object

com.codename1.maps.providers.MapProvider

com.codename1.maps.providers.TiledProvider
Direct Known Subclasses:
GoogleMapsProvider, OpenStreetMapProvider

public abstract class


extends MapProvider

This is a tiled map provider

Field Summary
Modifier and Type Field and Description
protected String

_url

protected int

_zoomLevel

Constructor Summary
Constructor and Description
TiledProvider(String url, Projection projection, Dimension tileSize)

Creates a new Tiled provider

Method Summary
Modifier and Type
BoundingBox

Method and Description


bboxFor(Coord position, int zoomLevel)

Returns the bounding box of a position ina given zoom level


scale(int zoomLevel)

Coord

Scale to the zoom level


tileFor(BoundingBox bbox)

Tile

Gets a tile for the given bounding box

protected String

url(int zoomLevel, int xTile, int yTile)

build a url request for a tile

Methods inherited from


class com.codename1.maps.providers.MapProvider
attribution, maxZoomFor, maxZoomLevel, minZoomLevel, projection, tileSize,
tileSize, translate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Class TiledProvider

2146

Overview (Codename One API)


_url
protected final String _url

_zoomLevel
protected int _zoomLevel

Constructor Detail
TiledProvider
public TiledProvider(String url,
Projection projection,
Dimension tileSize)

Creates a new Tiled provider


Parameters:
url - the url of the provider
projection - the Projection system of the Provider
tileSize - the tiles size(usually 256x256)

Method Detail
url
protected String url(int zoomLevel,
int xTile,
int yTile)

build a url request for a tile


Parameters:
zoomLevel - the zoom level
xTile - x position of the tile
yTile - y position of the tile
Returns:
the image url of the tile
scale
public Coord scale(int zoomLevel)

Scale to the zoom level


Specified by:
scale in class MapProvider
Parameters:
zoomLevel - to scale to
Returns:
a scaled coordinate.
bboxFor
public BoundingBox bboxFor(Coord position,
int zoomLevel)

Returns the bounding box of a position ina given zoom level


Specified by:
bboxFor in class MapProvider
Parameters:
position - on the map
zoomLevel - the zoom level
Returns:
a bounding box
tileFor
public Tile tileFor(BoundingBox bbox)

Gets a tile for the given bounding box

Field Detail

2147

Overview (Codename One API)


Specified by:
tileFor

in class MapProvider

Parameters:
bbox - a bounding box
Returns:
a Tile for the given bounding box

Method Detail

2148

Overview (Codename One API)


com.codename1.maps.providers

Class OpenStreetMapProvider
java.lang.Object

com.codename1.maps.providers.MapProvider

com.codename1.maps.providers.TiledProvider

com.codename1.maps.providers.OpenStreetMapProvider

public class
extends TiledProvider

This is an OpenStreetMap Provider http://www.openstreetmap.org/

Field Summary

Fields inherited from


class com.codename1.maps.providers.TiledProvider
_url, _zoomLevel

Constructor Summary
Constructor and Description
OpenStreetMapProvider()

Empty Constructor

Method Summary
Modifier and Type Method and Description
attribution()

String

The provider attribution.


maxZoomLevel()

int

Maximal zoom level.

Methods inherited from


class com.codename1.maps.providers.TiledProvider
bboxFor, scale, tileFor, url

Methods inherited from


class com.codename1.maps.providers.MapProvider
maxZoomFor, minZoomLevel, projection, tileSize, tileSize, translate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class OpenStreetMapProvider

2149

Overview (Codename One API)


OpenStreetMapProvider
public OpenStreetMapProvider()

Empty Constructor

Method Detail
attribution
public String attribution()

The provider attribution.


Specified by:
attribution in class MapProvider
Returns:
a String of the provider attribution
maxZoomLevel
public int maxZoomLevel()

Maximal zoom level. Zoom levels are counted from zero to maxZoomLevel(). 0 is
farest view, where the scale is greatest.
Specified by:
maxZoomLevel in class MapProvider
Returns:

Constructor Detail

2150

Overview (Codename One API)


com.codename1.maps.providers

Class MapProvider
java.lang.Object

com.codename1.maps.providers.MapProvider
Direct Known Subclasses:
TiledProvider

public abstract class


extends Object

This is a generic map provider.

Constructor Summary
Modifier
protected

Constructor and Description


MapProvider(Projection p, Dimension tileSize)

Creates a new MapProvider

Method Summary
Modifier and Type
abstract String
abstract
BoundingBox

Method and Description


attribution()

The provider attribution.


bboxFor(Coord position, int zoomLevel)

Returns the bounding box of a position ina given zoom level


maxZoomFor(Tile tile)

int

Returns the maximum zoom of a specific Tile.

abstract int

maxZoomLevel()

Maximal zoom level.


minZoomLevel()

int

Minimal zoom level user is able to see.

Projection

projection()

Gets the Provider projection


scale(int zoomLevel)

abstract Coord

abstract Tile
Dimension

Scale is the distance in map units between each pixel in tile at given
zoom level.
tileFor(BoundingBox bbox)

Gets a tile for the given bounding box


tileSize()

Gets the tile size


tileSize(Dimension size)

void

Request map to provide tiles of specific sizes.


translate(Coord position, int zoomLevel, int pixelsX,
int pixelsY)

Coord

Translates position by [pixelsX, pixelsY] at zoomLevel acordingly to


maps scale.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

2151

Overview (Codename One API)


Constructor

Detail

MapProvider
protected MapProvider(Projection p,
Dimension tileSize)

Creates a new MapProvider


Parameters:
p - the projection system
tileSize - the tile size

Method Detail
tileSize
public void tileSize(Dimension size)

Request map to provide tiles of specific sizes. May not be supported by map
provider. By default it does nothing;
Parameters:
size - requested tile size
bboxFor
public abstract BoundingBox bboxFor(Coord position,
int zoomLevel)

Returns the bounding box of a position ina given zoom level


Parameters:
position - on the map
zoomLevel - the zoom level
Returns:
a bounding box
tileFor
public abstract Tile tileFor(BoundingBox bbox)

Gets a tile for the given bounding box


Parameters:
bbox - a bounding box
Returns:
a Tile for the given bounding box
maxZoomLevel
public abstract int maxZoomLevel()

Maximal zoom level. Zoom levels are counted from zero to maxZoomLevel(). 0 is
farest view, where the scale is greatest.
Returns:
minZoomLevel
public int minZoomLevel()

Minimal zoom level user is able to see.


Returns:
scale
public abstract Coord scale(int zoomLevel)

Scale is the distance in map units between each pixel in tile at given zoom level.
Returns:
Scale at given zoom level.

Constructor Detail

2152

Overview (Codename One API)

translate
public Coord translate(Coord position,
int zoomLevel,
int pixelsX,
int pixelsY)

Translates position by [pixelsX, pixelsY] at zoomLevel acordingly to maps scale.


Parameters:
position - in map projection
zoomLevel pixelsX pixelsY Returns:
translated position.
projection
public Projection projection()

Gets the Provider projection


Returns:
the Provider projection
tileSize
public Dimension tileSize()

Gets the tile size


Returns:
the tile size
attribution
public abstract String attribution()

The provider attribution.


Returns:
a String of the provider attribution
maxZoomFor
public int maxZoomFor(Tile tile)

Returns the maximum zoom of a specific Tile.


Parameters:
tile - tile to check the max zoom
Returns:
the max zoom of the tile

Method Detail

2153

Overview (Codename One API)


com.codename1.maps.providers

Class GoogleMapsProvider
java.lang.Object

com.codename1.maps.providers.MapProvider

com.codename1.maps.providers.TiledProvider

com.codename1.maps.providers.GoogleMapsProvider

public class
extends TiledProvider

This is a GoogleMaps Provider https://developers.google.com/maps/documentation/staticmaps/

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


HYBRID

This is a satellite + road map


REGULAR

This is a regular road map


SATELLITE

This is a satellite map

Fields inherited from


class com.codename1.maps.providers.TiledProvider
_url, _zoomLevel

Constructor Summary
Constructor and Description
GoogleMapsProvider(String apiKey)

Google map provider Constructor

Method Summary
Modifier and
Type
String
String
static int

Method and Description


attribution()

The provider attribution.


getLanguage()

Defines the language to use for display of labels on map tiles.


getTileSize()
isSensor()

boolean

int
void
void
void

Class GoogleMapsProvider

Specifies whether the application requesting the static map is using a sensor
to determine the user's location.
maxZoomLevel()

Maximal zoom level.


setLanguage(String language)

Defines the language to use for display of labels on map tiles.


setMapType(int type)

Sets the map type


setSensor(boolean sensor)

2154

Overview (Codename One API)


Specifies whether the application requesting the static map is using a sensor
to determine the user's location.
static void

setTileSize(int aTileSize)
tileFor(BoundingBox bbox)

Tile

Gets a tile for the given bounding box

Methods inherited from


class com.codename1.maps.providers.TiledProvider
bboxFor, scale, url

Methods inherited from


class com.codename1.maps.providers.MapProvider
maxZoomFor, minZoomLevel, projection, tileSize, tileSize, translate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
REGULAR
public static final int REGULAR

This is a regular road map


See Also:
Constant Field Values
SATELLITE
public static final int SATELLITE

This is a satellite map


See Also:
Constant Field Values
HYBRID
public static final int HYBRID

This is a satellite + road map


See Also:
Constant Field Values

Constructor Detail
GoogleMapsProvider
public GoogleMapsProvider(String apiKey)

Google map provider Constructor


Parameters:
apiKey - google maps api key
https://developers.google.com/maps/documentation/staticmaps/#api_key

Method Detail

Method Summary

2155

Overview (Codename One API)


getTileSize
public static int getTileSize()

Returns:
the tileSize
setTileSize
public static void setTileSize(int aTileSize)

Parameters:
aTileSize

- the tileSize to set

setMapType
public void setMapType(int type)

Sets the map type


maxZoomLevel
public int maxZoomLevel()

Maximal zoom level. Zoom levels are counted from zero to maxZoomLevel(). 0 is
farest view, where the scale is greatest.
Specified by:
maxZoomLevel in class MapProvider
Returns:
attribution
public String attribution()

The provider attribution.


Specified by:
attribution in class MapProvider
Returns:
a String of the provider attribution
tileFor
public Tile tileFor(BoundingBox bbox)

Gets a tile for the given bounding box


Overrides:
tileFor in class TiledProvider
Parameters:
bbox - a bounding box
Returns:
a Tile for the given bounding box
getLanguage
public String getLanguage()

Defines the language to use for display of labels on map tiles. Note that this
parameter is only supported for some country tiles; if the specific language requested
is not supported for the tile set, then the default language for that tileset will be used.
Returns:
the language
setLanguage
public void setLanguage(String language)

Defines the language to use for display of labels on map tiles. Note that this
parameter is only supported for some country tiles; if the specific language requested
is not supported for the tile set, then the default language for that tileset will be used.
Parameters:
language - the language to set

Method Detail

2156

Overview (Codename One API)


isSensor
public boolean isSensor()

Specifies whether the application requesting the static map is using a sensor to
determine the user's location.
Returns:
the sensor
setSensor
public void setSensor(boolean sensor)

Specifies whether the application requesting the static map is using a sensor to
determine the user's location.
Parameters:
sensor - the sensor to set

Method Detail

2157

Overview (Codename One API)


com.codename1.maps.layers

Class PointsLayer
java.lang.Object

com.codename1.maps.layers.AbstractLayer

com.codename1.maps.layers.PointsLayer
All Implemented Interfaces:
Layer

public class
extends AbstractLayer

This is a Points Layer

Field Summary

Fields inherited from


class com.codename1.maps.layers.AbstractLayer
name, projection

Constructor Summary
Constructor and Description
PointsLayer()

Constructor with default projection Mercator.


PointsLayer(Projection p, String name)
PointsLayer(String name)

Constructor with default projection Mercator.

Method Summary
Modifier and
Type

Method and Description


addActionListener(ActionListener l)

void

void
BoundingBox
void
void
void
void
void

Class PointsLayer

Adds a listener to the Points Layer which will cause an event to dispatch on
click the ActionEvent will contain the pressed PointLayer unprojected
addPoint(PointLayer point)

Adds a point to the PointsLayer


boundingBox()

The bounding box of this Layer


fireActionEvent(BoundingBox box)

Trigger an event for the points that in contained in the BoundingBox


paint(Graphics g, Tile tile)

Paints the Layer on the given Graphics


removeActionListener(ActionListener l)

Removes the given action listener Points Layer


removePoint(PointLayer point)

Removes a point from the PointsLayer


setPointIcon(Image icon)

Sets the Points icon

2158

Overview (Codename One API)


Methods

inherited from
class com.codename1.maps.layers.AbstractLayer
getName, getProjection

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
PointsLayer
public PointsLayer()

Constructor with default projection Mercator.


PointsLayer
public PointsLayer(String name)

Constructor with default projection Mercator.


PointsLayer
public PointsLayer(Projection p,
String name)

Method Detail
setPointIcon
public void setPointIcon(Image icon)

Sets the Points icon


Parameters:
icon paint
public void paint(Graphics g,
Tile tile)

Paints the Layer on the given Graphics


Parameters:
g - a Graphics Object to paint on
tile - the screen tile
addPoint
public void addPoint(PointLayer point)

Adds a point to the PointsLayer


Parameters:
point - a point to add
removePoint
public void removePoint(PointLayer point)

Removes a point from the PointsLayer


Parameters:
point - to remove from the PointsLayer
boundingBox
public BoundingBox boundingBox()

The bounding box of this Layer


Specified by:

Methods inherited from class com.codename1.maps.layers.AbstractLayer

2159

Overview (Codename One API)


boundingBox

in interface Layer

Specified by:
boundingBox in class AbstractLayer
Returns:
the Layer bounding box
addActionListener
public void addActionListener(ActionListener l)

Adds a listener to the Points Layer which will cause an event to dispatch on click the
ActionEvent will contain the pressed PointLayer unprojected
Parameters:
l - implementation of the action listener interface
removeActionListener
public void removeActionListener(ActionListener l)

Removes the given action listener Points Layer


Parameters:
l - implementation of the action listener interface
fireActionEvent
public void fireActionEvent(BoundingBox box)

Trigger an event for the points that in contained in the BoundingBox


Parameters:
box - the BoundingBox to trigger event.

Method Detail

2160

Overview (Codename One API)


com.codename1.maps.layers

Class PointLayer
java.lang.Object

com.codename1.maps.Coord

com.codename1.maps.layers.PointLayer
All Implemented Interfaces:
Layer

public class
extends Coord
implements Layer

Do not use this layer directly, you need to add this layer into a PointsLayer class instance in order for
it to work as expected!

Constructor Summary
Constructor and Description
PointLayer(Coord position, String name, Image icon)

Creates a Point Layer.

Method Summary
Modifier and Type
BoundingBox

Method and Description


boundingBox()

The bounding box of this Layer


getIcon()

Image

Gets the point Icon

String

getName()

Gets the Point name


paint(Graphics g, Tile tile)

void

Paints the Layer on the given Graphics


setDisplayName(boolean displayName)

void

This method declares if the point name should be displayed


setIcon(Image icon)

void

Sets the display icon

String

toString()

Returns a string representation of the object.

Methods inherited from class com.codename1.maps.Coord


equals, getLatitude, getLongitude, hashCode, isProjected, setLatitude,
setLongitude, setProjected, translate, translate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

Class PointLayer

2161

Overview (Codename One API)


PointLayer
public PointLayer(Coord position,
String name,
Image icon)

Creates a Point Layer.


Parameters:
position - the position of the Point
getName - the getName of the Point
icon - icon of the Point

Method Detail
getName
public String getName()

Gets the Point name


Specified by:
getName in interface Layer
Returns:
the Point name
getIcon
public Image getIcon()

Gets the point Icon


Returns:
the point Icon
setIcon
public void setIcon(Image icon)

Sets the display icon


Parameters:
icon setDisplayName
public void setDisplayName(boolean displayName)

This method declares if the point name should be displayed


Parameters:
displayName paint
public void paint(Graphics g,
Tile tile)

Paints the Layer on the given Graphics


Specified by:
paint in interface Layer
Parameters:
g - a Graphics Object to paint on
tile - the screen tile
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:

Constructor Detail

2162

Overview (Codename One API)


getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Coord
boundingBox
public BoundingBox boundingBox()

The bounding box of this Layer


Specified by:
boundingBox in interface Layer
Returns:
the Layer bounding box

Method Detail

2163

Overview (Codename One API)


com.codename1.maps.layers

Class LinesLayer
java.lang.Object

com.codename1.maps.layers.AbstractLayer

com.codename1.maps.layers.LinesLayer
All Implemented Interfaces:
Layer
Direct Known Subclasses:
ArrowLinesLayer

public class
extends AbstractLayer

This is a Lines Layer

Field Summary
Modifier and Type Field and Description
protected int

_lineColor

Fields inherited from


class com.codename1.maps.layers.AbstractLayer
name, projection

Constructor Summary
Constructor and Description
LinesLayer()

Constructor with default projection Mercator.


LinesLayer(Projection p, String name)
LinesLayer(String name)

Constructor with default projection Mercator.

Method Summary
Modifier and Type

Method and Description


addLineSegment(Coord[] coords)

void

Adds a Line segment to the Layer

BoundingBox

boundingBox()

The bounding box of this Layer


lineColor(int rgb)

void

Sets the color of the Lines


paint(Graphics g, Tile screenTile)

void

Paints the Layer on the given Graphics

protected void

paintSegment(Graphics g, Coord[] segment, Tile tile)

Paint a segment.

Methods inherited from


class com.codename1.maps.layers.AbstractLayer
getName, getProjection

Class LinesLayer

2164

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
_lineColor
protected int _lineColor

Constructor Detail
LinesLayer
public LinesLayer()

Constructor with default projection Mercator.


LinesLayer
public LinesLayer(String name)

Constructor with default projection Mercator.


LinesLayer
public LinesLayer(Projection p,
String name)

Method Detail
paint
public void paint(Graphics g,
Tile screenTile)

Paints the Layer on the given Graphics


Parameters:
g - a Graphics Object to paint on
screenTile - the screen tile
paintSegment
protected void paintSegment(Graphics g,
Coord[] segment,
Tile tile)

Paint a segment.
Parameters:
g - a Graphics Object to paint on
segment - array of Coord to draw a Line.
tile addLineSegment
public void addLineSegment(Coord[] coords)

Adds a Line segment to the Layer


Parameters:
coords lineColor
public void lineColor(int rgb)

Sets the color of the Lines


Parameters:
rgb -

Methods inherited from class java.lang.Object

2165

Overview (Codename One API)


boundingBox
public BoundingBox boundingBox()

The bounding box of this Layer


Specified by:
boundingBox in interface Layer
Specified by:
boundingBox in class AbstractLayer
Returns:
the Layer bounding box

Method Detail

2166

Overview (Codename One API)


com.codename1.maps.layers

Interface Layer
All Known Implementing Classes:
AbstractLayer, ArrowLinesLayer, LinesLayer, PointLayer, PointsLayer

public interface

a Layer interface. Each Layer needs to ability to paint itself on the map

Method Summary
Modifier and Type
BoundingBox

The bounding box of this Layer


getName()

String

Gets the name of this Layer


paint(Graphics g, Tile screenTile)

void

Method and Description


boundingBox()

Paints the Layer on the given Graphics

Method Detail
paint
void paint(Graphics g,
Tile screenTile)

Paints the Layer on the given Graphics


Parameters:
g - a Graphics Object to paint on
screenTile - the screen tile
boundingBox
BoundingBox boundingBox()

The bounding box of this Layer


Returns:
the Layer bounding box
getName
String getName()

Gets the name of this Layer


Returns:
the name of this Layer

Interface Layer

2167

Overview (Codename One API)


com.codename1.maps.layers

Class ArrowLinesLayer
java.lang.Object

com.codename1.maps.layers.AbstractLayer

com.codename1.maps.layers.LinesLayer

com.codename1.maps.layers.ArrowLinesLayer
All Implemented Interfaces:
Layer

public class
extends LinesLayer

This class is responsible for painting arrows that indicates direction of walk on map.

Field Summary

Fields inherited from


class com.codename1.maps.layers.LinesLayer
_lineColor

Fields inherited from


class com.codename1.maps.layers.AbstractLayer
name, projection

Constructor Summary
Constructor and Description
ArrowLinesLayer()

Constructor with default projection Mercator.


ArrowLinesLayer(Projection p, String name)
ArrowLinesLayer(String name)

Constructor with default projection Mercator.

Method Summary
Modifier and Type
int
int
int
protected void
void
void
void

Method Detail

Method and Description


getArrowHeight()

Returns the arrow height in pixels


getArrowSegmentLength()

Gets the arrow segment length


getArrowWidth()

Gets the arrow width in pixels


paintSegment(Graphics g, Coord[] segment, Tile tile)

Paints arrows on each segment.


setArrowHeight(int arrowHeight)

Sets the arrow height


setArrowSegmentLength(int arrowSegmentLength)

Sets the arrow segment length


setArrowWidth(int arrowWidth)

Sets the arrow width

2168

Overview (Codename One API)


Methods

inherited from
class com.codename1.maps.layers.LinesLayer
addLineSegment, boundingBox, lineColor, paint

Methods inherited from


class com.codename1.maps.layers.AbstractLayer
getName, getProjection

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ArrowLinesLayer
public ArrowLinesLayer()

Constructor with default projection Mercator.


ArrowLinesLayer
public ArrowLinesLayer(String name)

Constructor with default projection Mercator.


ArrowLinesLayer
public ArrowLinesLayer(Projection p,
String name)

Method Detail
paintSegment
protected void paintSegment(Graphics g,
Coord[] segment,
Tile tile)

Paints arrows on each segment. arrowSegmentLength decides how many arrows will
be on each segment.
Overrides:
paintSegment in class LinesLayer
Parameters:
gsegment tile getArrowHeight
public int getArrowHeight()

Returns the arrow height in pixels


Returns:
the arrow height
setArrowHeight
public void setArrowHeight(int arrowHeight)

Sets the arrow height


Parameters:
arrowHeight -

Methods inherited from class com.codename1.maps.layers.LinesLayer

2169

Overview (Codename One API)


getArrowSegmentLength
public int getArrowSegmentLength()

Gets the arrow segment length


Returns:
segment length
setArrowSegmentLength
public void setArrowSegmentLength(int arrowSegmentLength)

Sets the arrow segment length


Parameters:
arrowSegmentLength - to set
getArrowWidth
public int getArrowWidth()

Gets the arrow width in pixels


Returns:
the arrow width
setArrowWidth
public void setArrowWidth(int arrowWidth)

Sets the arrow width


Parameters:
arrowWidth - to set

Method Detail

2170

Overview (Codename One API)


com.codename1.maps.layers

Class AbstractLayer
java.lang.Object

com.codename1.maps.layers.AbstractLayer
All Implemented Interfaces:
Layer
Direct Known Subclasses:
LinesLayer, PointsLayer

public abstract class


extends Object
implements Layer

This class represents an abstract layer on the map.

Field Summary
Modifier and Type
protected String

Field and Description


name

protected Projection projection

Constructor Summary
Constructor and Description
AbstractLayer(Projection p, String name)

Creates an abstract layer.

Method Summary
Modifier and Type
abstract BoundingBox

Method and Description


boundingBox()

The bounding box of this Layer


getName()

String

Gets the name of this Layer

Projection

getProjection()

The projection of this Layer

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from


interface com.codename1.maps.layers.Layer
paint

Field Detail

Class AbstractLayer

2171

Overview (Codename One API)


name
protected final String name

projection
protected Projection projection

Constructor Detail
AbstractLayer
public AbstractLayer(Projection p,
String name)

Creates an abstract layer.


Parameters:
p - the projection system of this Layer
name - the name of this Layer

Method Detail
getName
public String getName()

Gets the name of this Layer


Specified by:
getName in interface Layer
Returns:
the name of this Layer
getProjection
public Projection getProjection()

The projection of this Layer


Returns:
the projection of this Layer
boundingBox
public abstract BoundingBox boundingBox()

The bounding box of this Layer


Specified by:
boundingBox in interface Layer
Returns:
the Layer bounding box

Field Detail

2172

Overview (Codename One API)


com.codename1.maps

Class Tile
java.lang.Object

com.codename1.maps.Tile
Direct Known Subclasses:
ProxyHttpTile

public class
extends Object

This class represents a single tile on a map. a map is been constructed from a few tiles that are been
tiled on next to the other.

Constructor Summary
Constructor and Description
Tile(Dimension dimension, BoundingBox boundingBox, Image image)

Creates a new Tile.

Method Summary
Modifier and
Type
Dimension
protected
void
BoundingBox
boolean

Method and Description


dimension()

Gets the tile dimension


fireReady()

inform the TileReadyListener that this tile is ready to be painted


getBoundingBox()

Gets the tile bounding box.


paint(Graphics g)

Paints the tile on the Graphics Object


paint(Graphics g, int x, int y)

void

Paints the tile on the Graphics Object translated to the given x, y, This
method paints the tile image if available or will call paintTileLoading
paintTileLoading(Graphics g)

void

Point
Coord

This method paints a "tile loading" on the Graphics if boolean paint(Graphics


g) returned false.
pointPosition(Coord point)

Returns the x, y point of the given coordinate relative to this tile


position(int posX, int posY)

Returns the Coordinate of the given x, y position on the tile


setPaintLoading(boolean toPaint)

static void

void

This flag indicates if the Tile should paint a Loading image or Text or simply
not do any painting if a map image is not ready for painting
setsTileReadyListener(ActionListener listener)

Sets a Listener to be notified when the tile is fireReady to be painted


setTileLoadingImage(Image tileLoadingImage)

static void

static void
String

Method Detail

Sets a static image that will be drawn on the map if the tile image is not
available yet.
setTileLoadingText(String tileLoadingText)

Sets a static text to paint.


toString()

Returns a string representation of the object.

2173

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Tile
public Tile(Dimension dimension,
BoundingBox boundingBox,
Image image)

Creates a new Tile.


Parameters:
dimension - the tile Dimensions (usually 256x256)
getBoundingBox - the bounding box this tile is showing
image - the map image or null.

Method Detail
pointPosition
public Point pointPosition(Coord point)

Returns the x, y point of the given coordinate relative to this tile


Parameters:
point - a coordinate to translate to x, y
Returns:
a Point object relative to this tile
position
public Coord position(int posX,
int posY)

Returns the Coordinate of the given x, y position on the tile


Parameters:
posX posY Returns:
a Coordinate that was created from the given x, y position
dimension
public Dimension dimension()

Gets the tile dimension


Returns:
the tile dimension
getBoundingBox
public BoundingBox getBoundingBox()

Gets the tile bounding box.


Returns:
the tile bounding box.
paint
public boolean paint(Graphics g)

Paints the tile on the Graphics Object


Parameters:
g - Graphics object to paint on.
Returns:
true if painting succeeded.

Methods inherited from class java.lang.Object

2174

Overview (Codename One API)


paint
public void paint(Graphics g,
int x,
int y)

Paints the tile on the Graphics Object translated to the given x, y, This method paints
the tile image if available or will call paintTileLoading
Parameters:
g - Graphics object to paint on.
x - translate to x before painting
y - translate to y before painting
paintTileLoading
public void paintTileLoading(Graphics g)

This method paints a "tile loading" on the Graphics if boolean paint(Graphics g)


returned false.
Parameters:
g - Graphics object to paint on.
setPaintLoading
public static void setPaintLoading(boolean toPaint)

This flag indicates if the Tile should paint a Loading image or Text or simply not do
any painting if a map image is not ready for painting
Parameters:
if - true a Loading rect is displayed when map image is being downloaded
setTileLoadingImage
public static void setTileLoadingImage(Image tileLoadingImage)

Sets a static image that will be drawn on the map if the tile image is not available yet.
Parameters:
tileLoadingImage setTileLoadingText
public static void setTileLoadingText(String tileLoadingText)

Sets a static text to paint. This will be used if the map if the tile image is not available
yet and the tileLoadingImage is null
Parameters:
tileLoadingText setsTileReadyListener
public void setsTileReadyListener(ActionListener listener)

Sets a Listener to be notified when the tile is fireReady to be painted


Parameters:
listener fireReady
protected void fireReady()

inform the TileReadyListener that this tile is ready to be painted


toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())

Method Detail

2175

Overview (Codename One API)


Overrides:
toString

Method Detail

in class Object

2176

Overview (Codename One API)


com.codename1.maps

Class ProxyHttpTile
java.lang.Object

com.codename1.maps.Tile

com.codename1.maps.ProxyHttpTile

public class
extends Tile

This Tile brings the tile image from a given http url.

Constructor Summary
Constructor and Description
ProxyHttpTile(Dimension tileSize, BoundingBox bbox, String url)

Creates an Http Tile

Method Summary
Modifier and Type
boolean

Method and Description


paint(Graphics g)

Paints the tile on the Graphics Object

Methods inherited from class com.codename1.maps.Tile


dimension, fireReady, getBoundingBox, paint, paintTileLoading,
pointPosition, position, setPaintLoading, setsTileReadyListener,
setTileLoadingImage, setTileLoadingText, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ProxyHttpTile
public ProxyHttpTile(Dimension tileSize,
BoundingBox bbox,
String url)

Creates an Http Tile


Parameters:
tileSize - the tile size
bbox - the tile bounding box
url - the url to bring the image from

Method Detail
paint
public boolean paint(Graphics g)

Paints the tile on the Graphics Object

Class ProxyHttpTile

2177

Overview (Codename One API)


Overrides:
paint in class Tile
Parameters:
g - Graphics object to paint on.
Returns:
true if painting succeeded.

Method Detail

2178

Overview (Codename One API)


com.codename1.maps

Class Projection
java.lang.Object

com.codename1.maps.Projection
Direct Known Subclasses:
Mercator

public abstract class


extends Object

This class represents a projection type. a Projection has the ability to translate a WGS84 Coordinate
to a projected Coordinate.

Constructor Summary
Modifier
protected

Constructor and Description


Projection(BoundingBox extent)

Creates a projection to the given bounding box

Method Summary
Modifier and
Type
BoundingBox
BoundingBox
abstract Coord

Method and Description


extent()

Gets the projection bounding box


fromWGS84(BoundingBox bbox)

Converts a WGS84 bounding box to the projection system bounding box


fromWGS84(Coord wgs84)

Converts a given WGS84 coordinate to a projection coordinate


fromWGS84(Coord[] coords)

Coord[]

BoundingBox
abstract Coord

a utility method that converts an array of WGS84 coordinate to the


projection coordinates system.
toWGS84(BoundingBox bbox)

Converts a projected bounding box to a WGS84 bounding box


toWGS84(Coord projection)

Converts a projected coordinate to a WGS84 coordinate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Projection
protected Projection(BoundingBox extent)

Creates a projection to the given bounding box


Parameters:
extent - the bounding box of this projection

Class Projection

2179

Overview (Codename One API)


Method

Detail

extent
public BoundingBox extent()

Gets the projection bounding box


Returns:
bounding box
fromWGS84
public abstract Coord fromWGS84(Coord wgs84)

Converts a given WGS84 coordinate to a projection coordinate


Parameters:
wgs84 Returns:
toWGS84
public abstract Coord toWGS84(Coord projection)

Converts a projected coordinate to a WGS84 coordinate


Parameters:
projection Returns:
fromWGS84
public final Coord[] fromWGS84(Coord[] coords)

a utility method that converts an array of WGS84 coordinate to the projection


coordinates system.
Parameters:
coords - an array to converts
Returns:
a converted array
fromWGS84
public final BoundingBox fromWGS84(BoundingBox bbox)

Converts a WGS84 bounding box to the projection system bounding box


Parameters:
bbox - bounding box too convert
Returns:
a converted bounding box
toWGS84
public final BoundingBox toWGS84(BoundingBox bbox)

Converts a projected bounding box to a WGS84 bounding box


Parameters:
bbox - bounding box too convert
Returns:
a converted bounding box

Method Detail

2180

Overview (Codename One API)


com.codename1.maps

Class Mercator
java.lang.Object

com.codename1.maps.Projection

com.codename1.maps.Mercator

public class
extends Projection

Represents a Mercator projection http://en.wikipedia.org/wiki/Mercator_projection

Constructor Summary
Constructor and Description
Mercator()

Creates a new Mercator projection

Method Summary
Modifier and
Type
static Coord

Method and Description


forwardMercator(double latitude, double longitude)

Create a projected Mercator Coord from the given coordinate


fromWGS84(Coord wgs84)

Coord

Create a projected Mercator Coord from the given coordinate


inverseMercator(double latitude, double longitude)

static Coord

Create a unprojected Coord(Latitude, Longitude) from the projected


Coord
toWGS84(Coord projection)

Coord

Create a Coord(Latitude, Longitude) from the projected Coord

Methods inherited from class com.codename1.maps.Projection


extent, fromWGS84, fromWGS84, toWGS84

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Mercator
public Mercator()

Creates a new Mercator projection

Method Detail

Class Mercator

2181

Overview (Codename One API)


forwardMercator
public static Coord forwardMercator(double latitude,
double longitude)

Create a projected Mercator Coord from the given coordinate


Parameters:
latitude - to project
longitude - to project
Returns:
a projected Mercator
inverseMercator
public static Coord inverseMercator(double latitude,
double longitude)

Create a unprojected Coord(Latitude, Longitude) from the projected Coord


Parameters:
latitude - projected latitude
longitude - projected longitude
Returns:
unprojected Coord
fromWGS84
public Coord fromWGS84(Coord wgs84)

Create a projected Mercator Coord from the given coordinate


Specified by:
fromWGS84 in class Projection
Parameters:
wgs84 - coordinate to project
Returns:
projected Mercator Coord
toWGS84
public Coord toWGS84(Coord projection)

Create a Coord(Latitude, Longitude) from the projected Coord


Specified by:
toWGS84 in class Projection
Parameters:
wgs84 - projected Coord
Returns:
unprojected Latitude, Longitude

Method Detail

2182

Overview (Codename One API)


com.codename1.maps

Interface MapListener

public interface

Invoked when the map is panned or zoomed

Method Summary
Modifier and Type

mapPositionUpdated(Component source, int zoom, Coord center)

void

Method and Description


Invoked when the map is zoomed or panned

Method Detail
mapPositionUpdated
void mapPositionUpdated(Component source,
int zoom,
Coord center)

Invoked when the map is zoomed or panned


Parameters:
source - = the component that fired the event
zoom - the zoom level of the current map
center - the center position of the map

Interface MapListener

2183

Overview (Codename One API)


com.codename1.maps

Class MapComponent
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.maps.MapComponent
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

All communication with the map and layers should be done in WGS84, it takes care of coordinates
transformation.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
MapComponent()

Empty constructor creates a map with OpenStreetMapProvider on the Last known Location
of the LocationManager
MapComponent(MapProvider provider)

Constructor with a given provider


MapComponent(MapProvider provider, Coord centerPosition, int zoomLevel)

Constructor
MapComponent(MapProvider provider, Coord centerPosition, int zoomLevel,
boolean cacheEnabled)

Constructor
MapComponent(MapProvider provider, Location centerPosition, int zoomLevel)

Constructor
MapComponent(MapProvider provider, Location centerPosition, int zoomLevel,
boolean cacheEnabled)

Constructor

Method Summary
Modifier and
Type
void
void
void

Method Detail

Method and Description


addLayer(Layer layer)

Adds a layer to the map


addLayer(Layer layer, int minZoomLevel, int maxZoomLevel)

Adds a layer to the map


addMapListener(MapListener listener)

Adds a listener to map panning/zooming

2184

Overview (Codename One API)


protected
Dimension
Coord

static long

calcPreferredSize()

Calculates the preferred size based on component content.


center()

Gets the center of the map.


distance(double latitude1, double longitude1, double latitude2,
double longitude2)

Returns the distance between 2 points in meters


protected
void
Coord
Coord
Layer
int
int
int
Point

focusGained()

Callback allowing a developer to track wheh the component gains focus


getCenter()

Returns the center location of the map in WGS84 format.


getCoordFromPosition(int x, int y)

Gets the Coord location on the map from a x, y position.


getLayerAt(int index)

Returns Layer at index


getLayersConut()

Returns layers count


getMaxZoomLevel()

Returns the max zoom level of the map


getMinZoomLevel()

Returns the min zoom level of the map


getPointFromCoord(Coord coord)

Gets the screen coordinates of a specific Coord


getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

MapProvider
int

Returns the current value of the property name, this method is used by the
GUI builder
getProvider()

Gets the map provider


getZoomLevel()

Returns the current zoom level of the map.

protected
boolean

isDownKey(int keyCode)

protected
boolean

isLeftKey(int keyCode)

protected
boolean

isRightKey(int keyCode)

protected
boolean

isUpKey(int keyCode)

protected
boolean

isZoomInKey(int keyCode)

protected
boolean

isZoomOutKey(int keyCode)

protected
boolean

isZoomToLayersKey(int keyCode)

void
protected
void
void
void

Method Summary

Returns true if this is a down keycode


Returns true if this is a left keycode
Returns true if this is a right keycode
Returns true if this is a up keycode
Returns true if this is a zoom in keycode
Returns true if this is a zoom out keycode
Returns true if this is a zoom to layers keycode
keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
laidOut()

This is a callback method to inform the Component when it's been laidout
on the parent Container
moveDown()

move the map 25% down


moveLeft()

move the map 25% left

2185

Overview (Codename One API)


moveRight()

void

move the map 25% right


moveUp()

void

move the map 25% up


paintBackground(Graphics g)

This method paints the Component background, it should be overriden by


subclasses to perform custom background drawing.

void

pointerDragged(int[] x, int[] y)

void

If this Component is focused, the pointer dragged event will call this method
pointerDragged(int x, int y)

void

If this Component is focused, the pointer dragged event will call this method
pointerPressed(int x, int y)

void

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this method

protected
void

pointerTapped(int x, int y, int tapCount)


removeAllLayers()

void

Removes all layers from the map


removeLayer(Layer layer)

void

Removes a Layer from the map


removeMapListener(MapListener listener)

void

Removes the map listener callback


repaint()

Repaint this Component, the repaint call causes a callback of the paint
method on the event dispatch thread.

void

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed
and null if successful.

String

setZoomLevel(int zoom)

void

Sets the current zoom level of the map.

protected
boolean

shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it
from being used for some other purpose when on top of said component.
zoomIn()

void

zoom in the map one level if possible


zoomOut()

void

zoom out the map one level if possible


zoomTo(BoundingBox boundingBox)

void

Zoom the map the the giving bounding box


zoomTo(Coord coord, int zoomLevel)

void

Zoom map to the center of the given coordinate with the given zoom level
zoomToLayers()

void

zoom map to largest zoom while all Layers are contained

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyReleased, layoutContainer, morph,
morphAndWait, paint, paintComponentBackground, paintGlass, paramString,
pointerHover, refreshTheme, removeAll, removeComponent, replace, replace,
replaceAndWait, replaceAndWait, replaceAndWait, revalidate,

Methods inherited from class com.codename1.ui.Container

2186

Overview (Codename One API)


scrollComponentToVisible, setCellRenderer, setEnabled, setLayout,
setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles,
getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer,
isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion,
isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHidden,
isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyRepeated, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerHoverPressed,
pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,
setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,
setScrollY, setSelectCommandText, setSelectedStyle, setSize,
setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled,
setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX,
setY, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
MapComponent
public MapComponent()

Empty constructor creates a map with OpenStreetMapProvider on the Last known


Location of the LocationManager

Methods inherited from class com.codename1.ui.Component

2187

Overview (Codename One API)


MapComponent
public MapComponent(MapProvider provider)

Constructor with a given provider


Parameters:
provider - map provider
MapComponent
public MapComponent(MapProvider provider,
Location centerPosition,
int zoomLevel)

Constructor
Parameters:
provider - map provider
centerPosition - center position
zoomLevel - zoom level

MapComponent
public MapComponent(MapProvider provider,
Location centerPosition,
int zoomLevel,
boolean cacheEnabled)

Constructor
Parameters:
provider - map provider
centerPosition - center position
zoomLevel - zoom level
cacheEnabled - is cache enabled

MapComponent
public MapComponent(MapProvider provider,
Coord centerPosition,
int zoomLevel)

Constructor
Parameters:
provider - map provider
centerPosition - center position
zoomLevel - zoom level

MapComponent
public MapComponent(MapProvider provider,
Coord centerPosition,
int zoomLevel,
boolean cacheEnabled)

Constructor
Parameters:
provider - map provider
centerPosition - center position
zoomLevel - zoom level
cacheEnabled - is cache enabled

Method Detail
paintBackground
public void paintBackground(Graphics g)

This method paints the Component background, it should be overriden by subclasses


to perform custom background drawing.
Overrides:
paintBackground in class Component
Parameters:

Constructor Detail

2188

Overview (Codename One API)


g

- the component graphics

laidOut
protected void laidOut()

This is a callback method to inform the Component when it's been laidout on the
parent Container
Overrides:
laidOut in class Component
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from being
used for some other purpose when on top of said component.
Overrides:
shouldBlockSideSwipe in class Component
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content
focusGained
protected void focusGained()

Callback allowing a developer to track wheh the component gains focus


Overrides:
focusGained in class Component
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Container
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int[] x,
int[] y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

Method Detail

2189

Overview (Codename One API)


pointerTapped
protected void pointerTapped(int x,
int y,
int tapCount)

pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
getCoordFromPosition
public Coord getCoordFromPosition(int x,
int y)

Gets the Coord location on the map from a x, y position.


Parameters:
xyReturns:
a Coord Object.
getPointFromCoord
public Point getPointFromCoord(Coord coord)

Gets the screen coordinates of a specific Coord


Parameters:
coord - a lat,lon location
Returns:
the Point of the coordinate on the Map
keyPressed
public void keyPressed(int keyCode)

If this Component is focused, the key pressed event will call this method
Overrides:
keyPressed in class Container
Parameters:
keyCode - the key code value to indicate a physical key.
addLayer
public void addLayer(Layer layer)

Adds a layer to the map


Parameters:
layer - to add
addLayer
public void addLayer(Layer layer,
int minZoomLevel,
int maxZoomLevel)

Adds a layer to the map


Parameters:
layer - to add
minZoomLevel - min zoom level of this Layer
maxZoomLevel - max zoom level of this Layer
removeLayer
public void removeLayer(Layer layer)

Removes a Layer from the map

Method Detail

2190

Overview (Codename One API)


Parameters:
layer - to remove
removeAllLayers
public void removeAllLayers()

Removes all layers from the map


getLayersConut
public int getLayersConut()

Returns layers count


getLayerAt
public Layer getLayerAt(int index)

Returns Layer at index


Parameters:
index - the index of the layer
Throws:
ArrayIndexOutOfBoundsException

- - if the index is out of range (index < 0 ||

index >= size())


getProvider
public MapProvider getProvider()

Gets the map provider


Returns:
the map provider
repaint
public void repaint()

Description copied from class: Component


Repaint this Component, the repaint call causes a callback of the paint method on the
event dispatch thread.
Overrides:
repaint in class Component
See Also:
Display

moveLeft
public void moveLeft()

move the map 25% left


moveRight
public void moveRight()

move the map 25% right


moveUp
public void moveUp()

move the map 25% up


moveDown
public void moveDown()

move the map 25% down


zoomIn
public void zoomIn()

zoom in the map one level if possible

Method Detail

2191

Overview (Codename One API)


zoomOut
public void zoomOut()

zoom out the map one level if possible


zoomTo
public void zoomTo(BoundingBox boundingBox)

Zoom the map the the giving bounding box


Parameters:
boundingBox - to zoom to
Throws:
IllegalArgumentException - if the boundingBox is not wg84 format
zoomTo
public void zoomTo(Coord coord,
int zoomLevel)

Zoom map to the center of the given coordinate with the given zoom level
Parameters:
coord - center map to this coordinate, coord should be in wg84 format
zoomLevel - zoom map to this level;
Throws:
IllegalArgumentException - if the coord is not wg84 format
zoomToLayers
public void zoomToLayers()

zoom map to largest zoom while all Layers are contained


getCenter
public Coord getCenter()

Returns the center location of the map in WGS84 format.


getZoomLevel
public int getZoomLevel()

Returns the current zoom level of the map.


Returns:
zoom level
setZoomLevel
public void setZoomLevel(int zoom)

Sets the current zoom level of the map.


getMaxZoomLevel
public int getMaxZoomLevel()

Returns the max zoom level of the map


Returns:
max zoom level
getMinZoomLevel
public int getMinZoomLevel()

Returns the min zoom level of the map


Returns:
min zoom level
center
public Coord center()

Gets the center of the map.


Returns:

Method Detail

2192

Overview (Codename One API)


Coord in WGS84
isLeftKey
protected boolean isLeftKey(int keyCode)

Returns true if this is a left keycode


Parameters:
keyCode Returns:
true if this is a left keycode
isRightKey
protected boolean isRightKey(int keyCode)

Returns true if this is a right keycode


Parameters:
keyCode Returns:
isDownKey
protected boolean isDownKey(int keyCode)

Returns true if this is a down keycode


Parameters:
keyCode Returns:
isUpKey
protected boolean isUpKey(int keyCode)

Returns true if this is a up keycode


Parameters:
keyCode Returns:
isZoomInKey
protected boolean isZoomInKey(int keyCode)

Returns true if this is a zoom in keycode


Parameters:
keyCode Returns:
isZoomOutKey
protected boolean isZoomOutKey(int keyCode)

Returns true if this is a zoom out keycode


Parameters:
keyCode Returns:
isZoomToLayersKey
protected boolean isZoomToLayersKey(int keyCode)

Returns true if this is a zoom to layers keycode


Parameters:
keyCode Returns:
distance
public static long distance(double
double
double
double

latitude1,
longitude1,
latitude2,
longitude2)

Returns the distance between 2 points in meters


Parameters:

Method Detail

2193

Overview (Codename One API)


latitude1 longitude1 latitude2 longitude2 -

Returns:
distance in meters
addMapListener
public void addMapListener(MapListener listener)

Adds a listener to map panning/zooming


Parameters:
listener - the listener callback
removeMapListener
public void removeMapListener(MapListener listener)

Removes the map listener callback


Parameters:
listener - the listener
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2194

Overview (Codename One API)


com.codename1.maps

Class Coord
java.lang.Object

com.codename1.maps.Coord
Direct Known Subclasses:
PointLayer

public class
extends Object

This class declares a coordinate point on a map.

Constructor Summary
Constructor and Description
Coord(Coord toClone)

Copy Constructor
Coord(double latitude, double longitude)

Creates a isProjected Coord


Coord(double latitude, double longitude, boolean projected)

a Constructor with getLatitude, getLongitude

Method Summary
Modifier and
Type
boolean
double
double
int
boolean
void
void
void
String

Method and Description


equals(Object other)

Indicates whether some other object is "equal to" this one.


getLatitude()

Gets the Coord Latitude


getLongitude()

Gets the Coord Longitude.


hashCode()

Returns a hash code value for the object.


isProjected()

Returns true if this is a projected Coordinate


setLatitude(double latitude)

Sets the Coord Latitude.


setLongitude(double longitude)

Sets the Coord Longitude.


setProjected(boolean projected)

Sets Coord projected


toString()

Returns a string representation of the object.


translate(Coord coordinates)

Coord

Create a new Coord object which is translated with the given


coordinates
translate(double latitude, double longitude)

Coord

Class Coord

Create a new Coord object which is translated with the given


coordinates

2195

Overview (Codename One API)


Methods

inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
Coord
public Coord(double latitude,
double longitude)

Creates a isProjected Coord


Parameters:
getLatitude - the getLatitude of this Coordinate
getLongitude - the getLongitude of this Coordinate
Coord
public Coord(double latitude,
double longitude,
boolean projected)

a Constructor with getLatitude, getLongitude


Parameters:
getLatitude - the Coordinate getLatitude
getLongitude - the Coordinate getLongitude
isProjected - declares if this is a isProjected Coordinate
Coord
public Coord(Coord toClone)

Copy Constructor
Parameters:
toClone - to copy

Method Detail
getLongitude
public double getLongitude()

Gets the Coord Longitude.


Returns:
the Coord Longitude
getLatitude
public double getLatitude()

Gets the Coord Latitude


Returns:
the Coord Latitude
setLongitude
public void setLongitude(double longitude)

Sets the Coord Longitude.


setLatitude
public void setLatitude(double latitude)

Sets the Coord Latitude.

Methods inherited from class java.lang.Object

2196

Overview (Codename One API)


toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
translate
public Coord translate(double latitude,
double longitude)

Create a new Coord object which is translated with the given coordinates
Parameters:
latitude - translate current latitude with this latitude
longitude - translate current longitude with this longitude
Returns:
a new translated Coord object
translate
public Coord translate(Coord coordinates)

Create a new Coord object which is translated with the given coordinates
Parameters:
coordinates - translate current Coord with the given coordinates
Returns:
a new translated Coord object
equals
public boolean equals(Object other)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer

Method Detail

2197

Overview (Codename One API)


results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
isProjected
public final boolean isProjected()

Returns true if this is a projected Coordinate


Returns:
true if projected
setProjected
public void setProjected(boolean projected)

Sets Coord projected


Parameters:
projected - flag

Method Detail

2198

Overview (Codename One API)


com.codename1.maps

Class BoundingBox
java.lang.Object

com.codename1.maps.BoundingBox

public class
extends Object

This class declares a bounding box of coordinates on the map.

Constructor Summary
Constructor and Description
BoundingBox(Coord southWest, Coord northEast)

Constructor with 2 coordinates for south west and north east

Method Summary
Modifier and
Type
boolean
static
BoundingBox
static
BoundingBox
boolean

Method and Description


contains(Coord cur)

indicates if the given coordinate is inside the counding box


create(Coord[] coords)

create a smallest bounding box that contains all of the given coordinates
create(Vector coords)

/** create a smallest bounding box that contains all of the given
coordinates
equals(Object other)

Indicates whether some other object is "equal to" this one.


extend(BoundingBox other)

BoundingBox

create a new bounding box that extends this bounding box with the
given bounding box
getNorthEast()

Coord

Gets the north east coordinate


getSouthWest()

Coord

Gets the /south west coordinate


hashCode()

int

Returns a hash code value for the object.

double

latitudeDifference()

double

longitudeDifference()

boolean
String

projected()

Indicates if this bounding box is isProjected


toString()

Returns a string representation of the object.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Class BoundingBox

2199

Overview (Codename One API)


Constructor

Detail

BoundingBox
public BoundingBox(Coord southWest,
Coord northEast)

Constructor with 2 coordinates for south west and north east


Parameters:
getSouthWest - coordinate
getNorthEast - coordinate

Method Detail
getSouthWest
public Coord getSouthWest()

Gets the /south west coordinate


Returns:
getNorthEast
public Coord getNorthEast()

Gets the north east coordinate


Returns:
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
latitudeDifference
public double latitudeDifference()

Returns:
The difference between SE and NW getLongitude in degrees.
longitudeDifference
public double longitudeDifference()

Returns:
The difference between SE and NW latitudes in degrees.
contains
public boolean contains(Coord cur)

indicates if the given coordinate is inside the counding box


Parameters:
cur - coordinate to check
Returns:
true if the given coordinate is contained in the bounding box

Constructor Detail

2200

Overview (Codename One API)


equals
public boolean equals(Object other)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
create
public static BoundingBox create(Coord[] coords)

create a smallest bounding box that contains all of the given coordinates
Parameters:
coords - given coordinates to create a wrapping bounding box.
Returns:
a bounding box that contains all of the coordinates
create
public static BoundingBox create(Vector coords)

/** create a smallest bounding box that contains all of the given coordinates
Parameters:
coords - given coordinates to create a wrapping bounding box.
Returns:
a bounding box that contains all of the coordinates
extend
public BoundingBox extend(BoundingBox other)

create a new bounding box that extends this bounding box with the given bounding
box
Parameters:

Method Detail

2201

Overview (Codename One API)

other - a bounding box that needs to extends the current bounding box
Returns:
a new bounding box that was extended from the current and the other
projected
public boolean projected()

Indicates if this bounding box is isProjected


Returns:
true if it's a isProjected bounding box

Method Detail

2202

Overview (Codename One API)


com.codename1.maker

Class MakerPlugin
java.lang.Object

com.codename1.maker.MakerPlugin

Deprecated.
this class is no longer supported and will be removed in an upcoming revision
public abstract class
extends Object

A Maker plugin allows developers to build extensions to the Codename One Maker tool, it is
implemented as an abstract class to allow future extensibility.

Constructor Summary
Constructor and Description
MakerPlugin()

Deprecated.

Method Summary
Modifier and Type

Method and Description


createEmbeddedUI()

abstract Container

Deprecated.
Creates a container version of the UI that will be added to the
flow based on maker logic
createStandaloneUI()

Form

Deprecated.
Creates a standalone version of the UI that will be shown by
the maker tool, notice that back functionality will be added by
the maker tool and should not be incorporated into the form!
The default implementation just used the embedded container
version.
getDescription()

String

Deprecated.
The description that the user has set to this plugin
getDeveloperEmailId()

abstract String

Deprecated.
Returns the email for the developer used in registration to the
Codename One build server
getIcon()

EncodedImage

Deprecated.
The icon that the user has set to this plugin
getMetaData()

Hashtable<String,Object>

Deprecated.
The meta data associated with the given plugin based on the
definitions in the accompanying plugin descriptor file
getPackageName()

abstract String

Deprecated.
A unique identifier for this specific plugin
getPluginName()

abstract String

Class MakerPlugin

Deprecated.
Returns the user displayable name of the plugin

2203

Overview (Codename One API)


getTitle()

Deprecated.
The title that the user has set to this plugin

String

setDescription(String description)

Deprecated.
The description that the user has set to this plugin

void

setIcon(EncodedImage icon)

Deprecated.
The icon that the user has set to this plugin

void

setMetaData(Hashtable<String,Object> data)

Deprecated.
The meta data associated with the given plugin based on the
definitions in the accompanying plugin descriptor file

void

setTitle(String title)

Deprecated.
The title that the user has set to this plugin

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MakerPlugin
public MakerPlugin()

Deprecated.

Method Detail
getPackageName
public abstract String getPackageName()

Deprecated.
A unique identifier for this specific plugin
Returns:
the package of the plugin in the form of com.companyname.pluginname etc.
getDeveloperEmailId
public abstract String getDeveloperEmailId()

Deprecated.
Returns the email for the developer used in registration to the Codename One build
server
Returns:
the email for the developer used in registration to the Codename One build
server
getPluginName
public abstract String getPluginName()

Deprecated.
Returns the user displayable name of the plugin
Returns:
the user displayable name of the plugin

Method Summary

2204

Overview (Codename One API)


getTitle
public final String getTitle()

Deprecated.
The title that the user has set to this plugin
Returns:
the title
setTitle
public final void setTitle(String title)

Deprecated.
The title that the user has set to this plugin
Parameters:
title - the title to set
getDescription
public final String getDescription()

Deprecated.
The description that the user has set to this plugin
Returns:
the description
setDescription
public final void setDescription(String description)

Deprecated.
The description that the user has set to this plugin
Parameters:
description - the description to set
getIcon
public final EncodedImage getIcon()

Deprecated.
The icon that the user has set to this plugin
Returns:
the icon
setIcon
public final void setIcon(EncodedImage icon)

Deprecated.
The icon that the user has set to this plugin
Parameters:
icon - the icon to set
setMetaData
public final void setMetaData(Hashtable<String,Object> data)

Deprecated.
The meta data associated with the given plugin based on the definitions in the
accompanying plugin descriptor file
Parameters:
data - the data
getMetaData
public final Hashtable<String,Object> getMetaData()

Deprecated.
The meta data associated with the given plugin based on the definitions in the
accompanying plugin descriptor file
Returns:
the data

Method Detail

2205

Overview (Codename One API)


createEmbeddedUI
public abstract Container createEmbeddedUI()

Deprecated.
Creates a container version of the UI that will be added to the flow based on maker
logic
Returns:
the embedded UI
createStandaloneUI
public Form createStandaloneUI()

Deprecated.
Creates a standalone version of the UI that will be shown by the maker tool, notice
that back functionality will be added by the maker tool and should not be incorporated
into the form! The default implementation just used the embedded container version.
Normally developers don't need to override this method unless they need specific
behavior for a form
Returns:
the standalone UI

Method Detail

2206

Overview (Codename One API)


com.codename1.location

Class LocationRequest
java.lang.Object

com.codename1.location.LocationRequest

public class
extends Object

This class is used when requesting to listen to location update. See setLocationListener

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


PRIORITY_HIGH_ACCUARCY

When you need gps location updates


PRIORITY_LOW_ACCUARCY

When accuracy is not important and you want to save battery


PRIORITY_MEDIUM_ACCUARCY

When accuracy is not highly important and you want to save battery

Constructor Summary
Constructor and Description
LocationRequest()

Empty Constructor
LocationRequest(int priority, long interval)

Simple Constructor

Method Summary
Modifier and Type

Method and Description


getInterval()

long

Gest the request time interval


getPriority()

int

Gets the request priority

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
PRIORITY_HIGH_ACCUARCY
public static int PRIORITY_HIGH_ACCUARCY

When you need gps location updates

Class LocationRequest

2207

Overview (Codename One API)


PRIORITY_MEDIUM_ACCUARCY
public static int PRIORITY_MEDIUM_ACCUARCY

When accuracy is not highly important and you want to save battery
PRIORITY_LOW_ACCUARCY
public static int PRIORITY_LOW_ACCUARCY

When accuracy is not important and you want to save battery

Constructor Detail
LocationRequest
public LocationRequest()

Empty Constructor
LocationRequest
public LocationRequest(int priority,
long interval)

Simple Constructor
Parameters:
priority - The priority we are interested to listen for location updates.
PRIORITY_HIGH_ACCUARCY, PRIORITY_MEDIUM_ACCUARCY,
PRIORITY_LOW_ACCUARCY High priority means gps locations which is
CPU intensive and consumes more battery. Medium priority is less intensive
in terms of battery and might return a gps or a network location which is less
accurate. Low priority won't consume the battery and will return a gps
location if available otherwise the location would be a network location.
interval - time in milliseconds which determines what are the time intervals
that we would like to get updates from the OS. This is a request only and
might not be respected by the underlying OS

Method Detail
getPriority
public int getPriority()

Gets the request priority


getInterval
public long getInterval()

Gest the request time interval

Field Detail

2208

Overview (Codename One API)


com.codename1.location

Class LocationManager
java.lang.Object

com.codename1.location.LocationManager

public abstract class


extends Object

The LocationManager is the main entry to retrieveLocation or to bind a LocationListener, important: in


order to use location on iOS you will need to define the build argument ios.locationUsageDescription.
This build argument should be used to describe to Apple & the users why you need to use the
location functionality.
Usage:
public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();

Field Summary
Modifier and Type

Field and Description

static int

AVAILABLE

static int

OUT_OF_SERVICE

static int

TEMPORARILY_UNAVAILABLE

Constructor Summary
Constructor and Description
LocationManager()

Method Summary
Modifier and Type

Method and Description


addGeoFencing(Class GeofenceListenerClass, Geofence gf)

void

protected void
protected abstract
void

Method Detail

Adds a geo fence listener to gets an event once the device is


in/out of the Geofence range.
bindBackgroundListener()

Bind the Background LocationListener to get events


bindListener()

Bind the LocationListener to get events

2209

Overview (Codename One API)


protected void
protected abstract
void

clearBackgroundListener()

Stop deliver events for the Background LocationListener


clearListener()

Stop deliver events for the LocationListener


getBackgroundLocationListener()

protected Class

Gets the LocationListener class that handles background location


updates.
getCurrentLocation()

abstract Location

Gets the current Location of the device, in most cases this uses
the GPS.
getCurrentLocationSync()

Location

Returns the current location synchronously, this is useful if you


just want to know the location NOW and don't care about tracking
location.
getCurrentLocationSync(long timeout)

Location

abstract Location
protected
LocationListener
static LocationManager
protected
LocationRequest

Returns the current location synchronously, this is useful if you


just want to know the location NOW and don't care about tracking
location.
getLastKnownLocation()

Gets the last known Location of the device.


getLocationListener()

Allows the implementation to notify the location listener of


changes to location
getLocationManager()

Gets the LocationManager instance


getRequest()

Gets the LocationRequest


getStatus()

int

boolean
boolean

Gets the Manager status: AVAILABLE, OUT_OF_SERVICE or


TEMPORARILY_UNAVAILABLE
isBackgroundLocationSupported()

Returns true if the platform is able to track background location.


isGeofenceSupported()

Returns true if the platform supports Geofence


isGPSDetectionSupported()

boolean

Returns true if the platform is able to detect if the GPS is on or


off.
isGPSEnabled()

boolean

Returns GPS on/off state if isGPSDetectionSupported() returns


true
removeGeoFencing(String id)

void

Stop tracking a Geofence if isGeofenceSupported() returns false


this method does nothing
setBackgroundLocationListener(Class locationListener)

void

Use this method to track background location updates when the


application is not running anymore.
setLocationListener(LocationListener l)

void

Sets a LocationListener on the device, use this method if you


need to be updated on the device Locations rather then calling
getCurrentLocation.
setLocationListener(LocationListener l,
LocationRequest req)

void

protected void

Method Summary

Sets a LocationListener on the device, use this method if you


need to be updated on the device Locations rather then calling
getCurrentLocation.
setStatus(int status)

Allows the implentation to set the status of the location

2210

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
AVAILABLE
public static final int AVAILABLE

See Also:
Constant Field Values
OUT_OF_SERVICE
public static final int OUT_OF_SERVICE

See Also:
Constant Field Values
TEMPORARILY_UNAVAILABLE
public static final int TEMPORARILY_UNAVAILABLE

See Also:
Constant Field Values

Constructor Detail
LocationManager
public LocationManager()

Method Detail
getLocationManager
public static LocationManager getLocationManager()

Gets the LocationManager instance


Returns:
getStatus
public int getStatus()

Gets the Manager status: AVAILABLE, OUT_OF_SERVICE or


TEMPORARILY_UNAVAILABLE
Returns:
the status of the LoactionManager
setStatus
protected void setStatus(int status)

Allows the implentation to set the status of the location


Parameters:
status - the new status
getCurrentLocation
public abstract Location getCurrentLocation()
throws IOException

Gets the current Location of the device, in most cases this uses the GPS. Notice!
This method will only return a valid value after the location listener callback returns
Returns:

Methods inherited from class java.lang.Object

2211

Overview (Codename One API)


a Location Object
Throws:
IOException - if Location cannot be retrieve from the device
getCurrentLocationSync
public Location getCurrentLocationSync()

Returns the current location synchronously, this is useful if you just want to know the
location NOW and don't care about tracking location. Notice that this method will
block until a result is returned so you might want to use something like
InfiniteProgress while this is running
Returns:
the current location or null in case of an error
getCurrentLocationSync
public Location getCurrentLocationSync(long timeout)

Returns the current location synchronously, this is useful if you just want to know the
location NOW and don't care about tracking location. Notice that this method will
block until a result is returned so you might want to use something like
InfiniteProgress while this is running
Parameters:
timeout - timeout in milliseconds or -1 to never timeout
Returns:
the current location or null in case of an error
getLastKnownLocation
public abstract Location getLastKnownLocation()

Gets the last known Location of the device.


Returns:
a Location Object
setLocationListener
public void setLocationListener(LocationListener l)

Sets a LocationListener on the device, use this method if you need to be updated on
the device Locations rather then calling getCurrentLocation.
Parameters:
l - a LocationListener or null to stop the current listener from getting updates
setLocationListener
public void setLocationListener(LocationListener l,
LocationRequest req)

Sets a LocationListener on the device, use this method if you need to be updated on
the device Locations rather then calling getCurrentLocation.
Parameters:
l - a LocationListener or null to stop the current listener from getting updates
req - provide the settings in which we are interested to get updates to the
Listener.
setBackgroundLocationListener
public void setBackgroundLocationListener(Class locationListener)

Use this method to track background location updates when the application is not
running anymore. Do not perform long operations here, iOS wake-up time is very
short(around 10 seconds). Notice this listener can sends events also when the app is
in the foreground, therefore it is recommended to check the app state before deciding
how to process this event. Use Display.isMinimized() to know if the app is currently
running.
Parameters:
locationListener - a class that implements the LocationListener interface
this class must have an empty constructor since the underlying
implementation will try to create an instance and invoke the locationUpdated
method

Method Detail

2212

Overview (Codename One API)


addGeoFencing
public void addGeoFencing(Class GeofenceListenerClass,
Geofence gf)

Adds a geo fence listener to gets an event once the device is in/out of the Geofence
range. The GeoFence events can arrive in the background therefore it is
recommended to check the app state before deciding how to process this event. Use
Display.isMinimized() to know if the app is currently running. if
isGeofenceSupported() returns false this method does nothing
NOTE: For iOS you must include the ios.background_modes build hint with a value
that includes "location" for geofencing to work.
Parameters:
- a Class that implements the GeofenceListener interface this class
must have an empty constructor
gf - a Geofence to track
removeGeoFencing
listener

public void removeGeoFencing(String id)

Stop tracking a Geofence if isGeofenceSupported() returns false this method does


nothing
NOTE: For iOS you must include the ios.background_modes build hint with a value
that includes "location" for geofencing to work.
Parameters:
id - a Geofence id to stop tracking
getLocationListener
protected LocationListener getLocationListener()

Allows the implementation to notify the location listener of changes to location


Returns:
location listener instance
getRequest
protected LocationRequest getRequest()

Gets the LocationRequest


getBackgroundLocationListener
protected Class getBackgroundLocationListener()

Gets the LocationListener class that handles background location updates.


NOTE: For iOS you must include the ios.background_modes build hint with a value
that includes "location" for background locations to work.
bindListener
protected abstract void bindListener()

Bind the LocationListener to get events


clearListener
protected abstract void clearListener()

Stop deliver events for the LocationListener


bindBackgroundListener
protected void bindBackgroundListener()

Bind the Background LocationListener to get events

Method Detail

2213

Overview (Codename One API)


clearBackgroundListener
protected void clearBackgroundListener()

Stop deliver events for the Background LocationListener


isGPSDetectionSupported
public boolean isGPSDetectionSupported()

Returns true if the platform is able to detect if the GPS is on or off. see also
isGPSEnabled()
Returns:
true if platform is able to detect GPS on/off
isBackgroundLocationSupported
public boolean isBackgroundLocationSupported()

Returns true if the platform is able to track background location.


NOTE: For iOS you must include the ios.background_modes build hint with a value
that includes "location" for background locations to work.
Returns:
true if platform supports background location
isGeofenceSupported
public boolean isGeofenceSupported()

Returns true if the platform supports Geofence


NOTE: For iOS you must include the ios.background_modes build hint with a value
that includes "location" for geofencing to work.
Returns:
true if platform supports Geofence
isGPSEnabled
public boolean isGPSEnabled()

Returns GPS on/off state if isGPSDetectionSupported() returns true


Returns:
true if GPS is on

Method Detail

2214

Overview (Codename One API)


com.codename1.location

Interface LocationListener

public interface

This is a Listener to the Locations events see LocationManager.setLocationListener

Method Summary
Modifier and
Type

Method and Description


locationUpdated(Location location)

void

This method is been called by the system when Location is being updated
providerStateChanged(int newState)

This method is been called by the system when the provider state has
being Changed

void

Method Detail
locationUpdated
void locationUpdated(Location location)

This method is been called by the system when Location is being updated
Parameters:
location - a Location Object
providerStateChanged
void providerStateChanged(int newState)

This method is been called by the system when the provider state has being
Changed
Parameters:
newState - a new state one of the following: LocationManager.AVAILABLE,
LocationManager.OUT_OF_SERVICE or
LocationManager.TEMPORARILY_UNAVAILABLE

Interface LocationListener

2215

Overview (Codename One API)


com.codename1.location

Class Location
java.lang.Object

com.codename1.location.Location

public class
extends Object

This class represents a Location Object

Constructor Summary
Constructor and Description
Location()

Method Summary
Modifier
and Type
float
double
float
double
double

Method and Description


getAccuracy()

Returns the horizontal accuracy of the location in meters


getAltitude()

Returns the altitude of this Location


getDirection()

Returns the direction of this Location in degress 0-360


getLatitude()

Returns the latitude of this Location


getLongitude()

Returns the longitude of this Location


getLongtitude()

double

Deprecated.
use getLongitude
getStatus()

int

long
float
void
void
void
void
void

The status of the location one of: LocationManager.AVAILABLE,


LocationManager.OUT_OF_SERVICE or
LocationManager.TEMPORARILY_UNAVAILABLE:
getTimeStamp()

Returns the timestamp of this Location


getVelocity()

Returns the velocity of this Location in meters per second (m/s)


setAccuracy(float accuracy)
setAltitude(double altitude)

Sets the altitude of this Location


setDirection(float direction)

Sets the direction of this Location


setLatitude(double latitude)

Sets the latitude of this Location


setLongitude(double longtitude)

Sets the longitude of this Location


setLongtitude(double longtitude)

void

Method Detail

Deprecated.
use setLongitude

2216

Overview (Codename One API)


setStatus(int status)

The status of the location one of: LocationProvider.AVAILABLE,


LocationProvider.OUT_OF_SERVICE or
LocationProvider.TEMPORARILY_UNAVAILABLE:

void

setTimeStamp(long timeStamp)

void

Sets the timeStamp of this Location


setVelocity(float velocity)

void

Sets the velocity of this Location

String

toString()

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Location
public Location()

Method Detail
getAccuracy
public float getAccuracy()

Returns the horizontal accuracy of the location in meters


Returns:
the accuracy if exists or 0.0 if not.
getAltitude
public double getAltitude()

Returns the altitude of this Location


Returns:
altitude
getDirection
public float getDirection()

Returns the direction of this Location in degress 0-360


Returns:
direction in degrees
getLatitude
public double getLatitude()

Returns the latitude of this Location


Returns:
latitude
getLongitude
public double getLongitude()

Returns the longitude of this Location


Returns:
longitude

Method Summary

2217

Overview (Codename One API)


getLongtitude
public double getLongtitude()

Deprecated. use getLongitude


Returns the longitude of this Location
Returns:
longitude
getStatus
public int getStatus()

The status of the location one of: LocationManager.AVAILABLE,


LocationManager.OUT_OF_SERVICE or
LocationManager.TEMPORARILY_UNAVAILABLE:
getTimeStamp
public long getTimeStamp()

Returns the timestamp of this Location


Returns:
timestamp
getVelocity
public float getVelocity()

Returns the velocity of this Location in meters per second (m/s)


Returns:
velocity
setAccuracy
public void setAccuracy(float accuracy)

setAltitude
public void setAltitude(double altitude)

Sets the altitude of this Location


Parameters:
altitude setDirection
public void setDirection(float direction)

Sets the direction of this Location


Parameters:
direction setLatitude
public void setLatitude(double latitude)

Sets the latitude of this Location


Parameters:
latitude setLongitude
public void setLongitude(double longtitude)

Sets the longitude of this Location


Parameters:
longitude setLongtitude
public void setLongtitude(double longtitude)

Deprecated. use setLongitude


Sets the longitude of this Location
Parameters:

Method Detail

2218

Overview (Codename One API)


longitude

setStatus
public void setStatus(int status)

The status of the location one of: LocationProvider.AVAILABLE,


LocationProvider.OUT_OF_SERVICE or
LocationProvider.TEMPORARILY_UNAVAILABLE:
setTimeStamp
public void setTimeStamp(long timeStamp)

Sets the timeStamp of this Location


Parameters:
timeStamp setVelocity
public void setVelocity(float velocity)

Sets the velocity of this Location


Parameters:
velocity toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

2219

Overview (Codename One API)


com.codename1.location

Interface GeofenceListener

public interface

Listener interface for the Geofence background tracking functionality. Usage:


public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();

Method Summary
Modifier and Type
onEntered(String id)

void

This callback gets called once the device enters the Geofence area
onExit(String id)

void

Method and Description

This callback gets called once the device is out of the Geofence area

Method Detail
onExit
void onExit(String id)

This callback gets called once the device is out of the Geofence area
onEntered
void onEntered(String id)

This callback gets called once the device enters the Geofence area

Interface GeofenceListener

2220

Overview (Codename One API)


com.codename1.location

Class Geofence
java.lang.Object

com.codename1.location.Geofence

public class
extends Object

Metadata for geofencing support that allows tracking user location in the background while the app is
inactive. Usage:
public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();

Constructor Summary
Constructor and Description
Geofence(String id, Location loc, int radius, long expiration)

Constructor

Method Summary
Modifier and Type Method and Description
getExpiration()

long

Simple Getter
getId()

String

Simple Getter

Location

getLoc()

Simple Getter
getRadius()

int

Simple Getter

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Method Detail

2221

Overview (Codename One API)


Geofence
public Geofence(String id,
Location loc,
int radius,
long expiration)

Constructor
Parameters:
id - unique identifier
loc - the center location of this Geofence
radius - the radius in meters
expiration - the expiration time in milliseconds

Method Detail
getId
public String getId()

Simple Getter
Returns:
the id
getLoc
public Location getLoc()

Simple Getter
Returns:
the center Location
getExpiration
public long getExpiration()

Simple Getter
Returns:
the Geofence expiration
getRadius
public int getRadius()

Simple Getter
Returns:
Geofence radius

Constructor Detail

2222

Overview (Codename One API)


com.codename1.l10n

Class SimpleDateFormat
java.lang.Object

com.codename1.l10n.Format

com.codename1.l10n.DateFormat

com.codename1.l10n.SimpleDateFormat
All Implemented Interfaces:
Cloneable

public class
extends DateFormat

A class for parsing and formatting dates with a given pattern, compatible with the Java 6 API. See
http://docs.oracle.com/javase/6/docs/api/java/text/DateFormat.html

Field Summary

Fields inherited from class com.codename1.l10n.DateFormat


DEFAULT, FULL, LONG, MEDIUM, SHORT

Constructor Summary
Constructor and Description
SimpleDateFormat()

Construct a SimpleDateFormat with no pattern.


SimpleDateFormat(String pattern)

Construct a SimpleDateFormat with a given pattern.

Method Summary
Modifier and Type

Method and Description


applyPattern(String pattern)

void

Apply a new pattern.

Object

clone()
format(Date source)

String

Format a given date.


getDateFormatSymbols()

DateFormatSymbols

Get the date format symbols for parsing/formatting textual components


of dates in a localization sensitive way.
parse(String source)

Date

NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.


setDateFormatSymbols(DateFormatSymbols newSymbols)

Apply new date format symbols for parsing/formatting textual


components of dates in a localisation sensitive way.

void
String

toPattern()

Methods inherited from class com.codename1.l10n.DateFormat


equals, format, getDateInstance, getDateInstance, getDateTimeInstance,
getInstance, getTimeInstance, getTimeInstance, hashCode, parseObject

Method Detail

2223

Overview (Codename One API)


Methods

inherited from class java.lang.Object

getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SimpleDateFormat
public SimpleDateFormat()

Construct a SimpleDateFormat with no pattern.


SimpleDateFormat
public SimpleDateFormat(String pattern)

Construct a SimpleDateFormat with a given pattern.


Parameters:
pattern

Method Detail
toPattern
public String toPattern()

Returns:
the pattern
getDateFormatSymbols
public DateFormatSymbols getDateFormatSymbols()

Get the date format symbols for parsing/formatting textual components of dates in a
localization sensitive way.
Returns:
current symbols.
setDateFormatSymbols
public void setDateFormatSymbols(DateFormatSymbols newSymbols)

Apply new date format symbols for parsing/formatting textual components of dates in
a localisation sensitive way.
Parameters:
newSymbols - new format symbols.
applyPattern
public void applyPattern(String pattern)

Apply a new pattern.


Parameters:
pattern - the pattern to set
clone
public Object clone()

Overrides:
clone

in class DateFormat

format
public String format(Date source)

Description copied from class: DateFormat


Format a given date.
Overrides:

Methods inherited from class java.lang.Object

2224

Overview (Codename One API)


format

in class DateFormat

Parameters:
source - date to be formatted.
Returns:
formatted date.
parse
public Date parse(String source)
throws ParseException

Description copied from class: DateFormat


NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.
Overrides:
parse in class DateFormat
Throws:
ParseException

Method Detail

2225

Overview (Codename One API)


com.codename1.l10n

Class ParseException
java.lang.Object

java.lang.Throwable

java.lang.Exception

com.codename1.l10n.ParseException

public class
extends Exception

An error occurred during parsing.

Constructor Summary
Constructor and Description
ParseException(String s, int errorOffset)

Method Summary
Modifier and Type Method and Description
int

getErrorOffset()

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ParseException
public ParseException(String s,
int errorOffset)

Parameters:
errorOffset

Method Detail
getErrorOffset
public int getErrorOffset()

Returns:
the errorOffset

Class ParseException

2226

Overview (Codename One API)


com.codename1.l10n

Class L10NManager
java.lang.Object

com.codename1.l10n.L10NManager

public class
extends Object

The localization manager allows adapting values for display in different locales

Constructor Summary
Modifier
protected

Constructor and Description


L10NManager(String language, String locale)

Instances of this class should be received via the Display class

Method Summary
Modifier and Type
String
String
String
String
String
String
String
String
String
String
static L10NManager
String
String
boolean
double
double
int

Method Detail

Method and Description


format(double number)

Format a double number for this locale


format(double number, int decimalPlaces)

Formats a number as a String with a fixed number of decimal places


format(int number)

Format an integer number for this locale


formatCurrency(double currency)

Format a currency value


formatDateLongStyle(Date d)

Formats a date in a long form e.g.


formatDateShortStyle(Date d)

Formats a date in a short form e.g.


formatDateTime(Date d)

Formats a date and a time in a default form e.g.


formatDateTimeMedium(Date d)

Formats a date and a time in a default form e.g.


formatDateTimeShort(Date d)

Formats a date and a time in a default form e.g.


getCurrencySymbol()

Returns the currency symbol for this locale


getInstance()

Convenience method that invokes Display.getLocalizationManager()


getLanguage()

Returns the current locale language as an ISO 639 two letter code
getLocale()

Determines the locale (location) as an ISO 3166 country code


isRTLLocale()

Indicates whether the language is a right to left language


parseCurrency(String amount)

Parses the currency value


parseDouble(String localeFormattedDecimal)

Parses a double based on locale conventions


parseInt(String localeFormattedInteger)

2227

Overview (Codename One API)


Parses an integer based on locale conventions
parseLong(String localeFormattedLong)

long

Parses a long based on locale conventions


setLocale(String locale, String language)

void

Forces the locale/language

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
L10NManager
protected L10NManager(String language,
String locale)

Instances of this class should be received via the Display class

Method Detail
getLanguage
public String getLanguage()

Returns the current locale language as an ISO 639 two letter code
Returns:
iso language string
setLocale
public void setLocale(String locale,
String language)

Forces the locale/language


Parameters:
locale - the new locale
language - the language to use
format
public String format(int number)

Format an integer number for this locale


Parameters:
number - the number to format
Returns:
a string representation of a number
format
public String format(double number)

Format a double number for this locale


Parameters:
number - the number to format
Returns:
a string representation of a number
formatCurrency
public String formatCurrency(double currency)

Format a currency value


Parameters:
currency - the monetary value

Method Summary

2228

Overview (Codename One API)


Returns:
a string representation of a number
getCurrencySymbol
public String getCurrencySymbol()

Returns the currency symbol for this locale


Returns:
currency symbol
formatDateLongStyle
public String formatDateLongStyle(Date d)

Formats a date in a long form e.g. Sunday January 1st 2001


Parameters:
d - the date
Returns:
the long form string
formatDateShortStyle
public String formatDateShortStyle(Date d)

Formats a date in a short form e.g. 1/1/2011


Parameters:
d - the date
Returns:
the short form string
formatDateTime
public String formatDateTime(Date d)

Formats a date and a time in a default form e.g. 1/1/2011 10:00AM


Parameters:
d - the date
Returns:
the date and time
formatDateTimeMedium
public String formatDateTimeMedium(Date d)

Formats a date and a time in a default form e.g. 1/1/2011 10:00AM


Parameters:
d - the date
Returns:
the date and time
formatDateTimeShort
public String formatDateTimeShort(Date d)

Formats a date and a time in a default form e.g. 1/1/2011 10:00AM


Parameters:
d - the date
Returns:
the date and time
isRTLLocale
public boolean isRTLLocale()

Indicates whether the language is a right to left language


Returns:
true for bidi/rtl languages
getLocale
public String getLocale()

Determines the locale (location) as an ISO 3166 country code


Returns:

Method Detail

2229

Overview (Codename One API)


the locale
getInstance
public static L10NManager getInstance()

Convenience method that invokes Display.getLocalizationManager()


Returns:
the L10NManager instance
format
public String format(double number,
int decimalPlaces)

Formats a number as a String with a fixed number of decimal places


Parameters:
number - the number
decimalPlaces - decimals
Returns:
formatted string
parseDouble
public double parseDouble(String localeFormattedDecimal)

Parses a double based on locale conventions


Parameters:
localeFormattedDecimal - the locale formatted number
Returns:
the parsed double
parseLong
public long parseLong(String localeFormattedLong)

Parses a long based on locale conventions


Parameters:
localeFormattedLong - the number
Returns:
a long
parseInt
public int parseInt(String localeFormattedInteger)

Parses an integer based on locale conventions


Parameters:
localeFormattedInteger - the number
Returns:
a parsed number
parseCurrency
public double parseCurrency(String amount)

Parses the currency value


Parameters:
amount - the amount
Returns:
a numeric value for the currency

Method Detail

2230

Overview (Codename One API)


com.codename1.l10n

Class Format
java.lang.Object

com.codename1.l10n.Format
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
DateFormat

public abstract class


extends Object
implements Cloneable

An abstract class for parsing and formatting localisation sensitive information, compatible with JDK 6.
See Also:
http://docs.oracle.com/javase/6/docs/api/java/text/Format.html

Constructor Summary
Constructor and Description
Format()

Method Summary
Modifier and Type
abstract String
abstract Object

Method and Description


format(Object source)

Format an object.
parseObject(String source)

Parse an string to an object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Format
public Format()

Method Detail
format
public abstract String format(Object source)
throws IllegalArgumentException

Format an object.
Parameters:
source - object to be formatted to text.
Returns:
formatted text.
Throws:

Class Format

2231

Overview (Codename One API)


IllegalArgumentException

- if the source can not be formatted.

parseObject
public abstract Object parseObject(String source)
throws ParseException

Parse an string to an object.


Parameters:
source - document to be parsed.
Returns:
parsed object.
Throws:
ParseException - if the source could not be parsed.

Method Detail

2232

Overview (Codename One API)


com.codename1.l10n

Class DateFormatSymbols
java.lang.Object

com.codename1.l10n.DateFormatSymbols
All Implemented Interfaces:
Cloneable

public class
extends Object
implements Cloneable

Field Summary
Modifier and Type Field and Description
static int

ZONE_ID

static int

ZONE_LONGNAME

static int

ZONE_LONGNAME_DST

static int

ZONE_SHORTNAME

static int

ZONE_SHORTNAME_DST

Constructor Summary
Constructor and Description
DateFormatSymbols()

Method Summary
Modifier and Type

Method and Description

Object

clone()

String[]

getAmPmStrings()

String[]

getEras()

String[]

getMonths()

Hashtable<String,String>

getResourceBundle()

String[]

getShortMonths()

String[]

getShortWeekdays()

String[]

getWeekdays()

String[][]

getZoneStrings()

void

setAmPmStrings(String[] newAmpms)

void

setEras(String[] newEras)

void

setMonths(String[] newMonths)

void

setResourceBundle(Hashtable<String,String> newResourceBundle)

void

setShortMonths(String[] newShortMonths)

void

setShortWeekdays(String[] newShortWeekdays)

void

setWeekdays(String[] newWeekdays)

void

setZoneStrings(String[][] newZoneStrings)

Class DateFormatSymbols

2233

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ZONE_ID
public static final int ZONE_ID

See Also:
Constant Field Values
ZONE_LONGNAME
public static final int ZONE_LONGNAME

See Also:
Constant Field Values
ZONE_SHORTNAME
public static final int ZONE_SHORTNAME

See Also:
Constant Field Values
ZONE_LONGNAME_DST
public static final int ZONE_LONGNAME_DST

See Also:
Constant Field Values
ZONE_SHORTNAME_DST
public static final int ZONE_SHORTNAME_DST

See Also:
Constant Field Values

Constructor Detail
DateFormatSymbols
public DateFormatSymbols()

Method Detail
getAmPmStrings
public String[] getAmPmStrings()

setAmPmStrings
public void setAmPmStrings(String[] newAmpms)

getResourceBundle
public Hashtable<String,String> getResourceBundle()

setResourceBundle
public void setResourceBundle(Hashtable<String,String> newResourceBundle)

getZoneStrings
public String[][] getZoneStrings()

Methods inherited from class java.lang.Object

2234

Overview (Codename One API)


setZoneStrings
public void setZoneStrings(String[][] newZoneStrings)

setShortWeekdays
public void setShortWeekdays(String[] newShortWeekdays)

getShortWeekdays
public String[] getShortWeekdays()

getWeekdays
public String[] getWeekdays()

setWeekdays
public void setWeekdays(String[] newWeekdays)

setShortMonths
public void setShortMonths(String[] newShortMonths)

getShortMonths
public String[] getShortMonths()

setMonths
public void setMonths(String[] newMonths)

getMonths
public String[] getMonths()

getEras
public String[] getEras()

setEras
public void setEras(String[] newEras)

clone
public Object clone()

Method Detail

2235

Overview (Codename One API)


com.codename1.l10n

Class DateFormatPatterns
java.lang.Object

com.codename1.l10n.DateFormatPatterns

public class
extends Object

Common patterns for dates, times, and timestamps.

Field Summary
Modifier and Type
static String
static String
static String
static String
static String
static String
static String
static String

Field and Description


ISO8601

Pattern for parsing/formatting ISO8601 timestamp.


RFC2822

Pattern for parsing/formatting RFC-2822 timestamp.


RFC822

Pattern for parsing/formatting RFC-822 timestamp.


TWITTER_SEARCH

Pattern for parsing/formatting Twitter search timestamp.


TWITTER_TIMELINE

Pattern for parsing/formatting Twitter timeline timestamp.


VERBOSE_DATE

Pattern for a verbose date


VERBOSE_TIME

Pattern for a verbose time


VERBOSE_TIMESTAMP

Pattern for a verbose timestamp

Constructor Summary
Constructor and Description
DateFormatPatterns()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RFC2822
public static final String RFC2822

Pattern for parsing/formatting RFC-2822 timestamp.


See Also:
Constant Field Values

Class DateFormatPatterns

2236

Overview (Codename One API)


RFC822
public static final String RFC822

Pattern for parsing/formatting RFC-822 timestamp.


See Also:
Constant Field Values
ISO8601
public static final String ISO8601

Pattern for parsing/formatting ISO8601 timestamp.


See Also:
Constant Field Values
TWITTER_TIMELINE
public static final String TWITTER_TIMELINE

Pattern for parsing/formatting Twitter timeline timestamp.


See Also:
Constant Field Values
TWITTER_SEARCH
public static final String TWITTER_SEARCH

Pattern for parsing/formatting Twitter search timestamp.


See Also:
Constant Field Values
VERBOSE_DATE
public static final String VERBOSE_DATE

Pattern for a verbose date


See Also:
Constant Field Values
VERBOSE_TIME
public static final String VERBOSE_TIME

Pattern for a verbose time


See Also:
Constant Field Values
VERBOSE_TIMESTAMP
public static final String VERBOSE_TIMESTAMP

Pattern for a verbose timestamp


See Also:
Constant Field Values

Constructor Detail
DateFormatPatterns
public DateFormatPatterns()

Field Detail

2237

Overview (Codename One API)


com.codename1.l10n

Class DateFormat
java.lang.Object

com.codename1.l10n.Format

com.codename1.l10n.DateFormat
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
SimpleDateFormat

public class
extends Format

A class for parsing and formatting localisation sensitive dates, compatible with Jave 6 SDK. This
implementation uses the Codename One localization manager for handling formatting dates. Parsing
dates is not implemented in this class since the localization pattern is not exposed.
See Also:
http://docs.oracle.com/javase/6/docs/api/java/text/DateFormat.html

Field Summary
Modifier and Type
static int
static int
static int
static int
static int

Field and Description


DEFAULT

Constant for default style (MEDIUM) parsing/formatting pattern.


FULL

Constant for full style parsing/formatting pattern.


LONG

Constant for long style parsing/formatting pattern.


MEDIUM

Constant for medium style parsing/formatting pattern.


SHORT

Constant for short style parsing/formatting pattern.

Method Summary
Modifier and
Type
Object
boolean
String
String

Method and Description


clone()
equals(Object obj)

Indicates whether some other object is "equal to" this one.


format(Date source)

Format a given date.


format(Object obj)

Format a given object.

static
DateFormat

getDateInstance()

static
DateFormat

getDateInstance(int style)

static
DateFormat

getDateTimeInstance(int dateStyle, int timeStyle)

static
DateFormat

Constructor Detail

Get a DateFormat instance with default style for date (SHORT).


Get a DateFormat instance that uses a given style for dates.
Get a DateFormat instance that uses a given style for dates and times.
getInstance()

Get a DateFormat instance with default style for date/time


(SHORT/SHORT).

2238

Overview (Codename One API)


static
DateFormat

getTimeInstance()

static
DateFormat

getTimeInstance(int style)

Get a DateFormat instance with default style for time (SHORT).


Get a DateFormat instance that uses a given style for times.
hashCode()

int

Returns a hash code value for the object.


parse(String source)

Date

NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.


parseObject(String source)

Object

NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
FULL
public static final int FULL

Constant for full style parsing/formatting pattern.


See Also:
Constant Field Values
LONG
public static final int LONG

Constant for long style parsing/formatting pattern.


See Also:
Constant Field Values
MEDIUM
public static final int MEDIUM

Constant for medium style parsing/formatting pattern.


See Also:
Constant Field Values
SHORT
public static final int SHORT

Constant for short style parsing/formatting pattern.


See Also:
Constant Field Values
DEFAULT
public static final int DEFAULT

Constant for default style (MEDIUM) parsing/formatting pattern.


See Also:
Constant Field Values

Method Detail
format
public String format(Object obj)
throws IllegalArgumentException

Format a given object.


Specified by:

Method Summary

2239

Overview (Codename One API)


format in class Format
Parameters:
obj - object to be formatted to text.
Returns:
formatted object.
Throws:
IllegalArgumentException - of the source can not be formatted.
format
public String format(Date source)

Format a given date.


Parameters:
source - date to be formatted.
Returns:
formatted date.
parseObject
public Object parseObject(String source)
throws ParseException

NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.


Specified by:
parseObject in class Format
Parameters:
source - document to be parsed.
Returns:
parsed object.
Throws:
ParseException - if the source could not be parsed.
parse
public Date parse(String source)
throws ParseException

NOT IMPLEMENTED - use SimpleDateFormat for parsing instead.


Throws:
ParseException

getInstance
public static final DateFormat getInstance()

Get a DateFormat instance with default style for date/time (SHORT/SHORT).


Returns:
a DateFormat instance.
getDateInstance
public static final DateFormat getDateInstance()

Get a DateFormat instance with default style for date (SHORT).


Returns:
a DateFormat instance.
getTimeInstance
public static final DateFormat getTimeInstance()

Get a DateFormat instance with default style for time (SHORT).


Returns:
a DateFormat instance.
getDateInstance
public static final DateFormat getDateInstance(int style)

Get a DateFormat instance that uses a given style for dates.


Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);

Method Detail

2240

Overview (Codename One API)


Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT
getTimeInstance
public static final DateFormat getTimeInstance(int style)

Get a DateFormat instance that uses a given style for times.


Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);
Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT
getDateTimeInstance
public static final DateFormat getDateTimeInstance(int dateStyle,
int timeStyle)

Get a DateFormat instance that uses a given style for dates and times.
Parameters:
style - style to use for parsing and formatting (SHORT, MEDIUM, LONG,
FULL, DEFAULT);
Returns:
a DateFormat instance.
See Also:
SHORT, MEDIUM, LONG, FULL, DEFAULT
hashCode
public int hashCode()

Description copied from class: Object


Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)

Description copied from class: Object


Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is

Method Detail

2241

Overview (Codename One API)


modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
clone
public Object clone()

Method Detail

2242

Overview (Codename One API)


com.codename1.javascript

Class JavascriptContext
java.lang.Object

com.codename1.javascript.JavascriptContext

public class
extends Object

Represents a Javascript context of a single BrowserComponent. This provides support for executing
Javascript in the BrowserComponent, registering Java callbacks to allow Javascript to call Java
functions, and returning values from Javascript to Java.
Typically you would obtain a context for a BrowserComponent via its constructor, passing the
BrowserComponent to the context.
E.g.
WebBrowser b = new WebBrowser();
BrowserComponent bc = (BrowserComponent)b.getInternal();
JavascriptContext ctx = new JavascriptContext(bc);
JSObject window = (JSObject)ctx.get("window");

Field Summary
Modifier and Type
static boolean

Field and Description


DEBUG

Flag to enable/disable logging to a debug log.

Constructor Summary
Constructor and Description
JavascriptContext(BrowserComponent c)

Creates a Javascript context for the given BrowserComponent.

Method Summary
Modifier
and Type

Method and Description


call(JSObject func, JSObject self, Object[] params)

Object

Object

Calls a Javascript function (encapsulated in a JSObject) with a specified


Javascript Object as the "this" context for the function call.
call(String jsFunc, JSObject self, Object[] params)

Calls a Javascript function with the given parameters.

Object

call(String jsFunc, JSObject self, Object[] params, boolean async,


Callback callback)

void

callAsync(JSObject func, JSObject self, Object[] params,


Callback callback)

void

callAsync(String jsFunc, JSObject self, Object[] params,


Callback callback)

void
Object

Class JavascriptContext

cleanup()

Cleans up stale references to Javascript objects.


get(String javascript)

2243

Overview (Codename One API)


Executes a javascript string and returns the result of the execution as an
appropriate object value depending on the type of value that was returned.
void

getAsync(String javascript, Callback callback)

JSObject

getWindow()
set(String key, Object value)

void

Sets a Javascript value given a compatible Java object value.

void

set(String key, Object value, boolean async)

void

setAsync(String key, Object value)


setBrowserComponent(BrowserComponent c)

void

Sets the BrowserComponent on which this javascript context runs.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
DEBUG
public static boolean DEBUG

Flag to enable/disable logging to a debug log.

Constructor Detail
JavascriptContext
public JavascriptContext(BrowserComponent c)

Creates a Javascript context for the given BrowserComponent.


Parameters:
c

Method Detail
setBrowserComponent
public final void setBrowserComponent(BrowserComponent c)

Sets the BrowserComponent on which this javascript context runs.


Parameters:
c - The BrowserComponent on which the context runs.
cleanup
public void cleanup()

Cleans up stale references to Javascript objects. This is triggered randomly


whenever a JSObject is constructed (with a given probability threshold). If this is
never called then the JS GC won't be able to free any objects that have ever been
wrapped by JSObject because they are stored in the global lookup table.
get
public Object get(String javascript)

Executes a javascript string and returns the result of the execution as an appropriate
object value depending on the type of value that was returned.
Return value types will depend on the Javascript type returned. The following table
shows the mappings:

Method Summary

2244

Overview (Codename One API)


Javascript Type Java Return Type
Number
java.lang.Double
String
java.lang.String
Boolean
Object
Function
null
undefined

java.lang.Boolean
JSObject
JSObject
null
null

Example
//Get the window object
JSObject window = (JSObject)ctx.get("window");
// Create a new empty Javascript Object
JSObject newObj = (JSObject)ctx.get("{}");
// Get the current document body contents as a string.
String html = (String)ctx.get("document.body.innerHTML");
// Get a numerical result
Double result = (Double)ctx.get("1+2");
// Get a Javascript function object
JSObject func = (JSObject)ctx.get("function(a,b){ return a+b }");
// Get a boolean result
Boolean res = (Boolean)ctx.get("1 < 2");

Parameters:
javascript - The javascript to be executed.
Returns:
The result of the javascript expression.
getWindow
public JSObject getWindow()

getAsync
public void getAsync(String javascript,
Callback callback)

set
public void set(String key,
Object value)

Sets a Javascript value given a compatible Java object value. This is an abstraction
upon javascript to execute key = value.
The key is any Javascript expression whose result can be assigned. The value is a
Java object that will be converted into a Javascript object as follows:
Java type Converted to
Double
Number
Integer
Number
Float
Number
Long
Number
String
String
JSObject Object by ref
null
null
Hence if you want to set a Javascript string value, you can just pass a Java string into
this method and it will be converted.
JSObject "By Ref"

You may notice that if you pass a JSObject as the value parameter, the table above
indicates that it is passed by reference. A JSObject merely stores a reference to a

Method Detail

2245

Overview (Codename One API)


Javascript object from a lookup table in the Javascript runtime environment. It is this
lookup that is ultimately assigned to the "key" when you pass a JSObject as the
value. This has the effect of setting the actual Javascript Object to this value, which is
effectively a pass-by-reference scenario.
Examples
// Set the window.location.href to a new URL
ctx.set("window.location.href", "http://google.com");
// Create a new JSObject, and set it as a property of another JSObject
JSObject camera = (JSObject)ctx.get("{}");
ctx.set("window.camera", camera);
// Set the name of the camera via JSObject.set()
camera.set("name", "My Camera");
// Get the camera's name via Javascript
String cameraName = (String)ctx.get("window.camera.name");
// Should be "My Camera"
// Set the camera name via context.set()
ctx.set("camera.name", "New name");
String newName = (String)camera.get("name");
// Should be "New name"

Parameters:
key - A javascript expression whose result is being assigned the value.
value - The object or value that is being assigned to the Javascript variable
on the left.
set
public void set(String key,
Object value,
boolean async)

setAsync
public void setAsync(String key,
Object value)

call
public Object call(JSObject func,
JSObject self,
Object[] params)

Calls a Javascript function (encapsulated in a JSObject) with a specified Javascript


Object as the "this" context for the function call. Also passes a set of arguments to the
method.
This operates almost exactly like the Javascript Function.apply() method.
Note that JSObject also has a couple of call() methods that may be more
convenient to use as they will automatically set the "self" parameter to the JSObject
callee. This version of the method is handy in cases where you have been passed a
function (perhaps as a callback) and you need to execute that function in a particular
context.
Example
// Get the Array.push method as an object
JSObject push = (JSObject)ctx.get("Array.prototype.push");
// Create a new array
JSObject colors = (JSObject)ctx.get("['red', 'green', 'blue']");
// "Push" a new color onto the array directly using the JSObject's call()
// method
colors.call("push", "purple");
// Alternate method using JavascriptContext.call()

Method Detail

2246

Overview (Codename One API)


ctx.call(push, colors, "orange");
// Check size of colors array now
Double size = (Double)colors.get("length");
// Should be 5.0
// Get 4th color (should be purple)
String purple = (String)colors.get(3);
// Get 5th color (should be orange)
String orange = (String)colors.get(4);

Parameters:
func - The Javascript function object that is being called.
self - Javascript Object that should act as "this" for the function call.
params - The parameters that should be passed to the function. These

parameters should be passed as Java objects but will be converted into their
associated Javascript version.
Returns:
The result of the function call. Javascript results will be automatically
converted to their associated Java types.
callAsync
public void callAsync(JSObject
JSObject
Object[]
Callback

func,
self,
params,
callback)

call
public Object call(String jsFunc,
JSObject self,
Object[] params)

Calls a Javascript function with the given parameters. This would translate roughly
into executing the following javascript: jsFunc.call(self, param1, param1, ...,
paramn)

Parameters:
- A javascript expression that resolves to a function object that is to be
called.
self - The Javascript object that is used as "this" for the method call.
params - Array of the Javascript parameters, as Java objects. These use the
same conversions as are described in the docs for set().
Returns:
Returns the return value converted to the corresponding Java object type.
callAsync
jsFunc

public void callAsync(String jsFunc,


JSObject self,
Object[] params,
Callback callback)

call
public Object call(String jsFunc,
JSObject self,
Object[] params,
boolean async,
Callback callback)

Method Detail

2247

Overview (Codename One API)


com.codename1.javascript

Class JSObject
java.lang.Object

com.codename1.javascript.JSObject

public class
extends Object

A Java Wrapper around a Javascript object. In Javascript there are only a few different types:
Number, String, Boolean, Null, Undefined, and Object. Arrays and functions are objects also.
A JSObject is associated with a particular JavascriptContext and it is backed by a Javascript object
inside the javascript context. This object acts as a proxy to call methods and access properties of the
actual javascript object.
All return values for Javascript calls in the JavascriptContext will be converted to the appropriate
Java type. Javascript objects will automatically be wrapped in a JSObject proxy.
Getting and Setting Properties

JSObject provides get(String) and set(String,Object) methods to get and set properties on the
object. E.g.
obj.set("name", "Steve");
obj.set("age", 12);
String name = (String)obj.get("name");
Double age = (Double)obj.get("age");

// Steve
// 12.0

Typed Getters

The return value of get(String) will be one of Double, String, Boolean, or JSObject depending on the
type of Javascript value that is being returned. get(String) requires you to cast the return value to
the correct type, which is a bit a pain. Luckily, JSObject provides a set of typed getter methods that
will automatically cast to particular types:
getInt()
getString()
getDouble()
getObject()
getBoolean()

Returns int
Returns String
Returns double
Returns JSObject
Returns boolean

Indexed Properties

JSObject can wrap Javascript arrays also. You can retrieve the indexed properties of the array using
indexed versions of get(int) and set(int,Object) (i.e. they take an int as their first parameter
instead of a String). There are also typed versions of the indexed get(int) method to allow directly
returning values of the correct type without having to type cast
Example, looping through array

JSObject colors = ctx.get("['red','green','blue']");


int len = colors.getInt("length");
for ( int i=0; i< len; i++ ){
System.out.println("Color "+i+" is "+colors.getString(i));
}

Calling Object Methods

JSObject allows you to call Javascript object methods on the wrapped Javascript object via the its
call(String,Object[]) method. It takes the name of the method (i.e. property name that stores the
function), and an array of parameters to pass to the method.

Class JSObject

2248

Overview (Codename One API)


JSObject document = (JSObject)context.get("document");
// Call document.writeln("Hello world");
document.call("writeln", new Object[]{"Hello world"});

Calling Wrapped Functions

Since, in Javascript, functions are objects, it is possible to wrap a function with a JSObject object also.
You can then call the function using the alternate version of the #call(JSObject,Object[]) method.
JSObject window = (JSObject)context.get("window");
// reference to the window object so that we can pass it as the context
// of the function call.
JSObject myfunc = (JSObject)context.get("function(a,b){ return a+b}");
Double result = (Double)myfunc.call(window, new Object[]{new Integer(1), new Integer(2)});

Calling Java Methods from Javascript

The JSFunction interface allows you to implement functions in Java that can be called from
Javascript. You can assign any JSFunction object to be a member method of an existing JSObject via
the JSObject.set() method. Then the function can be called from javascript just like any other
Javascript method. JSFunction methods are called asynchronously from Javascript to prevent
deadlocks. If you require a return value to Javascript, you can do that by passing a callback function
which is called by the JSFunction with some parameters.
The following example, adds a camera object to the Javascript environment that has a capture()
method, which can be used to capture images using the device's camera:
// Create a new Javascript object "camera"
final JSObject camera = (JSObject)ctx.get("{}");
// Create a capture() method on the camera object
// as a JSFunction callback.
camera.set("capture", new JSFunction(){
public void apply(JSObject self, final Object[] args) {
Display.getInstance().capturePhoto(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
String imagePath = (String)evt.getSource();
// Get the callback function that was provided
// from javascript
JSObject callback = (JSObject)args[0];
ctx.call(
callback, // The function
camera,
// The "this" object
new Object[]{"file://"+imagePath}
);

// Parameters

}
});
}
});

// Add the camera object to the top-level window object


ctx.set("window.camera", camera);

We can then capture photos directly from Javascript using a function similar to the following:
camera.capture(function(url){
if ( url == null ){
// No image was captured
return;
}

Class JSObject

2249

Overview (Codename One API)


// Fetch the preview <img> tag.
var image = document.getElementById('preview-image');
// Set the preview URL to the image that was taken.
image.src = url;
});

Constructor Summary
Constructor and Description
JSObject(JavascriptContext context, String expr)

Constructor for a JSObject.

Method Summary
Modifier and
Type
Object
Object
Object

Method and Description


call(Object[] params)

Calls the object as a function statically.


call(String key)
call(String key, Object[] params)

Calls a method on the underlying Javascript object.

void

callAsync(Object[] params, Callback callback)

void

callAsync(String key, Callback callback)

void

callAsync(String key, Object[] params, Callback callback)

double

callDouble(String key)

void

callDoubleAsync(String key, Callback<Double> callback)

int

callInt(String key)

void

callIntAsync(String key, Callback<Integer> callback)

JSObject

callObject(String key)

void

callObjectAsync(String key, Callback<JSObject> callback)

String

callString(String key)

void

callStringAsync(String key, Callback<String> callback)


get(int index)

Object

Object
boolean
boolean
double
double
int
int
JSObject
JSObject

Constructor Summary

This method is useful only for JSObjects that encapsulate Javascript


arrays.
get(String key)

Returns a member variable of the Javascript object.


getBoolean(int index)

Wrapper for get(int) for indexed boolean values.


getBoolean(String key)

Wrapper around get() to return a boolean.


getDouble(int index)

Wrapper for get(int) for indexed double values.


getDouble(String key)

Wrapper around get() to return a double.


getInt(int index)

Wrapper for get(int) for indexed int values.


getInt(String key)

Wrapper around get() to return an int


getObject(int index)

Wrapper for get(int) for indexed object values.


getObject(String key)

Wrapper around the get() method to return a JSObject.

2250

Overview (Codename One API)


getString(int index)

String

Wrapper for get(int) for indexed string values.


getString(String key)

String

Wrapper around get() to return a String.

void

set(int index, Object js)

void

set(int index, Object js, boolean async)

void

set(String key, Object js)


set(String key, Object js, boolean async)

void

Sets a property on the underlying Javascript object.

void

setBoolean(int index, boolean value)

void

setBoolean(int index, boolean value, boolean async)

void

setBoolean(String key, boolean value)

void

setBoolean(String key, boolean value, boolean async)

void

setDouble(int index, double value)

void

setDouble(int index, double value, boolean async)

void

setDouble(String key, double value)

void

setDouble(String key, double value, boolean async)

void

setInt(int index, int value)

void

setInt(int index, int value, boolean async)

void

setInt(String key, int value)

void

setInt(String key, int value, boolean async)


toJSPointer()

String

Returns a Javascript variable name for the underlying Javascript object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
JSObject
public JSObject(JavascriptContext context,
String expr)

Constructor for a JSObject.


Example
// Create a JavascriptContext for a browser component
JavascriptContext ctx = new JavascriptContext(browserComponent);
// Get reference to the window object
JSObject window = new JSObject(ctx, "window");
// This is equivalent to
window = (JSObject)ctx.get("window");

Parameters:
context - The javascript context in which this object is being created.
expr - A javascript expression that resolves to an Javascript Object.

Method Detail

Method Summary

2251

Overview (Codename One API)


get
public Object get(String key)

Returns a member variable of the Javascript object.


E.g., suppose you have a Javascript object myCar whose JSON representation is
{ make : 'Ford', model : 'Escort', 'year' : 1989}

Then the JSObject proxy for this object could call:


String model = (String)myCar.get("model");

And this would return "Ford".


Example
JSObject document = (JSObject)ctx.get("document");
// Get document title
String title = document.get("title");
// Since the "title" property is a string, get() returns a String.
// We could equivalently use
title = document.getString("title");
// Get a grandchild property
Double titleLength = (Double)document.get("title.length");
// Since length is an integer, it is probably easier to use getInt()
int titleLengthInt = document.getInt("title.length");
// Get a child object
JSObject body = (JSObject)document.get("body");
// Since "body" is a Javascript object, it is probably easier to use
// getObject()
JSObject body2 = document.getObject("body");
// Get a method as a function object
JSObject open = (JSObject) document.get("open");
// Call the open() method, with document as "this"
open.call(document, new Object[]{}); // Takes no parameters
// Equivalently we could have called open via the document object
document.call("open", new Object[]{});

Parameters:
key - The name of the property to retrieve on this object.
Returns:
The value of the property specified converted to the appropriate Java value.
See @ref JavascriptContext.get() for a table of the Javascript to Java type
conversions.
getString
public String getString(String key)

Wrapper around get() to return a String.


Parameters:
key - The name of the property in the object to retrieve. Value of this property
must be a string.
Returns:
The property value as a string.

Method Detail

2252

Overview (Codename One API)


getInt
public int getInt(String key)

Wrapper around get() to return an int


Parameters:
key - The name of the property in the object to retrieve. Value of this property
must be an integer.
Returns:
The property value as an integer.
getDouble
public double getDouble(String key)

Wrapper around get() to return a double.


Parameters:
key - The name of the property in the object to retrieve. Value of this property
must be a number.
Returns:
The property value as a double.
getBoolean
public boolean getBoolean(String key)

Wrapper around get() to return a boolean.


Parameters:
key - The name of the property in the object to retrieve. Value of this property
must be a boolean.
Returns:
The property value as a boolean.
getObject
public JSObject getObject(String key)

Wrapper around the get() method to return a JSObject.


Parameters:
key - The name of the property in the object to retrieve. Value of this property
must be an Javascript object or function.
Returns:
The property value as a JSObject.
get
public Object get(int index)

This method is useful only for JSObjects that encapsulate Javascript arrays. It
provides a method to get indexed properties of the array. E.g. to retrieve the 5th
element of the wrapped array, you could use this method.
Example
JSObject colors = ctx.get("['red','green','blue']");
String red = (String)colors.get(0);
String green = (String)colors.get(1);
String blue = (String)colors.get(2);

It may be more convenient to use the typed wrapper methods so that you don't have
to typecast the values. E.g.
String red = colors.getString(0);
String green = colors.getString(1);
String blue = colors.getString(2);

Example, looping through array


JSObject colors = ctx.get("['red','green','blue']");
int len = colors.getInt("length");
for ( int i=0; i< len; i++ ){

Method Detail

2253

Overview (Codename One API)


System.out.println("Color "+i+" is "+colors.getString(i));
}

Parameters:
index - The index of the entry within the array to return.
Returns:
The value of the specified indexed element.
getString
public String getString(int index)

Wrapper for get(int) for indexed string values.


Parameters:
index - The index within an Array object whose value to retrieve.
Returns:
The value of the indexed element. Must be a String.
getInt
public int getInt(int index)

Wrapper for get(int) for indexed int values.


Parameters:
index - The index within the Array object whose value to retrieve.
Returns:
The value of the indexed element. Must be an integer.
getDouble
public double getDouble(int index)

Wrapper for get(int) for indexed double values.


Parameters:
index - The index within the Array object whose value to retrieve.
Returns:
The value of the indexed element. Must be a number.
getBoolean
public boolean getBoolean(int index)

Wrapper for get(int) for indexed boolean values.


Parameters:
index - The index within the Array object whose value to retrieve.
Returns:
The value of the indexed element. Must be a boolean.
getObject
public JSObject getObject(int index)

Wrapper for get(int) for indexed object values.


Parameters:
index - The index within the Array object whose value to retrieve.
Returns:
The value of the indexed element. Must be an Object. (e.g. can be Object,
Function, Array, or any other type of Javascript object).
set
public void set(String key,
Object js,
boolean async)

Sets a property on the underlying Javascript object.


Parameters:
key - The name of the property to set on the current object.
js - The value of the property. This value should be provided as a Java value
and it will be converted to the appropriate Javascript value. See @ref
JavascriptContext.set() for a conversion table of the Java to Javascript type
conversions.

Method Detail

2254

Overview (Codename One API)


set
public void set(String key,
Object js)

setInt
public void setInt(String key,
int value,
boolean async)

setInt
public void setInt(String key,
int value)

setDouble
public void setDouble(String key,
double value,
boolean async)

setDouble
public void setDouble(String key,
double value)

setBoolean
public void setBoolean(String key,
boolean value,
boolean async)

setBoolean
public void setBoolean(String key,
boolean value)

set
public void set(int index,
Object js,
boolean async)

set
public void set(int index,
Object js)

setInt
public void setInt(int index,
int value,
boolean async)

setInt
public void setInt(int index,
int value)

setDouble
public void setDouble(int index,
double value,
boolean async)

setDouble
public void setDouble(int index,
double value)

setBoolean
public void setBoolean(int index,
boolean value,
boolean async)

setBoolean
public void setBoolean(int index,
boolean value)

toJSPointer
public String toJSPointer()

Method Detail

2255

Overview (Codename One API)


Returns a Javascript variable name for the underlying Javascript object. This refers to
the object inside the JavascriptContext's lookup table.
Returns:
call
public Object call(String key,
Object[] params)

Calls a method on the underlying Javascript object.


Parameters:
key - The name of the method to call.
params - Array of parameters to pass to the method. These will be converted
to corresponding Javascript types according to the translation table specified
in JavascriptContext.set(String,Object)
Returns:
The result of calling the method. Javascript return values will be converted to
corresponding Java types according to the rules described in
JavascriptContext.get(String)

callAsync
public void callAsync(String key,
Object[] params,
Callback callback)

call
public Object call(String key)

callAsync
public void callAsync(String key,
Callback callback)

callInt
public int callInt(String key)

callIntAsync
public void callIntAsync(String key,
Callback<Integer> callback)

callDouble
public double callDouble(String key)

callDoubleAsync
public void callDoubleAsync(String key,
Callback<Double> callback)

callString
public String callString(String key)

callStringAsync
public void callStringAsync(String key,
Callback<String> callback)

callObject
public JSObject callObject(String key)

callObjectAsync
public void callObjectAsync(String key,
Callback<JSObject> callback)

call
public Object call(Object[] params)

Calls the object as a function statically. In this case "this" will be window.
E.g.
JSObject alert = (JSObject)ctx.get("window.alert");
alert.call(new Object[]{"An alert message"});

Method Detail

2256

Overview (Codename One API)


The above gets a reference to the alert() function (remember functions are objects in
Javascript). Then it calls it via Java, passing it a single string parameter. This is
equivalent to the following Javasript:
alert("An alert message");

Parameters:
- The parameters to pass to the function. These will be converted to
the appropriate Javascript type.
Returns:
The result of the javascript function call converted to the appropriate Java
type.
callAsync
params

public void callAsync(Object[] params,


Callback callback)

Method Detail

2257

Overview (Codename One API)


com.codename1.javascript

Interface JSFunction

public interface

The JSFunction interface allows you to implement functions in Java that can be called from
Javascript. You can assign any JSFunction object to be a member method of an existing JSObject via
the JSObject.set() method. Then the function can be called from javascript just like any other
Javascript method. JSFunction methods are called asynchronously from Javascript to prevent
deadlocks. If you require a return value to Javascript, you can do that by passing a callback function
which is called by the JSFunction with some parameters.
The following example, adds a camera object to the Javascript environment that has a capture()
method, which can be used to capture images using the device's camera:
// Create a new Javascript object "camera"
final JSObject camera = (JSObject)ctx.get("{}");
// Create a capture() method on the camera object
// as a JSFunction callback.
camera.set("capture", new JSFunction(){
public void apply(JSObject self, final Object[] args) {
Display.getInstance().capturePhoto(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
String imagePath = (String)evt.getSource();
// Get the callback function that was provided
// from javascript
JSObject callback = (JSObject)args[0];
ctx.call(
callback, // The function
camera, // The "this" object
new Object[]{"file://"+imagePath} // Parameters
);
}
});
}
});

// Add the camera object to the top-level window object


ctx.set("window.camera", camera);

We can then capture photos directly from Javascript using a function similar to the following:
camera.capture(function(url){
if ( url == null ){
// No image was captured
return;
}
// Fetch the preview <img> tag.
var image = document.getElementById('preview-image');
// Set the preview URL to the image that was taken.
image.src = url;
});

Interface JSFunction

2258

Overview (Codename One API)

Method

Summary

Modifier and Type


void

Method and Description


apply(JSObject self, Object[] args)

Method Detail
apply
void apply(JSObject self,
Object[] args)

Method Summary

2259

Overview (Codename One API)


com.codename1.io.tar

Class TarUtils
java.lang.Object

com.codename1.io.tar.TarUtils

public class
extends Object

Constructor Summary
Constructor and Description
TarUtils()

Method Summary
Modifier and Type

Method and Description


calculateTarSize(String path)

static long

Determines the tar file size of the given folder/file path

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
TarUtils
public TarUtils()

Method Detail
calculateTarSize
public static long calculateTarSize(String path)
throws IOException

Determines the tar file size of the given folder/file path


Parameters:
path Returns:
Throws:
IOException

Method Detail

2260

Overview (Codename One API)


com.codename1.io.tar

Class TarOutputStream
java.lang.Object

java.io.OutputStream

com.codename1.io.BufferedOutputStream

com.codename1.io.tar.TarOutputStream
All Implemented Interfaces:
AutoCloseable

public class
extends BufferedOutputStream

Field Summary

Fields inherited from


class com.codename1.io.BufferedOutputStream
buf, count

Constructor Summary
Constructor and Description
TarOutputStream(OutputStream out)

Method Summary
Modifier and Type

Method and Description


close()

void

Appends the EOF record and closes the stream

protected void
protected void

closeCurrentEntry()

Closes the current tar entry


pad()

Pads the last content block


putNextEntry(TarEntry entry)

void

Writes the next tar entry header on the stream


write(byte[] b, int off, int len)

void

Checks if the bytes being written exceed the current entry size.
write(int b)

void

Writes a byte to the stream and updates byte counters

Methods inherited from


class com.codename1.io.BufferedOutputStream
flush, flushBuffer, getConnection, getDefaultBufferSize,
getLastActivityTime, getName, getTotalBytesWritten, setConnection,
setDefaultBufferSize, setProgressListener, write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

2261

Overview (Codename One API)


Constructor

Detail

TarOutputStream
public TarOutputStream(OutputStream out)

Method Detail
close
public void close()
throws IOException

Appends the EOF record and closes the stream


Specified by:
close in interface AutoCloseable
Overrides:
close in class BufferedOutputStream
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.close()

write
public void write(int b)
throws IOException

Writes a byte to the stream and updates byte counters


Overrides:
write in class BufferedOutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.write(int)

write
public void write(byte[] b,
int off,
int len)
throws IOException

Checks if the bytes being written exceed the current entry size.
Overrides:
write in class BufferedOutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.write(byte[], int, int)

putNextEntry
public void putNextEntry(TarEntry entry)
throws IOException

Writes the next tar entry header on the stream


Parameters:
entry Throws:
IOException

Constructor Detail

2262

Overview (Codename One API)

closeCurrentEntry
protected void closeCurrentEntry()
throws IOException

Closes the current tar entry


Throws:
IOException

pad
protected void pad()
throws IOException

Pads the last content block


Throws:
IOException

Method Detail

2263

Overview (Codename One API)


com.codename1.io.tar

Class TarInputStream
java.lang.Object

java.io.InputStream

com.codename1.io.BufferedInputStream

com.codename1.io.tar.TarInputStream
All Implemented Interfaces:
AutoCloseable

public class
extends BufferedInputStream

Constructor Summary
Constructor and Description
TarInputStream(InputStream in)

Method Summary
Modifier and
Type
protected void
TarEntry
boolean

Method and Description


closeCurrentEntry()

Closes the current tar entry


getNextEntry()

Returns the next entry in the tar file


isDefaultSkip()
mark(int readlimit)

void

Not supported

boolean

markSupported()

Tests if this input stream supports the mark and reset methods.
read()

int

Read a byte
read(byte[] b, int off, int len)

Checks if the bytes being read exceed the entry size and adjusts the byte
array length.

int

reset()

void

Not supported

void

setDefaultSkip(boolean defaultSkip)
skip(long n)

Skips 'n' bytes on the InputStream


Overrides default implementation of skip

long

protected void

skipPad()

Skips the pad at the end of each tar entry file content

Methods inherited from


class com.codename1.io.BufferedInputStream
available, close, getConnection, getDefaultBufferSize, getInternal,
getLastActivityTime, getName, getTotalBytesRead, getYield,
isDisableBuffering, isPrintInput, read, setConnection,
setDefaultBufferSize, setDisableBuffering, setPrintInput,
setProgressListener, setYield, stop

Class TarInputStream

2264

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
TarInputStream
public TarInputStream(InputStream in)

Method Detail
markSupported
public boolean markSupported()

Description copied from class: BufferedInputStream


Tests if this input stream supports the mark and reset methods. The markSupported
method of BufferedInputStream returns true.
Overrides:
markSupported in class BufferedInputStream
Returns:
a boolean indicating if this stream type supports the mark and reset methods.
See Also:
InputStream.mark(int), InputStream.reset()
mark
public void mark(int readlimit)

Not supported
Overrides:
mark in class BufferedInputStream
Parameters:
readlimit - the maximum limit of bytes that can be read before the mark
position becomes invalid.
reset
public void reset()
throws IOException

Not supported
Overrides:
reset

in class BufferedInputStream

Throws:
- if this stream has not been marked or, if the mark has been
invalidated, or the stream has been closed by invoking its
BufferedInputStream.close() method, or an I/O error occurs.
IOException

read
public int read()
throws IOException

Read a byte
Overrides:
read in class BufferedInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if this input stream has been closed by invoking its
BufferedInputStream.close() method, or an I/O error occurs.
See Also:
FilterInputStream.read()

Methods inherited from class java.lang.Object

2265

Overview (Codename One API)


read
public int read(byte[] b,
int off,
int len)
throws IOException

Checks if the bytes being read exceed the entry size and adjusts the byte array
length. Updates the byte counters
Overrides:
read in class BufferedInputStream
Parameters:
b - destination buffer.
off - offset at which to start storing bytes.
len - maximum number of bytes to read.
Returns:
the number of bytes read, or -1 if the end of the stream has been reached.
Throws:
IOException - if this input stream has been closed by invoking its
BufferedInputStream.close() method, or an I/O error occurs.
See Also:
FilterInputStream.read(byte[], int, int)

getNextEntry
public TarEntry getNextEntry()
throws IOException

Returns the next entry in the tar file


Returns:
TarEntry
Throws:
IOException

closeCurrentEntry
protected void closeCurrentEntry()
throws IOException

Closes the current tar entry


Throws:
IOException

skipPad
protected void skipPad()
throws IOException

Skips the pad at the end of each tar entry file content
Throws:
IOException

skip
public long skip(long n)
throws IOException

Skips 'n' bytes on the InputStream


Overrides default implementation of skip
Overrides:
skip in class BufferedInputStream
Throws:
IOException - if the stream does not support seek, or if this input stream has
been closed by invoking its BufferedInputStream.close() method, or an I/O
error occurs.
isDefaultSkip
public boolean isDefaultSkip()

Method Detail

2266

Overview (Codename One API)


setDefaultSkip
public void setDefaultSkip(boolean defaultSkip)

Method Detail

2267

Overview (Codename One API)


com.codename1.io.tar

Class TarHeader
java.lang.Object

com.codename1.io.tar.TarHeader

public class
extends Object

Header
Offset
0
100
108
116
124
136
148
156
157

Size
100
8
8
8
12
12
8
1
100

Field
File name
File mode
Owner's numeric user ID
Group's numeric user ID
File size in bytes
Last modification time in numeric Unix time format
Checksum for header block
Link indicator (file type)
Name of linked file

File Types
Value
'0'
(ASCII NUL)
'1'
'2'
'3'
'4'
'5'
'6'
'7'

Meaning
Normal file
Normal file (now obsolete)
Hard link
Symbolic link
Character special
Block special
Directory
FIFO
Contigous

Ustar header
Offset
257
263
265
297
329
337
345

Size
6
2
32
32
8
8
155

Field
UStar indicator "ustar"
UStar version "00"
Owner user name
Owner group name
Device major number
Device minor number
Filename prefix

Field Summary
Modifier and Type

Field and Description

int

checkSum

static int

CHKSUMLEN

static int

DEVLEN

int

devMajor

int

devMinor

static int

GIDLEN

static int

GNAMELEN

static String

Class TarHeader

GNU_TMAGIC

The magic tag representing a GNU tar archive.

2268

Overview (Codename One API)


int

groupId

StringBuffer

groupName

static byte

LF_BLK

static byte

LF_CHR

static byte

LF_CONTIG

static byte

LF_DIR

static byte

LF_FIFO

static byte

LF_LINK

static byte

LF_NORMAL

static byte

LF_OLDNORM

static byte

LF_SYMLINK

byte

linkFlag

StringBuffer

linkName

StringBuffer

magic

static int

MAGICLEN

int

mode

static int

MODELEN

long

modTime

static int

MODTIMELEN

StringBuffer

name

static int

NAMELEN

long

size

static int

SIZELEN

static String

TMAGIC

The magic tag representing a POSIX tar archive.

static int

UIDLEN

static int

UNAMELEN

int

userId

StringBuffer

userName

Constructor Summary
Constructor and Description
TarHeader()

Method Summary
Modifier and Type
static int

Method and Description


getNameBytes(StringBuffer name, byte[] buf, int offset,
int length)

Determine the number of bytes in an entry name.


static
StringBuffer

parseName(byte[] header, int offset, int length)

Parse an entry name from a header buffer.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Summary

2269

Overview (Codename One API)

Field Detail
NAMELEN
public static final int NAMELEN

See Also:
Constant Field Values
MODELEN
public static final int MODELEN

See Also:
Constant Field Values
UIDLEN
public static final int UIDLEN

See Also:
Constant Field Values
GIDLEN
public static final int GIDLEN

See Also:
Constant Field Values
SIZELEN
public static final int SIZELEN

See Also:
Constant Field Values
MODTIMELEN
public static final int MODTIMELEN

See Also:
Constant Field Values
CHKSUMLEN
public static final int CHKSUMLEN

See Also:
Constant Field Values
LF_OLDNORM
public static final byte LF_OLDNORM

See Also:
Constant Field Values
LF_NORMAL
public static final byte LF_NORMAL

See Also:
Constant Field Values
LF_LINK
public static final byte LF_LINK

See Also:
Constant Field Values

Field Detail

2270

Overview (Codename One API)


LF_SYMLINK
public static final byte LF_SYMLINK

See Also:
Constant Field Values
LF_CHR
public static final byte LF_CHR

See Also:
Constant Field Values
LF_BLK
public static final byte LF_BLK

See Also:
Constant Field Values
LF_DIR
public static final byte LF_DIR

See Also:
Constant Field Values
LF_FIFO
public static final byte LF_FIFO

See Also:
Constant Field Values
LF_CONTIG
public static final byte LF_CONTIG

See Also:
Constant Field Values
MAGICLEN
public static final int MAGICLEN

See Also:
Constant Field Values
TMAGIC
public static final String TMAGIC

The magic tag representing a POSIX tar archive.


See Also:
Constant Field Values
GNU_TMAGIC
public static final String GNU_TMAGIC

The magic tag representing a GNU tar archive.


See Also:
Constant Field Values
UNAMELEN
public static final int UNAMELEN

See Also:
Constant Field Values
GNAMELEN
public static final int GNAMELEN

See Also:

Field Detail

2271

Overview (Codename One API)

Constant Field Values


DEVLEN
public static final int DEVLEN

See Also:
Constant Field Values
name
public StringBuffer name

mode
public int mode

userId
public int userId

groupId
public int groupId

size
public long size

modTime
public long modTime

checkSum
public int checkSum

linkFlag
public byte linkFlag

linkName
public StringBuffer linkName

magic
public StringBuffer magic

userName
public StringBuffer userName

groupName
public StringBuffer groupName

devMajor
public int devMajor

devMinor
public int devMinor

Constructor Detail
TarHeader
public TarHeader()

Method Detail
parseName
public static StringBuffer parseName(byte[] header,
int offset,
int length)

Parse an entry name from a header buffer.


Parameters:

Field Detail

2272

Overview (Codename One API)

name header
offset
length

- The header buffer from which to parse.


- The offset into the buffer from which to parse.
- The number of header bytes to parse.

Returns:
The header's entry name.
getNameBytes
public static int getNameBytes(StringBuffer name,
byte[] buf,
int offset,
int length)

Determine the number of bytes in an entry name.


Parameters:
name header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The number of bytes in a header's entry name.

Method Detail

2273

Overview (Codename One API)


com.codename1.io.tar

Class TarEntry
java.lang.Object

com.codename1.io.tar.TarEntry

public class
extends Object

Field Summary
Modifier and Type

Field and Description

protected String

file

protected TarHeader header

Constructor Summary
Constructor and Description
TarEntry(byte[] headerBuf)
TarEntry(String file, String entryName)

Method Summary
Modifier and Type
long
boolean
void

computeCheckSum(byte[] buf)

Calculate checksum
equals(TarEntry it)
extractTarHeader(String entryName)

Extract header from File

String

getFile()

int

getGroupId()

String

getGroupName()

TarHeader

getHeader()

Date

getModTime()

String

getName()

long

getSize()

int

getUserId()

String

getUserName()

boolean

isDescendent(TarEntry desc)

boolean
void

Class TarEntry

Method and Description

isDirectory()

Checks if the org.xeustechnologies.jtar entry is a directory


parseTarHeader(byte[] bh)

Parses the tar header to the byte buffer

void

setGroupId(int groupId)

void

setGroupName(String groupName)

void

setIds(int userId, int groupId)

void

setModTime(Date time)

2274

Overview (Codename One API)


void

setModTime(long time)

void

setName(String name)

void

setSize(long size)

void

setUserId(int userId)

void

setUserName(String userName)
writeEntryHeader(byte[] outbuf)

void

Writes the header to the byte buffer

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
file
protected String file

header
protected TarHeader header

Constructor Detail
TarEntry
public TarEntry(String file,
String entryName)

TarEntry
public TarEntry(byte[] headerBuf)

Method Detail
equals
public boolean equals(TarEntry it)

isDescendent
public boolean isDescendent(TarEntry desc)

getHeader
public TarHeader getHeader()

getName
public String getName()

setName
public void setName(String name)

getUserId
public int getUserId()

setUserId
public void setUserId(int userId)

getGroupId
public int getGroupId()

Method Summary

2275

Overview (Codename One API)


setGroupId
public void setGroupId(int groupId)

getUserName
public String getUserName()

setUserName
public void setUserName(String userName)

getGroupName
public String getGroupName()

setGroupName
public void setGroupName(String groupName)

setIds
public void setIds(int userId,
int groupId)

setModTime
public void setModTime(long time)

setModTime
public void setModTime(Date time)

getModTime
public Date getModTime()

getFile
public String getFile()

getSize
public long getSize()

setSize
public void setSize(long size)

isDirectory
public boolean isDirectory()

Checks if the org.xeustechnologies.jtar entry is a directory


Returns:
extractTarHeader
public void extractTarHeader(String entryName)

Extract header from File


Parameters:
entryName computeCheckSum
public long computeCheckSum(byte[] buf)

Calculate checksum
Parameters:
buf Returns:
writeEntryHeader
public void writeEntryHeader(byte[] outbuf)

Writes the header to the byte buffer


Parameters:
outbuf -

Method Detail

2276

Overview (Codename One API)


parseTarHeader
public void parseTarHeader(byte[] bh)

Parses the tar header to the byte buffer


Parameters:
header bh -

Method Detail

2277

Overview (Codename One API)


com.codename1.io.tar

Class TarConstants
java.lang.Object

com.codename1.io.tar.TarConstants

public class
extends Object

Field Summary
Modifier and Type Field and Description
static int

DATA_BLOCK

static int

EOF_BLOCK

static int

HEADER_BLOCK

Constructor Summary
Constructor and Description
TarConstants()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
EOF_BLOCK
public static final int EOF_BLOCK

See Also:
Constant Field Values
DATA_BLOCK
public static final int DATA_BLOCK

See Also:
Constant Field Values
HEADER_BLOCK
public static final int HEADER_BLOCK

See Also:
Constant Field Values

Constructor Detail

Class TarConstants

2278

Overview (Codename One API)


TarConstants
public TarConstants()

Constructor Detail

2279

Overview (Codename One API)


com.codename1.io.tar

Class Octal
java.lang.Object

com.codename1.io.tar.Octal

public class
extends Object

Constructor Summary
Constructor and Description
Octal()

Method Summary
Modifier and
Type
static int

Method and Description


getCheckSumOctalBytes(long value, byte[] buf, int offset,
int length)

Parse the checksum octal integer from a header buffer.


static int

getLongOctalBytes(long value, byte[] buf, int offset,


int length)

Parse an octal long integer from a header buffer.


static int
static long

getOctalBytes(long value, byte[] buf, int offset, int length)

Parse an octal integer from a header buffer.


parseOctal(byte[] header, int offset, int length)

Parse an octal string from a header buffer.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Octal
public Octal()

Method Detail
parseOctal
public static long parseOctal(byte[] header,
int offset,
int length)

Parse an octal string from a header buffer. This is used for the file permission mode
value.
Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:

Class Octal

2280

Overview (Codename One API)


The long value of the octal string.
getOctalBytes
public static int getOctalBytes(long value,
byte[] buf,
int offset,
int length)

Parse an octal integer from a header buffer.


Parameters:
value buf - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The integer value of the octal bytes.
getCheckSumOctalBytes
public static int getCheckSumOctalBytes(long value,
byte[] buf,
int offset,
int length)

Parse the checksum octal integer from a header buffer.


Parameters:
value buf - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The integer value of the entry's checksum.
getLongOctalBytes
public static int getLongOctalBytes(long value,
byte[] buf,
int offset,
int length)

Parse an octal long integer from a header buffer.


Parameters:
value buf - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The long value of the octal bytes.

Method Detail

2281

Overview (Codename One API)


com.codename1.io.services

Class TwitterRESTService
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.services.TwitterRESTService
All Implemented Interfaces:
IOProgressListener

public class
extends ConnectionRequest

Calls to the Twitter REST API can be performed via this class although currently support for
authentication isn't implemented due to the transition to oAuth instead of basic authentication.

Field Summary
Modifier and Type Field and Description
static String

METHOD_TWEETS

static String

METHOD_USER_TIMELINE

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Constructor and Description
TwitterRESTService(String method)

The constructor accepts the method to invoke


TwitterRESTService(String method, boolean post)

The constructor accepts the method to invoke


TwitterRESTService(String method, String version, boolean post)

The constructor accepts the method to invoke

Method Summary
Modifier and Type

Method and Description


getIdStr()

String

Hashtable<String,Object>
Hashtable<String,Object>
int
static String
protected void

Class TwitterRESTService

Gets the id string of the first entry which is important if we want


to set the id to start with in the next request
getParseTree()

Returns the full Hashtable parse tree read from the server
getStatus(int offset)

Returns the status at the given offset


getStatusesCount()

Returns the number of statuses within the response


initToken(String consumerKey, String consumerSecret)

Logs in to twitter as an application


readResponse(InputStream input)

2282

Overview (Codename One API)


Callback for the server response with the input stream from the
server.
static void

setToken(String token)

For every request twitter now needs an authorization token

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleErrorResponseCode, handleException, handleIOException,
handleRuntimeException, hashCode, hasResponseListeners, initConnection,
initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,
kill, onRedirect, pause, postResponse, readErrorCodeHeaders, readHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
METHOD_USER_TIMELINE
public static final String METHOD_USER_TIMELINE

See Also:
Constant Field Values
METHOD_TWEETS
public static final String METHOD_TWEETS

See Also:
Constant Field Values

Constructor Detail
TwitterRESTService
public TwitterRESTService(String method)

The constructor accepts the method to invoke


Parameters:
method - the api method to invoke e.g. "statuses/public_timeline"

Method Summary

2283

Overview (Codename One API)


TwitterRESTService
public TwitterRESTService(String method,
boolean post)

The constructor accepts the method to invoke


Parameters:
method - the api method to invoke e.g. "statuses/public_timeline"
post - true for post requests and false for get request
TwitterRESTService
public TwitterRESTService(String method,
String version,
boolean post)

The constructor accepts the method to invoke


Parameters:
method - the api method to invoke e.g. "statuses/public_timeline"
version - the API version to send e.g. "1"
post - true for post requests and false for get request

Method Detail
initToken
public static String initToken(String consumerKey,
String consumerSecret)

Logs in to twitter as an application


Parameters:
consumerKey - the key to login with
consumerSecret - the secret to to login with
Returns:
the authorization token
setToken
public static void setToken(String token)

For every request twitter now needs an authorization token


Parameters:
token - the token
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs
getParseTree
public Hashtable<String,Object> getParseTree()

Returns the full Hashtable parse tree read from the server
Returns:
the parse tree
getStatusesCount
public int getStatusesCount()

Returns the number of statuses within the response

Constructor Detail

2284

Overview (Codename One API)


Returns:
the number of statuses
getStatus
public Hashtable<String,Object> getStatus(int offset)

Returns the status at the given offset


Parameters:
offset - the offset for the status
Returns:
the status hashtable
getIdStr
public String getIdStr()

Gets the id string of the first entry which is important if we want to set the id to start
with in the next request
Returns:
the id of the first entry

Method Detail

2285

Overview (Codename One API)


com.codename1.io.services

Class RSSService
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.services.RSSService
All Implemented Interfaces:
IOProgressListener, ParserCallback

public class
extends ConnectionRequest
implements ParserCallback

Simple RSS read and parse request, to handle errors just subclass this and override parsingError.

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Fields inherited from


interface com.codename1.xml.ParserCallback
ERROR_ATTIBUTE_VALUE_INVALID, ERROR_ATTRIBUTE_NOT_SUPPORTED,
ERROR_ENCODING, ERROR_MULTIPLE_ROOTS, ERROR_NO_CLOSE_TAG, ERROR_NO_ROOTS,
ERROR_TAG_NOT_SUPPORTED, ERROR_UNEXPECTED_CHARACTER,
ERROR_UNEXPECTED_TAG_CLOSING, ERROR_UNRECOGNIZED_CHAR_ENTITY

Constructor Summary
Constructor and Description
RSSService(String url)

Simple constructor accepting the RSS url


RSSService(String url, int limit)

Simple constructor accepting the RSS url


RSSService(String url, int limit, int startOffset)

Simple constructor accepting the RSS url

Method Summary
Modifier
and Type
Image

Method and Description


getIconPlaceholder()
getResults()

Vector

The results are presented as a vector of hashtables easily presentable in


Codename One
hasMore()

boolean

Indicates whether more entries might be available since the limt might have
been reached
isCreatePlainTextDetails()

boolean

Class RSSService

Creates an additional "details" attribute in the resulting hashtables which


effectively contains a plain text version of the description tag.

2286

Overview (Codename One API)


boolean

parsingError(int errorId, String tag, String attribute, String value,


String description)

Called when encountering an error while parsing the XML document.


protected
void

readResponse(InputStream input)

Callback for the server response with the input stream from the server.
setCreatePlainTextDetails(boolean createPlainTextDetails)

Creates an additional "details" attribute in the resulting hashtables which


effectively contains a plain text version of the description tag.

void
void

setIconPlaceholder(Image iconPlaceholder)

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleErrorResponseCode, handleException, handleIOException,
handleRuntimeException, hashCode, hasResponseListeners, initConnection,
initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,
kill, onRedirect, pause, postResponse, readErrorCodeHeaders, readHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
RSSService
public RSSService(String url)

Simple constructor accepting the RSS url


Parameters:
url - rss link
RSSService
public RSSService(String url,
int limit)

Simple constructor accepting the RSS url


Parameters:
url - rss link
limit - the limit on the number of RSS entries supported

Method Summary

2287

Overview (Codename One API)


RSSService
public RSSService(String url,
int limit,
int startOffset)

Simple constructor accepting the RSS url


Parameters:
url - rss link
limit - the limit on the number of RSS entries supported
startOffset - indicates the entry offset which we are interested in, this is
useful if previously the limit for RSS entries was reached.

Method Detail
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs
getResults
public Vector getResults()

The results are presented as a vector of hashtables easily presentable in Codename


One
Returns:
vector of hashtables
parsingError
public boolean parsingError(int errorId,
String tag,
String attribute,
String value,
String description)

Called when encountering an error while parsing the XML document. When
implementing this, the developer should return true if the error should be ignored and
the document needs to be further parsed, or false to stop parsing and issue an error
to the user Note that this method is always called NOT on the EDT thread.
Specified by:
parsingError in interface ParserCallback
Parameters:
errorId - The error ID, one of the ERROR_* constants
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)
value - The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Returns:
true to continue parsing, false to stop
hasMore
public boolean hasMore()

Constructor Detail

2288

Overview (Codename One API)


Indicates whether more entries might be available since the limt might have been
reached
Returns:
the hasMore
isCreatePlainTextDetails
public boolean isCreatePlainTextDetails()

Creates an additional "details" attribute in the resulting hashtables which effectively


contains a plain text version of the description tag.
Returns:
the createPlainTextDetails
setCreatePlainTextDetails
public void setCreatePlainTextDetails(boolean createPlainTextDetails)

Creates an additional "details" attribute in the resulting hashtables which effectively


contains a plain text version of the description tag.
Parameters:
createPlainTextDetails - the createPlainTextDetails to set
getIconPlaceholder
public Image getIconPlaceholder()

Returns:
the iconPlaceholder
setIconPlaceholder
public void setIconPlaceholder(Image iconPlaceholder)

Parameters:
iconPlaceholder

Method Detail

- the iconPlaceholder to set

2289

Overview (Codename One API)


com.codename1.io.services

Class ImageDownloadService
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.services.ImageDownloadService
All Implemented Interfaces:
IOProgressListener
Deprecated.
this class uses an unconventional storage mechanism and has many issues, we recommend
replacing it with the simpler and more powerful URLImage or Util.dowloadFileTo* calls.
public class
extends ConnectionRequest

Simplifies the process of implementing an image link for labels and lists by binding a request to a
component. On the completion of the request a Codename One encoded image is created and
installs itself into the given component. For the case of a Label this is seamless, in case of a List
renderer the model or the renderer must register itself as a listener and update the data when the
response arrives.
See Also:
URLImage, Util.downloadUrlToFile(java.lang.String, java.lang.String, boolean),
Util.downloadUrlToStorage(java.lang.String, java.lang.String, boolean)

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Constructor and Description
ImageDownloadService(String url, ActionListener l)

Deprecated.
Accepts the url to bind to the list renderer, on completion the action listener will be invoked
with the image so a list can be updated with the data
ImageDownloadService(String url, Component targetList, int targetOffset,
String targetKey)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives.
ImageDownloadService(String url, Label parentLabel)

Deprecated.
Accepts the url to bind to the label, on completion the label will be updated and revalidated
with the new image.
ImageDownloadService(String url, List targetList, int targetOffset,
String targetKey)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives.

Method Summary

Class ImageDownloadService

2290

Overview (Codename One API)


Modifier and
Type

Method and Description


addErrorListener(ActionListener listener)

static void

Deprecated.
Binds an error listener that will fire an instance of NetworkEvent with an error
for a specific fetch operation if applicable
createImageToFileSystem(String url, ActionListener callback,
String destFile)

static void

Deprecated.
Constructs an image request that will automatically populate the given Label
when the response arrives, it will cache the file locally.
createImageToFileSystem(String url, Component targetList,
int targetOffset, String targetKey, String destFile,
Dimension toScale, byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToFileSystem(String url, Component targetList,
int targetOffset, String targetKey, String destFile,
Image placeholder, byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToFileSystem(String url, Component targetList,
ListModel model, int targetOffset, String targetKey,
String destFile, Image placeholder, byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToFileSystem(String url, List targetList,
int targetOffset, String targetKey, String destFile,
Dimension toScale)

static void

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToStorage(String url, ActionListener callback,
String cacheId)

Deprecated.
createImageToStorage(String url, ActionListener callback,
String cacheId, boolean keep)

static void

Deprecated.
Constructs an image request that will automatically populate the given Label
when the response arrives, it will cache the file locally.
createImageToStorage(String url, Component targetList,
int targetOffset, String targetKey, String cacheId, Dimension scale,
byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToStorage(String url, Component targetList,
int targetOffset, String targetKey, String cacheId,
Image placeholderImage, byte priority)

static void

static void

Method Summary

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToStorage(String url, Component targetList,
ListModel model, int targetOffset, String targetKey, String cacheId,
Image placeholderImage, byte priority)

2291

Overview (Codename One API)


Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
createImageToStorage(String url, Label l, String cacheId,
Dimension toScale)
static void

Deprecated.
Constructs an image request that will automatically populate the given Label
when the response arrives, it will cache the file locally to the Storage
createImageToStorage(String url, Label l, String cacheId,
Dimension toScale, byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given Label
when the response arrives, it will cache the file locally to the Storage
createImageToStorage(String url, Label l, String cacheId,
Image placeholder, byte priority)

static void

Deprecated.
Constructs an image request that will automatically populate the given Label
when the response arrives, it will cache the file locally to the Storage
createImageToStorage(String url, List targetList, int targetOffset,
String targetKey, String cacheId, Dimension scale)

static void

Deprecated.
Constructs an image request that will automatically populate the given list
when the response arrives, it will cache the file locally as a file in the file
storage.
equals(Object o)

boolean

Deprecated.
Indicates whether some other object is "equal to" this one.
getDefaultTimeout()

static int

Deprecated.
Indicates the default timeout to use for image download service, -1 indicates
no default is set.
getResult()

EncodedImage

Deprecated.
Returns the image returned from the server, this method is useful for
renderers
handleErrorResponseCode(int code, String message)

protected
void

Deprecated.
Handles a server response code that is not 200 and not a redirect (unless
redirect handling is disabled)
handleException(Exception err)

protected
void

Deprecated.
Handles an exception thrown when performing a network operation, the
default implementation shows a retry dialog.
isAlwaysRevalidate()

static
boolean

static
boolean

Deprecated.
By default lists don't revalidate on every change to avoid "jumpiness" when
scrolling
isDefaultMaintainAspectRatio()

Deprecated.
isDownloadToStyles()

boolean

static
boolean

Deprecated.
Downloads the image to the style objects associated with this component,
effectively sets the bgImage property on all the styles for the component
instead of invoking setIcon
isFastScale()

Deprecated.
Fast scaling uses runtime draw scaling rather than the Image scaled method.
isMaintainAspectRatio()

boolean

Method Summary

Deprecated.

2292

Overview (Codename One API)


postResponse()
protected
void

protected
void

Deprecated.
A callback method that's invoked on the EDT after the readResponse()
method has finished, this is the place where developers should change their
Codename One user interface to avoid race conditions that might be
triggered by modifications within readResponse.
readResponse(InputStream input)

Deprecated.
Callback for the server response with the input stream from the server.
removeErrorListener(ActionListener listener)

static void

Deprecated.
Unbinds an error listener that will fire an instance of NetworkEvent with an
error for a specific fetch operation if applicable
setAlwaysRevalidate(boolean aAlwaysRevalidate)

static void

Deprecated.
By default lists don't revalidate on every change to avoid "jumpiness" when
scrolling
setDefaultMaintainAspectRatio(boolean aDefaultMaintainAspectRatio)

static void

Deprecated.
setDefaultTimeout(int aDefaultTimeout)

static void

Deprecated.
Indicates the default timeout to use for image download service, -1 indicates
no default is set.
setDownloadToStyles(boolean downloadToStyles)

Deprecated.
Downloads the image to the style objects associated with this component,
effectively sets the bgImage property on all the styles for the component
instead of invoking setIcon

void

setEntryInListModel(int offset, Image img)


protected
void

Deprecated.
This method is invoked when an image finished downloading and should be
set to an offset in the list model.
setFastScale(boolean aFastScale)

static void

Deprecated.
Fast scaling uses runtime draw scaling rather than the Image scaled method.
setMaintainAspectRatio(boolean maintainAspectRatio)

Deprecated.

void

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, fetchJSON,
fireResponseListener, getContentLength, getContentType, getCookieHeader,
getDefaultUserAgent, getDestinationFile, getDestinationStorage,
getDisposeOnCompletion, getHeader, getHeaderFieldNames, getHeaders,
getHttpMethod, getPriority, getResponseCode, getResponseContentType,
getResponseData, getResposeCode, getShowOnInit, getSilentRetryCount,
getTimeout, getUrl, getUserAgent, getYield, handleIOException,
handleRuntimeException, hashCode, hasResponseListeners, initConnection,
initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,
kill, onRedirect, pause, readErrorCodeHeaders, readHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,

Methods inherited from class com.codename1.io.ConnectionRequest

2293

Overview (Codename One API)


setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ImageDownloadService
public ImageDownloadService(String url,
ActionListener l)

Deprecated.
Accepts the url to bind to the list renderer, on completion the action listener will be
invoked with the image so a list can be updated with the data
Parameters:
url - the image URL
l - an action listener callback
ImageDownloadService
public ImageDownloadService(String url,
Component targetList,
int targetOffset,
String targetKey)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives. This assumes the GenericListCellRenderer style of list which relies
on a map based model approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
ImageDownloadService
public ImageDownloadService(String url,
List targetList,
int targetOffset,
String targetKey)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives. This assumes the GenericListCellRenderer style of list which relies
on a Map based model approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
ImageDownloadService
public ImageDownloadService(String url,
Label parentLabel)

Deprecated.
Accepts the url to bind to the label, on completion the label will be updated and
revalidated with the new image.
Parameters:
url - the image URL
parentLabel - the label to update

Methods inherited from class java.lang.Object

2294

Overview (Codename One API)

Method Detail
isFastScale
public static boolean isFastScale()

Deprecated.
Fast scaling uses runtime draw scaling rather than the Image scaled method. This
works better on smartphones but doesn't work well on feature phones
Returns:
the fastScale
setFastScale
public static void setFastScale(boolean aFastScale)

Deprecated.
Fast scaling uses runtime draw scaling rather than the Image scaled method. This
works better on smartphones but doesn't work well on feature phones
Parameters:
aFastScale - the fastScale to set
isAlwaysRevalidate
public static boolean isAlwaysRevalidate()

Deprecated.
By default lists don't revalidate on every change to avoid "jumpiness" when scrolling
Returns:
the alwaysRevalidate
setAlwaysRevalidate
public static void setAlwaysRevalidate(boolean aAlwaysRevalidate)

Deprecated.
By default lists don't revalidate on every change to avoid "jumpiness" when scrolling
Parameters:
aAlwaysRevalidate - the alwaysRevalidate to set
isDefaultMaintainAspectRatio
public static boolean isDefaultMaintainAspectRatio()

Deprecated.
Returns:
the defaultMaintainAspectRatio
setDefaultMaintainAspectRatio

public static void setDefaultMaintainAspectRatio(boolean aDefaultMaintainAspectRatio

Deprecated.
Parameters:
aDefaultMaintainAspectRatio

- the defaultMaintainAspectRatio to set

getDefaultTimeout
public static int getDefaultTimeout()

Deprecated.
Indicates the default timeout to use for image download service, -1 indicates no
default is set.
Returns:
the defaultTimeout
setDefaultTimeout
public static void setDefaultTimeout(int aDefaultTimeout)

Deprecated.
Indicates the default timeout to use for image download service, -1 indicates no
default is set.

Method Detail

2295

Overview (Codename One API)


Parameters:
aDefaultTimeout

- the defaultTimeout to set

setEntryInListModel
protected void setEntryInListModel(int offset,
Image img)

Deprecated.
This method is invoked when an image finished downloading and should be set to an
offset in the list model. This is useful for special cases with complex list model
hierarchies or proxies.
Parameters:
offset - the offset in the list given when creating the service
img - the image
createImageToFileSystem
public static void createImageToFileSystem(String url,
List targetList,
int targetOffset,
String targetKey,
String destFile,
Dimension toScale)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
destFile - local file to store the data into the given path
createImageToFileSystem
public static void createImageToFileSystem(String url,
Component targetList,
int targetOffset,
String targetKey,
String destFile,
Dimension toScale,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
destFile - local file to store the data into the given path
createImageToFileSystem
public static void createImageToFileSystem(String url,
Component targetList,
int targetOffset,
String targetKey,
String destFile,
Image placeholder,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model

Method Detail

2296

Overview (Codename One API)


approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
destFile - local file to store the data into the given path
createImageToFileSystem
public static void createImageToFileSystem(String url,
Component targetList,
ListModel model,
int targetOffset,
String targetKey,
String destFile,
Image placeholder,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
model - the list model
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
destFile - local file to store the data into the given path
handleException
protected void handleException(Exception err)

Deprecated.
Handles an exception thrown when performing a network operation, the default
implementation shows a retry dialog.
Overrides:
handleException in class ConnectionRequest
Parameters:
err - the exception thrown
handleErrorResponseCode
protected void handleErrorResponseCode(int code,
String message)

Deprecated.
Handles a server response code that is not 200 and not a redirect (unless redirect
handling is disabled)
Overrides:
handleErrorResponseCode in class ConnectionRequest
Parameters:
code - the response code from the server
message - the response message from the server
addErrorListener
public static void addErrorListener(ActionListener listener)

Deprecated.
Binds an error listener that will fire an instance of NetworkEvent with an error for a
specific fetch operation if applicable
Parameters:
listener - the listener
removeErrorListener
public static void removeErrorListener(ActionListener listener)

Deprecated.

Method Detail

2297

Overview (Codename One API)


Unbinds an error listener that will fire an instance of NetworkEvent with an error for a
specific fetch operation if applicable
Parameters:
listener - the listener
createImageToStorage
public static void createImageToStorage(String url,
List targetList,
int targetOffset,
String targetKey,
String cacheId,
Dimension scale)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
cacheId - a unique identifier to be used to store the image into storage
scale - the scale of the image to put in the List or null
createImageToStorage
public static void createImageToStorage(String url,
Component targetList,
int targetOffset,
String targetKey,
String cacheId,
Dimension scale,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
cacheId - a unique identifier to be used to store the image into storage
scale - the scale of the image to put in the List or null
createImageToStorage
public static void createImageToStorage(String url,
Component targetList,
int targetOffset,
String targetKey,
String cacheId,
Image placeholderImage,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
cacheId - a unique identifier to be used to store the image into storage
placeholderImage - the image placeholder

Method Detail

2298

Overview (Codename One API)


createImageToStorage
public static void createImageToStorage(String url,
Component targetList,
ListModel model,
int targetOffset,
String targetKey,
String cacheId,
Image placeholderImage,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given list when the
response arrives, it will cache the file locally as a file in the file storage. This assumes
the GenericListCellRenderer style of list which relies on a map based model
approach.
Parameters:
url - the image URL
targetList - the list that should be updated when the data arrives
model - the model destination
targetOffset - the offset within the list to insert the image
targetKey - the key for the map in the target offset
cacheId - a unique identifier to be used to store the image into storage
placeholderImage - the image placeholder
createImageToStorage
public static void createImageToStorage(String url,
Label l,
String cacheId,
Dimension toScale)

Deprecated.
Constructs an image request that will automatically populate the given Label when
the response arrives, it will cache the file locally to the Storage
Parameters:
url - the image URL
l - the Label that should be updated when the data arrives to just use storage
and the url as the key
cacheId - a unique identifier to be used to store the image into storage
toScale - the scale dimension or null
createImageToStorage
public static void createImageToStorage(String url,
Label l,
String cacheId,
Dimension toScale,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given Label when
the response arrives, it will cache the file locally to the Storage
Parameters:
url - the image URL
l - the Label that should be updated when the data arrives to just use storage
and the url as the key
cacheId - a unique identifier to be used to store the image into storage
toScale - the scale dimension or null
priority - the priority for the task
createImageToStorage
public static void createImageToStorage(String url,
Label l,
String cacheId,
Image placeholder,
byte priority)

Deprecated.
Constructs an image request that will automatically populate the given Label when
the response arrives, it will cache the file locally to the Storage

Method Detail

2299

Overview (Codename One API)


Parameters:
url - the image URL
l - the Label that should be updated when the data arrives to just use storage
and the url as the key
cacheId - a unique identifier to be used to store the image into storage
placeholder - the image that will appear as a placeholder
priority - the priority for the task
createImageToFileSystem
public static void createImageToFileSystem(String url,
ActionListener callback,
String destFile)

Deprecated.
Constructs an image request that will automatically populate the given Label when
the response arrives, it will cache the file locally.
Parameters:
url - the image URL
callback - the callback that should be updated when the data arrives
destFile - local file to store the data into the given path
createImageToStorage
public static void createImageToStorage(String url,
ActionListener callback,
String cacheId)

Deprecated.
createImageToStorage
public static void createImageToStorage(String url,
ActionListener callback,
String cacheId,
boolean keep)

Deprecated.
Constructs an image request that will automatically populate the given Label when
the response arrives, it will cache the file locally.
Parameters:
url - the image URL
callback - the callback that should be updated when the data arrives
cacheId - a unique identifier to be used to store the image into storage
keep - if set to true keeps the file in RAM once loaded
postResponse
protected void postResponse()

Deprecated.
A callback method that's invoked on the EDT after the readResponse() method has
finished, this is the place where developers should change their Codename One user
interface to avoid race conditions that might be triggered by modifications within
readResponse. Notice this method is only invoked on a successful response and will
not be invoked in case of a failure.
Overrides:
postResponse in class ConnectionRequest
readResponse
protected void readResponse(InputStream input)
throws IOException

Deprecated.
Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs

Method Detail

2300

Overview (Codename One API)

getResult
public EncodedImage getResult()

Deprecated.
Returns the image returned from the server, this method is useful for renderers
Returns:
the result
isDownloadToStyles
public boolean isDownloadToStyles()

Deprecated.
Downloads the image to the style objects associated with this component, effectively
sets the bgImage property on all the styles for the component instead of invoking
setIcon
Returns:
the downloadToStyles
setDownloadToStyles
public void setDownloadToStyles(boolean downloadToStyles)

Deprecated.
Downloads the image to the style objects associated with this component, effectively
sets the bgImage property on all the styles for the component instead of invoking
setIcon
Parameters:
downloadToStyles - the downloadToStyles to set
equals
public boolean equals(Object o)

Deprecated.
Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class ConnectionRequest
isMaintainAspectRatio
public boolean isMaintainAspectRatio()

Deprecated.
Returns:
the maintainAspectRatio
setMaintainAspectRatio
public void setMaintainAspectRatio(boolean maintainAspectRatio)

Deprecated.
Parameters:
maintainAspectRatio

Method Detail

- the maintainAspectRatio to set

2301

Overview (Codename One API)


com.codename1.io.services

Class CachedDataService
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.services.CachedDataService
All Implemented Interfaces:
IOProgressListener

public class
extends ConnectionRequest

Simple service that allows downloading and caching data locally. When the data is requested again
the server is queried with a conditional get query.

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Method Summary
Modifier and
Type
protected
void
protected
void
protected
void
protected
void

Method and Description


handleErrorResponseCode(int code, String message)

Handles a server response code that is not 200 and not a redirect (unless
redirect handling is disabled)
handleException(Exception err)

Handles an exception thrown when performing a network operation, the


default implementation shows a retry dialog.
readHeaders(Object connection)

Allows reading the headers from the connection by calling the getHeader()
method.
readResponse(InputStream input)

Callback for the server response with the input stream from the server.
register()

static void

Makes sure the cached data class is properly registered as an


externalizable.
updateData(CachedData d, ActionListener callback)

static void

Checks that the cached data is up to date and if a newer version exits it
updates the data in place

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleIOException, handleRuntimeException, hashCode,

Class CachedDataService

2302

Overview (Codename One API)


hasResponseListeners, initConnection, initCookieHeader, ioStreamUpdate,
isCookiesEnabled, isCookiesEnabledDefault, isDefaultFollowRedirects,
isDuplicateSupported, isFailSilently, isFollowRedirects, isKilled,
isPausable, isPaused, isPost, isReadRequest, isReadResponseForErrors,
isRedirecting, isWriteRequest, kill, onRedirect, pause, postResponse,
readErrorCodeHeaders, removeAllArguments, removeArgument,
removeResponseCodeListener, removeResponseListener, resume, retry,
setChunkedStreamingMode, setContentType, setCookieHeader,
setCookiesEnabled, setCookiesEnabledDefault, setDefaultFollowRedirects,
setDefaultUserAgent, setDestinationFile, setDestinationStorage,
setDisposeOnCompletion, setDuplicateSupported, setFailSilently,
setFollowRedirects, setHttpMethod, setKilled, setPaused, setPost,
setPriority, setReadRequest, setReadResponseForErrors, setShowOnInit,
setSilentRetryCount, setTimeout, setUrl, setUseNativeCookieStore,
setUserAgent, setWriteRequest, shouldAutoCloseResponse,
shouldConvertPostToGetOnRedirect, shouldStop, shouldWriteUTFAsGetBytes,
validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Method Detail
register
public static void register()

Makes sure the cached data class is properly registered as an externalizable. This
must be invoked for caching to work
updateData
public static void updateData(CachedData d,
ActionListener callback)

Checks that the cached data is up to date and if a newer version exits it updates the
data in place
Parameters:
d - the data to check
callback - optional callback to be invoked on request completion
handleException
protected void handleException(Exception err)

Handles an exception thrown when performing a network operation, the default


implementation shows a retry dialog.
Overrides:
handleException in class ConnectionRequest
Parameters:
err - the exception thrown
handleErrorResponseCode
protected void handleErrorResponseCode(int code,
String message)

Handles a server response code that is not 200 and not a redirect (unless redirect
handling is disabled)
Overrides:
handleErrorResponseCode in class ConnectionRequest
Parameters:
code - the response code from the server
message - the response message from the server
readHeaders
protected void readHeaders(Object connection)
throws IOException

Methods inherited fromclass com.codename1.io.ConnectionRequest

2303

Overview (Codename One API)


Allows reading the headers from the connection by calling the getHeader() method.
Overrides:
readHeaders in class ConnectionRequest
Parameters:
connection - used when invoking getHeader
Throws:
IOException - thrown on failure
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs

Method Detail

2304

Overview (Codename One API)


com.codename1.io.services

Class CachedData
java.lang.Object

com.codename1.io.services.CachedData
All Implemented Interfaces:
Externalizable

public class
extends Object
implements Externalizable

Cached data class for use with the cached data service

Constructor Summary
Constructor and Description
CachedData()

Method Summary
Modifier
and Type

Method and Description


externalize(DataOutputStream out)

void

Allows us to store an object state, this method must be implemented in order to


save the state of an object

byte[]

getData()
getObjectId()

String

The object id must be unique, it is used to identify the object when loaded even
when it is obfuscated.

String

getUrl()
getVersion()

Returns the version for the current persistance code, the version will be pased
to internalized thus allowing the internalize method to recognize classes
persisted in older revisions

int

internalize(int version, DataInputStream in)

void

Loads the object from the input stream and allows deserialization

void

setData(byte[] data)

void

setUrl(String url)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CachedData
public CachedData()

Class CachedData

2305

Overview (Codename One API)

Method Detail
getVersion
public int getVersion()

Returns the version for the current persistance code, the version will be pased to
internalized thus allowing the internalize method to recognize classes persisted in
older revisions
Specified by:
getVersion in interface Externalizable
Returns:
version number for the persistant code
externalize
public void externalize(DataOutputStream out)
throws IOException

Allows us to store an object state, this method must be implemented in order to save
the state of an object
Specified by:
externalize in interface Externalizable
Parameters:
out - the stream into which the object must be serialized
Throws:
IOException - the method may throw an exception
internalize
public void internalize(int version,
DataInputStream in)
throws IOException

Loads the object from the input stream and allows deserialization
Specified by:
internalize in interface Externalizable
Parameters:
version - the version the class returned during the externalization processs
in - the input stream used to load the class
Throws:
IOException - the method may throw an exception
getObjectId
public String getObjectId()

Description copied from interface: Externalizable


The object id must be unique, it is used to identify the object when loaded even when
it is obfuscated.
Specified by:
getObjectId in interface Externalizable
Returns:
a unique id
getData
public byte[] getData()

Returns:
the data
setData
public void setData(byte[] data)

Parameters:
data

Method Detail

- the data to set

2306

Overview (Codename One API)

getUrl
public String getUrl()

Returns:
the url
setUrl
public void setUrl(String url)

Parameters:
url - the url to set

Method Detail

2307

Overview (Codename One API)


com.codename1.io.gzip

Class ZStream
java.lang.Object

com.codename1.io.gzip.ZStream
Direct Known Subclasses:
Deflater, Inflater
Deprecated.
Not for public use in the future.
@Deprecated
public class
extends Object

ZStream

Field Summary
Modifier and Type Field and Description
avail_in

Deprecated.

int

avail_out

Deprecated.

int

msg

Deprecated.

String

next_in

Deprecated.

byte[]

next_in_index

Deprecated.

int

next_out

Deprecated.

byte[]

next_out_index

Deprecated.

int

total_in

Deprecated.

long

total_out

Deprecated.

long

Constructor Summary
Constructor and Description
ZStream()

Deprecated.
ZStream(com.codename1.io.gzip.Checksum adler)

Deprecated.

Class ZStream

2308

Overview (Codename One API)

Method Summary
Modifier
and Type

Method and Description


deflate(int flush)

int

Deprecated.
deflateEnd()

int

Deprecated.
deflateInit(int level)

int

Deprecated.
deflateInit(int level, boolean nowrap)

int

Deprecated.
deflateInit(int level, int bits)

int

Deprecated.
deflateInit(int level, int bits, boolean nowrap)

int

Deprecated.
deflateInit(int level, int bits, int memlevel)

int

int

Deprecated.
deflateInit(int level, int bits, int memlevel,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Deprecated.
deflateParams(int level, int strategy)

int

Deprecated.
deflateSetDictionary(byte[] dictionary, int dictLength)

int

Deprecated.
end()

int

Deprecated.
Those methods are expected to be override by Inflater and Deflater.
finished()

boolean

Deprecated.
free()

void

Deprecated.
getAdler()

long

Deprecated.
getAvailIn()

int

Deprecated.
getAvailOut()

int

Deprecated.
getMessage()

String

Deprecated.

byte[]

getNextIn()

Constructor Summary

2309

Overview (Codename One API)


Deprecated.
getNextInIndex()
int

Deprecated.
getNextOut()

byte[]

Deprecated.
getNextOutIndex()

int

Deprecated.
getTotalIn()

long

Deprecated.
getTotalOut()

long

Deprecated.
inflate(int f)

int

Deprecated.
inflateEnd()

int

Deprecated.
inflateFinished()

boolean

Deprecated.
inflateInit()

int

Deprecated.
inflateInit(boolean nowrap)

int

Deprecated.
inflateInit(int w)

int

Deprecated.
inflateInit(int w, boolean nowrap)

int

Deprecated.
inflateInit(int w, com.codename1.io.gzip.JZlib.WrapperType wrapperType)

int

Deprecated.
inflateInit(com.codename1.io.gzip.JZlib.WrapperType wrapperType)

int

Deprecated.
inflateSetDictionary(byte[] dictionary, int dictLength)

int

Deprecated.
inflateSync()

int

Deprecated.
inflateSyncPoint()

int

Deprecated.
setAvailIn(int avail_in)

void

Deprecated.
setAvailOut(int avail_out)

void

Deprecated.

void

setInput(byte[] buf)

Method Summary

2310

Overview (Codename One API)


Deprecated.
setInput(byte[] buf, boolean append)

Deprecated.

void

setInput(byte[] buf, int off, int len, boolean append)

Deprecated.

void

setNextIn(byte[] next_in)

Deprecated.

void

setNextInIndex(int next_in_index)

Deprecated.

void

setNextOut(byte[] next_out)

Deprecated.

void

setNextOutIndex(int next_out_index)

Deprecated.

void

setOutput(byte[] buf)

Deprecated.

void

setOutput(byte[] buf, int off, int len)

Deprecated.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
next_in
public byte[] next_in

Deprecated.
next_in_index
public int next_in_index

Deprecated.
avail_in
public int avail_in

Deprecated.
total_in
public long total_in

Deprecated.
next_out
public byte[] next_out

Deprecated.

Methods inherited from class java.lang.Object

2311

Overview (Codename One API)


next_out_index
public int next_out_index

Deprecated.
avail_out
public int avail_out

Deprecated.
total_out
public long total_out

Deprecated.
msg
public String msg

Deprecated.

Constructor Detail
ZStream
public ZStream()

Deprecated.
ZStream
public ZStream(com.codename1.io.gzip.Checksum adler)

Deprecated.

Method Detail
inflateInit
public int inflateInit()

Deprecated.
inflateInit
public int inflateInit(boolean nowrap)

Deprecated.
inflateInit
public int inflateInit(int w)

Deprecated.
inflateInit
public int inflateInit(com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Deprecated.
inflateInit
public int inflateInit(int w,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Deprecated.

Field Detail

2312

Overview (Codename One API)


inflateInit
public int inflateInit(int w,
boolean nowrap)

Deprecated.
inflate
public int inflate(int f)

Deprecated.
inflateEnd
public int inflateEnd()

Deprecated.
inflateSync
public int inflateSync()

Deprecated.
inflateSyncPoint
public int inflateSyncPoint()

Deprecated.
inflateSetDictionary
public int inflateSetDictionary(byte[] dictionary,
int dictLength)

Deprecated.
inflateFinished
public boolean inflateFinished()

Deprecated.
deflateInit
public int deflateInit(int level)

Deprecated.
deflateInit
public int deflateInit(int level,
boolean nowrap)

Deprecated.
deflateInit
public int deflateInit(int level,
int bits)

Deprecated.
deflateInit
public int deflateInit(int level,
int bits,
int memlevel,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Deprecated.
deflateInit
public int deflateInit(int level,
int bits,
int memlevel)

Deprecated.

Method Detail

2313

Overview (Codename One API)


deflateInit
public int deflateInit(int level,
int bits,
boolean nowrap)

Deprecated.
deflate
public int deflate(int flush)

Deprecated.
deflateEnd
public int deflateEnd()

Deprecated.
deflateParams
public int deflateParams(int level,
int strategy)

Deprecated.
deflateSetDictionary
public int deflateSetDictionary(byte[] dictionary,
int dictLength)

Deprecated.
getAdler
public long getAdler()

Deprecated.
free
public void free()

Deprecated.
setOutput
public void setOutput(byte[] buf)

Deprecated.
setOutput
public void setOutput(byte[] buf,
int off,
int len)

Deprecated.
setInput
public void setInput(byte[] buf)

Deprecated.
setInput
public void setInput(byte[] buf,
boolean append)

Deprecated.
setInput
public void setInput(byte[] buf,
int off,
int len,
boolean append)

Method Detail

2314

Overview (Codename One API)


Deprecated.
getNextIn
public byte[] getNextIn()

Deprecated.
setNextIn
public void setNextIn(byte[] next_in)

Deprecated.
getNextInIndex
public int getNextInIndex()

Deprecated.
setNextInIndex
public void setNextInIndex(int next_in_index)

Deprecated.
getAvailIn
public int getAvailIn()

Deprecated.
setAvailIn
public void setAvailIn(int avail_in)

Deprecated.
getNextOut
public byte[] getNextOut()

Deprecated.
setNextOut
public void setNextOut(byte[] next_out)

Deprecated.
getNextOutIndex
public int getNextOutIndex()

Deprecated.
setNextOutIndex
public void setNextOutIndex(int next_out_index)

Deprecated.
getAvailOut
public int getAvailOut()

Deprecated.
setAvailOut
public void setAvailOut(int avail_out)

Deprecated.
getTotalOut
public long getTotalOut()

Deprecated.

Method Detail

2315

Overview (Codename One API)


getTotalIn
public long getTotalIn()

Deprecated.
getMessage
public String getMessage()

Deprecated.
end
public int end()

Deprecated.
Those methods are expected to be override by Inflater and Deflater. In the future,
they will become abstract methods.
finished
public boolean finished()

Deprecated.

Method Detail

2316

Overview (Codename One API)


com.codename1.io.gzip

Class JZlib
java.lang.Object

com.codename1.io.gzip.JZlib

public final class


extends Object

Field Summary
Modifier and Type

Field and Description

static int

DEF_WBITS

static int

MAX_WBITS

static com.codename1.io.gzip.JZlib.WrapperType W_ANY


static com.codename1.io.gzip.JZlib.WrapperType W_GZIP
static com.codename1.io.gzip.JZlib.WrapperType W_NONE
static com.codename1.io.gzip.JZlib.WrapperType W_ZLIB
static byte

Z_ASCII

static int

Z_BEST_COMPRESSION

static int

Z_BEST_SPEED

static byte

Z_BINARY

static int

Z_BUF_ERROR

static int

Z_DATA_ERROR

static int

Z_DEFAULT_COMPRESSION

static int

Z_DEFAULT_STRATEGY

static int

Z_ERRNO

static int

Z_FILTERED

static int

Z_FINISH

static int

Z_FULL_FLUSH

static int

Z_HUFFMAN_ONLY

static int

Z_MEM_ERROR

static int

Z_NEED_DICT

static int

Z_NO_COMPRESSION

static int

Z_NO_FLUSH

static int

Z_OK

static int

Z_PARTIAL_FLUSH

static int

Z_STREAM_END

static int

Z_STREAM_ERROR

static int

Z_SYNC_FLUSH

static byte

Z_UNKNOWN

static int

Z_VERSION_ERROR

Constructor Summary

Class JZlib

2317

Overview (Codename One API)


Constructor and Description
JZlib()

Method Summary
Modifier and Type

Method and Description

static long

adler32_combine(long adler1, long adler2, long len2)

static long

crc32_combine(long crc1, long crc2, long len2)

static String

version()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
MAX_WBITS
public static final int MAX_WBITS

See Also:
Constant Field Values
DEF_WBITS
public static final int DEF_WBITS

See Also:
Constant Field Values
W_NONE
public static final com.codename1.io.gzip.JZlib.WrapperType W_NONE

W_ZLIB
public static final com.codename1.io.gzip.JZlib.WrapperType W_ZLIB

W_GZIP
public static final com.codename1.io.gzip.JZlib.WrapperType W_GZIP

W_ANY
public static final com.codename1.io.gzip.JZlib.WrapperType W_ANY

Z_NO_COMPRESSION
public static final int Z_NO_COMPRESSION

See Also:
Constant Field Values
Z_BEST_SPEED
public static final int Z_BEST_SPEED

See Also:
Constant Field Values
Z_BEST_COMPRESSION
public static final int Z_BEST_COMPRESSION

See Also:
Constant Field Values

Constructor Summary

2318

Overview (Codename One API)


Z_DEFAULT_COMPRESSION
public static final int Z_DEFAULT_COMPRESSION

See Also:
Constant Field Values
Z_FILTERED
public static final int Z_FILTERED

See Also:
Constant Field Values
Z_HUFFMAN_ONLY
public static final int Z_HUFFMAN_ONLY

See Also:
Constant Field Values
Z_DEFAULT_STRATEGY
public static final int Z_DEFAULT_STRATEGY

See Also:
Constant Field Values
Z_NO_FLUSH
public static final int Z_NO_FLUSH

See Also:
Constant Field Values
Z_PARTIAL_FLUSH
public static final int Z_PARTIAL_FLUSH

See Also:
Constant Field Values
Z_SYNC_FLUSH
public static final int Z_SYNC_FLUSH

See Also:
Constant Field Values
Z_FULL_FLUSH
public static final int Z_FULL_FLUSH

See Also:
Constant Field Values
Z_FINISH
public static final int Z_FINISH

See Also:
Constant Field Values
Z_OK
public static final int Z_OK

See Also:
Constant Field Values
Z_STREAM_END
public static final int Z_STREAM_END

See Also:
Constant Field Values

Field Detail

2319

Overview (Codename One API)


Z_NEED_DICT
public static final int Z_NEED_DICT

See Also:
Constant Field Values
Z_ERRNO
public static final int Z_ERRNO

See Also:
Constant Field Values
Z_STREAM_ERROR
public static final int Z_STREAM_ERROR

See Also:
Constant Field Values
Z_DATA_ERROR
public static final int Z_DATA_ERROR

See Also:
Constant Field Values
Z_MEM_ERROR
public static final int Z_MEM_ERROR

See Also:
Constant Field Values
Z_BUF_ERROR
public static final int Z_BUF_ERROR

See Also:
Constant Field Values
Z_VERSION_ERROR
public static final int Z_VERSION_ERROR

See Also:
Constant Field Values
Z_BINARY
public static final byte Z_BINARY

See Also:
Constant Field Values
Z_ASCII
public static final byte Z_ASCII

See Also:
Constant Field Values
Z_UNKNOWN
public static final byte Z_UNKNOWN

See Also:
Constant Field Values

Constructor Detail

Field Detail

2320

Overview (Codename One API)


JZlib
public JZlib()

Method Detail
version
public static String version()

adler32_combine
public static long adler32_combine(long adler1,
long adler2,
long len2)

crc32_combine
public static long crc32_combine(long crc1,
long crc2,
long len2)

Constructor Detail

2321

Overview (Codename One API)


com.codename1.io.gzip

Class InflaterInputStream
java.lang.Object

java.io.InputStream

com.codename1.io.gzip.FilterInputStream

com.codename1.io.gzip.InflaterInputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
GZIPInputStream

public class
extends FilterInputStream

Field Summary
Modifier and Type
protected byte[]

Field and Description


buf

protected static int DEFAULT_BUFSIZE


protected Inflater

inflater

protected boolean

myinflater

Fields inherited from


class com.codename1.io.gzip.FilterInputStream
in

Constructor Summary
Constructor and Description
InflaterInputStream(InputStream in)
InflaterInputStream(InputStream in, boolean nowrap)
InflaterInputStream(InputStream in, Inflater inflater)
InflaterInputStream(InputStream in, Inflater inflater, int size)
InflaterInputStream(InputStream in, Inflater inflater, int size,
boolean close_in)

Method Summary
Modifier and
Type

Method and Description


available()

int

Returns the number of bytes that can be read (or skipped over) from this
input stream without blocking by the next caller of a method for this input
stream.
close()

void
protected
void

Method Detail

Closes this input stream and releases any system resources associated with
the stream.
fill()

2322

Overview (Codename One API)


byte[]

getAvailIn()

Inflater

getInflater()

long

getTotalIn()

long

getTotalOut()
mark(int readlimit)

void

Marks the current position in this input stream.

boolean

markSupported()

Tests if this input stream supports the mark and reset methods.
read()

int

Reads the next byte of data from the input stream.


read(byte[] b, int off, int len)

int

Reads up to len bytes of data from the input stream into an array of bytes.

void

readHeader()
reset()

Repositions this stream to the position at the time the mark method was last
called on this input stream.

void

skip(long n)

long

Skips over and discards n bytes of data from this input stream.

Methods inherited from


class com.codename1.io.gzip.FilterInputStream
read

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
inflater
protected final Inflater inflater

buf
protected byte[] buf

DEFAULT_BUFSIZE
protected static final int DEFAULT_BUFSIZE

See Also:
Constant Field Values
myinflater
protected boolean myinflater

Constructor Detail
InflaterInputStream
public InflaterInputStream(InputStream in)
throws IOException

Throws:
IOException

Method Summary

2323

Overview (Codename One API)


InflaterInputStream
public InflaterInputStream(InputStream in,
boolean nowrap)
throws IOException

Throws:
IOException

InflaterInputStream
public InflaterInputStream(InputStream in,
Inflater inflater)
throws IOException

Throws:
IOException

InflaterInputStream
public InflaterInputStream(InputStream in,
Inflater inflater,
int size)
throws IOException

Throws:
IOException

InflaterInputStream
public InflaterInputStream(InputStream in,
Inflater inflater,
int size,
boolean close_in)
throws IOException

Throws:
IOException

Method Detail
read
public int read()
throws IOException

Description copied from class: InputStream


Reads the next byte of data from the input stream. The value byte is returned as an
int in the range 0 to 255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown. A subclass
must provide an implementation of this method.
Overrides:
read in class FilterInputStream
Throws:
IOException

read
public int read(byte[] b,
int off,
int len)
throws IOException

Description copied from class: InputStream


Reads up to len bytes of data from the input stream into an array of bytes. An attempt
is made to read as many as len bytes, but a smaller number may be read, possibly
zero. The number of bytes actually read is returned as an integer. This method blocks
until input data is available, end of file is detected, or an exception is thrown. If b is
null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len
is greater than the length of the array b, then an IndexOutOfBoundsException is
thrown. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an
attempt to read at least one byte. If no byte is available because the stream is at end

Constructor Detail

2324

Overview (Codename One API)


of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
The first byte read is stored into element b[off], the next one into b[off+1], and so on.
The number of bytes read is, at most, equal to len. Let k be the number of bytes
actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving
elements b[off+k] through b[off+len-1] unaffected. In every case, elements b[0]
through b[off] and elements b[off+len] through b[b.length-1] are unaffected. If the first
byte cannot be read for any reason other than end of file, then an IOException is
thrown. In particular, an IOException is thrown if the input stream has been closed.
The read(b, off, len) method for class InputStream simply calls the method read()
repeatedly. If the first such call results in an IOException, that exception is returned
from the call to the read(b, off, len) method. If any subsequent call to read() results in
a IOException, the exception is caught and treated as if it were end of file; the bytes
read up to that point are stored into b and the number of bytes read before the
exception occurred is returned. Subclasses are encouraged to provide a more
efficient implementation of this method.
Overrides:
read in class FilterInputStream
Throws:
IOException

available
public int available()
throws IOException

Description copied from class: InputStream


Returns the number of bytes that can be read (or skipped over) from this input stream
without blocking by the next caller of a method for this input stream. The next caller
might be the same thread or another thread. The available method for class
InputStream always returns 0. This method should be overridden by subclasses.
Overrides:
available in class FilterInputStream
Throws:
IOException

skip
public long skip(long n)
throws IOException

Description copied from class: InputStream


Skips over and discards n bytes of data from this input stream. The skip method may,
for a variety of reasons, end up skipping over some smaller number of bytes, possibly
0. This may result from any of a number of conditions; reaching end of file before n
bytes have been skipped is only one possibility. The actual number of bytes skipped
is returned. If n is negative, no bytes are skipped. The skip method of InputStream
creates a byte array and then repeatedly reads into it until n bytes have been read or
the end of the stream has been reached. Subclasses are encouraged to provide a
more efficient implementation of this method.
Overrides:
skip in class FilterInputStream
Throws:
IOException

close
public void close()
throws IOException

Description copied from class: InputStream


Closes this input stream and releases any system resources associated with the
stream. The close method of InputStream does nothing.
Specified by:
close in interface AutoCloseable
Overrides:
close in class FilterInputStream
Throws:
IOException

Method Detail

2325

Overview (Codename One API)


fill
protected void fill()
throws IOException

Throws:
IOException

markSupported
public boolean markSupported()

Description copied from class: InputStream


Tests if this input stream supports the mark and reset methods. The markSupported
method of InputStream returns false.
Overrides:
markSupported in class FilterInputStream
mark
public void mark(int readlimit)

Description copied from class: InputStream


Marks the current position in this input stream. A subsequent call to the reset method
repositions this stream at the last marked position so that subsequent reads re-read
the same bytes. The readlimit arguments tells this input stream to allow that many
bytes to be read before the mark position gets invalidated. The general contract of
mark is that, if the method markSupported returns true, the stream somehow
remembers all the bytes read after the call to mark and stands ready to supply those
same bytes again if and whenever the method reset is called. However, the stream is
not required to remember any data at all if more than readlimit bytes are read from
the stream before reset is called. The mark method of InputStream does nothing.
Overrides:
mark in class FilterInputStream
reset
public void reset()
throws IOException

Description copied from class: InputStream


Repositions this stream to the position at the time the mark method was last called on
this input stream. The general contract of reset is: If the method markSupported
returns true, then: If the method mark has not been called since the stream was
created, or the number of bytes read from the stream since mark was last called is
larger than the argument to mark at that last call, then an IOException might be
thrown. If such an IOException is not thrown, then the stream is reset to a state such
that all the bytes read since the most recent call to mark (or since the start of the file,
if mark has not been called) will be resupplied to subsequent callers of the read
method, followed by any bytes that otherwise would have been the next input data as
of the time of the call to reset. If the method markSupported returns false, then: The
call to reset may throw an IOException. If an IOException is not thrown, then the
stream is reset to a fixed state that depends on the particular type of the input stream
and how it was created. The bytes that will be supplied to subsequent callers of the
read method depend on the particular type of the input stream. The method reset for
class InputStream does nothing and always throws an IOException.
Overrides:
reset in class FilterInputStream
Throws:
IOException

getTotalIn
public long getTotalIn()

getTotalOut
public long getTotalOut()

Method Detail

2326

Overview (Codename One API)


getAvailIn
public byte[] getAvailIn()

readHeader
public void readHeader()
throws IOException

Throws:
IOException

getInflater
public Inflater getInflater()

Method Detail

2327

Overview (Codename One API)


com.codename1.io.gzip

Class Inflater
java.lang.Object

com.codename1.io.gzip.ZStream

com.codename1.io.gzip.Inflater

public final class


extends ZStream

Field Summary

Fields inherited from class com.codename1.io.gzip.ZStream


avail_in, avail_out, msg, next_in, next_in_index, next_out, next_out_index,
total_in, total_out

Constructor Summary
Constructor and Description
Inflater()
Inflater(boolean nowrap)
Inflater(int w)
Inflater(int w, boolean nowrap)
Inflater(int w, com.codename1.io.gzip.JZlib.WrapperType wrapperType)
Inflater(com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Method Summary
Modifier and
Type
int

Class Inflater

Method and Description


end()

Those methods are expected to be override by Inflater and Deflater.

boolean

finished()

int

inflate(int f)

int

init()

int

init(boolean nowrap)

int

init(int w)

int

init(int w, boolean nowrap)

int

init(int w,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

int

init(com.codename1.io.gzip.JZlib.WrapperType wrapperType)

int

setDictionary(byte[] dictionary, int dictLength)

int

sync()

int

syncPoint()

2328

Overview (Codename One API)


Methods

inherited from class com.codename1.io.gzip.ZStream

deflate, deflateEnd, deflateInit, deflateInit, deflateInit, deflateInit,


deflateInit, deflateInit, deflateParams, deflateSetDictionary, free,
getAdler, getAvailIn, getAvailOut, getMessage, getNextIn, getNextInIndex,
getNextOut, getNextOutIndex, getTotalIn, getTotalOut, inflateEnd,
inflateFinished, inflateInit, inflateInit, inflateInit, inflateInit,
inflateInit, inflateInit, inflateSetDictionary, inflateSync,
inflateSyncPoint, setAvailIn, setAvailOut, setInput, setInput, setInput,
setNextIn, setNextInIndex, setNextOut, setNextOutIndex, setOutput,
setOutput

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Inflater
public Inflater()

Inflater
public Inflater(com.codename1.io.gzip.JZlib.WrapperType wrapperType)
throws GZIPException

Throws:
GZIPException

Inflater
public Inflater(int w,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)
throws GZIPException

Throws:
GZIPException

Inflater
public Inflater(int w)
throws GZIPException

Throws:
GZIPException

Inflater
public Inflater(boolean nowrap)
throws GZIPException

Throws:
GZIPException

Inflater
public Inflater(int w,
boolean nowrap)
throws GZIPException

Throws:
GZIPException

Method Detail
init
public int init()

Methods inherited from class com.codename1.io.gzip.ZStream

2329

Overview (Codename One API)


init
public int init(com.codename1.io.gzip.JZlib.WrapperType wrapperType)

init
public int init(int w,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

init
public int init(boolean nowrap)

init
public int init(int w)

init
public int init(int w,
boolean nowrap)

inflate
public int inflate(int f)

Overrides:
inflate

in class ZStream

end
public int end()

Description copied from class: ZStream


Those methods are expected to be override by Inflater and Deflater. In the future,
they will become abstract methods.
Overrides:
end in class ZStream
sync
public int sync()

syncPoint
public int syncPoint()

setDictionary
public int setDictionary(byte[] dictionary,
int dictLength)

finished
public boolean finished()

Overrides:
finished

Method Detail

in class ZStream

2330

Overview (Codename One API)


com.codename1.io.gzip

Class GZIPOutputStream
java.lang.Object

java.io.OutputStream

com.codename1.io.gzip.FilterOutputStream

com.codename1.io.gzip.DeflaterOutputStream

com.codename1.io.gzip.GZIPOutputStream
All Implemented Interfaces:
AutoCloseable

public class
extends DeflaterOutputStream

Field Summary

Fields inherited from


class com.codename1.io.gzip.DeflaterOutputStream
buffer, DEFAULT_BUFSIZE, deflater, mydeflater

Fields inherited from


class com.codename1.io.gzip.FilterOutputStream
out

Constructor Summary
Constructor and Description
GZIPOutputStream(OutputStream out)
GZIPOutputStream(OutputStream out, Deflater deflater, int size,
boolean close_out)
GZIPOutputStream(OutputStream out, int size)
GZIPOutputStream(OutputStream out, int size, boolean close_out)

Method Summary
Modifier and Type

Method and Description

long

getCRC()

void

setComment(String comment)

void

setModifiedTime(long mtime)

void

setName(String name)

void

setOS(int os)

Methods inherited from


class com.codename1.io.gzip.DeflaterOutputStream
close, deflate, finish, flush, getDeflater, getSyncFlush, getTotalIn,
getTotalOut, setSyncFlush, write, write

Class GZIPOutputStream

2331

Overview (Codename One API)


Methods

inherited from
class com.codename1.io.gzip.FilterOutputStream
write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GZIPOutputStream
public GZIPOutputStream(OutputStream out)
throws IOException

Throws:
IOException

GZIPOutputStream
public GZIPOutputStream(OutputStream out,
int size)
throws IOException

Throws:
IOException

GZIPOutputStream
public GZIPOutputStream(OutputStream out,
int size,
boolean close_out)
throws IOException

Throws:
IOException

GZIPOutputStream
public GZIPOutputStream(OutputStream out,
Deflater deflater,
int size,
boolean close_out)
throws IOException

Throws:
IOException

Method Detail
setModifiedTime
public void setModifiedTime(long mtime)
throws GZIPException

Throws:
GZIPException

setOS
public void setOS(int os)
throws GZIPException

Throws:
GZIPException

Methods inherited from class com.codename1.io.gzip.FilterOutputStream

2332

Overview (Codename One API)


setName
public void setName(String name)
throws GZIPException

Throws:
GZIPException

setComment
public void setComment(String comment)
throws GZIPException

Throws:
GZIPException

getCRC
public long getCRC()
throws GZIPException

Throws:
GZIPException

Method Detail

2333

Overview (Codename One API)


com.codename1.io.gzip

Class GZIPInputStream
java.lang.Object

java.io.InputStream

com.codename1.io.gzip.FilterInputStream

com.codename1.io.gzip.InflaterInputStream

com.codename1.io.gzip.GZIPInputStream
All Implemented Interfaces:
AutoCloseable

public class
extends InflaterInputStream

Field Summary

Fields inherited from


class com.codename1.io.gzip.InflaterInputStream
buf, DEFAULT_BUFSIZE, inflater, myinflater

Fields inherited from


class com.codename1.io.gzip.FilterInputStream
in

Constructor Summary
Constructor and Description
GZIPInputStream(InputStream in)
GZIPInputStream(InputStream in, Inflater inflater, int size, boolean close_in)
GZIPInputStream(InputStream in, int size, boolean close_in)

Method Summary
Modifier and Type Method and Description
String

getComment()

long

getCRC()

long

getModifiedtime()

String

getName()

int

getOS()

void

readHeader()

Methods inherited from


class com.codename1.io.gzip.InflaterInputStream
available, close, fill, getAvailIn, getInflater, getTotalIn, getTotalOut,
mark, markSupported, read, read, reset, skip

Class GZIPInputStream

2334

Overview (Codename One API)


Methods

inherited from
class com.codename1.io.gzip.FilterInputStream
read

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GZIPInputStream
public GZIPInputStream(InputStream in)
throws IOException

Throws:
IOException

GZIPInputStream
public GZIPInputStream(InputStream in,
int size,
boolean close_in)
throws IOException

Throws:
IOException

GZIPInputStream
public GZIPInputStream(InputStream in,
Inflater inflater,
int size,
boolean close_in)
throws IOException

Throws:
IOException

Method Detail
getModifiedtime
public long getModifiedtime()

getOS
public int getOS()

getName
public String getName()

getComment
public String getComment()

getCRC
public long getCRC()
throws GZIPException

Throws:
GZIPException

readHeader
public void readHeader()
throws IOException

Overrides:
readHeader

in class InflaterInputStream

Methods inherited from class com.codename1.io.gzip.FilterInputStream

2335

Overview (Codename One API)


Throws:
IOException

Method Detail

2336

Overview (Codename One API)


com.codename1.io.gzip

Class GZIPHeader
java.lang.Object

com.codename1.io.gzip.GZIPHeader

public class
extends Object

See Also:
"http://www.ietf.org/rfc/rfc1952.txt"

Field Summary
Modifier and Type Field and Description
static byte

OS_AMIGA

static byte

OS_ATARI

static byte

OS_CPM

static byte

OS_MACOS

static byte

OS_MSDOS

static byte

OS_OS2

static byte

OS_QDOS

static byte

OS_RISCOS

static byte

OS_TOPS20

static byte

OS_UNIX

static byte

OS_UNKNOWN

static byte

OS_VMCMS

static byte

OS_VMS

static byte

OS_WIN32

static byte

OS_ZSYSTEM

Constructor Summary
Constructor and Description
GZIPHeader()

Method Summary
Modifier and Type

Method and Description

Object

clone()

String

getComment()

long

getCRC()

long

getModifiedTime()

String

getName()

int

getOS()

void

setComment(String comment)

Class GZIPHeader

2337

Overview (Codename One API)


void

setCRC(long crc)

void

setModifiedTime(long mtime)

void

setName(String name)

void

setOS(int os)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
OS_MSDOS
public static final byte OS_MSDOS

See Also:
Constant Field Values
OS_AMIGA
public static final byte OS_AMIGA

See Also:
Constant Field Values
OS_VMS
public static final byte OS_VMS

See Also:
Constant Field Values
OS_UNIX
public static final byte OS_UNIX

See Also:
Constant Field Values
OS_ATARI
public static final byte OS_ATARI

See Also:
Constant Field Values
OS_OS2
public static final byte OS_OS2

See Also:
Constant Field Values
OS_MACOS
public static final byte OS_MACOS

See Also:
Constant Field Values
OS_TOPS20
public static final byte OS_TOPS20

See Also:
Constant Field Values

Method Summary

2338

Overview (Codename One API)


OS_WIN32
public static final byte OS_WIN32

See Also:
Constant Field Values
OS_VMCMS
public static final byte OS_VMCMS

See Also:
Constant Field Values
OS_ZSYSTEM
public static final byte OS_ZSYSTEM

See Also:
Constant Field Values
OS_CPM
public static final byte OS_CPM

See Also:
Constant Field Values
OS_QDOS
public static final byte OS_QDOS

See Also:
Constant Field Values
OS_RISCOS
public static final byte OS_RISCOS

See Also:
Constant Field Values
OS_UNKNOWN
public static final byte OS_UNKNOWN

See Also:
Constant Field Values

Constructor Detail
GZIPHeader
public GZIPHeader()

Method Detail
setModifiedTime
public void setModifiedTime(long mtime)

getModifiedTime
public long getModifiedTime()

setOS
public void setOS(int os)

getOS
public int getOS()

Field Detail

2339

Overview (Codename One API)


setName
public void setName(String name)

getName
public String getName()

setComment
public void setComment(String comment)

getComment
public String getComment()

setCRC
public void setCRC(long crc)

getCRC
public long getCRC()

clone
public Object clone()

Method Detail

2340

Overview (Codename One API)


com.codename1.io.gzip

Class GZIPException
java.lang.Object

java.lang.Throwable

java.lang.Exception

java.io.IOException

com.codename1.io.gzip.GZIPException

public class
extends IOException

Constructor Summary
Constructor and Description
GZIPException()
GZIPException(String s)

Method Summary

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
GZIPException
public GZIPException()

GZIPException
public GZIPException(String s)

Class GZIPException

2341

Overview (Codename One API)


com.codename1.io.gzip

Class GZConnectionRequest
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.gzip.GZConnectionRequest
All Implemented Interfaces:
IOProgressListener

public class
extends ConnectionRequest

A connection request that can detect a GZipped response and parse it

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Constructor and Description
GZConnectionRequest()

Method Summary
Modifier and
Type

Method and Description


readHeaders(Object connection)

protected void

Allows reading the headers from the connection by calling the getHeader()
method.
readResponse(InputStream input)

protected void

protected void

Overridden to convert the input stream you should now override


readUnzipedResponse()
readUnzipedResponse(InputStream input)

This method can be overridden instead of readResponse

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleErrorResponseCode, handleException, handleIOException,
handleRuntimeException, hashCode, hasResponseListeners, initConnection,
initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,

Constructor Detail

2342

Overview (Codename One API)


kill, onRedirect, pause, postResponse, readErrorCodeHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GZConnectionRequest
public GZConnectionRequest()

Method Detail
readHeaders
protected void readHeaders(Object connection)
throws IOException

Allows reading the headers from the connection by calling the getHeader() method.
Overrides:
readHeaders in class ConnectionRequest
Parameters:
connection - used when invoking getHeader
Throws:
IOException - thrown on failure
readResponse
protected final void readResponse(InputStream input)
throws IOException

Overridden to convert the input stream you should now override


readUnzipedResponse()
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs
readUnzipedResponse
protected void readUnzipedResponse(InputStream input)
throws IOException

This method can be overridden instead of readResponse


Parameters:
input - an input stream that is guaranteed to be deflated
Throws:
IOException

Methods inherited fromclass com.codename1.io.ConnectionRequest

2343

Overview (Codename One API)


com.codename1.io.gzip

Class FilterOutputStream
java.lang.Object

java.io.OutputStream

com.codename1.io.gzip.FilterOutputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
DeflaterOutputStream

public class
extends OutputStream

Dummy implementation of filter output stream

Field Summary
Modifier and Type

Field and Description

protected OutputStream out

Constructor Summary
Modifier

Constructor and Description

protected FilterOutputStream(OutputStream underlying)

Method Summary
Modifier and
Type

Method and Description


close()

Closes this output stream and releases any system resources associated
with this stream.

void

flush()

Flushes this output stream and forces any buffered output bytes to be
written out.

void

write(byte[] b)

void

Writes b.length bytes from the specified byte array to this output stream.
write(byte[] b, int offset, int length)

Writes len bytes from the specified byte array starting at offset off to this
output stream.

void

write(int b)

void

Writes the specified byte to this output stream.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Method Detail

2344

Overview (Codename One API)


out
protected OutputStream out

Constructor Detail
FilterOutputStream
protected FilterOutputStream(OutputStream underlying)

Method Detail
write
public void write(int b)
throws IOException

Description copied from class: OutputStream


Writes the specified byte to this output stream. The general contract for write is that
one byte is written to the output stream. The byte to be written is the eight low-order
bits of the argument b. The 24 high-order bits of b are ignored. Subclasses of
OutputStream must provide an implementation for this method.
Specified by:
write in class OutputStream
Throws:
IOException

write
public void write(byte[] b)
throws IOException

Description copied from class: OutputStream


Writes b.length bytes from the specified byte array to this output stream. The general
contract for write(b) is that it should have exactly the same effect as the call write(b,
0, b.length).
Overrides:
write in class OutputStream
Throws:
IOException

write
public void write(byte[] b,
int offset,
int length)
throws IOException

Description copied from class: OutputStream


Writes len bytes from the specified byte array starting at offset off to this output
stream. The general contract for write(b, off, len) is that some of the bytes in the array
b are written to the output stream in order; element b[off] is the first byte written and
b[off+len-1] is the last byte written by this operation. The write method of
OutputStream calls the write method of one argument on each of the bytes to be
written out. Subclasses are encouraged to override this method and provide a more
efficient implementation. If b is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array b, then
an IndexOutOfBoundsException is thrown.
Overrides:
write in class OutputStream
Throws:
IOException

flush
public void flush()
throws IOException

Description copied from class: OutputStream

Field Detail

2345

Overview (Codename One API)


Flushes this output stream and forces any buffered output bytes to be written out.
The general contract of flush is that calling it is an indication that, if any bytes
previously written have been buffered by the implementation of the output stream,
such bytes should immediately be written to their intended destination. The flush
method of OutputStream does nothing.
Overrides:
flush in class OutputStream
Throws:
IOException

close
public void close()
throws IOException

Description copied from class: OutputStream


Closes this output stream and releases any system resources associated with this
stream. The general contract of close is that it closes the output stream. A closed
stream cannot perform output operations and cannot be reopened. The close method
of OutputStream does nothing.
Specified by:
close in interface AutoCloseable
Overrides:
close in class OutputStream
Throws:
IOException

Method Detail

2346

Overview (Codename One API)


com.codename1.io.gzip

Class FilterInputStream
java.lang.Object

java.io.InputStream

com.codename1.io.gzip.FilterInputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
InflaterInputStream

public class
extends InputStream

Simple version of filter input stream

Field Summary
Modifier and Type

Field and Description

protected InputStream in

Constructor Summary
Modifier

Constructor and Description

protected FilterInputStream(InputStream underlying)

Method Summary
Modifier
and Type

Method and Description


available()

int

Returns the number of bytes that can be read (or skipped over) from this input
stream without blocking by the next caller of a method for this input stream.
close()

void

void
boolean
int

Closes this input stream and releases any system resources associated with
the stream.
mark(int readlimit)

Marks the current position in this input stream.


markSupported()

Tests if this input stream supports the mark and reset methods.
read()

Reads the next byte of data from the input stream.


read(byte[] b)

int

int

Reads some number of bytes from the input stream and stores them into the
buffer array b.
read(byte[] b, int offset, int length)

Reads up to len bytes of data from the input stream into an array of bytes.
reset()

void

long

Class FilterInputStream

Repositions this stream to the position at the time the mark method was last
called on this input stream.
skip(long n)

Skips over and discards n bytes of data from this input stream.

2347

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
in
protected InputStream in

Constructor Detail
FilterInputStream
protected FilterInputStream(InputStream underlying)

Method Detail
read
public int read()
throws IOException

Description copied from class: InputStream


Reads the next byte of data from the input stream. The value byte is returned as an
int in the range 0 to 255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown. A subclass
must provide an implementation of this method.
Specified by:
read in class InputStream
Throws:
IOException

read
public int read(byte[] b)
throws IOException

Description copied from class: InputStream


Reads some number of bytes from the input stream and stores them into the buffer
array b. The number of bytes actually read is returned as an integer. This method
blocks until input data is available, end of file is detected, or an exception is thrown. If
b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are
read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no
byte is available because the stream is at end of file, the value -1 is returned;
otherwise, at least one byte is read and stored into b. The first byte read is stored into
element b[0], the next one into b[1], and so on. The number of bytes read is, at most,
equal to the length of b. Let k be the number of bytes actually read; these bytes will
be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1]
unaffected. If the first byte cannot be read for any reason other than end of file, then
an IOException is thrown. In particular, an IOException is thrown if the input stream
has been closed. The read(b) method for class InputStream has the same effect as:
read(b, 0, b.length)
Overrides:
read in class InputStream
Throws:
IOException

read
public int read(byte[] b,
int offset,
int length)
throws IOException

Methods inherited from class java.lang.Object

2348

Overview (Codename One API)


Description copied from class: InputStream
Reads up to len bytes of data from the input stream into an array of bytes. An attempt
is made to read as many as len bytes, but a smaller number may be read, possibly
zero. The number of bytes actually read is returned as an integer. This method blocks
until input data is available, end of file is detected, or an exception is thrown. If b is
null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len
is greater than the length of the array b, then an IndexOutOfBoundsException is
thrown. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an
attempt to read at least one byte. If no byte is available because the stream is at end
of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
The first byte read is stored into element b[off], the next one into b[off+1], and so on.
The number of bytes read is, at most, equal to len. Let k be the number of bytes
actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving
elements b[off+k] through b[off+len-1] unaffected. In every case, elements b[0]
through b[off] and elements b[off+len] through b[b.length-1] are unaffected. If the first
byte cannot be read for any reason other than end of file, then an IOException is
thrown. In particular, an IOException is thrown if the input stream has been closed.
The read(b, off, len) method for class InputStream simply calls the method read()
repeatedly. If the first such call results in an IOException, that exception is returned
from the call to the read(b, off, len) method. If any subsequent call to read() results in
a IOException, the exception is caught and treated as if it were end of file; the bytes
read up to that point are stored into b and the number of bytes read before the
exception occurred is returned. Subclasses are encouraged to provide a more
efficient implementation of this method.
Overrides:
read in class InputStream
Throws:
IOException

skip
public long skip(long n)
throws IOException

Description copied from class: InputStream


Skips over and discards n bytes of data from this input stream. The skip method may,
for a variety of reasons, end up skipping over some smaller number of bytes, possibly
0. This may result from any of a number of conditions; reaching end of file before n
bytes have been skipped is only one possibility. The actual number of bytes skipped
is returned. If n is negative, no bytes are skipped. The skip method of InputStream
creates a byte array and then repeatedly reads into it until n bytes have been read or
the end of the stream has been reached. Subclasses are encouraged to provide a
more efficient implementation of this method.
Overrides:
skip in class InputStream
Throws:
IOException

available
public int available()
throws IOException

Description copied from class: InputStream


Returns the number of bytes that can be read (or skipped over) from this input stream
without blocking by the next caller of a method for this input stream. The next caller
might be the same thread or another thread. The available method for class
InputStream always returns 0. This method should be overridden by subclasses.
Overrides:
available in class InputStream
Throws:
IOException

close
public void close()
throws IOException

Description copied from class: InputStream

Method Detail

2349

Overview (Codename One API)


Closes this input stream and releases any system resources associated with the
stream. The close method of InputStream does nothing.
Specified by:
close in interface AutoCloseable
Overrides:
close in class InputStream
Throws:
IOException

mark
public void mark(int readlimit)

Description copied from class: InputStream


Marks the current position in this input stream. A subsequent call to the reset method
repositions this stream at the last marked position so that subsequent reads re-read
the same bytes. The readlimit arguments tells this input stream to allow that many
bytes to be read before the mark position gets invalidated. The general contract of
mark is that, if the method markSupported returns true, the stream somehow
remembers all the bytes read after the call to mark and stands ready to supply those
same bytes again if and whenever the method reset is called. However, the stream is
not required to remember any data at all if more than readlimit bytes are read from
the stream before reset is called. The mark method of InputStream does nothing.
Overrides:
mark in class InputStream
reset
public void reset()
throws IOException

Description copied from class: InputStream


Repositions this stream to the position at the time the mark method was last called on
this input stream. The general contract of reset is: If the method markSupported
returns true, then: If the method mark has not been called since the stream was
created, or the number of bytes read from the stream since mark was last called is
larger than the argument to mark at that last call, then an IOException might be
thrown. If such an IOException is not thrown, then the stream is reset to a state such
that all the bytes read since the most recent call to mark (or since the start of the file,
if mark has not been called) will be resupplied to subsequent callers of the read
method, followed by any bytes that otherwise would have been the next input data as
of the time of the call to reset. If the method markSupported returns false, then: The
call to reset may throw an IOException. If an IOException is not thrown, then the
stream is reset to a fixed state that depends on the particular type of the input stream
and how it was created. The bytes that will be supplied to subsequent callers of the
read method depend on the particular type of the input stream. The method reset for
class InputStream does nothing and always throws an IOException.
Overrides:
reset in class InputStream
Throws:
IOException

markSupported
public boolean markSupported()

Description copied from class: InputStream


Tests if this input stream supports the mark and reset methods. The markSupported
method of InputStream returns false.
Overrides:
markSupported in class InputStream

Method Detail

2350

Overview (Codename One API)


com.codename1.io.gzip

Class DeflaterOutputStream
java.lang.Object

java.io.OutputStream

com.codename1.io.gzip.FilterOutputStream

com.codename1.io.gzip.DeflaterOutputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
GZIPOutputStream

public class
extends FilterOutputStream

Field Summary
Modifier and Type
protected byte[]

Field and Description


buffer

protected static int DEFAULT_BUFSIZE


protected Deflater

deflater

protected boolean

mydeflater

Fields inherited from


class com.codename1.io.gzip.FilterOutputStream
out

Constructor Summary
Constructor and Description
DeflaterOutputStream(OutputStream out)
DeflaterOutputStream(OutputStream out, Deflater def)
DeflaterOutputStream(OutputStream out, Deflater deflater, int size)
DeflaterOutputStream(OutputStream out, Deflater deflater, int size,
boolean close_out)

Method Summary
Modifier and
Type

Method and Description


close()

void

Closes this output stream and releases any system resources associated
with this stream.

protected int

deflate(int flush)

void

finish()
flush()

void

Flushes this output stream and forces any buffered output bytes to be
written out.

Deflater

getDeflater()

boolean

getSyncFlush()

Class DeflaterOutputStream

2351

Overview (Codename One API)


long

getTotalIn()

long

getTotalOut()

void

setSyncFlush(boolean syncFlush)
write(byte[] b, int off, int len)

Writes len bytes from the specified byte array starting at offset off to this
output stream.

void

write(int b)

void

Writes the specified byte to this output stream.

Methods inherited from


class com.codename1.io.gzip.FilterOutputStream
write

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
deflater
protected final Deflater deflater

buffer
protected byte[] buffer

mydeflater
protected boolean mydeflater

DEFAULT_BUFSIZE
protected static final int DEFAULT_BUFSIZE

See Also:
Constant Field Values

Constructor Detail
DeflaterOutputStream
public DeflaterOutputStream(OutputStream out)
throws IOException

Throws:
IOException

DeflaterOutputStream
public DeflaterOutputStream(OutputStream out,
Deflater def)
throws IOException

Throws:
IOException

DeflaterOutputStream
public DeflaterOutputStream(OutputStream out,
Deflater deflater,
int size)
throws IOException

Throws:
IOException

Method Summary

2352

Overview (Codename One API)


DeflaterOutputStream
public DeflaterOutputStream(OutputStream out,
Deflater deflater,
int size,
boolean close_out)
throws IOException

Throws:
IOException

Method Detail
write
public void write(int b)
throws IOException

Description copied from class: OutputStream


Writes the specified byte to this output stream. The general contract for write is that
one byte is written to the output stream. The byte to be written is the eight low-order
bits of the argument b. The 24 high-order bits of b are ignored. Subclasses of
OutputStream must provide an implementation for this method.
Overrides:
write in class FilterOutputStream
Throws:
IOException

write
public void write(byte[] b,
int off,
int len)
throws IOException

Description copied from class: OutputStream


Writes len bytes from the specified byte array starting at offset off to this output
stream. The general contract for write(b, off, len) is that some of the bytes in the array
b are written to the output stream in order; element b[off] is the first byte written and
b[off+len-1] is the last byte written by this operation. The write method of
OutputStream calls the write method of one argument on each of the bytes to be
written out. Subclasses are encouraged to override this method and provide a more
efficient implementation. If b is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array b, then
an IndexOutOfBoundsException is thrown.
Overrides:
write in class FilterOutputStream
Throws:
IOException

finish
public void finish()
throws IOException

Throws:
IOException

close
public void close()
throws IOException

Description copied from class: OutputStream


Closes this output stream and releases any system resources associated with this
stream. The general contract of close is that it closes the output stream. A closed
stream cannot perform output operations and cannot be reopened. The close method
of OutputStream does nothing.
Specified by:
close in interface AutoCloseable

Constructor Detail

2353

Overview (Codename One API)


Overrides:
close

in class FilterOutputStream

Throws:
IOException

deflate
protected int deflate(int flush)
throws IOException

Throws:
IOException

flush
public void flush()
throws IOException

Description copied from class: OutputStream


Flushes this output stream and forces any buffered output bytes to be written out.
The general contract of flush is that calling it is an indication that, if any bytes
previously written have been buffered by the implementation of the output stream,
such bytes should immediately be written to their intended destination. The flush
method of OutputStream does nothing.
Overrides:
flush in class FilterOutputStream
Throws:
IOException

getTotalIn
public long getTotalIn()

getTotalOut
public long getTotalOut()

setSyncFlush
public void setSyncFlush(boolean syncFlush)

getSyncFlush
public boolean getSyncFlush()

getDeflater
public Deflater getDeflater()

Method Detail

2354

Overview (Codename One API)


com.codename1.io.gzip

Class Deflater
java.lang.Object

com.codename1.io.gzip.ZStream

com.codename1.io.gzip.Deflater

public final class


extends ZStream

Field Summary

Fields inherited from class com.codename1.io.gzip.ZStream


avail_in, avail_out, msg, next_in, next_in_index, next_out, next_out_index,
total_in, total_out

Constructor Summary
Constructor and Description
Deflater()
Deflater(int level)
Deflater(int level, boolean nowrap)
Deflater(int level, int bits)
Deflater(int level, int bits, boolean nowrap)
Deflater(int level, int bits, int memlevel)
Deflater(int level, int bits, int memlevel,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

Method Summary
Modifier
and Type
int

copy(Deflater src)

int

deflate(int flush)

int

Class Deflater

Method and Description

end()

Those methods are expected to be override by Inflater and Deflater.

boolean

finished()

int

init(int level)

int

init(int level, boolean nowrap)

int

init(int level, int bits)

int

init(int level, int bits, boolean nowrap)

int

init(int level, int bits, int memlevel)

int

init(int level, int bits, int memlevel,


com.codename1.io.gzip.JZlib.WrapperType wrapperType)

int

params(int level, int strategy)

int

setDictionary(byte[] dictionary, int dictLength)

2355

Overview (Codename One API)


Methods

inherited from class com.codename1.io.gzip.ZStream

deflateEnd, deflateInit, deflateInit, deflateInit, deflateInit,


deflateInit, deflateInit, deflateParams, deflateSetDictionary, free,
getAdler, getAvailIn, getAvailOut, getMessage, getNextIn, getNextInIndex,
getNextOut, getNextOutIndex, getTotalIn, getTotalOut, inflate, inflateEnd,
inflateFinished, inflateInit, inflateInit, inflateInit, inflateInit,
inflateInit, inflateInit, inflateSetDictionary, inflateSync,
inflateSyncPoint, setAvailIn, setAvailOut, setInput, setInput, setInput,
setNextIn, setNextInIndex, setNextOut, setNextOutIndex, setOutput,
setOutput

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Deflater
public Deflater()

Deflater
public Deflater(int level)
throws GZIPException

Throws:
GZIPException

Deflater
public Deflater(int level,
boolean nowrap)
throws GZIPException

Throws:
GZIPException

Deflater
public Deflater(int level,
int bits)
throws GZIPException

Throws:
GZIPException

Deflater
public Deflater(int level,
int bits,
boolean nowrap)
throws GZIPException

Throws:
GZIPException

Deflater
public Deflater(int level,
int bits,
int memlevel,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)
throws GZIPException

Throws:
GZIPException

Deflater
public Deflater(int level,
int bits,
int memlevel)
throws GZIPException

Methods inherited from class com.codename1.io.gzip.ZStream

2356

Overview (Codename One API)


Throws:
GZIPException

Method Detail
init
public int init(int level)

init
public int init(int level,
boolean nowrap)

init
public int init(int level,
int bits)

init
public int init(int level,
int bits,
int memlevel,
com.codename1.io.gzip.JZlib.WrapperType wrapperType)

init
public int init(int level,
int bits,
int memlevel)

init
public int init(int level,
int bits,
boolean nowrap)

deflate
public int deflate(int flush)

Overrides:
deflate

in class ZStream

end
public int end()

Description copied from class: ZStream


Those methods are expected to be override by Inflater and Deflater. In the future,
they will become abstract methods.
Overrides:
end in class ZStream
params
public int params(int level,
int strategy)

setDictionary
public int setDictionary(byte[] dictionary,
int dictLength)

finished
public boolean finished()

Overrides:
finished

in class ZStream

copy
public int copy(Deflater src)

Constructor Detail

2357

Overview (Codename One API)


com.codename1.io.gzip

Class Deflate
java.lang.Object

com.codename1.io.gzip.Deflate

public final class


extends Object

Method Summary
Modifier and Type Method and Description
Object

clone()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
clone
public Object clone()

Method Detail

2358

Overview (Codename One API)


com.codename1.io.gzip

Class CRC32
java.lang.Object

com.codename1.io.gzip.CRC32

public final class


extends Object

Constructor Summary
Constructor and Description
CRC32()

Method Summary
Modifier and Type

Method and Description

CRC32

copy()

static int[]

getCRC32Table()

long

getValue()

void

reset()

void

reset(long vv)

void

update(byte[] buf, int index, int len)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CRC32
public CRC32()

Method Detail
update
public void update(byte[] buf,
int index,
int len)

reset
public void reset()

reset
public void reset(long vv)

getValue
public long getValue()

Method Detail

2359

Overview (Codename One API)


copy
public CRC32 copy()

getCRC32Table
public static int[] getCRC32Table()

Method Detail

2360

Overview (Codename One API)


com.codename1.io.gzip

Class Adler32
java.lang.Object

com.codename1.io.gzip.Adler32

public final class


extends Object

Constructor Summary
Constructor and Description
Adler32()

Method Summary
Modifier and Type

Method and Description

Adler32

copy()

long

getValue()

void

reset()

void

reset(long init)

void

update(byte[] buf, int index, int len)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Adler32
public Adler32()

Method Detail
reset
public void reset(long init)

reset
public void reset()

getValue
public long getValue()

update
public void update(byte[] buf,
int index,
int len)

Class Adler32

2361

Overview (Codename One API)


copy
public Adler32 copy()

Method Detail

2362

Overview (Codename One API)


com.codename1.io

Class WebServiceProxyCall
java.lang.Object

com.codename1.io.WebServiceProxyCall

public class
extends Object

Utility class used by the webservice proxy code to invoke server code

Nested Class Summary


Modifier and
Type

Class and Description


WebServiceProxyCall.WSDefinition

static class

Webservice definition type, allows defining the argument values for a


specific WS call

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

Class WebServiceProxyCall

Field and Description


TYPE_BOOLEAN

Web protocol argument/return type


TYPE_BOOLEAN_ARRAY

Web protocol argument/return type


TYPE_BOOLEAN_OBJECT

Web protocol argument/return type


TYPE_BYTE

Web protocol argument/return type


TYPE_BYTE_ARRAY

Web protocol argument/return type


TYPE_BYTE_OBJECT

Web protocol argument/return type


TYPE_CHAR

Web protocol argument/return type


TYPE_CHAR_ARRAY

Web protocol argument/return type


TYPE_CHARACTER_OBJECT

Web protocol argument/return type


TYPE_DOUBLE

Web protocol argument/return type


TYPE_DOUBLE_ARRAY

Web protocol argument/return type


TYPE_DOUBLE_OBJECT

Web protocol argument/return type


TYPE_EXTERNALIABLE

Web protocol argument/return type


TYPE_FLOAT

Web protocol argument/return type


TYPE_FLOAT_ARRAY

Web protocol argument/return type


TYPE_FLOAT_OBJECT

2363

Overview (Codename One API)


Web protocol argument/return type
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int

TYPE_INT

Web protocol argument/return type


TYPE_INT_ARRAY

Web protocol argument/return type


TYPE_INTEGER_OBJECT

Web protocol argument/return type


TYPE_LONG

Web protocol argument/return type


TYPE_LONG_ARRAY

Web protocol argument/return type


TYPE_LONG_OBJECT

Web protocol argument/return type


TYPE_SHORT

Web protocol argument/return type


TYPE_SHORT_ARRAY

Web protocol argument/return type


TYPE_SHORT_OBJECT

Web protocol argument/return type


TYPE_STRING

Web protocol argument/return type


TYPE_STRING_ARRAY

Web protocol argument/return type


TYPE_VOID

Web protocol argument/return type

Constructor Summary
Constructor and Description
WebServiceProxyCall()

Method Summary
Modifier and Type
static
WebServiceProxyCall.WSDefinition

static void

static Object

Method and Description


defineWebService(String url,
String serviceName, int returnType,
int... argumentTypes)

Creates a webservice definition object which can be


used to invoke the webservice.
invokeWebserviceASync(WebServiceProxyCall.WSDefinition
Callback call, Object... arguments)

Invokes a web asynchronously and calls the


callback on completion

invokeWebserviceSync(WebServiceProxyCall.WSDefinition d
Object... arguments)

Invokes a webservice synchronously and returns


result

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Field Summary

2364

Overview (Codename One API)


TYPE_VOID
public static final int TYPE_VOID

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_BYTE
public static final int TYPE_BYTE

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_CHAR
public static final int TYPE_CHAR

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_SHORT
public static final int TYPE_SHORT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_INT
public static final int TYPE_INT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_LONG
public static final int TYPE_LONG

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_DOUBLE
public static final int TYPE_DOUBLE

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_FLOAT
public static final int TYPE_FLOAT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN

Web protocol argument/return type


See Also:
Constant Field Values

Field Detail

2365

Overview (Codename One API)


TYPE_BYTE_OBJECT
public static final int TYPE_BYTE_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_CHARACTER_OBJECT
public static final int TYPE_CHARACTER_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_SHORT_OBJECT
public static final int TYPE_SHORT_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_INTEGER_OBJECT
public static final int TYPE_INTEGER_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_LONG_OBJECT
public static final int TYPE_LONG_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_DOUBLE_OBJECT
public static final int TYPE_DOUBLE_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_FLOAT_OBJECT
public static final int TYPE_FLOAT_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_BOOLEAN_OBJECT
public static final int TYPE_BOOLEAN_OBJECT

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_STRING
public static final int TYPE_STRING

Web protocol argument/return type


See Also:
Constant Field Values

Field Detail

2366

Overview (Codename One API)


TYPE_BYTE_ARRAY
public static final int TYPE_BYTE_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_CHAR_ARRAY
public static final int TYPE_CHAR_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_SHORT_ARRAY
public static final int TYPE_SHORT_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_INT_ARRAY
public static final int TYPE_INT_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_LONG_ARRAY
public static final int TYPE_LONG_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_DOUBLE_ARRAY
public static final int TYPE_DOUBLE_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_FLOAT_ARRAY
public static final int TYPE_FLOAT_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_BOOLEAN_ARRAY
public static final int TYPE_BOOLEAN_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values
TYPE_STRING_ARRAY
public static final int TYPE_STRING_ARRAY

Web protocol argument/return type


See Also:
Constant Field Values

Field Detail

2367

Overview (Codename One API)


TYPE_EXTERNALIABLE
public static final int TYPE_EXTERNALIABLE

Web protocol argument/return type


See Also:
Constant Field Values

Constructor Detail
WebServiceProxyCall
public WebServiceProxyCall()

Method Detail
invokeWebserviceSync
public static Object invokeWebserviceSync(WebServiceProxyCall.WSDefinition def,
Object... arguments)
throws IOException

Invokes a webservice synchronously and returns result


Parameters:
def - definition of the webservice request
arguments - the arguments to the service
Returns:
the value of the sync call
Throws:
IOException - an exception in case of a webservice fail
invokeWebserviceASync
public static void invokeWebserviceASync(WebServiceProxyCall.WSDefinition def,
Callback call,
Object... arguments)

Invokes a web asynchronously and calls the callback on completion


Parameters:
def - definition of the webservice request
call - the return value containing an error callback or value
arguments - the arguments to the webservice
defineWebService

public static WebServiceProxyCall.WSDefinition defineWebService(String url,


String serviceName,
int returnType,
int... argumentTypes

Creates a webservice definition object which can be used to invoke the webservice.
Parameters:
url - the url of the webservice
serviceName - the name of the service method
returnType - the return type for the webservice one of the TYPE_* constants
argumentTypes - the arguments for the webservice using the TYPE_*
constants
Returns:
a WSDefinition object

Field Detail

2368

Overview (Codename One API)


com.codename1.io

Class WebServiceProxyCall.WSDefinition
java.lang.Object

com.codename1.io.WebServiceProxyCall.WSDefinition
Enclosing class:
WebServiceProxyCall

public static class


extends Object

Webservice definition type, allows defining the argument values for a specific WS call

Constructor Summary
Constructor and Description
WSDefinition()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
WSDefinition
public WSDefinition()

Method Detail

2369

Overview (Codename One API)


com.codename1.io

Class Util
java.lang.Object

com.codename1.io.Util

public class
extends Object

Various utility methods used for HTTP/IO operations

Constructor Summary
Constructor and Description
Util()

Method Summary
Modifier
and Type
static
void
static
void
static
void
static
String
static
boolean
static
void

static
void

static
boolean
static
void

static
void

static
String

Constructor Detail

Method and Description


cleanup(Object o)

Closes the object (connection, stream etc.) without throwing any exception, even
if the object is null
copy(InputStream i, OutputStream o)

Copy the input stream into the output stream, closes both streams when
finishing or in a case of an exception
copy(InputStream i, OutputStream o, int bufferSize)

Copy the input stream into the output stream, closes both streams when
finishing or in a case of an exception
decode(String s, String enc, boolean plusToSpace)

Decodes a String URL encoded URL


downloadUrlToFile(String url, String fileName, boolean showProgress)

Blocking method that will download the given URL to the file system storage and
return when the operation completes
downloadUrlToFileSystemInBackground(String url, String fileName)

Non-blocking method that will download the given URL to file system storage in
the background and return immediately
downloadUrlToFileSystemInBackground(String url, String fileName,
ActionListener onCompletion)

Non-blocking method that will download the given URL to file system storage in
the background and return immediately
downloadUrlToStorage(String url, String fileName, boolean showProgress)

Blocking method that will download the given URL to storage and return when
the operation completes
downloadUrlToStorageInBackground(String url, String fileName)

Non-blocking method that will download the given URL to storage in the
background and return immediately.
downloadUrlToStorageInBackground(String url, String fileName,
ActionListener onCompletion)

Non-blocking method that will download the given URL to storage in the
background and return immediately
encodeBody(byte[] buf)

Deprecated.
use encodeUrl(char[]) instead

2370

Overview (Codename One API)


static
String
static
String
static
String

encodeBody(char[] buf)

Encode a string for HTML post requests matching the style used in
application/x-www-form-urlencoded
encodeBody(String str)

Encode a string for HTML post requests matching the style used in
application/x-www-form-urlencoded
encodeUrl(byte[] buf)

Deprecated.
use encodeUrl(char[]) instead

static
String

encodeUrl(char[] buf)

static
String

encodeUrl(String str)

static
String
static
String

Encode a string for HTML requests


Encode a string for HTML requests
getIgnorCharsWhileEncoding()

These chars will not be encoded by the encoding method in this class as
requested in RFE 427 http://java.net/jira/browse/LWUIT-427
getURLBasePath(String url)

Returns the URL's base path, which is the same as the path only without an
ending file e.g.: http://domain.com/f/f.html would return as: /f/

static
String

getURLHost(String url)

static
String

getURLPath(String url)

static
String

getURLProtocol(String url)

Returns the URL's host portion


Returns the URL's path
Returns the protocol of an absolute URL e.g.
indexOf(Object[] arr, Object value)

static
int

static
void

Finds the object at the given offset while using the == operator and not the
equals method call, it doesn't rely on the ordering of the elements like the Arrays
method.
insertObjectAtOffset(Object[] sourceArray, Object[] destinationArray,
int offset, Object o)

Inserts the object at the destination array offset


instanceofByteArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofDoubleArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofFloatArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofIntArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofLongArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofObjArray(Object o)

static
boolean

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed
instanceofShortArray(Object o)

static
boolean

Method Summary

Deprecated.
this method serves as a temporary workaround for an XMLVM bug and will be
removed once the bug is fixed

2371

Overview (Codename One API)


static
void

mergeArrays(Object[] arr1, Object[] arr2, Object[] destinationArray)

static
int

readAll(InputStream i, byte[] b)

static
void
static
void

Merges arrays into one larger array


Reads until the array is full or until the stream ends
readFully(InputStream i, byte[] b)

The read fully method from data input stream is very useful for all types of
streams...
readFully(InputStream i, byte[] b, int off, int len)

The read fully method from data input stream is very useful for all types of
streams...

static
byte[]

readInputStream(InputStream i)

static
Object

readObject(DataInputStream input)

static
String

readToString(InputStream i)

static
String

readToString(InputStream i, String encoding)

static
String

readUTF(DataInputStream d)

static
void

register(Externalizable e)

static
void

register(String id, Class c)

static
String

relativeToAbsolute(String baseURL, String relativeURL)

static
void

static
void

static
void
static
void
static
void
static
String[]

Converts a small input stream to a byte array


Reads an object from the stream
Reads an input stream to a string
Reads an input stream to a string
Reads a UTF string that may be null previously written by writeUTF
Registers this externalizable so readObject will be able to load such objects
Registers this externalizable so readObject will be able to load such objects
Converts a relative url e.g.: /myfile.html to an absolute url
removeObjectAtOffset(Object[] sourceArray, Object[] destinationArray,
int offset)

Removes the object at the source array offset and copies all other objects to the
destination array
removeObjectAtOffset(Object[] sourceArray, Object[] destinationArray,
Object o)

Removes the object at the source array offset and copies all other objects to the
destination array
setIgnorCharsWhileEncoding(String s)

These chars will not be encoded by the encoding method in this class as
requested in RFE 427 http://java.net/jira/browse/LWUIT-427
setImplementation(com.codename1.impl.CodenameOneImplementation impl)

Invoked internally from Display, this method is for internal use only
sleep(int t)

Shorthand method for Thread sleep that doesn't throw the stupid interrupted
checked exception
split(String original, String separator)

Provides a utility method breaks a given String to array of String according to the
given separator
toCharArray(String s)

static
char[]

toCharArray should return a new array always, however some devices might
suffer a bug that allows mutating a String (serious security hole in the JVM)
hence this method simulates the proper behavior
wait(Object o, int t)

static
void

Shorthand method wait method that doesn't throw the stupid interrupted
checked exception, it also includes the synchronized block to further reduce
code clutter

static
void

writeObject(Object o, DataOutputStream out)

static
void

writeUTF(String s, DataOutputStream d)

Method Summary

Writes an object to the given output stream


Writes a string with a null flag, this allows a String which may be null

2372

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Util
public Util()

Method Detail
setIgnorCharsWhileEncoding
public static void setIgnorCharsWhileEncoding(String s)

These chars will not be encoded by the encoding method in this class as requested in
RFE 427 http://java.net/jira/browse/LWUIT-427
Parameters:
s - set of characters to skip when encoding
getIgnorCharsWhileEncoding
public static String getIgnorCharsWhileEncoding()

These chars will not be encoded by the encoding method in this class as requested in
RFE 427 http://java.net/jira/browse/LWUIT-427
Returns:
chars skipped
copy
public static void copy(InputStream i,
OutputStream o)
throws IOException

Copy the input stream into the output stream, closes both streams when finishing or
in a case of an exception
Parameters:
i - source
o - destination
Throws:
IOException

copy
public static void copy(InputStream i,
OutputStream o,
int bufferSize)
throws IOException

Copy the input stream into the output stream, closes both streams when finishing or
in a case of an exception
Parameters:
i - source
o - destination
bufferSize - the size of the buffer, which should be a power of 2 large
enoguh
Throws:
IOException

cleanup
public static void cleanup(Object o)

Closes the object (connection, stream etc.) without throwing any exception, even if
the object is null
Parameters:

Methods inherited from class java.lang.Object

2373

Overview (Codename One API)


o - Connection, Stream or other closeable object
readToString
public static String readToString(InputStream i)
throws IOException

Reads an input stream to a string


Parameters:
i - the input stream
Returns:
a UTF-8 string
Throws:
IOException - thrown by the stream
readToString
public static String readToString(InputStream i,
String encoding)
throws IOException

Reads an input stream to a string


Parameters:
i - the input stream
encoding - the encoding of the stream
Returns:
a string
Throws:
IOException - thrown by the stream
readInputStream
public static byte[] readInputStream(InputStream i)
throws IOException

Converts a small input stream to a byte array


Parameters:
i - the stream to convert
Returns:
byte array of the content of the stream
Throws:
IOException

register
public static void register(Externalizable e)

Registers this externalizable so readObject will be able to load such objects


Parameters:
e - the externalizable instance
register
public static void register(String id,
Class c)

Registers this externalizable so readObject will be able to load such objects


Parameters:
id - id of the externalizable
c - the class for the externalizable
writeObject
public static void writeObject(Object o,
DataOutputStream out)
throws IOException

Writes an object to the given output stream


Parameters:
o - the object to write which can be null
out - the destination output stream
Throws:
IOException - thrown by the stream

Method Detail

2374

Overview (Codename One API)


instanceofObjArray
public static boolean instanceofObjArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
instanceofByteArray
public static boolean instanceofByteArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
instanceofShortArray
public static boolean instanceofShortArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
instanceofLongArray
public static boolean instanceofLongArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
instanceofIntArray
public static boolean instanceofIntArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
instanceofFloatArray
public static boolean instanceofFloatArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state

Method Detail

2375

Overview (Codename One API)


instanceofDoubleArray
public static boolean instanceofDoubleArray(Object o)

Deprecated. this method serves as a temporary workaround for an XMLVM bug and
will be removed once the bug is fixed
This method allows working around issue 58
Parameters:
o - object to test
Returns:
true if it matches the state
readObject
public static Object readObject(DataInputStream input)
throws IOException

Reads an object from the stream


Parameters:
input - the source input stream
Throws:
IOException - thrown by the stream
encodeUrl
public static String encodeUrl(String str)

Encode a string for HTML requests


Parameters:
str - none encoded string
Returns:
encoded string
toCharArray
public static char[] toCharArray(String s)

toCharArray should return a new array always, however some devices might suffer a
bug that allows mutating a String (serious security hole in the JVM) hence this
method simulates the proper behavior
Parameters:
s - a string
Returns:
the contents of the string as a char array guaranteed to be a copy of the
current array
decode
public static String decode(String s,
String enc,
boolean plusToSpace)

Decodes a String URL encoded URL


Parameters:
s - the string
enc - the encoding (defaults to UTF-8 if null)
plusToSpace - true if plus signs be converted to spaces
Returns:
a decoded string
encodeBody
public static String encodeBody(String str)

Encode a string for HTML post requests matching the style used in
application/x-www-form-urlencoded
Parameters:
str - none encoded string
Returns:
encoded string

Method Detail

2376

Overview (Codename One API)


encodeUrl
public static String encodeUrl(byte[] buf)

Deprecated. use encodeUrl(char[]) instead


Encode a string for HTML requests
Parameters:
buf - none encoded string
Returns:
encoded string
encodeUrl
public static String encodeUrl(char[] buf)

Encode a string for HTML requests


Parameters:
buf - none encoded string
Returns:
encoded string
encodeBody
public static String encodeBody(char[] buf)

Encode a string for HTML post requests matching the style used in
application/x-www-form-urlencoded
Parameters:
buf - none encoded string
Returns:
encoded string
encodeBody
public static String encodeBody(byte[] buf)

Deprecated. use encodeUrl(char[]) instead


Encode a string for HTML post requests matching the style used in
application/x-www-form-urlencoded
Parameters:
buf - none encoded string
Returns:
encoded string
relativeToAbsolute
public static String relativeToAbsolute(String baseURL,
String relativeURL)

Converts a relative url e.g.: /myfile.html to an absolute url


Parameters:
baseURL - a source URL whose properties should be used to construct the
actual URL
relativeURL - relative address
Returns:
an absolute URL
getURLProtocol
public static String getURLProtocol(String url)

Returns the protocol of an absolute URL e.g. http, https etc.


Parameters:
url - absolute URL
Returns:
protocol
getURLHost
public static String getURLHost(String url)

Returns the URL's host portion


Parameters:

Method Detail

2377

Overview (Codename One API)


url - absolute URL
Returns:
the domain of the URL
getURLPath
public static String getURLPath(String url)

Returns the URL's path


Parameters:
url - absolute URL
Returns:
the path within the host
getURLBasePath
public static String getURLBasePath(String url)

Returns the URL's base path, which is the same as the path only without an ending
file e.g.: http://domain.com/f/f.html would return as: /f/
Parameters:
url - absolute URL
Returns:
the path within the host
writeUTF
public static void writeUTF(String s,
DataOutputStream d)
throws IOException

Writes a string with a null flag, this allows a String which may be null
Parameters:
s - the string to write
d - the destination output stream
Throws:
IOException

readUTF
public static String readUTF(DataInputStream d)
throws IOException

Reads a UTF string that may be null previously written by writeUTF


Parameters:
d - the stream
Returns:
a string or null
Throws:
IOException

readFully
public static void readFully(InputStream i,
byte[] b)
throws IOException

The read fully method from data input stream is very useful for all types of streams...
Parameters:
b - the buffer into which the data is read.
Throws:
IOException - the stream has been closed and the contained input stream
does not support reading after close, or another I/O error occurs.
readFully
public static final void readFully(InputStream i,
byte[] b,
int off,
int len)
throws IOException

The read fully method from data input stream is very useful for all types of streams...
Parameters:

Method Detail

2378

Overview (Codename One API)


b - the buffer into which the data is
off - the start offset of the data.
len - the number of bytes to read.

read.

Throws:
- the stream has been closed and the contained input stream
does not support reading after close, or another I/O error occurs.
IOException

readAll
public static int readAll(InputStream i,
byte[] b)
throws IOException

Reads until the array is full or until the stream ends


Parameters:
b - the buffer into which the data is read.
Returns:
the amount read
Throws:
IOException - the stream has been closed and the contained input stream
does not support reading after close, or another I/O error occurs.
split
public static String[] split(String original,
String separator)

Provides a utility method breaks a given String to array of String according to the
given separator
Parameters:
original - the String to break
separator - the pattern to look in the original String
Returns:
array of Strings from the original String
setImplementation

public static void setImplementation(com.codename1.impl.CodenameOneImplementation im

Invoked internally from Display, this method is for internal use only
Parameters:
impl - implementation instance
mergeArrays
public static void mergeArrays(Object[] arr1,
Object[] arr2,
Object[] destinationArray)

Merges arrays into one larger array


removeObjectAtOffset
public static void removeObjectAtOffset(Object[] sourceArray,
Object[] destinationArray,
Object o)

Removes the object at the source array offset and copies all other objects to the
destination array
Parameters:
sourceArray - the source array
destinationArray - the resulting array which should be of the length
sourceArray.length - 1
o - the object to remove from the array
removeObjectAtOffset
public static void removeObjectAtOffset(Object[] sourceArray,
Object[] destinationArray,
int offset)

Removes the object at the source array offset and copies all other objects to the
destination array
Parameters:

Method Detail

2379

Overview (Codename One API)


sourceArray - the source array
destinationArray - the resulting

array which should be of the length

sourceArray.length - 1
offset - the offset of the array
insertObjectAtOffset
public static void insertObjectAtOffset(Object[] sourceArray,
Object[] destinationArray,
int offset,
Object o)

Inserts the object at the destination array offset


Parameters:
sourceArray - the source array
destinationArray - the resulting array which should be of the length
sourceArray.length + 1
offset - the offset of the array
o - the object
indexOf
public static int indexOf(Object[] arr,
Object value)

Finds the object at the given offset while using the == operator and not the equals
method call, it doesn't rely on the ordering of the elements like the Arrays method.
Parameters:
arr - the array
value - the value to search
Returns:
the offset or -1
downloadUrlToStorage
public static boolean downloadUrlToStorage(String url,
String fileName,
boolean showProgress)

Blocking method that will download the given URL to storage and return when the
operation completes
Parameters:
url - the URL
fileName - the storage file name
showProgress - whether to block the UI until download completes/fails
Returns:
true on success false on error
downloadUrlToFile
public static boolean downloadUrlToFile(String url,
String fileName,
boolean showProgress)

Blocking method that will download the given URL to the file system storage and
return when the operation completes
Parameters:
url - the URL
fileName - the file name
showProgress - whether to block the UI until download completes/fails
Returns:
true on success false on error
downloadUrlToStorageInBackground
public static void downloadUrlToStorageInBackground(String url,
String fileName)

Non-blocking method that will download the given URL to storage in the background
and return immediately. This method can be used to fetch data dynamically and
asynchronously e.g. in this code it is used to fetch book covers for the ImageViewer:
Form hi = new Form("ImageViewer", new BorderLayout());

Method Detail

2380

Overview (Codename One API)


final EncodedImage placeholder = EncodedImage.createFromImage(
FontImage.createMaterial(FontImage.MATERIAL_SYNC, s).
scaled(300, 300), false);
class ImageList implements ListModel<Image> {
private int selection;
private String[] imageURLs = {
"http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/300px-AGameOfThrones.jpg",
"http://awoiaf.westeros.org/images/thumb/3/39/AClashOfKings.jpg/300px-AClashOfKings.jpg",
"http://awoiaf.westeros.org/images/thumb/2/24/AStormOfSwords.jpg/300px-AStormOfSwords.jpg",
"http://awoiaf.westeros.org/images/thumb/a/a3/AFeastForCrows.jpg/300px-AFeastForCrows.jpg",
"http://awoiaf.westeros.org/images/7/79/ADanceWithDragons.jpg"
};
private Image[] images;
private EventDispatcher listeners = new EventDispatcher();
public ImageList() {
this.images = new EncodedImage[imageURLs.length];
}

public Image getItemAt(final int index) {


if(images[index] == null) {
images[index] = placeholder;
Util.downloadUrlToStorageInBackground(imageURLs[index], "list" + index, (e) -> {
try {
images[index] = EncodedImage.create(Storage.getInstance().createInputStream("
listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
} catch(IOException err) {
err.printStackTrace();
}
});
}
return images[index];
}
public int getSize() {
return imageURLs.length;
}
public int getSelectedIndex() {
return selection;
}
public void setSelectedIndex(int index) {
selection = index;
}
public void addDataChangedListener(DataChangedListener l) {
listeners.addListener(l);
}
public void removeDataChangedListener(DataChangedListener l) {
listeners.removeListener(l);
}
public void addSelectionListener(SelectionListener l) {
}
public void removeSelectionListener(SelectionListener l) {
}
public void addItem(Image item) {
}
public void removeItem(int index) {
}
};
ImageList imodel = new ImageList();
ImageViewer iv = new ImageViewer(imodel.getItemAt(0));
iv.setImageList(imodel);
hi.add(BorderLayout.CENTER, iv);

Method Detail

2381

Overview (Codename One API)

Parameters:
url - the URL
fileName - the storage file name
downloadUrlToFileSystemInBackground
public static void downloadUrlToFileSystemInBackground(String url,
String fileName)

Non-blocking method that will download the given URL to file system storage in the
background and return immediately
Parameters:
url - the URL
fileName - the file name
downloadUrlToStorageInBackground
public static void downloadUrlToStorageInBackground(String url,
String fileName,
ActionListener onCompletion)

Non-blocking method that will download the given URL to storage in the background
and return immediately
Parameters:
url - the URL
fileName - the storage file name
onCompletion - invoked when download completes
downloadUrlToFileSystemInBackground
public static void downloadUrlToFileSystemInBackground(String url,
String fileName,
ActionListener onCompletion)

Non-blocking method that will download the given URL to file system storage in the
background and return immediately
Parameters:
url - the URL
fileName - the file name
onCompletion - invoked when download completes

Method Detail

2382

Overview (Codename One API)


sleep
public static void sleep(int t)

Shorthand method for Thread sleep that doesn't throw the stupid interrupted checked
exception
Parameters:
t - the time
wait
public static void wait(Object o,
int t)

Shorthand method wait method that doesn't throw the stupid interrupted checked
exception, it also includes the synchronized block to further reduce code clutter
Parameters:
o - the object to wait on
t - the time

Method Detail

2383

Overview (Codename One API)


com.codename1.io

Class Storage
java.lang.Object

com.codename1.io.Storage

public class
extends Object

Abstracts the underlying application specific storage system such as RMS

Constructor Summary
Constructor and Description
Storage()

Method Summary
Modifier and
Type

Method and Description


clearCache()

void

void
InputStream
OutputStream
void
int
boolean

Storage is cached for faster access, however this might cause a problem
with refreshing objects since they are not cloned.
clearStorage()

Deletes all the files in the application storage


createInputStream(String name)

Creates an input stream to the given storage source file


createOutputStream(String name)

Creates an output stream to the storage with the given name


deleteStorageFile(String name)

Deletes the given file name from the storage


entrySize(String name)

Returns the size in bytes of the given entry


exists(String name)

Returns true if the given storage file exists


flushStorageCache()

void

Flush the storage cache allowing implementations that cache storage


objects to store
getInstance()

static Storage

static boolean

Returns the storage instance or null if the storage wasn't initialized using a
call to init(String) first.
isInitialized()

Returns true if the storage is initialized


isNormalizeNames()

boolean

String[]
Object
void
void

Class Storage

Indicates whether characters that are typically illegal in filesystems should


be sanitized and replaced with underscore
listEntries()

Lists the names of the storage files


readObject(String name)

Reads the object from the storage, returns null if the object isn't there
setHardCacheSize(int size)

Indicates the caching size, storage can be pretty slow


setNormalizeNames(boolean normalizeNames)

2384

Overview (Codename One API)


Indicates whether characters that are typically illegal in filesystems should
be sanitized and replaced with underscore
writeObject(String name, Object o)
boolean

Writes the given object to storage assuming it is an externalizable type or


one of the supported types

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Storage
public Storage()

Method Detail
setHardCacheSize
public void setHardCacheSize(int size)

Indicates the caching size, storage can be pretty slow


Parameters:
size - size in elements (not kb!)
isInitialized
public static boolean isInitialized()

Returns true if the storage is initialized


Returns:
true if the storage is initialized
getInstance
public static Storage getInstance()

Returns the storage instance or null if the storage wasn't initialized using a call to
init(String) first.
Returns:
storage instance
clearCache
public void clearCache()

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 void flushStorageCache()

Flush the storage cache allowing implementations that cache storage objects to store
deleteStorageFile
public void deleteStorageFile(String name)

Deletes the given file name from the storage


Parameters:
name - the name of the storage file

Method Summary

2385

Overview (Codename One API)


clearStorage
public void clearStorage()

Deletes all the files in the application storage


createOutputStream
public OutputStream createOutputStream(String name)
throws IOException

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

createInputStream
public InputStream createInputStream(String name)
throws IOException

Creates an input stream to the given storage source file


Parameters:
name - the name of the source file
Returns:
the input stream
Throws:
IOException

exists
public boolean exists(String name)

Returns true if the given storage file exists


Parameters:
name - the storage file name
Returns:
true if it exists
listEntries
public String[] listEntries()

Lists the names of the storage files


Returns:
the names of all the storage files
entrySize
public int entrySize(String name)

Returns the size in bytes of the given entry


Parameters:
name - the name of the entry
Returns:
the size in bytes
writeObject
public boolean writeObject(String name,
Object o)

Writes the given object to storage assuming it is an externalizable type or one of the
supported types
Parameters:
name - store name
o - object to store
Returns:
true for success, false for failue

Method Detail

2386

Overview (Codename One API)


readObject
public Object readObject(String name)

Reads the object from the storage, returns null if the object isn't there
Parameters:
name - name of the store
Returns:
object stored under that name
isNormalizeNames
public boolean isNormalizeNames()

Indicates whether characters that are typically illegal in filesystems should be


sanitized and replaced with underscore
Returns:
the normalizeNames
setNormalizeNames
public void setNormalizeNames(boolean normalizeNames)

Indicates whether characters that are typically illegal in filesystems should be


sanitized and replaced with underscore
Parameters:
normalizeNames - the normalizeNames to set

Method Detail

2387

Overview (Codename One API)


com.codename1.io

Class SocketConnection
java.lang.Object

com.codename1.io.SocketConnection

public abstract class


extends Object

Callback for establishment of a socket connection. Notice this callback is always invoked on a new
separate thread to allow uninterrupted IO.

Constructor Summary
Constructor and Description
SocketConnection()

Method Summary
Modifier and
Type

Method and Description


connectionError(int errorCode, String message)

abstract void

Invoked in case of an error in the socket connection, this method is


invoked off the EDT
connectionEstablished(InputStream is, OutputStream os)

abstract void

boolean

Invoked when a socket connection is established, this method is invoked


off the EDT
isConnected()

Returns true if this connection is currently active

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SocketConnection
public SocketConnection()

Method Detail
connectionError
public abstract void connectionError(int errorCode,
String message)

Invoked in case of an error in the socket connection, this method is invoked off the
EDT
Parameters:
errorCode - the error code
message - error message if applicable

Class SocketConnection

2388

Overview (Codename One API)


connectionEstablished
public abstract void connectionEstablished(InputStream is,
OutputStream os)

Invoked when a socket connection is established, this method is invoked off the EDT
Parameters:
is - input stream for the socket
os - output stream for the socket
isConnected
public boolean isConnected()

Returns true if this connection is currently active


Returns:
true if connected

Method Detail

2389

Overview (Codename One API)


com.codename1.io

Class Socket
java.lang.Object

com.codename1.io.Socket

public class
extends Object

Class implementing the socket API

Nested Class Summary


Modifier and Type
static interface

Class and Description


Socket.StopListening

This interface can be invoked to stop listening on a server socket

Method Summary
Modifier and Type
static void

Method and Description


connect(String host, int port, SocketConnection sc)

Connect to a remote host


getHostOrIP()

static String

Returns the hostname or ip address of the device if


available/applicable
isServerSocketSupported()

static boolean

static boolean
static
Socket.StopListening

Returns true if server sockets are supported in this port, if this


method returns false invocations of listen will always fail
isSupported()

Returns true if sockets are supported in this port, false otherwise


listen(int port, Class scClass)

Listen to incoming connections on port

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
isSupported
public static boolean isSupported()

Returns true if sockets are supported in this port, false otherwise


Returns:
true if sockets are supported in this port, false otherwise
isServerSocketSupported
public static boolean isServerSocketSupported()

Returns true if server sockets are supported in this port, if this method returns false
invocations of listen will always fail
Returns:
true if server sockets are supported in this port, false otherwise

Class Socket

2390

Overview (Codename One API)


connect
public static void connect(String host,
int port,
SocketConnection sc)

Connect to a remote host


Parameters:
host - the host
port - the connection port
sc - callback for when the connection is established or fails
listen
public static Socket.StopListening listen(int port,
Class scClass)

Listen to incoming connections on port


Parameters:
port - the device port
scClass - class of callback for when the connection is established or fails, this
class will be instantiated for every incoming connection and must have a
public no argument constructor.
Returns:
StopListening instance that allows the the caller to stop listening on a server
socket
getHostOrIP
public static String getHostOrIP()

Returns the hostname or ip address of the device if available/applicable


Returns:
the hostname or ip address of the device if available/applicable

Method Detail

2391

Overview (Codename One API)


com.codename1.io

Interface Socket.StopListening
Enclosing class:
Socket

public static interface

This interface can be invoked to stop listening on a server socket

Method Summary
Modifier and Type Method and Description
stop()

void

Stop listening

Method Detail
stop
void stop()

Stop listening

Interface Socket.StopListening

2392

Overview (Codename One API)


com.codename1.io

Class Properties
java.lang.Object

java.util.AbstractMap<K,V>

java.util.HashMap<String,String>

com.codename1.io.Properties
All Implemented Interfaces:
Map<String,String>

public class
extends HashMap<String,String>

A Properties object is a Hashtable where the keys and values must be Strings. Each property can
have a default Properties list which specifies the default values to be used when a given key is not
found in this Properties instance.

Character Encoding
Note that in some cases Properties uses ISO-8859-1 instead of UTF-8. ISO-8859-1 is only capable
of representing a tiny subset of Unicode. Use either the loadFromXML/storeToXML methods (which use
UTF-8 by default) or the load/store overloads that take an OutputStreamWriter (so you can supply a
UTF-8 instance) instead.
See Also:
Hashtable, java.lang.System#getProperties

Nested Class Summary

Nested classes/interfaces inherited from


class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

Field Summary
Modifier and Type
protected Properties

Field and Description


defaults

The default values for keys not found in this Properties instance.

Constructor Summary
Constructor and Description
Properties()

Constructs a new Properties object.


Properties(Properties properties)
Constructs a new Properties object using

the specified default Properties.

Method Summary
Modifier and
Type
String

Method Detail

Method and Description


getProperty(String name)

Searches for the property with the specified name.

2393

Overview (Codename One API)


getProperty(String name, String defaultValue)

String

Searches for the property with the specified name.


load(InputStream in)

Loads properties from the specified InputStream, assumed to be


ISO-8859-1.

void

load(Reader in)

void

Loads properties from the specified Reader.

Enumeration<?>

propertyNames()

Returns all of the property names (keys) in this Properties object.


save(OutputStream out, String comment)

Deprecated.
This method ignores any IOException thrown while writing -- use
store(java.io.OutputStream, java.lang.String) instead for better
exception handling.

void

setProperty(String name, String value)

Object

Maps the specified key to the specified value.


store(OutputStream out, String comment)
Stores properties to the specified OutputStream,

void

store(Writer writer, String comment)


Stores the mappings in this Properties object

void

using ISO-8859-1.

to out, putting the specified

comment at the beginning.


stringPropertyNames()
Set<String>

Returns those property names (keys) in this Properties object for which
both key and value are strings.

Methods inherited from class java.util.HashMap


clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put,
putAll, remove, size, values

Methods inherited from class java.util.AbstractMap


equals, hashCode, toString

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Map


equals, hashCode

Field Detail
defaults
protected Properties defaults

The default values for keys not found in this Properties instance.

Constructor Detail
Properties
public Properties()

Constructs a new Properties object.

Method Summary

2394

Overview (Codename One API)


Properties
public Properties(Properties properties)

Constructs a new Properties object using the specified default Properties.


Parameters:
properties - the default Properties.

Method Detail
getProperty
public String getProperty(String name)

Searches for the property with the specified name. If the property is not found, the
default Properties are checked. If the property is not found in the default Properties,
null is returned.
Parameters:
name - the name of the property to find.
Returns:
the named property value, or null if it can't be found.
getProperty
public String getProperty(String name,
String defaultValue)

Searches for the property with the specified name. If the property is not found, it looks
in the default Properties. If the property is not found in the default Properties, it
returns the specified default.
Parameters:
name - the name of the property to find.
defaultValue - the default value.
Returns:
the named property value.
load
public void load(InputStream in)
throws IOException

Loads properties from the specified InputStream, assumed to be ISO-8859-1. See


"Character Encoding".
Parameters:
in - the InputStream
Throws:
IOException

load
public void load(Reader in)
throws IOException

Loads properties from the specified Reader. The properties file is interpreted
according to the following rules:
Empty lines are ignored.
Lines starting with either a "#" or a "!" are comment lines and are ignored.
A backslash at the end of the line escapes the following newline character
("\r", "\n", "\r\n"). If there's whitespace after the backslash it will just escape
that whitespace instead of concatenating the lines. This does not apply to
comment lines.
A property line consists of the key, the space between the key and the value,
and the value. The key goes up to the first whitespace, "=" or ":" that is not
escaped. The space between the key and the value contains either one
whitespace, one "=" or one ":" and any amount of additional whitespace
before and after that character. The value starts with the first character after
the space between the key and the value.

Constructor Detail

2395

Overview (Codename One API)


Following escape sequences are recognized: "\ ", "\\", "\r", "\n", "\!", "\#", "\t",
"\b", "\f", and "\uXXXX" (unicode character).
Parameters:
in - the Reader
Throws:
IOException

Since:
1.6
propertyNames
public Enumeration<?> propertyNames()

Returns all of the property names (keys) in this Properties object.


stringPropertyNames
public Set<String> stringPropertyNames()

Returns those property names (keys) in this Properties object for which both key and
value are strings.
Returns:
a set of keys in the property list
Since:
1.6
save
@Deprecated
public void save(OutputStream out,
String comment)

Deprecated. This method ignores any IOException thrown while writing -- use
store(java.io.OutputStream, java.lang.String) instead for better exception
handling.
Saves the mappings in this Properties to the specified OutputStream, putting the
specified comment at the beginning. The output from this method is suitable for being
read by the load(InputStream) method.
Parameters:
out - the OutputStream to write to.
comment - the comment to add at the beginning.
Throws:
ClassCastException - if the key or value of a mapping is not a String.
setProperty
public Object setProperty(String name,
String value)

Maps the specified key to the specified value. If the key already exists, the old value
is replaced. The key and value cannot be null.
Parameters:
name - the key.
value - the value.
Returns:
the old value mapped to the key, or null.
store
public void store(OutputStream out,
String comment)
throws IOException

Stores properties to the specified OutputStream, using ISO-8859-1. See "Character


Encoding".
Parameters:
out - the OutputStream
comment - an optional comment to be written, or null
Throws:
IOException
ClassCastException

Method Detail

- if a key or value is not a string

2396

Overview (Codename One API)


store
public void store(Writer writer,
String comment)
throws IOException

Stores the mappings in this Properties object to out, putting the specified comment
at the beginning.
Parameters:
writer - the Writer
comment - an optional comment to be written, or null
Throws:
IOException
ClassCastException

- if a key or value is not a string

Since:
1.6

Method Detail

2397

Overview (Codename One API)


com.codename1.io

Class Preferences
java.lang.Object

com.codename1.io.Preferences

public class
extends Object

Simple map like class to store application and Codename One preference settings.

Method Summary
Modifier and Type
static void
static void
static boolean
static double
static float
static int
static long
static String
static void
static void
static void
static void
static void
static void

Method and Description


clearAll()

Remove all preferences


delete(String pref)

Deletes a value for the given setting


get(String pref, boolean def)

Gets the value as a number


get(String pref, double def)

Gets the value as a number


get(String pref, float def)

Gets the value as a number


get(String pref, int def)

Gets the value as a number


get(String pref, long def)

Gets the value as a number


get(String pref, String def)

Gets the value as a String


set(String pref, boolean b)

Sets a preference value


set(String pref, double d)

Sets a preference value


set(String pref, float f)

Sets a preference value


set(String pref, int i)

Sets a preference value


set(String pref, long l)

Sets a preference value


set(String pref, String s)

Sets a preference value

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
set
public static void set(String pref,
String s)

Class Preferences

2398

Overview (Codename One API)


Sets a preference value
Parameters:
pref - the key any unique none null value that doesn't start with cn1
s - a String
set
public static void set(String pref,
int i)

Sets a preference value


Parameters:
pref - the key any unique none null value that doesn't start with cn1
i - a number
set
public static void set(String pref,
long l)

Sets a preference value


Parameters:
pref - the key any unique none null value that doesn't start with cn1
l - a number
set
public static void set(String pref,
double d)

Sets a preference value


Parameters:
pref - the key any unique none null value that doesn't start with cn1
d - a number
set
public static void set(String pref,
float f)

Sets a preference value


Parameters:
pref - the key any unique none null value that doesn't start with cn1
f - a number
delete
public static void delete(String pref)

Deletes a value for the given setting


Parameters:
pref - the preference value
clearAll
public static void clearAll()

Remove all preferences


set
public static void set(String pref,
boolean b)

Sets a preference value


Parameters:
pref - the key any unique none null value that doesn't start with cn1
o - a String
get
public static String get(String pref,
String def)

Gets the value as a String


Parameters:

Method Detail

2399

Overview (Codename One API)


pref - the preference key
def - the default value

Returns:
the default value or the value
get
public static int get(String pref,
int def)

Gets the value as a number


Parameters:
pref - the preference key
def - the default value
Returns:
the default value or the value
get
public static long get(String pref,
long def)

Gets the value as a number


Parameters:
pref - the preference key
def - the default value
Returns:
the default value or the value
get
public static double get(String pref,
double def)

Gets the value as a number


Parameters:
pref - the preference key
def - the default value
Returns:
the default value or the value
get
public static float get(String pref,
float def)

Gets the value as a number


Parameters:
pref - the preference key
def - the default value
Returns:
the default value or the value
get
public static boolean get(String pref,
boolean def)

Gets the value as a number


Parameters:
pref - the preference key
def - the default value
Returns:
the default value or the value

Method Detail

2400

Overview (Codename One API)


com.codename1.io

Class Oauth2
java.lang.Object

com.codename1.io.Oauth2

public class
extends Object

This is a utility class that allows Oauth2 authentication This utility uses the Codename One XHTML
Component to display the authentication pages. http://tools.ietf.org/pdf/draft-ietf-oauth-v2-12.pdf

Field Summary
Modifier and Type Field and Description
static String

TOKEN

Constructor Summary
Constructor and Description
Oauth2(String oauth2URL, String clientId, String redirectURI)

Simple constructor
Oauth2(String oauth2URL, String clientId, String redirectURI, String scope)

Simple constructor
Oauth2(String oauth2URL, String clientId, String redirectURI, String scope,
String tokenRequestURL, String clientSecret)

Simple constructor
Oauth2(String oauth2URL, String clientId, String redirectURI, String scope,
String tokenRequestURL, String clientSecret, Hashtable additionalParams)

Simple constructor

Method Summary
Modifier and
Type

Method and Description


authenticate()

Deprecated.
use createAuthComponent or showAuthentication which work
asynchronously and adapt better to different platforms

String

Component

createAuthComponent(ActionListener al)

This method creates a component which can authenticate.

static
String

getExpires()

static
boolean

isBackToParent()

Returns the expiry for the token received via oauth

static void

Enables going back to the parent form after login is completed


setBackToParent(boolean aBackToParent)

Enables going back to the parent form after login is completed


showAuthentication(ActionListener al)

void

This method shows an authentication for login form

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class Oauth2

2401

Overview (Codename One API)


Field

Detail
TOKEN
public static final String TOKEN

See Also:
Constant Field Values

Constructor Detail
Oauth2
public Oauth2(String oauth2URL,
String clientId,
String redirectURI)

Simple constructor
Parameters:
oauth2URL - the authentication url of the service
clientId - the client id that would like to use the
redirectURI - the redirect uri

service

Oauth2
public Oauth2(String
String
String
String

oauth2URL,
clientId,
redirectURI,
scope)

Simple constructor
Parameters:
oauth2URL - the authentication url of the service
clientId - the client id that would like to use the
redirectURI - the redirect uri
scope - the authentication scope

service

Oauth2
public Oauth2(String
String
String
String
String
String

oauth2URL,
clientId,
redirectURI,
scope,
tokenRequestURL,
clientSecret)

Simple constructor
Parameters:
oauth2URL - the authentication url of the service
clientId - the client id that would like to use the
redirectURI - the redirect uri
scope - the authentication scope
clientSecret - the client secret

service

Oauth2
public Oauth2(String oauth2URL,
String clientId,
String redirectURI,
String scope,
String tokenRequestURL,
String clientSecret,
Hashtable additionalParams)

Simple constructor
Parameters:
oauth2URL - the authentication url of the service
clientId - the client id that would like to use the
redirectURI - the redirect uri
scope - the authentication scope

Field Detail

service

2402

Overview (Codename One API)


clientSecret - the client secret
additionalParams - hashtable of

additional parameters to the authentication

request

Method Detail
isBackToParent
public static boolean isBackToParent()

Enables going back to the parent form after login is completed


Returns:
the backToParent
setBackToParent
public static void setBackToParent(boolean aBackToParent)

Enables going back to the parent form after login is completed


Parameters:
aBackToParent - the backToParent to set
getExpires
public static String getExpires()

Returns the expiry for the token received via oauth


Returns:
the expires argument for the token
authenticate
public String authenticate()

Deprecated. use createAuthComponent or showAuthentication which work


asynchronously and adapt better to different platforms
This method preforms the actual authentication, this method is a blocking method
that will display the user the html authentication pages.
Returns:
the method if passes authentication will return the access token or null if
authentication failed.
Throws:
IOException - the method will throw an IOException if something went wrong
in the communication.
createAuthComponent
public Component createAuthComponent(ActionListener al)

This method creates a component which can authenticate. You will receive either the
authentication key or an Exception object within the ActionListener callback method.
Parameters:
al - a listener that will receive at its source either a token for the service or an
exception in case of a failure
Returns:
a component that should be displayed to the user in order to perform the
authentication
showAuthentication
public void showAuthentication(ActionListener al)

This method shows an authentication for login form


Parameters:
al - a listener that will receive at its source either a token for the service or an
exception in case of a failure

Constructor Detail

2403

Overview (Codename One API)


com.codename1.io

Class NetworkManager
java.lang.Object

com.codename1.io.NetworkManager

public class
extends Object

Main entry point for managing the connection requests, this is essentially a threaded queue that
makes sure to route all connections via the network thread while sending the callbacks through the
Codename One EDT.
The sample code below fetches a page of data from the nestoria housing listing API.
You can see instructions on how to display the data in the InfiniteScrollAdapter class.

int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
r.addArgument("page", "" + pageNumber);
pageNumber++;
r.addArgument("country", "uk");
r.addArgument("place_name", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getRes
Map<String, Object> response = (Map<String, Object>)result.get("response");
return (java.util.List<Map<String, Object>>)response.get("listings");
} catch(Exception err) {
Log.e(err);
return null;
}
}

Field Summary
Modifier and Type
static int
static int
static int
static int
static int
static int

Field and Description


ACCESS_POINT_TYPE_CABLE

Indicates an access point based on a cable


ACCESS_POINT_TYPE_CORPORATE

Indicates a corporate routing server access point type (e.g.


ACCESS_POINT_TYPE_NETWORK2G

Indicates a 2g network access point type


ACCESS_POINT_TYPE_NETWORK3G

Indicates a 3g network access point type


ACCESS_POINT_TYPE_UNKNOWN

Indicates an unknown access point type


ACCESS_POINT_TYPE_WLAN

Indicates a wlan (802.11b/c/g/n) access point type

Method Summary
Modifier and
Type

Method and Description


addDefaultHeader(String key, String value)

void

Method Detail

Adds a header to the global default headers, this header will be implicitly
added to all requests going out from this point onwards.

2404

Overview (Codename One API)


addErrorListener(ActionListener e)
void

void
void

Adds a generic listener to a network error that is invoked before the


exception is propagated.
addProgressListener(ActionListener al)

Adds a listener to be notified when progress updates


addToQueue(ConnectionRequest request)

Adds the given network connection to the queue of execution


addToQueueAndWait(ConnectionRequest request)

void

Identical to add to queue but waits until the request is processed in the
queue, this is useful for completely synchronous operations.
assignToThread(Class requestType, int offset)

void

Enumeration
String[]
String
int
static String
String
static
NetworkManager
int
int
boolean
boolean

Makes sure the given class (subclass of ConnectionRequest) is always


assigned to the given thread number.
enumurateQueue()

This method returns all pending ConnectioRequest connections.


getAPIds()

Returns the ids of the access points available if supported


getAPName(String id)

Returns the user displayable name for the given access point
getAPType(String id)

Returns the type of the access point


getAutoDetectURL()

This URL is used to check whether an Internet connection is available


getCurrentAccessPoint()

Returns the id of the current access point


getInstance()

Returns the singleton instance of this class


getThreadCount()

The number of threads


getTimeout()

Returns the timeout duration


isAPSupported()

Indicates whether looking up an access point is supported by this device


isQueueIdle()

Indicates that the network queue is idle


killAndWait(ConnectionRequest request)

void

void
void
static void
void

Kills the given request and waits until the request is killed if it is being
processed by one of the threads.
removeErrorListener(ActionListener e)

Removes the given error listener


removeProgressListener(ActionListener al)

Adds a listener to be notified when progress updates


setAutoDetectURL(String aAutoDetectURL)

This URL is used to check whether an Internet connection is available


setCurrentAccessPoint(String id)

Returns the id of the current access point


setThreadCount(int threadCount)

void

Thread count should never be changed when the network is running


since it will have no effect.
setTimeout(int t)

void

Sets the timeout in milliseconds for network connections, a timeout may


be "faked" for platforms that don't support the notion of a timeout such
as MIDP
shutdown()

void

void

Method Summary

Deprecated.
This method is for internal use only
shutdownSync()

Shuts down the network thread and waits for shutdown to complete

2405

Overview (Codename One API)


start()

There is no need to invoke this method since the network manager is


started implicitly.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ACCESS_POINT_TYPE_UNKNOWN
public static final int ACCESS_POINT_TYPE_UNKNOWN

Indicates an unknown access point type


See Also:
Constant Field Values
ACCESS_POINT_TYPE_WLAN
public static final int ACCESS_POINT_TYPE_WLAN

Indicates a wlan (802.11b/c/g/n) access point type


See Also:
Constant Field Values
ACCESS_POINT_TYPE_CABLE
public static final int ACCESS_POINT_TYPE_CABLE

Indicates an access point based on a cable


See Also:
Constant Field Values
ACCESS_POINT_TYPE_NETWORK3G
public static final int ACCESS_POINT_TYPE_NETWORK3G

Indicates a 3g network access point type


See Also:
Constant Field Values
ACCESS_POINT_TYPE_NETWORK2G
public static final int ACCESS_POINT_TYPE_NETWORK2G

Indicates a 2g network access point type


See Also:
Constant Field Values
ACCESS_POINT_TYPE_CORPORATE
public static final int ACCESS_POINT_TYPE_CORPORATE

Indicates a corporate routing server access point type (e.g. BIS etc.)
See Also:
Constant Field Values

Method Detail
getAutoDetectURL
public static String getAutoDetectURL()

This URL is used to check whether an Internet connection is available


Returns:
the autoDetectURL

Methods inherited from class java.lang.Object

2406

Overview (Codename One API)


setAutoDetectURL
public static void setAutoDetectURL(String aAutoDetectURL)

This URL is used to check whether an Internet connection is available


Parameters:
aAutoDetectURL - the autoDetectURL to set
getThreadCount
public int getThreadCount()

The number of threads


Returns:
the threadCount
setThreadCount
public void setThreadCount(int threadCount)

Thread count should never be changed when the network is running since it will have
no effect. Increasing the thread count can bring many race conditions and problems
to the surface, furthermore MIDP doesn't require support for more than one network
thread hence increasing the thread count might fail.
Parameters:
threadCount - the threadCount to set
start
public void start()

There is no need to invoke this method since the network manager is started
implicitly. It is useful only if you explicitly stop the network manager. Invoking this
method otherwise will just do nothing.
shutdown
public void shutdown()

Deprecated. This method is for internal use only


Shuts down the network thread, this will trigger failures if you have network requests
shutdownSync
public void shutdownSync()

Shuts down the network thread and waits for shutdown to complete
getInstance
public static NetworkManager getInstance()

Returns the singleton instance of this class


Returns:
instance of this class
addDefaultHeader
public void addDefaultHeader(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. 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
public void addToQueueAndWait(ConnectionRequest request)

Identical to add to queue but waits until the request is processed in the queue, this is
useful for completely synchronous operations.
Parameters:

Method Detail

2407

Overview (Codename One API)


request

- the request object to add

addToQueue
public void addToQueue(ConnectionRequest request)

Adds the given network connection to the queue of execution


Parameters:
request - network request for execution
killAndWait
public void killAndWait(ConnectionRequest request)

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 setTimeout
public void setTimeout(int t)

Sets the timeout in milliseconds for network connections, a timeout may be "faked"
for platforms that don't support the notion of a timeout such as MIDP
Parameters:
t - the timeout duration
getTimeout
public int getTimeout()

Returns the timeout duration


Returns:
timeout in milliseconds
addErrorListener
public void addErrorListener(ActionListener e)

Adds a generic listener to a network error that is invoked before the exception is
propagated. Notice that this doesn't apply to server error codes! Consume the event
in order to prevent it from propagating further.
Parameters:
e - callback will be invoked with the Exception as the source object
removeErrorListener
public void removeErrorListener(ActionListener e)

Removes the given error listener


Parameters:
e - callback to remove
addProgressListener
public void addProgressListener(ActionListener al)

Adds a listener to be notified when progress updates


Parameters:
al - action listener
removeProgressListener
public void removeProgressListener(ActionListener al)

Adds a listener to be notified when progress updates


Parameters:
al - action listener
assignToThread
public void assignToThread(Class requestType,
int offset)

Method Detail

2408

Overview (Codename One API)


Makes sure the given class (subclass of ConnectionRequest) is always assigned to
the given thread number. This is useful for a case of an application that wants all
background downloads to occur on one thread so it doesn't tie up the main network
thread (but doesn't stop like a low priority request would).
Parameters:
requestType - the class of the specific connection request
offset - the offset of the thread starting from 0 and smaller than thread count
enumurateQueue
public Enumeration enumurateQueue()

This method returns all pending ConnectioRequest connections.


Returns:
the queue elements
isQueueIdle
public boolean isQueueIdle()

Indicates that the network queue is idle


Returns:
true if no network activity is in progress or pending
isAPSupported
public boolean isAPSupported()

Indicates whether looking up an access point is supported by this device


Returns:
true if access point lookup is supported
getAPIds
public String[] getAPIds()

Returns the ids of the access points available if supported


Returns:
ids of access points
getAPType
public int getAPType(String id)

Returns the type of the access point


Parameters:
id - access point id
Returns:
one of the supported access point types from network manager
getAPName
public String getAPName(String id)

Returns the user displayable name for the given access point
Parameters:
id - the id of the access point
Returns:
the name of the access point
getCurrentAccessPoint
public String getCurrentAccessPoint()

Returns the id of the current access point


Returns:
id of the current access point
setCurrentAccessPoint
public void setCurrentAccessPoint(String id)

Returns the id of the current access point


Parameters:
id - id of the current access point

Method Detail

2409

Overview (Codename One API)


com.codename1.io

Class NetworkEvent
java.lang.Object

com.codename1.ui.events.ActionEvent

com.codename1.io.NetworkEvent

public class
extends ActionEvent

Event containing more meta data for network events which may be error events or an update for
progress indication code.

Nested Class Summary

Nested classes/interfaces inherited from


class com.codename1.ui.events.ActionEvent
ActionEvent.Type

Field Summary
Modifier and Type
static int
static int
static int
static int

Field and Description


PROGRESS_TYPE_COMPLETED

Indicates that the connection request has completed


PROGRESS_TYPE_INITIALIZING

Indicates that a new request is initializing its connection


PROGRESS_TYPE_INPUT

Indicates the value for the current input stream reading


PROGRESS_TYPE_OUTPUT

Indicates the value for the current output stream writing

Constructor Summary
Constructor and Description
NetworkEvent(ConnectionRequest source, Exception error)

Constructs an event for an error message


NetworkEvent(ConnectionRequest request, int progressType)

Constructs a network status update event used to update progress indicators and application
logic of the current state in the NetworkManager
NetworkEvent(ConnectionRequest request, int responseCode, String message)

Constructs a response code even


NetworkEvent(ConnectionRequest request, Object metaData)

Constructs a callback event from a connection request with some arbitrary associated meta
data

Method Summary
Modifier and Type
ConnectionRequest
Exception

Class NetworkEvent

Method and Description


getConnectionRequest()

Equivalent to getSource() casted to connection request


getError()

2410

Overview (Codename One API)


getLength()
int

Returns the length of the download event or the upload event in case it
is known.

String

getMessage()

Object

getMetaData()
getProgressPercentage()

Returns the percentage of progress for a download operation assuming


length is known

int

getProgressType()

int

Indicates the type of progres indication for this event


getResponseCode()

int

Indicates the response code sent by the response code listener


getSentReceived()

int

Returns the amount of data received up to this event or sent up to this


event (depending on the event type).

void

setError(Exception error)

Methods inherited from


class com.codename1.ui.events.ActionEvent
consume, getActualComponent, getCommand, getComponent, getDraggedComponent,
getDropTarget, getEventType, getKeyEvent, getSource, getX, getY,
isConsumed, isLongEvent

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
PROGRESS_TYPE_INITIALIZING
public static final int PROGRESS_TYPE_INITIALIZING

Indicates that a new request is initializing its connection


See Also:
Constant Field Values
PROGRESS_TYPE_OUTPUT
public static final int PROGRESS_TYPE_OUTPUT

Indicates the value for the current output stream writing


See Also:
Constant Field Values
PROGRESS_TYPE_INPUT
public static final int PROGRESS_TYPE_INPUT

Indicates the value for the current input stream reading


See Also:
Constant Field Values
PROGRESS_TYPE_COMPLETED
public static final int PROGRESS_TYPE_COMPLETED

Indicates that the connection request has completed


See Also:
Constant Field Values

Method Summary

2411

Overview (Codename One API)


Constructor

Detail

NetworkEvent
public NetworkEvent(ConnectionRequest source,
Exception error)

Constructs an event for an error message


Parameters:
source - source of the error message
error - the exception
NetworkEvent
public NetworkEvent(ConnectionRequest request,
int responseCode,
String message)

Constructs a response code even


Parameters:
request - the connection request indicating progress
responseCode - the code
message - the error message
NetworkEvent
public NetworkEvent(ConnectionRequest request,
int progressType)

Constructs a network status update event used to update progress indicators and
application logic of the current state in the NetworkManager
Parameters:
request - the connection request indicating progress
progressType NetworkEvent
public NetworkEvent(ConnectionRequest request,
Object metaData)

Constructs a callback event from a connection request with some arbitrary associated
meta data
Parameters:
request - the connection request
metaData - the data associated with the event

Method Detail
getConnectionRequest
public ConnectionRequest getConnectionRequest()

Equivalent to getSource() casted to connection request


Returns:
the source connection request
getError
public Exception getError()

Returns:
the error
setError
public void setError(Exception error)

Parameters:
error

Constructor Detail

- the error to set

2412

Overview (Codename One API)


getProgressType
public int getProgressType()

Indicates the type of progres indication for this event


Returns:
One of PROGRESS_TYPE_COMPLETED,
PROGRESS_TYPE_INITIALIZING, PROGRESS_TYPE_INPUT,
PROGRESS_TYPE_OUTPUT
getResponseCode
public int getResponseCode()

Indicates the response code sent by the response code listener


Returns:
HTTP error code
getLength
public int getLength()

Returns the length of the download event or the upload event in case it is known. -1
is returned when the value is unknown.
Returns:
the length length in bytes or -1
getSentReceived
public int getSentReceived()

Returns the amount of data received up to this event or sent up to this event
(depending on the event type).
Returns:
the receieved or sent value
getProgressPercentage
public int getProgressPercentage()

Returns the percentage of progress for a download operation assuming length is


known
Returns:
the percentage of the download or -1
getMetaData
public Object getMetaData()

Returns:
the metaData
getMessage
public String getMessage()

Returns:
the message

Method Detail

2413

Overview (Codename One API)


com.codename1.io

Class MultipartRequest
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.io.MultipartRequest
All Implemented Interfaces:
IOProgressListener

public class
extends ConnectionRequest

A multipart post request allows a developer to submit large binary data files to the server in a multipart
mime post request. This is a standard method for large binary file uploads to webservers and data
services. The demo code below demonstrates uploading to the filestack.com API.
public void pictureUpload(final Callback<String> resultURL) {
String picture = Capture.capturePhoto(1024, -1);
if(picture!=null){
String filestack = "https://www.filestackapi.com/api/store/S3?key=MY_KEY&filename=myPicture.jpg";
MultipartRequest request = new MultipartRequest() {
protected void readResponse(InputStream input) throws IOException {
JSONParser jp = new JSONParser();
Map<String, Object> result = jp.parseJSON(new InputStreamReader(input, "UTF-8"));
String url = (String)result.get("url");
if(url == null) {
resultURL.onError(null, null, 1, result.toString());
return;
}
resultURL.onSucess(url);
}
};
request.setUrl(filestack);
try {
request.addData("fileUpload", picture, "image/jpeg");
request.setFilename("fileUpload", "myPicture.jpg");
NetworkManager.getInstance().addToQueue(request);
} catch(IOException err) {
err.printStackTrace();
}
}
}

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Constructor and Description
MultipartRequest()

Initialize variables

Method Summary
Modifier
and Type
void

Class MultipartRequest

Method and Description


addArgument(String name, String value)

Add an argument to the request response

2414

Overview (Codename One API)


addArgumentNoEncoding(String key, String value)

Add an argument to the request response without encoding it, this is useful for
arguments which are already encoded

void

addData(String name, byte[] data, String mimeType)

void

Adds a binary argument to the arguments


addData(String name, InputStream data, long dataSize, String mimeType)

Adds a binary argument to the arguments, notice the input stream will be read
only during submission

void

addData(String name, String filePath, String mimeType)

void

Adds a binary argument to the arguments

protected
void
protected
long

buildRequestBody(OutputStream os)

Invoked when send body is true, by default sends the request arguments
based on "POST" conventions
calculateContentLength()
getBoundary()

String

Returns the boundary string which is normally generated based on system time
getContentLength()

int

Returns the content length header value

protected
void

initConnection(Object connection)

Invoked to initialize HTTP headers, cookies etc.


isManualRedirect()

boolean

boolean

By default redirect responses (302 etc.) are handled manually in multipart


requests
onRedirect(String url)

This is a callback method that been called when there is a redirect.


setBoundary(String boundary)

void

Sets the boundary string, normally you don't need this method.
setCanFlushStream(boolean flush)

static void

Sending large files requires flushing the writer once in a while to prevent Out
Of Memory Errors, Some J2ME implementation are not able to flush the
streams causing the upload to fail.
setFilename(String arg, String filename)

void

Sets the filename for the given argument


setManualRedirect(boolean autoRedirect)

By default redirect responses (302 etc.) are handled manually in multipart


requests, set this to false to handle the redirect.

void

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArguments, addRequestHeader,
addResponseCodeListener, addResponseListener, cookieReceived, cookieSent,
createRequestURL, equals, fetchJSON, fireResponseListener, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleErrorResponseCode, handleException, handleIOException,
handleRuntimeException, hashCode, hasResponseListeners, initCookieHeader,
ioStreamUpdate, isCookiesEnabled, isCookiesEnabledDefault,
isDefaultFollowRedirects, isDuplicateSupported, isFailSilently,
isFollowRedirects, isKilled, isPausable, isPaused, isPost, isReadRequest,
isReadResponseForErrors, isRedirecting, isWriteRequest, kill, pause,
postResponse, readErrorCodeHeaders, readHeaders, readResponse,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,

Method Summary

2415

Overview (Codename One API)


shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MultipartRequest
public MultipartRequest()

Initialize variables

Method Detail
getBoundary
public String getBoundary()

Returns the boundary string which is normally generated based on system time
Returns:
the multipart boundary string
setBoundary
public void setBoundary(String boundary)

Sets the boundary string, normally you don't need this method. Its useful to
workaround server issues only. Notice that this method must be invoked before
adding any elements.
Parameters:
boundary - the boundary string
initConnection
protected void initConnection(Object connection)

Description copied from class: ConnectionRequest


Invoked to initialize HTTP headers, cookies etc.
Overrides:
initConnection in class ConnectionRequest
Parameters:
connection - the connection object
addData
public void addData(String name,
byte[] data,
String mimeType)

Adds a binary argument to the arguments


Parameters:
name - the name of the data
data - the data as bytes
mimeType - the mime type for the content
addData
public void addData(String name,
String filePath,
String mimeType)
throws IOException

Adds a binary argument to the arguments


Parameters:
name - the name of the file data

Methods inherited fromclass com.codename1.io.ConnectionRequest

2416

Overview (Codename One API)


filePath
mimeType

- the path of the file to upload


- the mime type for the content

Throws:
IOException

- if the file cannot be opened

addData
public void addData(String name,
InputStream data,
long dataSize,
String mimeType)

Adds a binary argument to the arguments, notice the input stream will be read only
during submission
Parameters:
name - the name of the data
data - the data stream
dataSize - the byte size of the data stream, if the data stream is a file the file
size can be obtained using the
FileSystemStorage.getInstance().getLength(file) method
mimeType - the mime type for the content
setFilename
public void setFilename(String arg,
String filename)

Sets the filename for the given argument


Parameters:
arg - the argument name
filename - the file name
addArgumentNoEncoding
public void addArgumentNoEncoding(String key,
String value)

Add an argument to the request response without encoding it, this is useful for
arguments which are already encoded
Overrides:
addArgumentNoEncoding in class ConnectionRequest
Parameters:
key - the key of the argument
value - the value for the argument
addArgument
public void addArgument(String name,
String value)

Add an argument to the request response


Overrides:
addArgument in class ConnectionRequest
Parameters:
name - the key of the argument
value - the value for the argument
calculateContentLength
protected long calculateContentLength()

buildRequestBody
protected void buildRequestBody(OutputStream os)
throws IOException

Invoked when send body is true, by default sends the request arguments based on
"POST" conventions
Overrides:
buildRequestBody in class ConnectionRequest
Parameters:
os - output stream of the body
Throws:
IOException

Method Detail

2417

Overview (Codename One API)


getContentLength
public int getContentLength()

Description copied from class: ConnectionRequest


Returns the content length header value
Overrides:
getContentLength in class ConnectionRequest
Returns:
the content length
onRedirect
public boolean onRedirect(String url)

Description copied from class: ConnectionRequest


This is a callback method that been called when there is a redirect.
Overrides:
onRedirect in class ConnectionRequest
Parameters:
url - the url to be redirected
Returns:
true if the implementation would like to handle this by itself
isManualRedirect
public boolean isManualRedirect()

By default redirect responses (302 etc.) are handled manually in multipart requests
Returns:
the autoRedirect
setManualRedirect
public void setManualRedirect(boolean autoRedirect)

By default redirect responses (302 etc.) are handled manually in multipart requests,
set this to false to handle the redirect. Notice that a redirect converts a post to a get.
Parameters:
autoRedirect - the autoRedirect to set
setCanFlushStream
public static void setCanFlushStream(boolean flush)

Sending large files requires flushing the writer once in a while to prevent Out Of
Memory Errors, Some J2ME implementation are not able to flush the streams
causing the upload to fail. This method can indicate to the upload to not use the
flushing mechanism.

Method Detail

2418

Overview (Codename One API)


com.codename1.io

Class Log
java.lang.Object

com.codename1.io.Log

public class
extends Object

Pluggable logging framework that allows a developer to log into storage using the file connector API.
It is highly recommended to use this class coupled with Netbeans preprocessing tags to reduce its
overhead completely in runtime.

Field Summary
Modifier and
Type

Field and Description


DEBUG

Constant indicating the logging level Debug is the default and the lowest
level followed by info, warning and error

static int

ERROR

Constant indicating the logging level Debug is the default and the lowest
level followed by info, warning and error

static int

INFO

Constant indicating the logging level Debug is the default and the lowest
level followed by info, warning and error

static int

REPORTING_DEBUG

Indicates that log reporting to the cloud should occur regardless of whether
an error occurred

static int

REPORTING_NONE

static int

Indicates that log reporting to the cloud should be disabled


REPORTING_PRODUCTION

Indicates that log reporting to the cloud should occur only if an error
occurred

static int

WARNING

Constant indicating the logging level Debug is the default and the lowest
level followed by info, warning and error

static int

Constructor Summary
Modifier Constructor and Description
protected

Log()

Prevent new Log() syntax.

Method Summary
Modifier
and Type

Method and Description


bindCrashProtection(boolean consumeError)

static void

protected
Writer

Class Log

Binds pro based crash protection logic that will send out an email in case of an
exception thrown on the EDT
createWriter()

Default method for creating the output writer into which we write, this method
creates a simple log file using the file connector

2419

Overview (Codename One API)


static void

e(Throwable t)

This method is a shorthand form for logThrowable


getFileURL()

String

Indicates the URL where the log file is saved

static Log

getInstance()

Returns the singleton instance of the log


getLevel()

static int

Returns the logging level for printing log details, the lower the value the more
verbose would the printouts be
getLogContent()

static
String

Returns the contents of the log as a single long string to be displayed by the
application any way it sees fit
getReportingLevel()

static int

Indicates the level of log reporting, this allows developers to send device logs
to the cloud thus tracking crashes or functionality in the device.

protected
String

getThreadAndTimeStamp()

Returns a simple string containing a timestamp and thread name.


getUniqueDeviceId()

static long

static void
boolean

Returns a server generated unique device id that is cached locally and is only
valid per application.
install(Log newInstance)

Installs a log subclass that can replace the logging destination/behavior


isFileWriteEnabled()

Indicates whether GCF's file writing should be used to generate the log file
logThrowable(Throwable t)

protected
void

static void
static void
protected
void
static void

Logs an exception to the log, by default print is called with the exception
details, on supported devices the stack trace is also physically written to the
log
p(String text)

Default println method invokes the print instance method, uses DEBUG level
p(String text, int level)

Default println method invokes the print instance method, uses given level
print(String text, int level)

Default log implementation prints to the console and the file connector if
applicable.
sendLog()

Sends the current log to the cloud regardless of the reporting level
setFileURL(String fileURL)

void

Indicates the URL where the log file is saved


setFileWriteEnabled(boolean fileWriteEnabled)

void

Indicates whether GCF's file writing should be used to generate the log file
setLevel(int level)

static void

Sets the logging level for printing log details, the lower the value the more
verbose would the printouts be
setReportingLevel(int level)

static void

Indicates the level of log reporting, this allows developers to send device logs
to the cloud thus tracking crashes or functionality in the device.
showLog()

static void

Deprecated.
this method is an outdated method that's no longer supported
trackFileSystem()

void

Activates the filesystem tracking of file open/close operations

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Summary

2420

Overview (Codename One API)


Field

Detail
DEBUG
public static final int DEBUG

Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
See Also:
Constant Field Values
INFO
public static final int INFO

Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
See Also:
Constant Field Values
WARNING
public static final int WARNING

Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
See Also:
Constant Field Values
ERROR
public static final int ERROR

Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
See Also:
Constant Field Values
REPORTING_NONE
public static int REPORTING_NONE

Indicates that log reporting to the cloud should be disabled


REPORTING_DEBUG
public static int REPORTING_DEBUG

Indicates that log reporting to the cloud should occur regardless of whether an error
occurred
REPORTING_PRODUCTION
public static int REPORTING_PRODUCTION

Indicates that log reporting to the cloud should occur only if an error occurred

Constructor Detail
Log
protected Log()

Prevent new Log() syntax. Use getInstance()

Method Detail

Field Detail

2421

Overview (Codename One API)


setReportingLevel
public static void setReportingLevel(int level)

Indicates the level of log reporting, this allows developers to send device logs to the
cloud thus tracking crashes or functionality in the device.
Parameters:
level - one of REPORTING_NONE, REPORTING_DEBUG,
REPORTING_PRODUCTION
getReportingLevel
public static int getReportingLevel()

Indicates the level of log reporting, this allows developers to send device logs to the
cloud thus tracking crashes or functionality in the device.
Returns:
one of REPORTING_NONE, REPORTING_DEBUG,
REPORTING_PRODUCTION
getUniqueDeviceId
public static long getUniqueDeviceId()

Returns a server generated unique device id that is cached locally and is only valid
per application. Notice that this device id is specific to your application and to a
specific install, it is guaranteed to be completely unique or -1 if unavailable (which
can be due to a network error). Warning: this method might block while accessing the
server!s
Returns:
a unique device id
sendLog
public static void sendLog()

Sends the current log to the cloud regardless of the reporting level
install
public static void install(Log newInstance)

Installs a log subclass that can replace the logging destination/behavior


Parameters:
newInstance - the new instance for the Log object
p
public static void p(String text)

Default println method invokes the print instance method, uses DEBUG level
Parameters:
text - the text to print
p
public static void p(String text,
int level)

Default println method invokes the print instance method, uses given level
Parameters:
text - the text to print
level - one of DEBUG, INFO, WARNING, ERROR
e
public static void e(Throwable t)

This method is a shorthand form for logThrowable


Parameters:
t - the exception

Method Detail

2422

Overview (Codename One API)


logThrowable
protected void logThrowable(Throwable t)

Logs an exception to the log, by default print is called with the exception details, on
supported devices the stack trace is also physically written to the log
Parameters:
t print
protected void print(String text,
int level)

Default log implementation prints to the console and the file connector if applicable.
Also prepends the thread information and time before
Parameters:
text - the text to print
level - one of DEBUG, INFO, WARNING, ERROR
createWriter
protected Writer createWriter()
throws IOException

Default method for creating the output writer into which we write, this method creates
a simple log file using the file connector
Returns:
writer object
Throws:
IOException - when thrown by the connector
getThreadAndTimeStamp
protected String getThreadAndTimeStamp()

Returns a simple string containing a timestamp and thread name.


Returns:
timestamp string for use in the log
setLevel
public static void setLevel(int level)

Sets the logging level for printing log details, the lower the value the more verbose
would the printouts be
Parameters:
level - one of DEBUG, INFO, WARNING, ERROR
getLevel
public static int getLevel()

Returns the logging level for printing log details, the lower the value the more verbose
would the printouts be
Returns:
one of DEBUG, INFO, WARNING, ERROR
getLogContent
public static String getLogContent()

Returns the contents of the log as a single long string to be displayed by the
application any way it sees fit
Returns:
string containing the whole log
showLog
public static void showLog()

Deprecated. this method is an outdated method that's no longer supported


Places a form with the log as a TextArea on the screen, this method can be attached
to appear at a given time or using a fixed global key. Using this method might cause

Method Detail

2423

Overview (Codename One API)

a problem with further log output


getInstance
public static Log getInstance()

Returns the singleton instance of the log


Returns:
the singleton instance of the log
isFileWriteEnabled
public boolean isFileWriteEnabled()

Indicates whether GCF's file writing should be used to generate the log file
Returns:
the fileWriteEnabled
setFileWriteEnabled
public void setFileWriteEnabled(boolean fileWriteEnabled)

Indicates whether GCF's file writing should be used to generate the log file
Parameters:
fileWriteEnabled - the fileWriteEnabled to set
getFileURL
public String getFileURL()

Indicates the URL where the log file is saved


Returns:
the fileURL
setFileURL
public void setFileURL(String fileURL)

Indicates the URL where the log file is saved


Parameters:
fileURL - the fileURL to set
trackFileSystem
public void trackFileSystem()

Activates the filesystem tracking of file open/close operations


bindCrashProtection
public static void bindCrashProtection(boolean consumeError)

Binds pro based crash protection logic that will send out an email in case of an
exception thrown on the EDT
Parameters:
consumeError - true will hide the error from the user, false will leave the builtin
logic that defaults to showing an error dialog to the user

Method Detail

2424

Overview (Codename One API)


com.codename1.io

Class JSONParser
java.lang.Object

com.codename1.io.JSONParser
All Implemented Interfaces:
JSONParseCallback

public class
extends Object
implements JSONParseCallback

Fast and dirty parser for JSON content on the web, it essentially returns a Map object containing the
object fields mapped to their values. If the value is a nested object a nested Map/List is returned. The
sample code below fetches a page of data from the nestoria housing listing API as a list of Map
elements. You can see instructions on how to display the data in the InfiniteScrollAdapter class.

int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
r.addArgument("page", "" + pageNumber);
pageNumber++;
r.addArgument("country", "uk");
r.addArgument("place_name", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getRes
Map<String, Object> response = (Map<String, Object>)result.get("response");
return (java.util.List<Map<String, Object>>)response.get("listings");
} catch(Exception err) {
Log.e(err);
return null;
}
}

Constructor Summary
Constructor and Description
JSONParser()

Method Summary
Modifier and Type
void
void
boolean

Method and Description


endArray(String arrayName)

Indicates that the parser ran into an ending bracket event ]


endBlock(String blockName)

Indicates that the parser ran into an ending bracket event }


isAlive()

This method indicates to the Parser if this Callback is still alive


isUseLongs()

static boolean

Indicates that the parser will generate long objects and not just
doubles for numeric values
keyValue(String key, String value)

void

void

Class JSONParser

This method is called when a string key/value pair is detected


within the json it is essentially redundant when following
string/numeric token.
longToken(long tok)

2425

Overview (Codename One API)


Submits a numeric token from the JSON data
numericToken(double tok)

void

Submits a numeric token from the JSON data


parse(Reader i)

Hashtable<String,Object>

Deprecated.
use the new parseJSON instead
parse(Reader i, JSONParseCallback callback)

static void

Static method! Parses the given input stream and fires the data
into the given callback.
parseJSON(Reader i)

Map<String,Object>

Parses the given input stream into this object and returns the
parse tree
setUseLongs(boolean aUseLongsDefault)

static void

Indicates that the parser will generate long objects and not just
doubles for numeric values
startArray(String arrayName)

void

Indicates that the parser ran into an opening bracket event [


startBlock(String blockName)

void

Indicates that the parser ran into an opening bracket event {


stringToken(String tok)

Submits a token from the JSON data as a java string, this


token is always a string value

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
JSONParser
public JSONParser()

Method Detail
isUseLongs
public static boolean isUseLongs()

Indicates that the parser will generate long objects and not just doubles for numeric
values
Returns:
the useLongsDefault
setUseLongs
public static void setUseLongs(boolean aUseLongsDefault)

Indicates that the parser will generate long objects and not just doubles for numeric
values
Parameters:
aUseLongsDefault - the useLongsDefault to set
parse
public static void parse(Reader i,
JSONParseCallback callback)
throws IOException

Static method! Parses the given input stream and fires the data into the given
callback.
Parameters:
i - the reader

Method Summary

2426

Overview (Codename One API)


callback

- a generic callback to receive the parse events

Throws:
IOException

- if thrown by the stream

parseJSON
public Map<String,Object> parseJSON(Reader i)
throws IOException

Parses the given input stream into this object and returns the parse tree
Parameters:
i - the reader
Returns:
the parse tree as a hashtable
Throws:
IOException - if thrown by the stream
parse
public Hashtable<String,Object> parse(Reader i)
throws IOException

Deprecated. use the new parseJSON instead


Parses the given input stream into this object and returns the parse tree
Parameters:
i - the reader
Returns:
the parse tree as a hashtable
Throws:
IOException - if thrown by the stream
startBlock
public void startBlock(String blockName)

Indicates that the parser ran into an opening bracket event {


Specified by:
startBlock in interface JSONParseCallback
endBlock
public void endBlock(String blockName)

Indicates that the parser ran into an ending bracket event }


Specified by:
endBlock in interface JSONParseCallback
startArray
public void startArray(String arrayName)

Indicates that the parser ran into an opening bracket event [


Specified by:
startArray in interface JSONParseCallback
endArray
public void endArray(String arrayName)

Indicates that the parser ran into an ending bracket event ]


Specified by:
endArray in interface JSONParseCallback
stringToken
public void stringToken(String tok)

Submits a token from the JSON data as a java string, this token is always a string
value
Specified by:
stringToken in interface JSONParseCallback

Method Detail

2427

Overview (Codename One API)


numericToken
public void numericToken(double tok)

Submits a numeric token from the JSON data


Specified by:
numericToken in interface JSONParseCallback
longToken
public void longToken(long tok)

Submits a numeric token from the JSON data


Specified by:
longToken in interface JSONParseCallback
keyValue
public void keyValue(String key,
String value)

This method is called when a string key/value pair is detected within the json it is
essentially redundant when following string/numeric token.
Specified by:
keyValue in interface JSONParseCallback
Parameters:
key - the key
value - a string value
isAlive
public boolean isAlive()

This method indicates to the Parser if this Callback is still alive


Specified by:
isAlive in interface JSONParseCallback
Returns:
true if the Callback is still interested to get the JSON parse events from the
JSONParser

Method Detail

2428

Overview (Codename One API)


com.codename1.io

Interface JSONParseCallback
All Known Implementing Classes:
JSONParser

public interface

The event based parser allows parsing without creating an object tree by receiving callbacks to this
class.

Method Summary
Modifier
and Type

Method and Description


endArray(String arrayName)

void

Indicates that the parser ran into an ending bracket event ]


endBlock(String blockName)

void

Indicates that the parser ran into an ending bracket event }

boolean

isAlive()

This method indicates to the Parser if this Callback is still alive


keyValue(String key, String value)

void

void
void
void
void

This method is called when a string key/value pair is detected within the json it
is essentially redundant when following string/numeric token.
longToken(long tok)

Submits a numeric token from the JSON data


numericToken(double tok)

Submits a numeric token from the JSON data


startArray(String arrayName)

Indicates that the parser ran into an opening bracket event [


startBlock(String blockName)

Indicates that the parser ran into an opening bracket event {


stringToken(String tok)

void

Submits a token from the JSON data as a java string, this token is always a
string value

Method Detail
startBlock
void startBlock(String blockName)

Indicates that the parser ran into an opening bracket event {


endBlock
void endBlock(String blockName)

Indicates that the parser ran into an ending bracket event }


startArray
void startArray(String arrayName)

Indicates that the parser ran into an opening bracket event [

Interface JSONParseCallback

2429

Overview (Codename One API)


endArray
void endArray(String arrayName)

Indicates that the parser ran into an ending bracket event ]


stringToken
void stringToken(String tok)

Submits a token from the JSON data as a java string, this token is always a string
value
numericToken
void numericToken(double tok)

Submits a numeric token from the JSON data


longToken
void longToken(long tok)

Submits a numeric token from the JSON data


keyValue
void keyValue(String key,
String value)

This method is called when a string key/value pair is detected within the json it is
essentially redundant when following string/numeric token.
Parameters:
key - the key
value - a string value
isAlive
boolean isAlive()

This method indicates to the Parser if this Callback is still alive


Returns:
true if the Callback is still interested to get the JSON parse events from the
JSONParser

Method Detail

2430

Overview (Codename One API)


com.codename1.io

Interface IOProgressListener
All Known Implementing Classes:
AdsService, CachedDataService, ConnectionRequest, GZConnectionRequest,
ImageDownloadService, InnerActive, MultipartRequest, RSSService, TwitterRESTService

public interface

Callback for IO updates from a buffered input/output stream

Method Summary
Modifier and
Type

Method and Description


ioStreamUpdate(Object source, int bytes)

Indicates the number of bytes that were read/written to/from the source
stream

void

Method Detail
ioStreamUpdate
void ioStreamUpdate(Object source,
int bytes)

Indicates the number of bytes that were read/written to/from the source stream
Parameters:
source - the source stream which can be either an input stream or an output
stream
bytes - the number of bytes read or written

Interface IOProgressListener

2431

Overview (Codename One API)


com.codename1.io

Class FileSystemStorage
java.lang.Object

com.codename1.io.FileSystemStorage

public class
extends Object

Unlike networking, the file system storage mostly tries to emulate java.io.File with some simplifications
for mobile devices.
A lot of API's rely on FileSystemStorage as its the API native code usually uses consistently. E.g. in
this sample below the FileSystemStorage is used to save a screenshot image for sharing on social
media:
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");

Field Summary
Modifier
and Type

Field and Description


ROOT_TYPE_MAINSTORAGE

static int

Represents the type for the get root type method, this type generally
represents the main phone memory
ROOT_TYPE_SDCARD

static int

Represents the type for the get root type method, this type generally
represents an SD card although due to variability in phone standards an SD
card might be detected incorrectly.
ROOT_TYPE_UNKNOWN

static int

Returned for different types of root for which there is no specific knowledge
one way or the other.

Method Summary
Modifier and Type
void

Method and Description


delete(String file)

Deletes the specific file or empty directory.


deleteRetry(String file, int retryCount)

void

boolean
String
char

Method Detail

Deletes the specific file or empty directory, if the platform supports a


delete on exit this method will activate it.
exists(String file)

Indicates whether a file exists


getAppHomePath()

This will return the application home directory.


getFileSystemSeparator()

2432

Overview (Codename One API)


Returns the file system separator char normally '/'
static
FileSystemStorage

getInstance()

This class is a singleton


getLastModified(String file)

Returns the time that the file denoted by this abstract pathname
was last modified.

long

getLength(String file)

long

Returns the length of the file


getRootAvailableSpace(String root)

long

Returns the available space in the given root directory


getRoots()

String[]

Returns the filesystem roots from which the structure of the file
system can be traversed
getRootSizeBytes(String root)

long

Returns the size of the given root directory


getRootType(String root)

int

Returns the type of the root often by guessing

boolean
boolean

isDirectory(String file)

Indicates whether the given file is a directory


isHidden(String file)

Indicates the hidden state of the file


listFiles(String directory)

String[]

Lists the files within the given directory, returns relative file names
and not full file names.
mkdir(String directory)

void

Creates the given directory

InputStream
OutputStream
OutputStream

openInputStream(String file)

Opens an input stream to the given file


openOutputStream(String file)

Opens an output stream to the given file


openOutputStream(String file, int offset)

Opens an output stream to the given file


rename(String file, String newName)

Renames a file to the given name, expects the new name to be


relative to the current directory

void

setHidden(String file, boolean h)

void

Toggles the hidden state of the file

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
ROOT_TYPE_MAINSTORAGE
public static final int ROOT_TYPE_MAINSTORAGE

Represents the type for the get root type method, this type generally represents the
main phone memory
See Also:
Constant Field Values
ROOT_TYPE_SDCARD
public static final int ROOT_TYPE_SDCARD

Represents the type for the get root type method, this type generally represents an
SD card although due to variability in phone standards an SD card might be detected
incorrectly. E.g. newer Nokia devices such as N97 have a large storage area that is

Method Summary

2433

Overview (Codename One API)


marked as "E:" but is really internal storage. If an SD card isn't physically in the
phone the "F:" won't be returned and it will be impossible to detect that "E:" is not the
actual SD card.
See Also:
Constant Field Values
ROOT_TYPE_UNKNOWN
public static final int ROOT_TYPE_UNKNOWN

Returned for different types of root for which there is no specific knowledge one way
or the other.
See Also:
Constant Field Values

Method Detail
getInstance
public static FileSystemStorage getInstance()

This class is a singleton


Returns:
instance of this class
getRoots
public String[] getRoots()

Returns the filesystem roots from which the structure of the file system can be
traversed
Returns:
the roots of the filesystem
getRootType
public int getRootType(String root)

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
public String[] listFiles(String directory)
throws IOException

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

getRootSizeBytes
public long getRootSizeBytes(String root)

Returns the size of the given root directory


Parameters:
root - the root directory in the filesystem
Returns:
the byte size of the directory

Field Detail

2434

Overview (Codename One API)


getRootAvailableSpace
public long getRootAvailableSpace(String root)

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
public void mkdir(String directory)

Creates the given directory


Parameters:
directory - the directory name to create
delete
public void delete(String file)

Deletes the specific file or empty directory.


Parameters:
file - file or empty directory to delete
deleteRetry
public void deleteRetry(String file,
int retryCount)

Deletes the specific file or empty directory, if the platform supports a delete on exit
this method will activate it. Regardless it will retry deleting (with delay) several times
to allow streams time to close.
Parameters:
file - file to delete
retryCount - the number of times to retry
exists
public boolean exists(String file)

Indicates whether a file exists


Parameters:
file - the file to check
Returns:
true if the file exists and false otherwise
isHidden
public boolean isHidden(String file)

Indicates the hidden state of the file


Parameters:
file - file
Returns:
true for a hidden file
setHidden
public void setHidden(String file,
boolean h)

Toggles the hidden state of the file


Parameters:
file - file
h - hidden state
rename
public void rename(String file,
String newName)

Method Detail

2435

Overview (Codename One API)


Renames a file to the given name, expects the new name to be relative to the current
directory
Parameters:
file - absolute file name
newName - relative new name
getLength
public long getLength(String file)

Returns the length of the file


Parameters:
file - file
Returns:
length of said file
getLastModified
public long getLastModified(String file)

Returns the time that the file denoted by this abstract pathname was last modified.
Returns:
A long value representing the time the file was last modified, measured in
milliseconds
isDirectory
public boolean isDirectory(String file)

Indicates whether the given file is a directory


Parameters:
file - file
Returns:
true if its a directory
getFileSystemSeparator
public char getFileSystemSeparator()

Returns the file system separator char normally '/'


Returns:
the separator char
openOutputStream
public OutputStream openOutputStream(String file)
throws IOException

Opens an output stream to the given file


Parameters:
file - the file
Returns:
the output stream
Throws:
IOException

openInputStream
public InputStream openInputStream(String file)
throws IOException

Opens an input stream to the given file


Parameters:
file - the file
Returns:
the input stream
Throws:
IOException

openOutputStream
public OutputStream openOutputStream(String file,
int offset)
throws IOException

Method Detail

2436

Overview (Codename One API)


Opens an output stream to the given file
Parameters:
file - the file
offset - position in the file
Returns:
the output stream
Throws:
IOException

getAppHomePath
public String getAppHomePath()

This will return the application home directory. On some platforms such as Android
this path may be visible only to the application itself, other apps won't have
permission to access this path
Returns:
a writable directory that represent the application home directory

Method Detail

2437

Overview (Codename One API)


com.codename1.io

Interface Externalizable
All Known Implementing Classes:
AccessToken, CachedData, CloudObject, Cookie

public interface

Similar to the Java SE externalizable interface this interface allows an object to declare itself as
externalizable for serialization. However, due to the lack of reflection and use of obfuscation these
objects must be registered with the Util class. Notice that all externalizable objects must have a
default public constructor.

Method Summary
Modifier
and Type

Method and Description


externalize(DataOutputStream out)

Allows us to store an object state, this method must be implemented in order to


save the state of an object

void

getObjectId()

The object id must be unique, it is used to identify the object when loaded even
when it is obfuscated.

String

getVersion()

Returns the version for the current persistance code, the version will be pased
to internalized thus allowing the internalize method to recognize classes
persisted in older revisions

int

internalize(int version, DataInputStream in)

void

Loads the object from the input stream and allows deserialization

Method Detail
getVersion
int getVersion()

Returns the version for the current persistance code, the version will be pased to
internalized thus allowing the internalize method to recognize classes persisted in
older revisions
Returns:
version number for the persistant code
externalize
void externalize(DataOutputStream out)
throws IOException

Allows us to store an object state, this method must be implemented in order to save
the state of an object
Parameters:
out - the stream into which the object must be serialized
Throws:
IOException - the method may throw an exception
internalize
void internalize(int version,
DataInputStream in)
throws IOException

Interface Externalizable

2438

Overview (Codename One API)


Loads the object from the input stream and allows deserialization
Parameters:
version - the version the class returned during the externalization processs
in - the input stream used to load the class
Throws:
IOException - the method may throw an exception
getObjectId
String getObjectId()

The object id must be unique, it is used to identify the object when loaded even when
it is obfuscated.
Returns:
a unique id

Method Detail

2439

Overview (Codename One API)


com.codename1.io

Class Cookie
java.lang.Object

com.codename1.io.Cookie
All Implemented Interfaces:
Externalizable

public class
extends Object
implements Externalizable

A cookie for an HTTP request

Field Summary
Modifier and Type Field and Description
static String

STORAGE_NAME

Constructor Summary
Constructor and Description
Cookie()

Method Summary
Modifier
and Type
static
void

Method and Description


clearCookiesFromStorage()

Clears all cookies history from storage


externalize(DataOutputStream out)

void

Allows us to store an object state, this method must be implemented in order to


save the state of an object

String

getDomain()

long

getExpires()

String

getName()
getObjectId()

String

The object id must be unique, it is used to identify the object when loaded even
when it is obfuscated.

String

getPath()

String

getValue()
getVersion()

int

void

Class Cookie

Returns the version for the current persistance code, the version will be pased
to internalized thus allowing the internalize method to recognize classes
persisted in older revisions
internalize(int version, DataInputStream in)

Loads the object from the input stream and allows deserialization

static
boolean

isAutoStored()

boolean

isHttpOnly()

boolean

isSecure()

Returns true if the Cookies are auto stored to storage

2440

Overview (Codename One API)


static
void

setAutoStored(boolean autoStored)

void

setDomain(String domain)

void

setExpires(long expires)

void

setHttpOnly(boolean httpOnly)

void

setName(String name)

void

setPath(String path)

void

setSecure(boolean secure)

void

setValue(String value)

String

This method configures the auto storage of cookies

toString()

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
STORAGE_NAME
public static String STORAGE_NAME

Constructor Detail
Cookie
public Cookie()

Method Detail
getName
public String getName()

Returns:
the name
setName
public void setName(String name)

Parameters:
name

- the name to set

setSecure
public void setSecure(boolean secure)

isSecure
public boolean isSecure()

setHttpOnly
public void setHttpOnly(boolean httpOnly)

isHttpOnly
public boolean isHttpOnly()

setPath
public void setPath(String path)

Method Summary

2441

Overview (Codename One API)


getPath
public String getPath()

getValue
public String getValue()

Returns:
the value
setValue
public void setValue(String value)

Parameters:
value

- the value to set

getDomain
public String getDomain()

Returns:
the domain
setDomain
public void setDomain(String domain)

Parameters:
domain

- the domain to set

getExpires
public long getExpires()

Returns:
the expires
setExpires
public void setExpires(long expires)

Parameters:
expires

- the expires to set

getVersion
public int getVersion()

Returns the version for the current persistance code, the version will be pased to
internalized thus allowing the internalize method to recognize classes persisted in
older revisions
Specified by:
getVersion in interface Externalizable
Returns:
version number for the persistant code
externalize
public void externalize(DataOutputStream out)
throws IOException

Allows us to store an object state, this method must be implemented in order to save
the state of an object
Specified by:
externalize in interface Externalizable
Parameters:
out - the stream into which the object must be serialized
Throws:
IOException - the method may throw an exception

Method Detail

2442

Overview (Codename One API)


internalize
public void internalize(int version,
DataInputStream in)
throws IOException

Loads the object from the input stream and allows deserialization
Specified by:
internalize in interface Externalizable
Parameters:
version - the version the class returned during the externalization processs
in - the input stream used to load the class
Throws:
IOException - the method may throw an exception
getObjectId
public String getObjectId()

The object id must be unique, it is used to identify the object when loaded even when
it is obfuscated.
Specified by:
getObjectId in interface Externalizable
Returns:
a unique id
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
setAutoStored
public static void setAutoStored(boolean autoStored)

This method configures the auto storage of cookies


Parameters:
autoStored isAutoStored
public static boolean isAutoStored()

Returns true if the Cookies are auto stored to storage


Returns:
autoStored
clearCookiesFromStorage
public static void clearCookiesFromStorage()

Clears all cookies history from storage

Method Detail

2443

Overview (Codename One API)


com.codename1.io

Class ConnectionRequest
java.lang.Object

com.codename1.io.ConnectionRequest
All Implemented Interfaces:
IOProgressListener
Direct Known Subclasses:
AdsService, CachedDataService, GZConnectionRequest, ImageDownloadService,
MultipartRequest, RSSService, TwitterRESTService

public class
extends Object
implements IOProgressListener

This class represents a connection object in the form of a request response typically common for
HTTP/HTTPS connections. A connection request is added to the NetworkManager for processing in a
queue on one of the network threads.
The sample code below fetches a page of data from the nestoria housing listing API.
You can see instructions on how to display the data in the InfiniteScrollAdapter class.

int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
r.addArgument("page", "" + pageNumber);
pageNumber++;
r.addArgument("country", "uk");
r.addArgument("place_name", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getRes
Map<String, Object> response = (Map<String, Object>)result.get("response");
return (java.util.List<Map<String, Object>>)response.get("listings");
} catch(Exception err) {
Log.e(err);
return null;
}
}

Field Summary
Modifier
and Type

Field and Description


PRIORITY_CRITICAL

static byte

A critical priority request will "push" through the queue to the highest point
regardless of anything else and ignoring anything that is not in itself of critical
priority.
PRIORITY_HIGH

static byte

A high priority request is the second highest level, it will act exactly like a
critical priority with one difference.
PRIORITY_LOW

static byte

static byte
static byte

Class ConnectionRequest

Low priority requests are mostly background tasks that should still be
accomplished though
PRIORITY_NORMAL

Normal priority executes as usual on the queue


PRIORITY_REDUNDANT

Redundant elements can be discarded from the queue when paused

2444

Overview (Codename One API)


Constructor

Summary

Constructor and Description


ConnectionRequest()

Method Summary
Modifier and Type

Method and Description


addArgument(String key, byte[] value)

void

void

Deprecated.
use the version that accepts a string instead
addArgument(String key, String value)

Add an argument to the request response


addArgument(String key, String[] value)

void

Add an argument to the request response as an array of elements,


this will trigger multiple request entries with the same key
addArgumentNoEncoding(String key, String value)

void

Add an argument to the request response without encoding it, this is


useful for arguments which are already encoded
addArguments(String key, String... value)

void

void

Add an argument to the request response as an array of elements,


this will trigger multiple request entries with the same key
addRequestHeader(String key, String value)

Adds the given header to the request that will be sent


addResponseCodeListener(ActionListener a)

void

Adds a listener that would be notified on the CodenameOne thread


of a response code that is not a 200 (OK) or 301/2 (redirect)
response code.
addResponseListener(ActionListener a)

void

Adds a listener that would be notified on the CodenameOne thread


of a response from the server.
buildRequestBody(OutputStream os)

protected void

protected void
protected void
protected String
boolean
static
Map<String,Object>
protected void
int
String

Invoked when send body is true, by default sends the request


arguments based on "POST" conventions
cookieReceived(Cookie c)

Callback invoked for every cookie received from the server


cookieSent(Cookie c)

Callback invoked for every cookie being sent to the server


createRequestURL()

Creates the request URL mostly for a get request


equals(Object o)

Indicates whether some other object is "equal to" this one.


fetchJSON(String url)

Utility method that returns a JSON structure or throws an


IOException in case of a failure.
fireResponseListener(ActionEvent ev)

Fires the response event to the listeners on this connection


getContentLength()

Returns the content length header value


getContentType()
getCookieHeader()

static String

Workaround for https://bugs.php.net/bug.php?id=65633 allowing


developers to customize the name of the cookie header to Cookie

static String

getDefaultUserAgent()

String

getDestinationFile()

Constructor Summary

2445

Overview (Codename One API)


When set to a none null string saves the response to file system
under this file name
getDestinationStorage()
String

When set to a none null string saves the response to storage under
this file name
getDisposeOnCompletion()

Dialog

A dialog that will be seamlessly disposed once the given request


has been completed
getHeader(Object connection, String header)

protected String

Returns the HTTP header field for the given connection, this method
is only guaranteed to work when invoked from the readHeaders
method.
getHeaderFieldNames(Object connection)

protected String[]

Returns the HTTP header field names for the given connection, this
method is only guaranteed to work when invoked from the
readHeaders method.
getHeaders(Object connection, String header)

protected String[]

String
byte

Returns the HTTP header field for the given connection, this method
is only guaranteed to work when invoked from the readHeaders
method.
getHttpMethod()

Returns the http method


getPriority()

The priority of this connection based on the constants in this class


getResponseCode()

int

String

Returns the response code for this request, this is only relevant after
the request completed and might contain a temporary (e.g.
getResponseContentType()

Returns the content type from the response headers


getResponseData()

byte[]

This method will return a valid value for only some of the responses
and only after the response was processed
getResposeCode()

int

Deprecated.
misspelled method name please use getResponseCode
getShowOnInit()

Dialog

This dialog will be shown when this request enters the network
queue
getSilentRetryCount()

int

int

Indicates the number of times to silently retry a connection that


failed before prompting
getTimeout()

Indicates the timeout for this connection request

String

getUrl()

String

getUserAgent()
getYield()

protected int

Returns the amount of time to yield for other processes, this is an


implicit method that automatically generates values for lower priority
connections
handleErrorResponseCode(int code, String message)

protected void

Handles a server response code that is not 200 and not a redirect
(unless redirect handling is disabled)
handleException(Exception err)

protected void

protected void
protected void

Method Summary

Handles an exception thrown when performing a network operation,


the default implementation shows a retry dialog.
handleIOException(IOException err)

Handles IOException thrown when performing a network operation


handleRuntimeException(RuntimeException err)

Handles an exception thrown when performing a network operation

2446

Overview (Codename One API)


int

hashCode()

Returns a hash code value for the object.


hasResponseListeners()

protected boolean

protected void
protected String

Returns true if someone is listening to action response events, this


is useful so we can decide whether to bother collecting data for an
event in some cases since building the event object might be
memory/CPU intensive.
initConnection(Object connection)

Invoked to initialize HTTP headers, cookies etc.


initCookieHeader(String cookie)

Allows subclasses to inject cookies into the request


ioStreamUpdate(Object source, int bytes)

void

Indicates the number of bytes that were read/written to/from the


source stream

boolean

isCookiesEnabled()

static boolean

isCookiesEnabledDefault()

static boolean

isDefaultFollowRedirects()
isDuplicateSupported()

boolean

boolean

Indicates whether this connection request supports duplicate entries


in the request queue
isFailSilently()

Indicates that we are uninterested in error handling

boolean

isFollowRedirects()

protected boolean

isKilled()
isPausable()

protected boolean

Return true from this method if this connection can be paused and
resumed later on.

protected boolean

isPaused()

boolean
boolean

isPost()

Returns true for a post operation and false for a get operation
isReadRequest()
isReadResponseForErrors()

boolean

boolean
boolean
void
boolean

When set to true the read response code will happen even for error
codes such as 400 and 500
isRedirecting()

Returns true if this request is been redirected to a different url


isWriteRequest()
kill()

Kills this request if possible


onRedirect(String url)

This is a callback method that been called when there is a redirect.


pause()

boolean

Invoked to pause this opeation, this method will only be invoked if


isPausable() returns true (its false by default).
postResponse()

protected void

A callback method that's invoked on the EDT after the


readResponse() method has finished, this is the place where
developers should change their Codename One user interface to
avoid race conditions that might be triggered by modifications within
readResponse.
readErrorCodeHeaders(Object connection)

protected void

Allows reading the headers from the connection by calling the


getHeader() method when a response that isn't 200 OK is sent.
readHeaders(Object connection)

protected void

Allows reading the headers from the connection by calling the


getHeader() method.

protected void

readResponse(InputStream input)

Method Summary

2447

Overview (Codename One API)


Callback for the server response with the input stream from the
server.
void
void
void
void

removeAllArguments()

Removes all arguments


removeArgument(String key)

Removes the given argument from the request


removeResponseCodeListener(ActionListener a)

Removes the given listener


removeResponseListener(ActionListener a)

Removes the given listener


resume()

boolean

void

Called when a previously paused operation now has the networking


time to resume.
retry()

Retry the current operation in case of an exception


setChunkedStreamingMode(int chunklen)

void

void

This method is used to enable streaming of a HTTP request body


without internal buffering, when the content length is not known in
advance.
setContentType(String contentType)
setCookieHeader(String aCookieHeader)

static void

Workaround for https://bugs.php.net/bug.php?id=65633 allowing


developers to customize the name of the cookie header to Cookie

void

setCookiesEnabled(boolean cookiesEnabled)

static void

setCookiesEnabledDefault(boolean aCookiesEnabledDefault)

static void

setDefaultFollowRedirects(boolean aDefaultFollowRedirects)

static void

setDefaultUserAgent(String aDefaultUserAgent)
setDestinationFile(String destinationFile)

void

When set to a none null string saves the response to file system
under this file name
setDestinationStorage(String destinationStorage)

void

When set to a none null string saves the response to storage under
this file name
setDisposeOnCompletion(Dialog disposeOnCompletion)

void

A dialog that will be seamlessly disposed once the given request


has been completed
setDuplicateSupported(boolean duplicateSupported)

void

void
void
void

Indicates whether this connection request supports duplicate entries


in the request queue
setFailSilently(boolean failSilently)

Indicates that we are uninterested in error handling


setFollowRedirects(boolean followRedirects)
setHttpMethod(String httpMethod)

Sets the http method for the request

protected void

setKilled(boolean killed)

protected void

setPaused(boolean paused)
setPost(boolean post)

void

void
void

Set to true for a post operation and false for a get operation, this will
implicitly set the method to post/get respectively (which you can
change back by setting the method).
setPriority(byte priority)

The priority of this connection based on the constants in this class


setReadRequest(boolean readRequest)
setReadResponseForErrors(boolean readResponseForErrors)

void

Method Summary

When set to true the read response code will happen even for error
codes such as 400 and 500

2448

Overview (Codename One API)


setShowOnInit(Dialog showOnInit)

This dialog will be shown when this request enters the network
queue

void

setSilentRetryCount(int silentRetryCount)

Indicates the number of times to silently retry a connection that


failed before prompting

void

setTimeout(int timeout)

void

Indicates the timeout for this connection request

void

setUrl(String url)

static void

setUseNativeCookieStore(boolean b)

Indicates whether the native Cookie stores should be used

void

setUserAgent(String userAgent)

void

setWriteRequest(boolean writeRequest)
shouldAutoCloseResponse()

protected boolean

Indicates whether the response stream should be closed


automatically by the framework (defaults to true), this might cause
an issue if the stream needs to be passed to a separate thread for
reading.
shouldConvertPostToGetOnRedirect()

protected boolean

This mimics the behavior of browsers that convert post operations to


get operations when redirecting a request.
shouldStop()

protected boolean

Returns true if the request is paused or killed, developers should call


this method periodically to test whether they should quit the current
IO operation immediately
shouldWriteUTFAsGetBytes()

protected boolean

Returns whether when writing a post body the platform expects


something in the form of string.getBytes("UTF-8") or new
OutputStreamWriter(os, "UTF-8").
validate()

protected void

Validates that the request has the required information before being
added to the queue e.g.

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
PRIORITY_CRITICAL
public static final byte PRIORITY_CRITICAL

A critical priority request will "push" through the queue to the highest point regardless
of anything else and ignoring anything that is not in itself of critical priority. A critical
priority will stop any none critical connection in progress
See Also:
Constant Field Values
PRIORITY_HIGH
public static final byte PRIORITY_HIGH

A high priority request is the second highest level, it will act exactly like a critical
priority with one difference. It doesn't block another incoming high priority request.
E.g. if a high priority request
See Also:
Constant Field Values

Methods inherited from class java.lang.Object

2449

Overview (Codename One API)


PRIORITY_NORMAL
public static final byte PRIORITY_NORMAL

Normal priority executes as usual on the queue


See Also:
Constant Field Values
PRIORITY_LOW
public static final byte PRIORITY_LOW

Low priority requests are mostly background tasks that should still be accomplished
though
See Also:
Constant Field Values
PRIORITY_REDUNDANT
public static final byte PRIORITY_REDUNDANT

Redundant elements can be discarded from the queue when paused


See Also:
Constant Field Values

Constructor Detail
ConnectionRequest
public ConnectionRequest()

Method Detail
getCookieHeader
public static String getCookieHeader()

Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to


customize the name of the cookie header to Cookie
Returns:
the cookieHeader
setCookieHeader
public static void setCookieHeader(String aCookieHeader)

Workaround for https://bugs.php.net/bug.php?id=65633 allowing developers to


customize the name of the cookie header to Cookie
Parameters:
aCookieHeader - the cookieHeader to set
isCookiesEnabledDefault
public static boolean isCookiesEnabledDefault()

Returns:
the cookiesEnabledDefault
setCookiesEnabledDefault
public static void setCookiesEnabledDefault(boolean aCookiesEnabledDefault)

Parameters:
aCookiesEnabledDefault

- the cookiesEnabledDefault to set

isDefaultFollowRedirects
public static boolean isDefaultFollowRedirects()

Returns:
the defaultFollowRedirects

Field Detail

2450

Overview (Codename One API)


setDefaultFollowRedirects
public static void setDefaultFollowRedirects(boolean aDefaultFollowRedirects)

Parameters:
aDefaultFollowRedirects

- the defaultFollowRedirects to set

getResponseData
public byte[] getResponseData()

This method will return a valid value for only some of the responses and only after the
response was processed
Returns:
null or the actual data returned
setHttpMethod
public void setHttpMethod(String httpMethod)

Sets the http method for the request


Parameters:
httpMethod - the http method string
getHttpMethod
public String getHttpMethod()

Returns the http method


Returns:
the http method of the request
addRequestHeader
public void addRequestHeader(String key,
String value)

Adds the given header to the request that will be sent


Parameters:
key - the header key
value - the header value
initConnection
protected void initConnection(Object connection)

Invoked to initialize HTTP headers, cookies etc.


Parameters:
connection - the connection object
cookieReceived
protected void cookieReceived(Cookie c)

Callback invoked for every cookie received from the server


Parameters:
c - the cookie
cookieSent
protected void cookieSent(Cookie c)

Callback invoked for every cookie being sent to the server


Parameters:
c - the cookie
initCookieHeader
protected String initCookieHeader(String cookie)

Allows subclasses to inject cookies into the request


Parameters:
cookie - the cookie that the implementation is about to send or null for no
cookie
Returns:

Method Detail

2451

Overview (Codename One API)


new cookie or the value of cookie
getResponseCode
public int getResponseCode()

Returns the response code for this request, this is only relevant after the request
completed and might contain a temporary (e.g. redirect) code while the request is in
progress
Returns:
the response code
getResposeCode
public int getResposeCode()

Deprecated. misspelled method name please use getResponseCode


Returns the response code for this request, this is only relevant after the request
completed and might contain a temporary (e.g. redirect) code while the request is in
progress
Returns:
the response code
shouldConvertPostToGetOnRedirect
protected boolean shouldConvertPostToGetOnRedirect()

This mimics the behavior of browsers that convert post operations to get operations
when redirecting a request.
Returns:
defaults to true, this case be modified by subclasses
readHeaders
protected void readHeaders(Object connection)
throws IOException

Allows reading the headers from the connection by calling the getHeader() method.
Parameters:
connection - used when invoking getHeader
Throws:
IOException - thrown on failure
readErrorCodeHeaders
protected void readErrorCodeHeaders(Object connection)
throws IOException

Allows reading the headers from the connection by calling the getHeader() method
when a response that isn't 200 OK is sent.
Parameters:
connection - used when invoking getHeader
Throws:
IOException - thrown on failure
getHeader
protected String getHeader(Object connection,
String header)
throws IOException

Returns the HTTP header field for the given connection, this method is only
guaranteed to work when invoked from the readHeaders method.
Parameters:
connection - the connection to the network
header - the name of the header
Returns:
the value of the header
Throws:
IOException - thrown on failure

Method Detail

2452

Overview (Codename One API)


getHeaders
protected String[] getHeaders(Object connection,
String header)
throws IOException

Returns the HTTP header field for the given connection, this method is only
guaranteed to work when invoked from the readHeaders method. Unlike the
getHeader method this version works when the same header name is declared
multiple times.
Parameters:
connection - the connection to the network
header - the name of the header
Returns:
the value of the header
Throws:
IOException - thrown on failure
getHeaderFieldNames
protected String[] getHeaderFieldNames(Object connection)
throws IOException

Returns the HTTP header field names for the given connection, this method is only
guaranteed to work when invoked from the readHeaders method.
Parameters:
connection - the connection to the network
Returns:
the names of the headers
Throws:
IOException - thrown on failure
getYield
protected int getYield()

Returns the amount of time to yield for other processes, this is an implicit method that
automatically generates values for lower priority connections
Returns:
yield duration or -1 for no yield
shouldAutoCloseResponse
protected boolean shouldAutoCloseResponse()

Indicates whether the response stream should be closed automatically by the


framework (defaults to true), this might cause an issue if the stream needs to be
passed to a separate thread for reading.
Returns:
true to close the response stream automatically.
handleIOException
protected void handleIOException(IOException err)

Handles IOException thrown when performing a network operation


Parameters:
err - the exception thrown
handleRuntimeException
protected void handleRuntimeException(RuntimeException err)

Handles an exception thrown when performing a network operation


Parameters:
err - the exception thrown
handleException
protected void handleException(Exception err)

Handles an exception thrown when performing a network operation, the default


implementation shows a retry dialog.

Method Detail

2453

Overview (Codename One API)


Parameters:
err - the exception thrown
handleErrorResponseCode
protected void handleErrorResponseCode(int code,
String message)

Handles a server response code that is not 200 and not a redirect (unless redirect
handling is disabled)
Parameters:
code - the response code from the server
message - the response message from the server
retry
public void retry()

Retry the current operation in case of an exception


onRedirect
public boolean onRedirect(String url)

This is a callback method that been called when there is a redirect.


Parameters:
url - the url to be redirected
Returns:
true if the implementation would like to handle this by itself
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs
postResponse
protected void postResponse()

A callback method that's invoked on the EDT after the readResponse() method has
finished, this is the place where developers should change their Codename One user
interface to avoid race conditions that might be triggered by modifications within
readResponse. Notice this method is only invoked on a successful response and will
not be invoked in case of a failure.
createRequestURL
protected String createRequestURL()

Creates the request URL mostly for a get request


Returns:
the string of a request
buildRequestBody
protected void buildRequestBody(OutputStream os)
throws IOException

Invoked when send body is true, by default sends the request arguments based on
"POST" conventions
Parameters:
os - output stream of the body
Throws:
IOException

Method Detail

2454

Overview (Codename One API)


shouldWriteUTFAsGetBytes
protected boolean shouldWriteUTFAsGetBytes()

Returns whether when writing a post body the platform expects something in the form
of string.getBytes("UTF-8") or new OutputStreamWriter(os, "UTF-8").
kill
public void kill()

Kills this request if possible


shouldStop
protected boolean shouldStop()

Returns true if the request is paused or killed, developers should call this method
periodically to test whether they should quit the current IO operation immediately
Returns:
true if the request is paused or killed
isPausable
protected boolean isPausable()

Return true from this method if this connection can be paused and resumed later on.
A pausable network operation receives a "pause" invocation and is expected to stop
network operations as soon as possible. It will later on receive a resume() call and
optionally start downloading again.
Returns:
false by default.
pause
public boolean pause()

Invoked to pause this opeation, this method will only be invoked if isPausable()
returns true (its false by default). After this method is invoked current network
operations should be stoped as soon as possible for this class.
Returns:
This method can return false to indicate that there is no need to resume this
method since the operation has already been completed or made redundant
resume
public boolean resume()

Called when a previously paused operation now has the networking time to resume.
Assuming this method returns true, the network request will be resent to the server
and the operation can resume.
Returns:
This method can return false to indicate that there is no need to resume this
method since the operation has already been completed or made redundant
isPost
public boolean isPost()

Returns true for a post operation and false for a get operation
Returns:
the post
setPost
public void setPost(boolean post)

Set to true for a post operation and false for a get operation, this will implicitly set the
method to post/get respectively (which you can change back by setting the method).
The main importance of this method is how arguments are added to the request
(within the body or in the URL) and so it is important to invoke this method before any
argument was added.
Throws:
IllegalStateException - if invoked after an addArgument call

Method Detail

2455

Overview (Codename One API)


addArgument
public void addArgument(String key,
byte[] value)

Deprecated. use the version that accepts a string instead


Add an argument to the request response
Parameters:
key - the key of the argument
value - the value for the argument
removeArgument
public void removeArgument(String key)

Removes the given argument from the request


Parameters:
key - the key of the argument no longer used
removeAllArguments
public void removeAllArguments()

Removes all arguments


addArgumentNoEncoding
public void addArgumentNoEncoding(String key,
String value)

Add an argument to the request response without encoding it, this is useful for
arguments which are already encoded
Parameters:
key - the key of the argument
value - the value for the argument
addArgument
public void addArgument(String key,
String value)

Add an argument to the request response


Parameters:
key - the key of the argument
value - the value for the argument
addArgument
public void addArgument(String key,
String[] value)

Add an argument to the request response as an array of elements, this will trigger
multiple request entries with the same key
Parameters:
key - the key of the argument
value - the value for the argument
addArguments
public void addArguments(String key,
String... value)

Add an argument to the request response as an array of elements, this will trigger
multiple request entries with the same key
Parameters:
key - the key of the argument
value - the value for the argument
getContentType
public String getContentType()

Returns:
the contentType

Method Detail

2456

Overview (Codename One API)


setContentType
public void setContentType(String contentType)

Parameters:
contentType

- the contentType to set

isWriteRequest
public boolean isWriteRequest()

Returns:
the writeRequest
setWriteRequest
public void setWriteRequest(boolean writeRequest)

Parameters:
writeRequest

- the writeRequest to set

isReadRequest
public boolean isReadRequest()

Returns:
the readRequest
setReadRequest
public void setReadRequest(boolean readRequest)

Parameters:
readRequest

- the readRequest to set

isPaused
protected boolean isPaused()

Returns:
the paused
setPaused
protected void setPaused(boolean paused)

Parameters:
paused

- the paused to set

isKilled
protected boolean isKilled()

Returns:
the killed
setKilled
protected void setKilled(boolean killed)

Parameters:
killed

- the killed to set

getPriority
public byte getPriority()

The priority of this connection based on the constants in this class


Returns:
the priority
setPriority
public void setPriority(byte priority)

The priority of this connection based on the constants in this class


Parameters:

Method Detail

2457

Overview (Codename One API)


priority

- the priority to set

getUserAgent
public String getUserAgent()

Returns:
the userAgent
setUserAgent
public void setUserAgent(String userAgent)

Parameters:
userAgent - the userAgent to set
getDefaultUserAgent
public static String getDefaultUserAgent()

Returns:
the defaultUserAgent
setDefaultUserAgent
public static void setDefaultUserAgent(String aDefaultUserAgent)

Parameters:
aDefaultUserAgent

- the defaultUserAgent to set

isFollowRedirects
public boolean isFollowRedirects()

Returns:
the followRedirects
setFollowRedirects
public void setFollowRedirects(boolean followRedirects)

Parameters:
followRedirects

- the followRedirects to set

getTimeout
public int getTimeout()

Indicates the timeout for this connection request


Returns:
the timeout
setTimeout
public void setTimeout(int timeout)

Indicates the timeout for this connection request


Parameters:
timeout - the timeout to set
getContentLength
public int getContentLength()

Returns the content length header value


Returns:
the content length
ioStreamUpdate
public void ioStreamUpdate(Object source,
int bytes)

Indicates the number of bytes that were read/written to/from the source stream
Specified by:
ioStreamUpdate in interface IOProgressListener
Parameters:

Method Detail

2458

Overview (Codename One API)


- the source stream which can be either an input stream or an output
stream
bytes - the number of bytes read or written
source

getUrl
public String getUrl()

Returns:
the url
setUrl
public void setUrl(String url)

Parameters:
url - the url to set
addResponseListener
public void addResponseListener(ActionListener a)

Adds a listener that would be notified on the CodenameOne thread of a response


from the server. This event is specific to the connection request type and its firing will
change based on how the connection request is read/processed
Parameters:
a - listener
removeResponseListener
public void removeResponseListener(ActionListener a)

Removes the given listener


Parameters:
a - listener
addResponseCodeListener
public void addResponseCodeListener(ActionListener a)

Adds a listener that would be notified on the CodenameOne thread of a response


code that is not a 200 (OK) or 301/2 (redirect) response code.
Parameters:
a - listener
removeResponseCodeListener
public void removeResponseCodeListener(ActionListener a)

Removes the given listener


Parameters:
a - listener
hasResponseListeners
protected boolean hasResponseListeners()

Returns true if someone is listening to action response events, this is useful so we


can decide whether to bother collecting data for an event in some cases since
building the event object might be memory/CPU intensive.
Returns:
true or false
fireResponseListener
protected void fireResponseListener(ActionEvent ev)

Fires the response event to the listeners on this connection


Parameters:
ev - the event to fire
isDuplicateSupported
public boolean isDuplicateSupported()

Method Detail

2459

Overview (Codename One API)


Indicates whether this connection request supports duplicate entries in the request
queue
Returns:
the duplicateSupported value
setDuplicateSupported
public void setDuplicateSupported(boolean duplicateSupported)

Indicates whether this connection request supports duplicate entries in the request
queue
Parameters:
duplicateSupported - the duplicateSupported to set
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
equals
public boolean equals(Object o)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
validate
protected void validate()

Validates that the request has the required information before being added to the
queue e.g. checks if the URL is null. This method should throw an
IllegalStateException for a case where one of the values required for this connection
request is missing. This method can be overriden by subclasses to add additional
tests. It is usefull to do tests here since the exception will be thrown immediately
when invoking addToQueue which is more intuitive to debug than the alternative.

Method Detail

2460

Overview (Codename One API)


getDisposeOnCompletion
public Dialog getDisposeOnCompletion()

A dialog that will be seamlessly disposed once the given request has been completed
Returns:
the disposeOnCompletion
setDisposeOnCompletion
public void setDisposeOnCompletion(Dialog disposeOnCompletion)

A dialog that will be seamlessly disposed once the given request has been completed
Parameters:
disposeOnCompletion - the disposeOnCompletion to set
getShowOnInit
public Dialog getShowOnInit()

This dialog will be shown when this request enters the network queue
Returns:
the showOnInit
setShowOnInit
public void setShowOnInit(Dialog showOnInit)

This dialog will be shown when this request enters the network queue
Parameters:
showOnInit - the showOnInit to set
getSilentRetryCount
public int getSilentRetryCount()

Indicates the number of times to silently retry a connection that failed before
prompting
Returns:
the silentRetryCount
setSilentRetryCount
public void setSilentRetryCount(int silentRetryCount)

Indicates the number of times to silently retry a connection that failed before
prompting
Parameters:
silentRetryCount - the silentRetryCount to set
isFailSilently
public boolean isFailSilently()

Indicates that we are uninterested in error handling


Returns:
the failSilently
setFailSilently
public void setFailSilently(boolean failSilently)

Indicates that we are uninterested in error handling


Parameters:
failSilently - the failSilently to set
setUseNativeCookieStore
public static void setUseNativeCookieStore(boolean b)

Indicates whether the native Cookie stores should be used


Parameters:
b - true to enable native cookie stores when applicable

Method Detail

2461

Overview (Codename One API)


isReadResponseForErrors
public boolean isReadResponseForErrors()

When set to true the read response code will happen even for error codes such as
400 and 500
Returns:
the readResponseForErrors
setReadResponseForErrors
public void setReadResponseForErrors(boolean readResponseForErrors)

When set to true the read response code will happen even for error codes such as
400 and 500
Parameters:
readResponseForErrors - the readResponseForErrors to set
getResponseContentType
public String getResponseContentType()

Returns the content type from the response headers


Returns:
the content type
isRedirecting
public boolean isRedirecting()

Returns true if this request is been redirected to a different url


Returns:
true if redirecting
getDestinationFile
public String getDestinationFile()

When set to a none null string saves the response to file system under this file name
Returns:
the destinationFile
setDestinationFile
public void setDestinationFile(String destinationFile)

When set to a none null string saves the response to file system under this file name
Parameters:
destinationFile - the destinationFile to set
getDestinationStorage
public String getDestinationStorage()

When set to a none null string saves the response to storage under this file name
Returns:
the destinationStorage
setDestinationStorage
public void setDestinationStorage(String destinationStorage)

When set to a none null string saves the response to storage under this file name
Parameters:
destinationStorage - the destinationStorage to set
isCookiesEnabled
public boolean isCookiesEnabled()

Returns:
the cookiesEnabled

Method Detail

2462

Overview (Codename One API)


setCookiesEnabled
public void setCookiesEnabled(boolean cookiesEnabled)

Parameters:
cookiesEnabled - the cookiesEnabled to set
setChunkedStreamingMode
public void setChunkedStreamingMode(int chunklen)

This method is used to enable streaming of a HTTP request body without internal
buffering, when the content length is not known in advance. In this mode, chunked
transfer encoding is used to send the request body. Note, not all HTTP servers
support this mode. This mode is supported on Android and the Desktop ports.
Parameters:
chunklen - The number of bytes to write in each chunk. If chunklen is zero a
default value will be used.
fetchJSON
public static Map<String,Object> fetchJSON(String url)
throws IOException

Utility method that returns a JSON structure or throws an IOException in case of a


failure. This method blocks the EDT legally and can be used synchronously. Notice
that this method assumes all JSON data is UTF-8
Parameters:
url - the URL hosing the JSON
Returns:
map data
Throws:
IOException - in case of an error

Method Detail

2463

Overview (Codename One API)


com.codename1.io

Class CharArrayReader
java.lang.Object

java.io.Reader

com.codename1.io.CharArrayReader
All Implemented Interfaces:
AutoCloseable

public class
extends Reader

A specialized Reader for reading the contents of a char array.


See Also:
CharArrayWriter

Field Summary
Modifier and Type
protected char[]
protected int
protected int
protected int

Field and Description


buf

The buffer for characters.


count

The ending index of the buffer.


markedPos

The current mark position.


pos

The current buffer position.

Fields inherited from class java.io.Reader


lock

Constructor Summary
Constructor and Description
CharArrayReader(char[] buf)

Constructs a CharArrayReader on the char array buf.


CharArrayReader(char[] buf, int offset, int length)
Constructs a CharArrayReader on the char array buf.

Method Summary
Modifier and
Type
void
void
boolean

Method and Description


close()

This method closes this CharArrayReader.


mark(int readLimit)

Sets a mark position in this reader.


markSupported()

Indicates whether this reader supports the mark() and reset() methods.
read()

int

Class CharArrayReader

Reads a single character from this reader and returns it as an integer with
the two higher-order bytes set to 0.

2464

Overview (Codename One API)


read(char[] buffer, int offset, int len)
Reads at most count characters from this CharArrayReader
them at offset in the character array buf.

int

boolean

and stores

ready()

Indicates whether this reader is ready to be read without blocking.


reset()

void

Resets this reader's position to the last mark() location.


skip(long n)
Skips count number

long

of characters in this reader.

Methods inherited from class java.io.Reader


read

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
buf
protected char[] buf

The buffer for characters.


pos
protected int pos

The current buffer position.


markedPos
protected int markedPos

The current mark position.


count
protected int count

The ending index of the buffer.

Constructor Detail
CharArrayReader
public CharArrayReader(char[] buf)

Constructs a CharArrayReader on the char array buf. The size of the reader is set to
the length of the buffer and the object to read from is set to buf.
Parameters:
buf - the char array from which to read.
CharArrayReader
public CharArrayReader(char[] buf,
int offset,
int length)

Constructs a CharArrayReader on the char array buf. The size of the reader is set to
length and the start position from which to read the buffer is set to offset.
Parameters:
buf - the char array from which to read.
offset - the index of the first character in buf to read.

Method Summary

2465

Overview (Codename One API)


length

- the number of characters that can be read from buf.

Throws:
IllegalArgumentException greater than the size of buf .

if offset < 0 or length < 0, or if offset is

Method Detail
close
public void close()

This method closes this CharArrayReader. Once it is closed, you can no longer read
from it. Only the first invocation of this method has any effect.
Specified by:
close in interface AutoCloseable
Specified by:
close in class Reader
mark
public void mark(int readLimit)
throws IOException

Sets a mark position in this reader. The parameter readLimit is ignored for
CharArrayReaders. Calling reset() will reposition the reader back to the marked
position provided the mark has not been invalidated.
Overrides:
mark in class Reader
Parameters:
readLimit - ignored for CharArrayReaders.
Throws:
IOException - if this reader is closed.
markSupported
public boolean markSupported()

Indicates whether this reader supports the mark() and reset() methods.
Overrides:
markSupported in class Reader
Returns:
true for CharArrayReader.
See Also:
mark(int), reset()
read
public int read()
throws IOException

Reads a single character from this reader and returns it as an integer with the two
higher-order bytes set to 0. Returns -1 if no more characters are available from this
reader.
Overrides:
read in class Reader
Returns:
the character read as an int or -1 if the end of the reader has been reached.
Throws:
IOException - if this reader is closed.
read
public int read(char[] buffer,
int offset,
int len)
throws IOException

Reads at most count characters from this CharArrayReader and stores them at
offset in the character array buf. Returns the number of characters actually read or
-1 if the end of reader was encountered.

Constructor Detail

2466

Overview (Codename One API)


Specified by:
read

in class Reader

Parameters:
buffer
offset

- the character array to store the characters read.


- the initial position in buffer to store the characters read from this

reader.
len - the maximum number of characters to read.
Returns:
number of characters read or -1 if the end of the reader has been reached.
Throws:
IndexOutOfBoundsException - if offset < 0 or len < 0, or if offset + len is
bigger than the size of buffer.
IOException - if this reader is closed.
ready
public boolean ready()
throws IOException

Indicates whether this reader is ready to be read without blocking. Returns true if the
next read will not block. Returns false if this reader may or may not block when read
is called. The implementation in CharArrayReader always returns true even when it
has been closed.
Overrides:
ready in class Reader
Returns:
true if this reader will not block when read is called, false if unknown or
blocking will occur.
Throws:
IOException - if this reader is closed.
reset
public void reset()
throws IOException

Resets this reader's position to the last mark() location. Invocations of read() and
skip() will occur from this new location. If this reader has not been marked, it is reset
to the beginning of the string.
Overrides:
reset in class Reader
Throws:
IOException - if this reader is closed.
skip
public long skip(long n)
throws IOException

Skips count number of characters in this reader. Subsequent read()s will not return
these characters unless reset() is used. This method does nothing and returns 0 if n
is negative.
Overrides:
skip in class Reader
Parameters:
n - the number of characters to skip.
Returns:
the number of characters actually skipped.
Throws:
IOException - if this reader is closed.

Method Detail

2467

Overview (Codename One API)


com.codename1.io

Class CacheMap
java.lang.Object

com.codename1.io.CacheMap

public class
extends Object

A cache map is essentially a hashtable that indexes entries based on age and is limited to a fixed
size. Hence when an entry is placed into the cache map and the cache size needs to increase, the
least referenced entry is removed. A cache hit is made both on fetching and putting, hence frequently
fetched elements will never be removed from a sufficiently large cache. Cache can work purely in
memory or swap data into storage based on user definitions. Notice that this class isn't threadsafe.

Constructor Summary
Constructor and Description
CacheMap()

Default constructor
CacheMap(String prefix)

Creates a cache map with a prefix string

Method Summary
Modifier
and Type
void
void
void
void
Object
String

Method and Description


clearAllCache()

Clears the caches for this cache object


clearMemoryCache()

Clears the memory cache


clearStorageCache()

Clears the storage cache


delete(Object key)

Deletes a cached entry


get(Object key)

Returns the object matching the given key


getCachePrefix()

A prefix prepended to storage entries to differentiate them


getCacheSize()

int

Indicates the size of the memory cache after which the cache won't grow further
Size is indicated by number of elements stored and not by KB or similar
benchmark!
getKeysInCache()

Vector

Returns the keys for all the objects currently in cache, this is useful to traverse
all the objects and refresh them without actually deleting the cache and fetching
them from scratch.
Important this vector is a copy of a current state, keys might not exist anymore
or might change, others might be added in the interim.
getStorageCacheSize()

int

boolean

Class CacheMap

Indicates the size of the storage cache after which the cache won't grow further
Size is indicated by number of elements stored and not by KB or similar
benchmark!
isAlwaysStore()

2468

Overview (Codename One API)


When set to true indicates that all entries should be persisted to storage for a
constantly persisting cache
put(Object key, Object value)

void

Puts the given key/value pair in the cache


setAlwaysStore(boolean alwaysStore)

When set to true indicates that all entries should be persisted to storage for a
constantly persisting cache

void

setCachePrefix(String cachePrefix)

void

A prefix prepended to storage entries to differentiate them


setCacheSize(int cacheSize)

Indicates the size of the memory cache after which the cache won't grow further
Size is indicated by number of elements stored and not by KB or similar
benchmark!

void

setStorageCacheSize(int storageCacheSize)

Indicates the size of the storage cache after which the cache won't grow further
Size is indicated by number of elements stored and not by KB or similar
benchmark!

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CacheMap
public CacheMap()

Default constructor
CacheMap
public CacheMap(String prefix)

Creates a cache map with a prefix string


Parameters:
prefix - string to prepend to the cache entries in storage

Method Detail
getCacheSize
public int getCacheSize()

Indicates the size of the memory cache after which the cache won't grow further Size
is indicated by number of elements stored and not by KB or similar benchmark!
Returns:
the cacheSize
setCacheSize
public void setCacheSize(int cacheSize)

Indicates the size of the memory cache after which the cache won't grow further Size
is indicated by number of elements stored and not by KB or similar benchmark!
Parameters:
cacheSize - the cacheSize to set
put
public void put(Object key,
Object value)

Puts the given key/value pair in the cache

Method Summary

2469

Overview (Codename One API)


Parameters:
key - the key
value - the value
delete
public void delete(Object key)

Deletes a cached entry


Parameters:
key - entry to remove from the cache
get
public Object get(Object key)

Returns the object matching the given key


Parameters:
key - key object
Returns:
value from a previous put or null
clearAllCache
public void clearAllCache()

Clears the caches for this cache object


clearMemoryCache
public void clearMemoryCache()

Clears the memory cache


getKeysInCache
public Vector getKeysInCache()

Returns the keys for all the objects currently in cache, this is useful to traverse all the
objects and refresh them without actually deleting the cache and fetching them from
scratch.
Important this vector is a copy of a current state, keys might not exist anymore or
might change, others might be added in the interim.
Returns:
a vector containing a snapshot of the current elements within the cache.
clearStorageCache
public void clearStorageCache()

Clears the storage cache


getStorageCacheSize
public int getStorageCacheSize()

Indicates the size of the storage cache after which the cache won't grow further Size
is indicated by number of elements stored and not by KB or similar benchmark!
Returns:
the storageCacheSize
setStorageCacheSize
public void setStorageCacheSize(int storageCacheSize)

Indicates the size of the storage cache after which the cache won't grow further Size
is indicated by number of elements stored and not by KB or similar benchmark!
Parameters:
storageCacheSize - the storageCacheSize to set
getCachePrefix
public String getCachePrefix()

A prefix prepended to storage entries to differentiate them


Returns:

Method Detail

2470

Overview (Codename One API)


the cachePrefix
setCachePrefix
public void setCachePrefix(String cachePrefix)

A prefix prepended to storage entries to differentiate them


Parameters:
cachePrefix - the cachePrefix to set
isAlwaysStore
public boolean isAlwaysStore()

When set to true indicates that all entries should be persisted to storage for a
constantly persisting cache
Returns:
the alwaysStore
setAlwaysStore
public void setAlwaysStore(boolean alwaysStore)

When set to true indicates that all entries should be persisted to storage for a
constantly persisting cache
Parameters:
alwaysStore - the alwaysStore to set

Method Detail

2471

Overview (Codename One API)


com.codename1.io

Class CSVParser
java.lang.Object

com.codename1.io.CSVParser

public class
extends Object

Simple CSV parser very useful for importing data into applications quickly from a CSV source

Constructor Summary
Constructor and Description
CSVParser()

Initializes a parser with the default comma (',') separator char


CSVParser(char separatorChar)

Allows creating a parser with a custom separator char

Method Summary
Modifier and
Type

Method and Description


parse(InputStream r)

String[][]

Parses input from the given stream and returns the tokens broken into
rows and columns
parse(InputStream r, String encoding)

String[][]

Parses input from the given stream and returns the tokens broken into
rows and columns
parse(Reader r)

String[][]

Parses input from the given reader and returns the tokens broken into
rows and columns

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CSVParser
public CSVParser()

Initializes a parser with the default comma (',') separator char


CSVParser
public CSVParser(char separatorChar)

Allows creating a parser with a custom separator char


Parameters:
separatorChar - custom separator character such as semi-colon (';') etc.

Class CSVParser

2472

Overview (Codename One API)


Method

Detail

parse
public String[][] parse(InputStream r)
throws IOException

Parses input from the given stream and returns the tokens broken into rows and
columns
Parameters:
r - the input stream
Returns:
array of rows and columns
Throws:
IOException

parse
public String[][] parse(InputStream r,
String encoding)
throws IOException

Parses input from the given stream and returns the tokens broken into rows and
columns
Parameters:
r - the input stream
encoding - the encoding of the stream
Returns:
array of rows and columns
Throws:
IOException

parse
public String[][] parse(Reader r)
throws IOException

Parses input from the given reader and returns the tokens broken into rows and
columns
Parameters:
r - the reader stream
Returns:
array of rows and columns
Throws:
IOException

Method Detail

2473

Overview (Codename One API)


com.codename1.io

Class BufferedOutputStream
java.lang.Object

java.io.OutputStream

com.codename1.io.BufferedOutputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
TarOutputStream

public class
extends OutputStream

Based on the buffered output stream from the JDK with some minor tweaks to allow external classes
to monitor stream status and progress.

Field Summary
Modifier and Type
protected byte[]
protected int

Field and Description


buf

The internal buffer where data is stored.


count

The number of valid bytes in the buffer.

Constructor Summary
Constructor and Description
BufferedOutputStream(OutputStream out)

Creates a new buffered output stream to write data to the specified underlying output
stream.
BufferedOutputStream(OutputStream out, int size)

Creates a new buffered output stream to write data to the specified underlying output stream
with the specified buffer size.
BufferedOutputStream(OutputStream out, int size, String name)

Creates a new buffered output stream to write data to the specified underlying output stream
with the specified buffer size.
BufferedOutputStream(OutputStream out, String name)

Creates a new buffered output stream to write data to the specified underlying output
stream.

Method Summary
Modifier
and Type

Method and Description


close()

void

void
void
Object

Closes this output stream and releases any system resources associated with
the stream.
flush()

Flushes this buffered output stream.


flushBuffer()

Flush the internal buffer


getConnection()

If applicable this member represents the connection object for the stream

Class BufferedOutputStream

2474

Overview (Codename One API)


static int

getDefaultBufferSize()

The default size for a stream buffer


getLastActivityTime()

long

Returns the time of the last activity


getName()

String

Indicates the name of the stream for debugging purposes


getTotalBytesWritten()

int

Returns the total amount of bytes written to this stream so far


setConnection(Object connection)

void

If applicable this member represents the connection object for the stream

static void

setDefaultBufferSize(int aDefaultBufferSize)

The default size for a stream buffer


setProgressListener(IOProgressListener progressListener)

void

Sets the callback for IO updates from a buffered stream


write(byte[] b)
Writes b.length bytes

void

to this output stream.

write(byte[] b, int off, int len)


Writes len bytes from the specified byte

void

array starting at offset off to this

buffered output stream.


write(int b)

void

Writes the specified byte to this buffered output stream.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
buf
protected byte[] buf

The internal buffer where data is stored.


count
protected int count

The number of valid bytes in the buffer. This value is always in the range 0 through
buf.length; elements buf[0] through buf[count-1] contain valid byte data.

Constructor Detail
BufferedOutputStream
public BufferedOutputStream(OutputStream out)

Creates a new buffered output stream to write data to the specified underlying output
stream.
Parameters:
out - the underlying output stream.
BufferedOutputStream
public BufferedOutputStream(OutputStream out,
String name)

Creates a new buffered output stream to write data to the specified underlying output
stream.
Parameters:
out - the underlying output stream.
name - the name of the stream used for debugging/logging purposes

Method Summary

2475

Overview (Codename One API)


BufferedOutputStream
public BufferedOutputStream(OutputStream out,
int size)

Creates a new buffered output stream to write data to the specified underlying output
stream with the specified buffer size.
Parameters:
out - the underlying output stream.
size - the buffer size.
Throws:
IllegalArgumentException - if size <= 0.
BufferedOutputStream
public BufferedOutputStream(OutputStream out,
int size,
String name)

Creates a new buffered output stream to write data to the specified underlying output
stream with the specified buffer size.
Parameters:
out - the underlying output stream.
size - the buffer size.
name - the name of the stream used for debugging/logging purposes
Throws:
IllegalArgumentException - if size <= 0.

Method Detail
getName
public String getName()

Indicates the name of the stream for debugging purposes


Returns:
the name of the stream
flushBuffer
public void flushBuffer()
throws IOException

Flush the internal buffer


Throws:
IOException

write
public void write(int b)
throws IOException

Writes the specified byte to this buffered output stream.


Specified by:
write in class OutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
write
public void write(byte[] b,
int off,
int len)
throws IOException

Writes len bytes from the specified byte array starting at offset off to this buffered
output stream.

Constructor Detail

2476

Overview (Codename One API)


Ordinarily this method stores bytes from the given array into this stream's buffer,
flushing the buffer to the underlying output stream as needed. If the requested length
is at least as large as this stream's buffer, however, then this method will flush the
buffer and write the bytes directly to the underlying output stream. Thus redundant
BufferedOutputStreams will not copy data unnecessarily.
Overrides:
write in class OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
flush
public void flush()
throws IOException

Flushes this buffered output stream. This forces any buffered output bytes to be
written out to the underlying output stream.
Overrides:
flush in class OutputStream
Throws:
IOException - if an I/O error occurs.
getLastActivityTime
public long getLastActivityTime()

Returns the time of the last activity


Returns:
time of the last activity on this stream
getTotalBytesWritten
public int getTotalBytesWritten()

Returns the total amount of bytes written to this stream so far


Returns:
the total amount of bytes written to this stream so far
setProgressListener
public void setProgressListener(IOProgressListener progressListener)

Sets the callback for IO updates from a buffered stream


Parameters:
progressListener - the progressListener to set
getDefaultBufferSize
public static int getDefaultBufferSize()

The default size for a stream buffer


Returns:
the defaultBufferSize
setDefaultBufferSize
public static void setDefaultBufferSize(int aDefaultBufferSize)

The default size for a stream buffer


Parameters:
aDefaultBufferSize - the defaultBufferSize to set
write
public void write(byte[] b)
throws IOException

Writes b.length bytes to this output stream.

Method Detail

2477

Overview (Codename One API)


The write method of FilterOutputStream calls its write method of three arguments
with the arguments b, 0, and b.length.
Note that this method does not call the one-argument write method of its underlying
stream with the single argument b.
Overrides:
write in class OutputStream
Parameters:
b - the data to be written.
Throws:
IOException - if an I/O error occurs.
close
public void close()
throws IOException

Closes this output stream and releases any system resources associated with the
stream.
The close method of FilterOutputStream calls its flush method, and then calls the
close method of its underlying output stream.
Specified by:
close

in interface AutoCloseable

Overrides:
close

in class OutputStream

Throws:
IOException

- if an I/O error occurs.

getConnection
public Object getConnection()

If applicable this member represents the connection object for the stream
Returns:
the connection
setConnection
public void setConnection(Object connection)

If applicable this member represents the connection object for the stream
Parameters:
connection - the connection to set

Method Detail

2478

Overview (Codename One API)


com.codename1.io

Class BufferedInputStream
java.lang.Object

java.io.InputStream

com.codename1.io.BufferedInputStream
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
TarInputStream

public class
extends InputStream

Based on the buffered input stream from the JDK with some minor tweaks to allow external classes to
monitor stream status and progress.

Constructor Summary
Constructor and Description
BufferedInputStream(InputStream in)
Creates a BufferedInputStream and saves

its argument, the input stream in, for later use.

BufferedInputStream(InputStream in, int size)


Creates a BufferedInputStream with the specified buffer
input stream in, for later use.

size, and saves its argument, the

BufferedInputStream(InputStream in, int size, String name)


Creates a BufferedInputStream with the specified buffer size, and
input stream in, for later use.
BufferedInputStream(InputStream in, String name)
Creates a BufferedInputStream and saves its argument,

saves its argument, the

the input stream in, for later use.

Method Summary
Modifier and
Type

Method and Description


available()

int

Returns an estimate of the number of bytes that can be read (or skipped over)
from this input stream without blocking by the next invocation of a method for
this input stream.
close()

void

Object
static int
InputStream
long
String
int

Class BufferedInputStream

Closes this input stream and releases any system resources associated with
the stream.
getConnection()

If applicable this member represents the connection object for the stream
getDefaultBufferSize()

The default size for a stream buffer


getInternal()

Allows access to the underlying input stream if desired


getLastActivityTime()

Returns the time of the last activity


getName()

Indicates the name of the stream for debugging purposes


getTotalBytesRead()

Returns the total amount of bytes read from this stream so far

2479

Overview (Codename One API)


getYield()
int

Allows setting a yield duration for this stream which is useful for background
operations to release CPU

boolean

isDisableBuffering()

boolean

isPrintInput()

Prints out all the data that passes through this stream to the console.
mark(int readlimit)

void

See the general contract of the mark method of InputStream.

boolean

markSupported()

Tests if this input stream supports the mark and reset methods.
read()

int

See the general contract of the read method of InputStream.


read(byte[] b)

Reads some number of bytes from the input stream and stores them into the
buffer array b.

int

read(byte[] b, int off, int len)

Reads bytes from this byte-input stream into the specified byte array, starting
at the given offset.

int

reset()

void

See the general contract of the reset method of InputStream.


setConnection(Object connection)

void

If applicable this member represents the connection object for the stream

static void
void

setDefaultBufferSize(int aDefaultBufferSize)

The default size for a stream buffer


setDisableBuffering(boolean disableBuffering)
setPrintInput(boolean printInput)

void

Prints out all the data that passes through this stream to the console.
setProgressListener(IOProgressListener progressListener)

void

Sets the callback for IO updates from a buffered stream


setYield(int yield)

Allows setting a yield duration for this stream which is useful for background
operations to release CPU

void

skip(long n)

long

See the general contract of the skip method of InputStream.


stop()

void

Stop reading from the stream, invoking this will cause the read() to return -1

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
BufferedInputStream
public BufferedInputStream(InputStream in)

Creates a BufferedInputStream and saves its argument, the input stream in, for later
use. An internal buffer array is created and stored in buf.
Parameters:
in - the underlying input stream.
BufferedInputStream
public BufferedInputStream(InputStream in,
String name)

Creates a BufferedInputStream and saves its argument, the input stream in, for later
use. An internal buffer array is created and stored in buf.
Parameters:

Method Summary

2480

Overview (Codename One API)


in - the underlying
name - the name of

input stream.
the stream

BufferedInputStream
public BufferedInputStream(InputStream in,
int size)

Creates a BufferedInputStream with the specified buffer size, and saves its
argument, the input stream in, for later use. An internal buffer array of length size is
created and stored in buf.
Parameters:
in - the underlying input stream.
size - the buffer size.
Throws:
IllegalArgumentException - if size <= 0.
BufferedInputStream
public BufferedInputStream(InputStream in,
int size,
String name)

Creates a BufferedInputStream with the specified buffer size, and saves its
argument, the input stream in, for later use. An internal buffer array of length size is
created and stored in buf.
Parameters:
in - the underlying input stream.
size - the buffer size.
name - the name of the stream
Throws:
IllegalArgumentException - if size <= 0.

Method Detail
getName
public String getName()

Indicates the name of the stream for debugging purposes


Returns:
the name of the stream
getInternal
public InputStream getInternal()

Allows access to the underlying input stream if desired


Returns:
the internal input stream
read
public int read()
throws IOException

See the general contract of the read method of InputStream.


Specified by:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if this input stream has been closed by invoking its close()
method, or an I/O error occurs.
read
public int read(byte[] b,
int off,
int len)
throws IOException

Constructor Detail

2481

Overview (Codename One API)


Reads bytes from this byte-input stream into the specified byte array, starting at the
given offset.
This method implements the general contract of the corresponding read method of the
InputStream class. As an additional convenience, it attempts to read as many bytes as
possible by repeatedly invoking the read method of the underlying stream. This
iterated read continues until one of the following conditions becomes true:
The specified number of bytes have been read,
The read method of the underlying stream returns -1, indicating end-of-file, or
The available method of the underlying stream returns zero, indicating that
further input requests would block.
If the first read on the underlying stream returns -1 to indicate end-of-file then this
method returns -1. Otherwise this method returns the number of bytes actually read.
Subclasses of this class are encouraged, but not required, to attempt to read as
many bytes as possible in the same fashion.
Overrides:
read in class InputStream
Parameters:
b - destination buffer.
off - offset at which to start storing bytes.
len - maximum number of bytes to read.
Returns:
the number of bytes read, or -1 if the end of the stream has been reached.
Throws:
IOException - if this input stream has been closed by invoking its close()
method, or an I/O error occurs.
skip
public long skip(long n)
throws IOException

See the general contract of the skip method of InputStream.


Overrides:
skip in class InputStream
Throws:
IOException - if the stream does not support seek, or if this input stream has
been closed by invoking its close() method, or an I/O error occurs.
available
public int available()
throws IOException

Returns an estimate of the number of bytes that can be read (or skipped over) from
this input stream without blocking by the next invocation of a method for this input
stream. The next invocation might be the same thread or another thread. A single
read or skip of this many bytes will not block, but may read or skip fewer bytes.
This method returns the sum of the number of bytes remaining to be read in the
buffer (count - pos) and the result of calling the in.available().
Overrides:
available in class InputStream
Returns:
an estimate of the number of bytes that can be read (or skipped over) from
this input stream without blocking.
Throws:
IOException - if this input stream has been closed by invoking its close()
method, or an I/O error occurs.
mark
public void mark(int readlimit)

See the general contract of the mark method of InputStream.

Method Detail

2482

Overview (Codename One API)


Overrides:
mark

in class InputStream

Parameters:
- the maximum limit of bytes that can be read before the mark
position becomes invalid.
readlimit

reset
public void reset()
throws IOException

See the general contract of the reset method of InputStream.


If markpos is -1 (no mark has been set or the mark has been invalidated), an
IOException is thrown. Otherwise, pos is set equal to markpos.
Overrides:
reset

in class InputStream

Throws:
- if this stream has not been marked or, if the mark has been
invalidated, or the stream has been closed by invoking its close() method, or
an I/O error occurs.
markSupported
IOException

public boolean markSupported()

Tests if this input stream supports the mark and reset methods. The markSupported
method of BufferedInputStream returns true.
Overrides:
markSupported in class InputStream
Returns:
a boolean indicating if this stream type supports the mark and reset methods.
See Also:
InputStream.mark(int), InputStream.reset()
close
public void close()
throws IOException

Closes this input stream and releases any system resources associated with the
stream. Once the stream has been closed, further read(), available(), reset(), or skip()
invocations will throw an IOException. Closing a previously closed stream has no
effect.
Specified by:
close in interface AutoCloseable
Overrides:
close in class InputStream
Throws:
IOException - if an I/O error occurs.
getLastActivityTime
public long getLastActivityTime()

Returns the time of the last activity


Returns:
time of the last activity on this stream
getTotalBytesRead
public int getTotalBytesRead()

Returns the total amount of bytes read from this stream so far
Returns:
the total amount of bytes read from this stream so far
setProgressListener
public void setProgressListener(IOProgressListener progressListener)

Sets the callback for IO updates from a buffered stream

Method Detail

2483

Overview (Codename One API)


Parameters:
progressListener

- the progressListener to set

read
public int read(byte[] b)
throws IOException

Reads some number of bytes from the input stream and stores them into the buffer
array b. The number of bytes actually read is returned as an integer. This method
blocks until input data is available, end of file is detected, or an exception is thrown. If
b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are
read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no
byte is available because the stream is at end of file, the value -1 is returned;
otherwise, at least one byte is read and stored into b. The first byte read is stored into
element b[0], the next one into b[1], and so on. The number of bytes read is, at most,
equal to the length of b. Let k be the number of bytes actually read; these bytes will
be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1]
unaffected. If the first byte cannot be read for any reason other than end of file, then
an IOException is thrown. In particular, an IOException is thrown if the input stream
has been closed. The read(b) method for class InputStream has the same effect as:
read(b, 0, b.length)
Overrides:
read in class InputStream
Throws:
IOException

getDefaultBufferSize
public static int getDefaultBufferSize()

The default size for a stream buffer


Returns:
the defaultBufferSize
setDefaultBufferSize
public static void setDefaultBufferSize(int aDefaultBufferSize)

The default size for a stream buffer


Parameters:
aDefaultBufferSize - the defaultBufferSize to set
getConnection
public Object getConnection()

If applicable this member represents the connection object for the stream
Returns:
the connection
setConnection
public void setConnection(Object connection)

If applicable this member represents the connection object for the stream
Parameters:
connection - the connection to set
isDisableBuffering
public boolean isDisableBuffering()

Returns:
the disableBuffering
setDisableBuffering
public void setDisableBuffering(boolean disableBuffering)

Parameters:
disableBuffering

Method Detail

- the disableBuffering to set

2484

Overview (Codename One API)


isPrintInput
public boolean isPrintInput()

Prints out all the data that passes through this stream to the console. This is a very
useful debugging tool.
Returns:
the printInput
setPrintInput
public void setPrintInput(boolean printInput)

Prints out all the data that passes through this stream to the console. This is a very
useful debugging tool.
Parameters:
printInput - the printInput to set
getYield
public int getYield()

Allows setting a yield duration for this stream which is useful for background
operations to release CPU
Returns:
the yield
setYield
public void setYield(int yield)

Allows setting a yield duration for this stream which is useful for background
operations to release CPU
Parameters:
yield - the yield to set
stop
public void stop()

Stop reading from the stream, invoking this will cause the read() to return -1

Method Detail

2485

Overview (Codename One API)


com.codename1.io

Class AccessToken
java.lang.Object

com.codename1.io.AccessToken
All Implemented Interfaces:
Externalizable

public class
extends Object
implements Externalizable

This class represent an access token.

Constructor Summary
Constructor and Description
AccessToken(String token, String expires)

Constructor with parameters

Method Summary
Modifier
and Type

Method and Description


externalize(DataOutputStream out)

Allows us to store an object state, this method must be implemented in order to


save the state of an object

void

String

getExpires()

Simple getter
getObjectId()

String

String

The object id must be unique, it is used to identify the object when loaded even
when it is obfuscated.
getToken()

Simple getter
getVersion()

Returns the version for the current persistance code, the version will be pased
to internalized thus allowing the internalize method to recognize classes
persisted in older revisions

int

internalize(int version, DataInputStream in)

void

Loads the object from the input stream and allows deserialization

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
AccessToken
public AccessToken(String token,
String expires)

Constructor with parameters


Parameters:

Class AccessToken

2486

Overview (Codename One API)


token - the token string
expires - the access token

expires date

Method Detail
getToken
public String getToken()

Simple getter
Returns:
the token string
getExpires
public String getExpires()

Simple getter
Returns:
the expires date
getVersion
public int getVersion()

Description copied from interface: Externalizable


Returns the version for the current persistance code, the version will be pased to
internalized thus allowing the internalize method to recognize classes persisted in
older revisions
Specified by:
getVersion in interface Externalizable
Returns:
version number for the persistant code
externalize
public void externalize(DataOutputStream out)
throws IOException

Description copied from interface: Externalizable


Allows us to store an object state, this method must be implemented in order to save
the state of an object
Specified by:
externalize in interface Externalizable
Parameters:
out - the stream into which the object must be serialized
Throws:
IOException - the method may throw an exception
internalize
public void internalize(int version,
DataInputStream in)
throws IOException

Description copied from interface: Externalizable


Loads the object from the input stream and allows deserialization
Specified by:
internalize in interface Externalizable
Parameters:
version - the version the class returned during the externalization processs
in - the input stream used to load the class
Throws:
IOException - the method may throw an exception
getObjectId
public String getObjectId()

Description copied from interface: Externalizable

Constructor Detail

2487

Overview (Codename One API)


The object id must be unique, it is used to identify the object when loaded even when
it is obfuscated.
Specified by:
getObjectId in interface Externalizable
Returns:
a unique id

Method Detail

2488

Overview (Codename One API)


com.codename1.facebook.ui

Class LikeButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.facebook.ui.LikeButton
All Implemented Interfaces:
Animation, ActionListener, StyleListener

public class
extends Button
implements ActionListener

Generic "Like" button that enables us to submit a like to facebook, to get the post id required for the
like functionality you will need to use a tool such as:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fposts You can ask it to
list your posts and then seek the correct id within the returned JSON

Field Summary

Fields inherited from class com.codename1.ui.Button


STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
LikeButton()

Default constructor
LikeButton(String postId)

Constructor accepting the post id

Method Summary
Modifier
and
Type
void

Method and Description


actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component

String

getAppId()

String

getClientSecret()

String[] getPermissions()
String

getPostId()

String[] getPropertyNames()

Class LikeButton

2489

Overview (Codename One API)

A component may expose mutable property names for a UI designer to manipulate, this AP
usage internally by the GUI builder code
getPropertyTypeNames()
String[]

Class[]
Object

This method is here to workaround an XMLVM array type bug where property types aren't id
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListMod
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder

String

getRedirectURI()

void

setAppId(String appId)

void

setClientSecret(String clientSecret)

void

setPermissions(String[] permissions)

void

setPostId(String postId)

String
void

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if success
setRedirectURI(String redirectURI)

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, calcPreferredSize, dragInitiated, fireClicked,
getActionListeners, getBorder, getCommand, getDisabledIcon,
getIconFromState, getListeners, getPressedIcon, getReleaseRadius,
getRolloverIcon, getRolloverPressedIcon, getState, isAutoRelease,
isOppositeSide, isSelectableInteraction, isSelected, isToggle, keyPressed,
keyReleased, keyRepeated, pointerDragged, pointerHover,
pointerHoverReleased, pointerPressed, pointerReleased, pressed, released,
released, removeActionListener, resetFocusable, setAlignment,
setAutoRelease, setCommand, setDisabledIcon, setPressedIcon,
setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getIcon, getMask, getMaskedIcon, getMaskName, getShiftMillimeters,
getShiftText, getStringWidth, getText, getTextPosition,
getVerticalAlignment, isDefaultTickerEnabled, isEndsWith3Points,
isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank, isTickerEnabled,
isTickerRunning, paint, paramString, setBoundPropertyValue,
setDefaultTickerEnabled, setEndsWith3Points, setGap, setIcon,
setLegacyRenderer, setMask, setMaskName, setShiftMillimeters, setShiftText,
setShouldLocalize, setShowEvenIfBlank, setText, setTextPosition,
setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker,
startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,

Method Summary

2490

Overview (Codename One API)


initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
LikeButton
public LikeButton(String postId)

Constructor accepting the post id


Parameters:
postId LikeButton
public LikeButton()

Default constructor

Method Detail
actionPerformed
public void actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component


Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - event object describing the source of the action as well as its trigger
getPostId
public String getPostId()

Returns:
the postId

Methods inherited from class com.codename1.ui.Component

2491

Overview (Codename One API)


setPostId
public void setPostId(String postId)

Parameters:
postId - the postId to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Label
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Label
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Label
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Label
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Label
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2492

Overview (Codename One API)


getAppId
public String getAppId()

Returns:
the appId
setAppId
public void setAppId(String appId)

Parameters:
appId - the appId to set
getRedirectURI
public String getRedirectURI()

Returns:
the redirectURI
setRedirectURI
public void setRedirectURI(String redirectURI)

Parameters:
redirectURI

- the redirectURI to set

getClientSecret
public String getClientSecret()

Returns:
the clientSecret
setClientSecret
public void setClientSecret(String clientSecret)

Parameters:
clientSecret

- the clientSecret to set

getPermissions
public String[] getPermissions()

Returns:
the permissions
setPermissions
public void setPermissions(String[] permissions)

Parameters:
permissions

Method Detail

- the permissions to set

2493

Overview (Codename One API)


com.codename1.facebook

Class User
java.lang.Object

com.codename1.facebook.FBObject

com.codename1.facebook.User

public class
extends FBObject

This class represents a Facebook User objject


http://developers.facebook.com/docs/reference/api/user/

Constructor Summary
Constructor and Description
User()

Empty Contructor
User(Hashtable props)

Method Summary
Modifier and Type

Method and Description


copy(Hashtable props)

void

copies the relevant values from the given hashtable

String

getAbout()

String

getBio()

String

getBirthday()

String

getEmail()

String

getFirst_name()

String

getGender()

FBObject

getHometown()

Gets the user Hometown if available

String

getLast_name()

String

getLast_updated()

String

getLink()

String

getLocale()

FBObject

getLocation()

Gets the user City if available

String

getQuotes()

String

getRelationship_status()

long

getTimezone()

String
String

getUsername()

Returns the username


getWebsite()

Methods inherited from class com.codename1.facebook.FBObject


equals, getId, getName, hashCode, setId

Class User

2494

Overview (Codename One API)


Methods

inherited from class java.lang.Object

getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
User
public User()

Empty Contructor
User
public User(Hashtable props)

Method Detail
getFirst_name
public String getFirst_name()

Returns:
the first_name
getLast_name
public String getLast_name()

Returns:
the last_name
getLink
public String getLink()

Returns:
the link
getAbout
public String getAbout()

Returns:
the about
getBirthday
public String getBirthday()

Returns:
the birthday
getEmail
public String getEmail()

Returns:
the email
getWebsite
public String getWebsite()

Returns:
the website
getBio
public String getBio()

Returns:

Methods inherited from class java.lang.Object

2495

Overview (Codename One API)


the bio
getQuotes
public String getQuotes()

Returns:
the quotes
getGender
public String getGender()

Returns:
the gender
getRelationship_status
public String getRelationship_status()

Returns:
the relationship_status
getTimezone
public long getTimezone()

Returns:
the timezone
getLast_updated
public String getLast_updated()

Returns:
the last_updated
getLocale
public String getLocale()

Returns:
the locale
getUsername
public String getUsername()

Returns the username


getLocation
public FBObject getLocation()

Gets the user City if available


Returns:
getHometown
public FBObject getHometown()

Gets the user Hometown if available


Returns:
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Overrides:
copy in class FBObject
Parameters:
props - an hashtable to copy from

Method Detail

2496

Overview (Codename One API)


com.codename1.facebook

Class Post
java.lang.Object

com.codename1.facebook.FBObject

com.codename1.facebook.Post

public class
extends FBObject

This class represents a Facebook Post Object


http://developers.facebook.com/docs/reference/api/post/

Constructor Summary
Constructor and Description
Post()

Empty Contructor
Post(Hashtable props)

Method Summary
Modifier and Type
void
String
String
User
String
String

Method and Description


copy(Hashtable props)

copies the relevant values from the given hashtable


getAttribution()

Gets the Attribution


getCommentsCount()

Gets the comments count number


getFrom()

Gets the from User


getLikes()

Gets the Link Count


getLinkDescription()

Gets the linkDescription


getLinkName()

String

String
String
String
Vector
String
String

Class Post

Deprecated.
use getName() instead
getLinkUrl()

Gets the link Url


getMessage()

Gets the message


getPicture()

Gets the picture id


getTo()

Gets the to users


getType()

Get the type


toString()

Returns a string representation of the object.

2497

Overview (Codename One API)


Methods

inherited from class com.codename1.facebook.FBObject

equals, getId, getName, hashCode, setId

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Constructor Detail
Post
public Post()

Empty Contructor
Post
public Post(Hashtable props)

Method Detail
getFrom
public User getFrom()

Gets the from User


Returns:
from User
getTo
public Vector getTo()

Gets the to users


Returns:
Vector of Users
getType
public String getType()

Get the type


Returns:
the type
getAttribution
public String getAttribution()

Gets the Attribution


Returns:
the attribution
getMessage
public String getMessage()

Gets the message


Returns:
the message
getLinkUrl
public String getLinkUrl()

Gets the link Url


Returns:
the linkUrl

Methods inherited from class com.codename1.facebook.FBObject

2498

Overview (Codename One API)


getCommentsCount
public String getCommentsCount()

Gets the comments count number


Returns:
the comments count
getLinkName
public String getLinkName()

Deprecated. use getName() instead


Gets the Link Name
Returns:
the linkName
getLinkDescription
public String getLinkDescription()

Gets the linkDescription


Returns:
the linkDescription
getPicture
public String getPicture()

Gets the picture id


Returns:
the picture id
getLikes
public String getLikes()

Gets the Link Count


Returns:
the likes count
toString
public String toString()

Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Overrides:
copy in class FBObject
Parameters:
props - an hashtable to copy from

Method Detail

2499

Overview (Codename One API)


com.codename1.facebook

Class Photo
java.lang.Object

com.codename1.facebook.FBObject

com.codename1.facebook.Photo

public class
extends FBObject

This class represents a Facebook Photo Object


http://developers.facebook.com/docs/reference/api/photo/

Constructor Summary
Constructor and Description
Photo()

Empty Contructor
Photo(Hashtable props)

Method Summary
Modifier and Type

Method and Description


copy(Hashtable props)

void

copies the relevant values from the given hashtable

Vector
String

getComments()

Gets the comments on this Photos, where each entry is a Post Object
getCreated_time()

Get created_time
getFrom()

User

Get from
getHeight()

int

Get height

String
Vector
String
String

getIconUrl()

Get iconUrl
getImages()

Get images vector where each entry is a String of a url


getLink()

Get link
getPictureUrl()

Get pictureUrl
getPosition()

int

Get position

String
String

getSourceUrl()

Get sourceUrl
getUpdated_time()

Get updated_time
getWidth()

int

Get width

Methods inherited from class com.codename1.facebook.FBObject


equals, getId, getName, hashCode, setId

Class Photo

2500

Overview (Codename One API)


Methods

inherited from class java.lang.Object

getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Photo
public Photo()

Empty Contructor
Photo
public Photo(Hashtable props)

Method Detail
getCreated_time
public String getCreated_time()

Get created_time
Returns:
created_time
getFrom
public User getFrom()

Get from
Returns:
from
getHeight
public int getHeight()

Get height
Returns:
height
getIconUrl
public String getIconUrl()

Get iconUrl
Returns:
iconUrl
getLink
public String getLink()

Get link
Returns:
link
getPictureUrl
public String getPictureUrl()

Get pictureUrl
Returns:
pictureUrl

Methods inherited from class java.lang.Object

2501

Overview (Codename One API)


getPosition
public int getPosition()

Get position
Returns:
position
getSourceUrl
public String getSourceUrl()

Get sourceUrl
Returns:
sourceUrl
getUpdated_time
public String getUpdated_time()

Get updated_time
Returns:
updated_time
getWidth
public int getWidth()

Get width
Returns:
width
getImages
public Vector getImages()

Get images vector where each entry is a String of a url


Returns:
images
getComments
public Vector getComments()

Gets the comments on this Photos, where each entry is a Post Object
Returns:
a Vector of Post Objects
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Overrides:
copy in class FBObject
Parameters:
props - an hashtable to copy from

Method Detail

2502

Overview (Codename One API)


com.codename1.facebook

Class Page
java.lang.Object

com.codename1.facebook.FBObject

com.codename1.facebook.Page

public class
extends FBObject

This class represents a Facebook Page object


https://developers.facebook.com/docs/reference/api/page/

Constructor Summary
Constructor and Description
Page()

Empty Contructor
Page(Hashtable props)

Method Summary
Modifier and Type

Method and Description


copy(Hashtable props)

void

copies the relevant values from the given hashtable

String
String
String
String
String

getAbout()

Simple Getter
getCategory()

Simple Getter
getCoverId()

Simple Getter
getCoverLink()

Simple Getter
getFounded()

Simple Getter
getLikesCount()

int

Simple Getter

String
String
String

getLink()

Simple Getter
getUsername()

Simple Getter
getWebsite()

Simple Getter

Methods inherited from class com.codename1.facebook.FBObject


equals, getId, getName, hashCode, setId

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Class Page

2503

Overview (Codename One API)


Constructor

Detail

Page
public Page()

Empty Contructor
Page
public Page(Hashtable props)

Method Detail
getAbout
public String getAbout()

Simple Getter
getCategory
public String getCategory()

Simple Getter
getCoverId
public String getCoverId()

Simple Getter
getCoverLink
public String getCoverLink()

Simple Getter
getFounded
public String getFounded()

Simple Getter
getLikesCount
public int getLikesCount()

Simple Getter
getLink
public String getLink()

Simple Getter
getUsername
public String getUsername()

Simple Getter
getWebsite
public String getWebsite()

Simple Getter
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Overrides:
copy in class FBObject

Constructor Detail

2504

Overview (Codename One API)

Parameters:
props

Method Detail

- an hashtable to copy from

2505

Overview (Codename One API)


com.codename1.facebook

Class FaceBookAccess
java.lang.Object

com.codename1.facebook.FaceBookAccess

public class
extends Object

This is the main access API to the facebook graph API


http://developers.facebook.com/docs/reference/api/ This class encapsulates the Network access and
provide simple methods to acess the Facebook servers.

Method Summary
Modifier and Type
void

Method and Description


addResponseCodeListener(ActionListener a)

Adds a response listener on the requests


anonymousLogin(String appid, String clientSecret)

static void

void
Component
void

void

Some simple queries for public data can work just fine with anonymous
login without requiring the whole OAuth process, they still need a
facebook application though
cleanTempStorage()

Deletes all temp storage.


createAuthComponent(ActionListener al)

This method creates a component which can authenticate.


createNote(String userId, String subject, String message)

Post a note onto the users wall


createNote(String userId, String subject, String message,
ActionListener callback)

Post a note onto the users wall


Oauth2

createOAuth()
createObjectsModel(DefaultListModel hashtablesModel,
Class fbObjectClass)

static
DefaultListModel

void

This is a utility method that transforms a DefaultListModel that contains


Hashtable entries into a DefaultListModel that will contain FBObject
objects that will be initialized with the Hashtable entries
getAlbum(String albumId, Album album, ActionListener callback)

Gest an album from an albumId


getAlbum(String albumId, boolean needAuth)

Album

void

Gets a Album from a albumId This is a sync method it will block until a
response it returned
getAlbumPhotos(String albumId, DefaultListModel photos,
int offset, int limit, ActionListener callback)

Gets the albums photos


static String

getApiVersion()

Returns the api version used, if empty the non version-ed is used
getFaceBookObject(String faceBookId, ActionListener callback)

void

void

void

Class FaceBookAccess

This method returns immediately and will call the callback when it
returns with the FaceBook Object data.
getFaceBookObject(String faceBookId, ActionListener callback,
boolean needToken, boolean async)

This method returns immediately and will call the callback when it
returns with the FaceBook Object data.
getFaceBookObjectItems(String faceBookId,
String itemsConnection, DefaultListModel feed,

2506

Overview (Codename One API)


Hashtable params, ActionListener callback)

Get a list of FaceBook objects for a given id


String
static
FaceBookAccess

void

void

getImageURL(String id, Dimension toScale)

Returns the URL for a given image


getInstance()

gets the class instance


getNewsFeed(String userId, DefaultListModel feed,
ActionListener callback)

Gets the user news feed, the data is being stored in the given
DefaultListModel.
getNewsFeed(String userId, DefaultListModel feed, int limit,
ActionListener callback)

Gets the user news feed, the data is being stored in the given
DefaultListModel.
getPage(String pageId)

Page

Gets a Page from a pageId/name This is a sync method it will block


until a response it returned
getPhoto(String photoId, boolean needAuth)

Photo

void

void

Gets a Photo from a photoId This is a sync method it will block until a
response it returned
getPhoto(String photoId, Photo photo, ActionListener callback)

Gest a photo from a photo Id


getPhotoThumbnail(String photoId, ActionListener callback,
boolean tempStorage)

Gets the photo thumbnail of a Photo Object


void

getPhotoThumbnail(String photoId, Label label,


Dimension toScale, boolean tempStorage)

Gets the photo thumbnail of a Photo Object


void

getPicture(String id, ActionListener callback,


Dimension toScale, boolean tempStorage)

Gets the picture of the given facebook object id


getPicture(String id, Component targetList, int targetOffset,
String targetKey, Dimension toScale, boolean tempStorage)
void

void

Gets the picture of the given facebook object id and stores it in the
given List in the offset index This assumes the GenericListCellRenderer
style of list which relies on a hashtable based model approach.
getPicture(String id, Label label, Dimension toScale,
boolean tempStorage)

Gets the picture of the given facebook object id


EncodedImage

getPictureAndWait(String id, Dimension toScale)

Gets the picture of the given facebook object id


getPost(String postId, boolean needAuth)

Post

void

void

Gets a Post from a postId This is a sync method it will block until a
response it returned
getPost(String postId, Post post, ActionListener callback)

Gest a post from a post Id


getPostComments(String postId, DefaultListModel comments,
ActionListener callback)

Gets the post comments


getToken()
static String

Returns the Facebook authorization token that can be used for API
access
getUser(String userId)

User

void

void

Gets a User from a user id This is a sync method it will block until a
response it returned
getUser(String userId, User user, ActionListener callback)

Gets a user from a user id


getUserAlbums(String userId, DefaultListModel albums,
ActionListener callback)

Gets the user albums


void

Method Summary

2507

Overview (Codename One API)


getUserEvents(String userId, DefaultListModel events,
ActionListener callback)

Gets the user events


void

getUserFriends(String userId, DefaultListModel friends,


ActionListener callback)

Gets the user friends


void

getUserInboxThreads(String userId, DefaultListModel threads,


int limit, ActionListener callback)

Gets the user inbox Threads

void

getUserNotifications(String userId, String startTime,


boolean includeRead, DefaultListModel notifications,
ActionListener callback)

Gets the user notifications (this method uses the legacy rest api see
http://developers.facebook.com/docs/reference/rest/)
void

void

void

void

void

getUsersDetails(String[] usersIds, String[] fields,


ActionListener callback)

Gets users requested details ((this method uses the legacy rest api see
http://developers.facebook.com/docs/reference/rest/))
getWallFeed(String userId, DefaultListModel feed,
ActionListener callback)

Gets the user wall feed, the data is being stored in the given
DefaultListModel.
getWallFeed(String userId, DefaultListModel feed, int limit,
ActionListener callback)

Gets the user wall feed, the data is being stored in the given
DefaultListModel.
getWallPosts(String userId, DefaultListModel feed,
ActionListener callback)

Gets the user wall feed, the data is being stored in the given
DefaultListModel.
getWallPosts(String userId, DefaultListModel feed, int limit,
ActionListener callback)

Gets the user wall posts, the data is being stored in the given
DefaultListModel.
isAuthenticated()

boolean

void
static void
void

void

This method returns true if the user is authenticated to the facebook


service.
killCurrentRequest()

Kills the current request.


logOut()

log out the current user


postComment(String postId, String message)

Post a comment on a given post


postComment(String postId, String message,
ActionListener callback)

Post a comment on a given post


void
void
void

void

postLike(String postId)

Post like on a given post


postLike(String postId, ActionListener callback)

Post like on a given post


postOnWall(String userId, String message)

Post a message on the users wall


postOnWall(String userId, String message,
ActionListener callback)

Post a message on the users wall


void

postOnWall(String userId, String message, String name,


String link, String description, String picture,
String caption, ActionListener callback)

Post a message on the users wall


void

removeResponseCodeListener(ActionListener a)

Removes a response listener

void

Method Summary

2508

Overview (Codename One API)


search(String objectType, String query,
DefaultListModel results, ActionListener callback)

Serach for facebook objects


setApiVersion(String apiVersion)
static void

Sets the Facebook api version being used, by default the api calls the
non version-ed version of the API.
setClientId(String clientId)

static void

The client id (appid) which asks to connect (this is generated when an


app is created see: https://developers.facebook.com/apps)
setClientSecret(String clientSecret)

static void

The client secret is been generated by facebook see:


https://developers.facebook.com/apps
setPermissions(String[] permissions)

static void

The requested permissions of the app


http://developers.facebook.com/docs/reference/api/permissions/
setProgress(Slider slider)

void

Sets the progress indicator to get network updates on the queries


setRedirectURI(String redirectURI)

static void

This is generated when an app is created see:


https://developers.facebook.com/apps
setToken(String tok)

static void

Sets the token to the FaceBookAccess class, this is useful if the token
has not yet expired, get the expiration of the token with
Oauth2.getExpires()
showAuthentication(ActionListener al)

void

This method shows an authentication for login form

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
getInstance
public static FaceBookAccess getInstance()

gets the class instance


Returns:
a FaceBookAccess object
createOAuth
public Oauth2 createOAuth()

createAuthComponent
public Component createAuthComponent(ActionListener al)

This method creates a component which can authenticate. You will receive either the
authentication key or an Exception object within the ActionListener callback method.
Parameters:
al - a listener that will receive at its source either a token for the service or an
exception in case of a failure
Returns:
a component that should be displayed to the user in order to perform the
authentication
showAuthentication
public void showAuthentication(ActionListener al)

This method shows an authentication for login form


Parameters:

Methods inherited from class java.lang.Object

2509

Overview (Codename One API)


- a listener that will receive at its source either a token for the service or an
exception in case of a failure
isAuthenticated
al

public boolean isAuthenticated()

This method returns true if the user is authenticated to the facebook service.
Returns:
true if authenticated
setProgress
public void setProgress(Slider slider)

Sets the progress indicator to get network updates on the queries


Parameters:
slider getFaceBookObject
public void getFaceBookObject(String faceBookId,
ActionListener callback)
throws IOException

This method returns immediately and will call the callback when it returns with the
FaceBook Object data.
Parameters:
faceBookId - the object id that we would like to query
callback - the callback that should be updated when the data arrives
Throws:
IOException

getFaceBookObject
public void getFaceBookObject(String faceBookId,
ActionListener callback,
boolean needToken,
boolean async)
throws IOException

This method returns immediately and will call the callback when it returns with the
FaceBook Object data.
Parameters:
faceBookId - the object id that we would like to query
callback - the callback that should be updated when the data arrives
needToken - if true authentication is being checked
Throws:
IOException

getFaceBookObjectItems
public void getFaceBookObjectItems(String faceBookId,
String itemsConnection,
DefaultListModel feed,
Hashtable params,
ActionListener callback)
throws IOException

Get a list of FaceBook objects for a given id


Parameters:
faceBookId - the id to preform the query upon
itemsConnection - the type of the query
feed params callback - the callback that should be updated when the data arrives
Throws:
IOException

getUser
public void getUser(String userId,
User user,
ActionListener callback)
throws IOException

Method Detail

2510

Overview (Codename One API)


Gets a user from a user id
Parameters:
userId - the user id or null to get detaild on the authenticated user
user - an object to fill with the user details
callback - the callback that should be updated when the data arrives
Throws:
IOException

getUser
public User getUser(String userId)
throws IOException

Gets a User from a user id This is a sync method it will block until a response it
returned
Parameters:
userId - the user id or null to get details on the authenticated user
Returns:
the User requested
Throws:
IOException

getPage
public Page getPage(String pageId)
throws IOException

Gets a Page from a pageId/name This is a sync method it will block until a response
it returned
Parameters:
pageId - the pageId
Returns:
the Page requested
Throws:
IOException

getPost
public void getPost(String postId,
Post post,
ActionListener callback)
throws IOException

Gest a post from a post Id


Parameters:
postId - the postId
post - an Object to fill with the data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getPost
public Post getPost(String postId,
boolean needAuth)
throws IOException

Gets a Post from a postId This is a sync method it will block until a response it
returned
Parameters:
postId - the post id
needAuth - if this object is public needAuth can be false and no authentication
will be performed
Returns:
the Post requested
Throws:
IOException

getPhoto
public void getPhoto(String photoId,
Photo photo,
ActionListener callback)
throws IOException

Method Detail

2511

Overview (Codename One API)


Gest a photo from a photo Id
Parameters:
photoId - the photoId
photo - an Object to fill with the data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getPhoto
public Photo getPhoto(String photoId,
boolean needAuth)
throws IOException

Gets a Photo from a photoId This is a sync method it will block until a response it
returned
Parameters:
the - photoId
needAuth - if this object is public needAuth can be false and no authentication
will be performed
Returns:
the Photo requested
Throws:
IOException

getAlbum
public void getAlbum(String albumId,
Album album,
ActionListener callback)
throws IOException

Gest an album from an albumId


Parameters:
albumId - the albumId
album - an Object to fill with the data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getAlbum
public Album getAlbum(String albumId,
boolean needAuth)
throws IOException

Gets a Album from a albumId This is a sync method it will block until a response it
returned
Parameters:
the - albumId
needAuth - if this object is public needAuth can be false and no authentication
will be performed
Returns:
the Album requested
Throws:
IOException

getNewsFeed
public void getNewsFeed(String userId,
DefaultListModel feed,
ActionListener callback)
throws IOException

Gets the user news feed, the data is being stored in the given DefaultListModel. By
default this method will return last 13 news entries.
Parameters:
userId - the userid we would like to query
feed - the response to fill
callback - the callback that should be updated when the data arrives
Throws:
IOException

Method Detail

2512

Overview (Codename One API)


getNewsFeed
public void getNewsFeed(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
throws IOException

Gets the user news feed, the data is being stored in the given DefaultListModel.
Parameters:
userId - the userid we would like to query
feed - the response to fill
limit - the number of items to return
callback - the callback that should be updated when the data arrives
Throws:
IOException

getWallFeed
public void getWallFeed(String userId,
DefaultListModel feed,
ActionListener callback)
throws IOException

Gets the user wall feed, the data is being stored in the given DefaultListModel. By
default this method will return last 13 news entries.
Parameters:
userId - the userid we would like to query
feed - the response fo fill
callback - the callback that should be updated when the data arrives
Throws:
IOException

getWallFeed
public void getWallFeed(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
throws IOException

Gets the user wall feed, the data is being stored in the given DefaultListModel.
Parameters:
userId - the userid we would like to query
feed - the response to fill
limit - the number of items to return
callback - the callback that should be updated when the data arrives
Throws:
IOException

getWallPosts
public void getWallPosts(String userId,
DefaultListModel feed,
ActionListener callback)
throws IOException

Gets the user wall feed, the data is being stored in the given DefaultListModel. By
default this method will return last 13 news entries.
Parameters:
userId - the userid we would like to query
feed - the response fo fill
callback - the callback that should be updated when the data arrives
Throws:
IOException

getWallPosts
public void getWallPosts(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
throws IOException

Method Detail

2513

Overview (Codename One API)


Gets the user wall posts, the data is being stored in the given DefaultListModel.
Parameters:
userId - the userid we would like to query
feed - the response to fill
limit - the number of items to return
callback - the callback that should be updated when the data arrives
Throws:
IOException

getPicture
public void getPicture(String id,
Label label,
Dimension toScale,
boolean tempStorage)
throws IOException

Gets the picture of the given facebook object id


Parameters:
id - the object id to query
label - place the image on the given label as an icon
toScale - scale the image to the given dimension
tempStorage - if true place the image in a temp storage
Throws:
IOException

getPicture
public void getPicture(String id,
ActionListener callback,
Dimension toScale,
boolean tempStorage)
throws IOException

Gets the picture of the given facebook object id


Parameters:
id - the object id to query
callback - the callback that should be updated when the data arrives
toScale - picture dimension or null
tempStorage - if true place the image in a temp storage
Throws:
IOException

getPictureAndWait
public EncodedImage getPictureAndWait(String id,
Dimension toScale)

Gets the picture of the given facebook object id


Parameters:
id - the object id to query
toScale - picture dimension or null
Returns:
the picture
getImageURL
public String getImageURL(String id,
Dimension toScale)

Returns the URL for a given image


Parameters:
id - the id of the image
toScale - the resolution we want
Returns:
a link that should fetch that image
getPicture
public void getPicture(String id,
Component targetList,
int targetOffset,
String targetKey,
Dimension toScale,

Method Detail

2514

Overview (Codename One API)


boolean tempStorage)
throws IOException

Gets the picture of the given facebook object id and stores it in the given List in the
offset index This assumes the GenericListCellRenderer style of list which relies on a
hashtable based model approach.
Parameters:
id - the object id to query
targetList - the list that should be updated when the data arrives
targetOffset - the offset within the list to insert the image
targetKey - the key for the hashtable in the target offset
toScale - the scale of the image to put in the List or null
tempStorage - if true place the image in a temp storage
Throws:
IOException

getPhotoThumbnail
public void getPhotoThumbnail(String photoId,
ActionListener callback,
boolean tempStorage)
throws IOException

Gets the photo thumbnail of a Photo Object


Parameters:
photoId - the photo id
callback - the callback that should be updated when the data arrives
tempStorage - if true place the image in a temp storage
Throws:
IOException

getPhotoThumbnail
public void getPhotoThumbnail(String photoId,
Label label,
Dimension toScale,
boolean tempStorage)
throws IOException

Gets the photo thumbnail of a Photo Object


Parameters:
photoId - the photo id
label - place the image on the given label as an icon
toScale - scale the image to the given dimension
tempStorage - if true place the image in a temp storage
Throws:
IOException

getUserFriends
public void getUserFriends(String userId,
DefaultListModel friends,
ActionListener callback)
throws IOException

Gets the user friends


Parameters:
userId - the id
friends - store friends results into the given model, each entry is an
Hashtable Object contaning the Object data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getUserAlbums
public void getUserAlbums(String userId,
DefaultListModel albums,
ActionListener callback)
throws IOException

Gets the user albums


Parameters:

Method Detail

2515

Overview (Codename One API)


- the id
- store albums results into the given model, each entry is an
Hashtable Object contaning the Object data
callback - the callback that should be updated when the data arrives
userId
albums

Throws:
IOException

getAlbumPhotos
public void getAlbumPhotos(String albumId,
DefaultListModel photos,
int offset,
int limit,
ActionListener callback)
throws IOException

Gets the albums photos


Parameters:
albumId - the id
photos - store photos results into the given model, each entry is an Hashtable
Object contaning the Object data
offset - the offset of the photo in the album
limit - amount of photos to bring
callback - the callback that should be updated when the data arrives
Throws:
IOException

getPostComments
public void getPostComments(String postId,
DefaultListModel comments,
ActionListener callback)
throws IOException

Gets the post comments


Parameters:
postId - the id
comments - store comments results into the given model, each entry is an
Hashtable Object contaning the Object data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getUserInboxThreads
public void getUserInboxThreads(String userId,
DefaultListModel threads,
int limit,
ActionListener callback)
throws IOException

Gets the user inbox Threads


Parameters:
userId - the id
threads - store threads results into the given model, each entry is an
Hashtable Object contaning the Object data
limit - the amount of thread to return
callback - the callback that should be updated when the data arrives
Throws:
IOException

postOnWall
public void postOnWall(String userId,
String message)
throws IOException

Post a message on the users wall


Parameters:
userId - the userId
message - the message to post
Throws:
IOException

Method Detail

2516

Overview (Codename One API)


postLike
public void postLike(String postId)
throws IOException

Post like on a given post


Parameters:
postId - the post Id
Throws:
IOException

postComment
public void postComment(String postId,
String message)
throws IOException

Post a comment on a given post


Parameters:
postId - the post id
message - the message to post
Throws:
IOException

createNote
public void createNote(String userId,
String subject,
String message)
throws IOException

Post a note onto the users wall


Parameters:
userId - the userId
message - the message to post
Throws:
IOException

postOnWall
public void postOnWall(String userId,
String message,
ActionListener callback)
throws IOException

Post a message on the users wall


Parameters:
userId - the userId
message - the message to post
Throws:
IOException

postOnWall
public void postOnWall(String userId,
String message,
String name,
String link,
String description,
String picture,
String caption,
ActionListener callback)
throws IOException

Post a message on the users wall


Parameters:
userId - the userId
message - the message to post
name link description picture caption Throws:

Method Detail

2517

Overview (Codename One API)


IOException

postLike
public void postLike(String postId,
ActionListener callback)
throws IOException

Post like on a given post


Parameters:
postId - the post Id
Throws:
IOException

postComment
public void postComment(String postId,
String message,
ActionListener callback)
throws IOException

Post a comment on a given post


Parameters:
postId - the post id
message - the message to post
Throws:
IOException

createNote
public void createNote(String userId,
String subject,
String message,
ActionListener callback)
throws IOException

Post a note onto the users wall


Parameters:
userId - the userId
message - the message to post
Throws:
IOException

getUserNotifications
public void getUserNotifications(String userId,
String startTime,
boolean includeRead,
DefaultListModel notifications,
ActionListener callback)
throws IOException

Gets the user notifications (this method uses the legacy rest api see
http://developers.facebook.com/docs/reference/rest/)
Parameters:
userId - the user id
startTime - Indicates the earliest time to return a notification. This equates to
the updated_time field in the notification FQL table. If not specified, this call
returns all available notifications.
includeRead - Indicates whether to include notifications that have already
been read. By default, notifications a user has read are not included.
notifications - store notifications results into the given model, each entry is
an Hashtable Object contaning the Object data
callback - the callback that should be updated when the data arrives
Throws:
IOException

getUsersDetails
public void getUsersDetails(String[] usersIds,
String[] fields,
ActionListener callback)
throws IOException

Method Detail

2518

Overview (Codename One API)


Gets users requested details ((this method uses the legacy rest api see
http://developers.facebook.com/docs/reference/rest/))
Parameters:
usersIds - the users to query
fields - which fields to query on the users see
http://developers.facebook.com/docs/reference/rest/users.getInfo/
callback - the result will call the callback with the result to extrct the data
preform the following: public void actionPerformed(ActionEvent evt) { Vector
data = (Vector) ((NetworkEvent) evt).getMetaData(); Vector users = (Vector)
data.elementAt(0); }
Throws:
IOException

getUserEvents
public void getUserEvents(String userId,
DefaultListModel events,
ActionListener callback)
throws IOException

Gets the user events


Parameters:
userId - the user id
events - store events results into the given model, each entry is an Hashtable
Object contaning the Object data
callback - the callback that should be updated when the data arrives
Throws:
IOException

search
public void search(String objectType,
String query,
DefaultListModel results,
ActionListener callback)
throws IOException

Serach for facebook objects


Parameters:
objectType - one of each: post, user, page, event, group, place, checkin
query - the query string to search for
results - store results onto the given model, each entry is an Hashtable
Object contaning the Object data
callback - the callback that should be updated when the data arrives
Throws:
IOException

killCurrentRequest
public void killCurrentRequest()

Kills the current request.


addResponseCodeListener
public void addResponseCodeListener(ActionListener a)

Adds a response listener on the requests


Parameters:
a - response listener
removeResponseCodeListener
public void removeResponseCodeListener(ActionListener a)

Removes a response listener


createObjectsModel
public static DefaultListModel createObjectsModel(DefaultListModel hashtablesModel,
Class fbObjectClass)
throws IllegalAccessException,
InstantiationException

Method Detail

2519

Overview (Codename One API)


This is a utility method that transforms a DefaultListModel that contains Hashtable
entries into a DefaultListModel that will contain FBObject objects that will be initialized
with the Hashtable entries
Parameters:
hashtablesModel - the model to transform, this model should hold it's data
has Hashtable entries
fbObjectClass - this is the class of the entries to be created, this class should
be a FBObject type
Returns:
a DefaultListModel with fbObjectClass objects entries
Throws:
IllegalAccessException - if the fbObjectClass.newInstance() fails
InstantiationExceptionif - the fbObjectClass.newInstance() fails
InstantiationException

cleanTempStorage
public void cleanTempStorage()

Deletes all temp storage.


setClientId
public static void setClientId(String clientId)

The client id (appid) which asks to connect (this is generated when an app is created
see: https://developers.facebook.com/apps)
Parameters:
clientId setClientSecret
public static void setClientSecret(String clientSecret)

The client secret is been generated by facebook see:


https://developers.facebook.com/apps
Parameters:
clientSecret setPermissions
public static void setPermissions(String[] permissions)

The requested permissions of the app


http://developers.facebook.com/docs/reference/api/permissions/
Parameters:
permissions setRedirectURI
public static void setRedirectURI(String redirectURI)

This is generated when an app is created see: https://developers.facebook.com/apps


Parameters:
redirectURI setToken
public static void setToken(String tok)

Sets the token to the FaceBookAccess class, this is useful if the token has not yet
expired, get the expiration of the token with Oauth2.getExpires()
Parameters:
tok - the token of the
getToken
public static String getToken()

Returns the Facebook authorization token that can be used for API access
Returns:
the token

Method Detail

2520

Overview (Codename One API)


logOut
public static void logOut()

log out the current user


anonymousLogin
public static void anonymousLogin(String appid,
String clientSecret)

Some simple queries for public data can work just fine with anonymous login without
requiring the whole OAuth process, they still need a facebook application though
Parameters:
appid - the id of the application
clientSecret - the client secret for the application
getApiVersion
public static String getApiVersion()

Returns the api version used, if empty the non version-ed is used
setApiVersion
public static void setApiVersion(String apiVersion)

Sets the Facebook api version being used, by default the api calls the non version-ed
version of the API.
Parameters:
apiVersion - valid values are "1.0", "2.0", "2.1"

Method Detail

2521

Overview (Codename One API)


com.codename1.facebook

Class FBObject
java.lang.Object

com.codename1.facebook.FBObject
Direct Known Subclasses:
Album, Page, Photo, Post, User

public class
extends Object

This is a base class for all FaceBook Objects

Constructor Summary
Constructor and Description
FBObject()

Empty Contructor
FBObject(Hashtable props)

This contructor initialize it's attributes from the given Hashtable

Method Summary
Modifier and Type

Method and Description


copy(Hashtable props)

void

copies the relevant values from the given hashtable

boolean

equals(Object obj)

Indicates whether some other object is "equal to" this one.


getId()

String

Simple getter
getName()

String

Simple getter
hashCode()

int

Returns a hash code value for the object.


setId(String id)

void

Simple setter

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FBObject
public FBObject()

Empty Contructor
FBObject
public FBObject(Hashtable props)

This contructor initialize it's attributes from the given Hashtable


Parameters:

Class FBObject

2522

Overview (Codename One API)


props

- an Hashtable which contains the Object data

Method Detail
setId
public void setId(String id)

Simple setter
Parameters:
id - the Object Id, each facebook element had an id
getId
public String getId()

Simple getter
Returns:
the facebook object id
getName
public String getName()

Simple getter
Returns:
the FB Object name
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Parameters:
props - an hashtable to copy from
equals
public boolean equals(Object obj)

Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer

Constructor Detail

2523

Overview (Codename One API)


results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object

Method Detail

2524

Overview (Codename One API)


com.codename1.facebook

Class Album
java.lang.Object

com.codename1.facebook.FBObject

com.codename1.facebook.Album

public class
extends FBObject

This class represents a Facebook Photo Object


http://developers.facebook.com/docs/reference/api/album

Constructor Summary
Constructor and Description
Album()

Empty Contructor
Album(Hashtable props)

Method Summary
Modifier and Type

Method and Description


copy(Hashtable props)

void

copies the relevant values from the given hashtable


getCount()

int

Gets number of photos in this album

String
String
String

getCover_photo()

Gets the cover photos url of this album


getCreated_time()

Gets created_time
getDescription()

Gets description
getFrom()

User

Gets the from User

String
String
String
String
String

getLink()

Gets the link


getLocation()

Gets the location


getPrivacy()

Gets the privacy


getType()

Gets the type


getUpdated_time()

Gets the updated_time

Methods inherited from class com.codename1.facebook.FBObject


equals, getId, getName, hashCode, setId

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Class Album

2525

Overview (Codename One API)


Constructor

Detail

Album
public Album()

Empty Contructor
Album
public Album(Hashtable props)

Method Detail
getCount
public int getCount()

Gets number of photos in this album


Returns:
count
getCover_photo
public String getCover_photo()

Gets the cover photos url of this album


Returns:
cover_photo
getCreated_time
public String getCreated_time()

Gets created_time
Returns:
created_time
getDescription
public String getDescription()

Gets description
Returns:
description
getFrom
public User getFrom()

Gets the from User


Returns:
from
getLink
public String getLink()

Gets the link


Returns:
link
getLocation
public String getLocation()

Gets the location


Returns:
location

Constructor Detail

2526

Overview (Codename One API)

getPrivacy
public String getPrivacy()

Gets the privacy


Returns:
privacy
getType
public String getType()

Gets the type


Returns:
type
getUpdated_time
public String getUpdated_time()

Gets the updated_time


Returns:
updated_time
copy
public void copy(Hashtable props)

copies the relevant values from the given hashtable


Overrides:
copy in class FBObject
Parameters:
props - an hashtable to copy from

Method Detail

2527

Overview (Codename One API)


com.codename1.db

Interface Row

public interface

This Class represents a database row.

Method Summary
Modifier and Type

getBlob(int index)

byte[]

Gets column value by index.


getDouble(int index)

double

Gets column value by index.


getFloat(int index)

float

Gets column value by index.


getInteger(int index)

int

Gets column value by index.


getLong(int index)

long

Gets column value by index.


getShort(int index)

short

Gets column value by index.


getString(int index)

String

Method and Description

Gets column value by index.

Method Detail
getBlob
byte[] getBlob(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
byte [] data
Throws:
IOException

getDouble
double getDouble(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
a double data from the database
Throws:
IOException

getFloat
float getFloat(int index)
throws IOException

Gets column value by index.

Interface Row

2528

Overview (Codename One API)


Parameters:
index - starts with zero
Returns:
a float data from the database
Throws:
IOException

getInteger
int getInteger(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
a int data from the database
Throws:
IOException

getLong
long getLong(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
a long data from the database
Throws:
IOException

getShort
short getShort(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
a short data from the database
Throws:
IOException

getString
String getString(int index)
throws IOException

Gets column value by index.


Parameters:
index - starts with zero
Returns:
a String data from the database
Throws:
IOException

Method Detail

2529

Overview (Codename One API)


com.codename1.db

Class Database
java.lang.Object

com.codename1.db.Database

public abstract class


extends Object

This is a Database SQLite class, this class allows developers to connect to a database and preform
sql queries on the data. The Database class abstracts the underlying SQLite of the device if available.
Supported platforms for this feature are: IOS, Android, BB OS5+ and the Desktop Simulator (which
supports only cursor forward navigation). The SQLite should be used for very large data handling, for
small storage refer to Storage which is more portable.

Constructor Summary
Constructor and Description
Database()

Method Summary
Modifier and
Type
abstract void
abstract void
abstract void
static void
abstract void
void
abstract void

Method and Description


beginTransaction()

Starts a transaction
close()

Closes the database


commitTransaction()

Commits current transaction


delete(String databaseName)

Deletes database
execute(String sql)

Execute an update query.


execute(String sql, Object[] params)

Execute an update query with params.


execute(String sql, String[] params)

Execute an update query with params.


executeQuery(String sql)

abstract Cursor

This method should be called with SELECT type statements that return
row set.
executeQuery(String sql, String[] params)

abstract Cursor

static boolean

This method should be called with SELECT type statements that return
row set.
exists(String databaseName)

Indicates weather a database exists


getDatabasePath(String databaseName)

static String

static Database
abstract void

Class Database

Returns the file path of the Database if exists and if supported on the
platform.
openOrCreate(String databaseName)

Opens a database or create one if not exists


rollbackTransaction()

Rolls back current transaction

2530

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Database
public Database()

Method Detail
openOrCreate
public static Database openOrCreate(String databaseName)
throws IOException

Opens a database or create one if not exists


Parameters:
databaseName - the name of the database
Returns:
Database Object or null if not supported on the platform
Throws:
IOException - if database cannot be created
exists
public static boolean exists(String databaseName)

Indicates weather a database exists


Parameters:
databaseName - the name of the database
Returns:
true if database exists
delete
public static void delete(String databaseName)
throws IOException

Deletes database
Parameters:
databaseName

- the name of the database

Throws:
IOException

- if database cannot be deleted

getDatabasePath
public static String getDatabasePath(String databaseName)

Returns the file path of the Database if exists and if supported on the platform.
Returns:
the file path of the database
beginTransaction
public abstract void beginTransaction()
throws IOException

Starts a transaction
Throws:
IOException

- if database is not opened

commitTransaction
public abstract void commitTransaction()
throws IOException

Commits current transaction

Methods inherited from class java.lang.Object

2531

Overview (Codename One API)


Throws:
IOException - if database is not opened or transaction was not started
rollbackTransaction
public abstract void rollbackTransaction()
throws IOException

Rolls back current transaction


Throws:
IOException - if database is not opened or transaction was not started
close
public abstract void close()
throws IOException

Closes the database


Throws:
IOException

execute
public abstract void execute(String sql)
throws IOException

Execute an update query. Used for INSERT, UPDATE, DELETE and similar sql
statements.
Parameters:
sql - the sql to execute
Throws:
IOException

execute
public abstract void execute(String sql,
String[] params)
throws IOException

Execute an update query with params. Used for INSERT, UPDATE, DELETE and
similar sql statements. The sql can be constructed with '?' and the params will be
binded to the query
Parameters:
sql - the sql to execute
params - to bind to the query where the '?' exists
Throws:
IOException

execute
public void execute(String sql,
Object[] params)
throws IOException

Execute an update query with params. Used for INSERT, UPDATE, DELETE and
similar sql statements. The sql can be constructed with '?' and the params will be
binded to the query
Parameters:
sql - the sql to execute
params - to bind to the query where the '?' exists, supported object types are
String, byte[], Double, Long and null
Throws:
IOException

executeQuery
public abstract Cursor executeQuery(String sql,
String[] params)
throws IOException

This method should be called with SELECT type statements that return row set.
Parameters:
sql - the sql to execute
params - to bind to the query where the '?' exists
Returns:

Method Detail

2532

Overview (Codename One API)


a cursor to iterate over the results
Throws:
IOException

executeQuery
public abstract Cursor executeQuery(String sql)
throws IOException

This method should be called with SELECT type statements that return row set.
Parameters:
sql - the sql to execute
Returns:
a cursor to iterate over the results
Throws:
IOException

Method Detail

2533

Overview (Codename One API)


com.codename1.db

Interface Cursor

public interface

The Cursor Object is used to iterate over the results

Method Summary
Modifier and Type
close()

void

Close the cursor and release its resources


first()

boolean

Move the cursor to the first row.


getColumnCount()

int

Returns the column count


getColumnIndex(String columnName)

int

Returns the zero-based index for a given column name.


getColumnName(int columnIndex)

String

Returns the column name at a given zero-based column index.


getPosition()

int

Returns the current Cursor position.


getRow()

Row

Get the Row data Object.


last()

boolean

Move the cursor to the last row.


next()

boolean

Moves the cursor to the next row.


position(int row)

boolean

Move the cursor to an absolute row position


prev()

boolean

Method and Description

Moves the cursor to the previous row.

Method Detail
first
boolean first()
throws IOException

Move the cursor to the first row. If cursor provides forward-only navigation and is
positioned after the first row then calling first() method would throw a IOException.
Returns:
true if succeeded
Throws:
IOException

last
boolean last()
throws IOException

Move the cursor to the last row.


Returns:
true if succeeded
Throws:

Interface Cursor

2534

Overview (Codename One API)


IOException

next
boolean next()
throws IOException

Moves the cursor to the next row. Calling next() method the first time will position
cursor on the first.
Returns:
true if succeeded
Throws:
IOException

prev
boolean prev()
throws IOException

Moves the cursor to the previous row. If cursor is forward type then calling prev()
would throw a IOException.
Returns:
true if succeeded
Throws:
IOException

getColumnIndex
int getColumnIndex(String columnName)
throws IOException

Returns the zero-based index for a given column name. Note that columns meta
information is available only after navigation to the first row
Parameters:
columnName - the name of the column.
Returns:
the index of the column
Throws:
IOException

getColumnName
String getColumnName(int columnIndex)
throws IOException

Returns the column name at a given zero-based column index. Note that columns
meta information is available only after navigation to the first row
Parameters:
columnIndex - the index of the column
Returns:
the name of the column
Throws:
IOException

getColumnCount
int getColumnCount()
throws IOException

Returns the column count


Returns:
the column count
Throws:
IOException

getPosition
int getPosition()
throws IOException

Returns the current Cursor position.


Returns:
the cursor position
Throws:
IOException

Method Detail

2535

Overview (Codename One API)


position
boolean position(int row)
throws IOException

Move the cursor to an absolute row position


Parameters:
row - position to move to
Returns:
true if succeeded
Throws:
IOException

close
void close()
throws IOException

Close the cursor and release its resources


Throws:
IOException

getRow
Row getRow()
throws IOException

Get the Row data Object.


Returns:
a Row Object
Throws:
IOException

Method Detail

2536

Overview (Codename One API)


com.codename1.contacts

Class ContactsModel
java.lang.Object

com.codename1.ui.list.DefaultListModel

com.codename1.contacts.ContactsModel
All Implemented Interfaces:
ListModel

public class
extends DefaultListModel

This Contacts model is responsible for querying Contacts from the device and to cache the data for
faster usage

Constructor Summary
Constructor and Description
ContactsModel(String[] ids)

Constructor with contacts ids

Method Summary
Modifier and Type

Method and Description


addItem(Object item)

void

Adds the specified item to the end of this list.

Object

getItemAt(int index)

Returns the item at the given offset


removeItem(int index)

void

Removes the item at the specified position in this list.


setPlaceHolderImage(Image placeHolder)

void

Sets the Contacts place holder image.

Methods inherited from


class com.codename1.ui.list.DefaultListModel
addDataChangedListener, addItemAtIndex, addSelectionListener,
fireDataChangedEvent, getList, getSelectedIndex, getSize, removeAll,
removeDataChangedListener, removeSelectionListener, setItem,
setSelectedIndex

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ContactsModel
public ContactsModel(String[] ids)

Constructor with contacts ids


Parameters:
ids - the contact ids we would like this model to handle

Class ContactsModel

2537

Overview (Codename One API)


Method

Detail

setPlaceHolderImage
public void setPlaceHolderImage(Image placeHolder)

Sets the Contacts place holder image.


Parameters:
placeHolder - image place holder for the contacts
getItemAt
public Object getItemAt(int index)

Returns the item at the given offset


Specified by:
getItemAt in interface ListModel
Overrides:
getItemAt in class DefaultListModel
Parameters:
index - an index into this list
Returns:
the item at the specified index
addItem
public void addItem(Object item)

Adds the specified item to the end of this list. An optional operation for mutable lists, it
can throw an unsupported operation exception if a list model is not mutable.
Specified by:
addItem in interface ListModel
Overrides:
addItem in class DefaultListModel
Parameters:
item - the item to be added
removeItem
public void removeItem(int index)

Removes the item at the specified position in this list.


Specified by:
removeItem in interface ListModel
Overrides:
removeItem in class DefaultListModel
Parameters:
index - the index of the item to removed

Method Detail

2538

Overview (Codename One API)


com.codename1.contacts

Class ContactsManager
java.lang.Object

com.codename1.contacts.ContactsManager

public class
extends Object

This class uses as the Contacts manager of the device, it enables the possibility To get the Contacts
that are available on the device.

Constructor Summary
Constructor and Description
ContactsManager()

Method Summary
Modifier and
Type
static
String

Method and Description


createContact(String firstName, String familyName, String workPhone,
String homePhone, String mobilePhone, String email)

Create a contact to the device contacts book

static
boolean

deleteContact(String id)

static
String[]

getAllContacts()

Contact[]

removed a contact from the device contacts book


This method returns all contacts IDs
getAllContacts(boolean withNumbers, boolean includesFullName,
boolean includesPicture, boolean includesNumbers,
boolean includesEmail, boolean includeAddress)

Deprecated.
this method was incorrectly introduced use getContacts instead
static
String[]

getAllContactsWithNumbers()

static
Contact

getContactById(String id)

static
Contact

static
Contact[]

This method returns all contacts that has a phone number


This method returns a Contact by the contact id
getContactById(String id, boolean includesFullName,
boolean includesPicture, boolean includesNumbers,
boolean includesEmail, boolean includeAddress)

This method returns a Contact by the contact id and fills it's data according to
the given flags
getContacts(boolean withNumbers, boolean includesFullName,
boolean includesPicture, boolean includesNumbers,
boolean includesEmail, boolean includeAddress)

Notice: this method might be very slow and should be invoked on a separate
thread! It might have platform specific optimizations over getAllContacts
followed by looping over individual contacts but that isn't guaranteed.
isAllContactsFast()

static
boolean

Indicates if the getAllContacts is platform optimized, notice that the method


might still take seconds or more to run so you should still use a separate
thread!
isGetAllContactsFast()

boolean

Class ContactsManager

Deprecated.
this method was incorrectly introduced and isn't static use isAllContactsFast
instead

2539

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ContactsManager
public ContactsManager()

Method Detail
getAllContacts
public static String[] getAllContacts()

This method returns all contacts IDs


Returns:
array of contacts IDs
getAllContactsWithNumbers
public static String[] getAllContactsWithNumbers()

This method returns all contacts that has a phone number


Returns:
array of contacts IDs
getContactById
public static Contact getContactById(String id)

This method returns a Contact by the contact id


Parameters:
id - of the Contact
Returns:
a Contact Object
getContactById
public static Contact getContactById(String id,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)

This method returns a Contact by the contact id and fills it's data according to the
given flags
Parameters:
id - of the Contact
includesFullName - if true try to fetch the full name of the Contact(not just
display name)
includesPicture - if true try to fetch the Contact Picture if exists
includesNumbers - if true try to fetch all Contact numbers
includesEmail - if ture try to fetch all Contact Emails
includeAddress - if ture try to fetch all Contact Addresses
Returns:
a Contact Object
createContact
public static String createContact(String
String
String
String
String
String

Methods inherited from class java.lang.Object

firstName,
familyName,
workPhone,
homePhone,
mobilePhone,
email)

2540

Overview (Codename One API)


Create a contact to the device contacts book
Parameters:
firstName - the Contact firstName
familyName - the Contact familyName
workPhone - the Contact work phone or null
homePhone - the Contact home phone or null
mobilePhone - the Contact mobile phone or null
email - the Contact email or null
Returns:
the contact id if creation succeeded or null if failed
deleteContact
public static boolean deleteContact(String id)

removed a contact from the device contacts book


Parameters:
id - the contact id to remove
Returns:
true if deletion succeeded false otherwise
getAllContacts
public Contact[] getAllContacts(boolean
boolean
boolean
boolean
boolean
boolean

withNumbers,
includesFullName,
includesPicture,
includesNumbers,
includesEmail,
includeAddress)

Deprecated. this method was incorrectly introduced use getContacts instead


Notice: this method might be very slow and should be invoked on a separate thread!
It might have platform specific optimizations over getAllContacts followed by looping
over individual contacts but that isn't guaranteed. See isGetAllContactsFast for
information.
Parameters:
withNumbers - if true returns only contacts that has a number
includesFullName - if true try to fetch the full name of the Contact(not just
display name)
includesPicture - if true try to fetch the Contact Picture if exists
includesNumbers - if true try to fetch all Contact numbers
includesEmail - if true try to fetch all Contact Emails
includeAddress - if true try to fetch all Contact Addresses
Returns:
array of the contacts
isGetAllContactsFast
public boolean isGetAllContactsFast()

Deprecated. this method was incorrectly introduced and isn't static use
isAllContactsFast instead
Indicates if the getAllContacts is platform optimized, notice that the method might still
take seconds or more to run so you should still use a separate thread!
Returns:
true if getAllContacts will perform faster that just getting each contact
getContacts
public static Contact[] getContacts(boolean
boolean
boolean
boolean
boolean
boolean

withNumbers,
includesFullName,
includesPicture,
includesNumbers,
includesEmail,
includeAddress)

Notice: this method might be very slow and should be invoked on a separate thread!
It might have platform specific optimizations over getAllContacts followed by looping
over individual contacts but that isn't guaranteed. See isGetAllContactsFast for
information.
Parameters:
withNumbers - if true returns only contacts that has a number

Method Detail

2541

Overview (Codename One API)


includesFullName

- if true try to fetch the full name of the Contact(not just

display name)
includesPicture - if true try to fetch the Contact Picture if
includesNumbers - if true try to fetch all Contact numbers
includesEmail - if true try to fetch all Contact Emails
includeAddress - if true try to fetch all Contact Addresses

exists

Returns:
array of the contacts
isAllContactsFast
public static boolean isAllContactsFast()

Indicates if the getAllContacts is platform optimized, notice that the method might still
take seconds or more to run so you should still use a separate thread!
Returns:
true if getAllContacts will perform faster that just getting each contact

Method Detail

2542

Overview (Codename One API)


com.codename1.contacts

Class Contact
java.lang.Object

com.codename1.contacts.Contact

public class
extends Object

This class represents a Contact information from the device Address Book

Constructor Summary
Constructor and Description
Contact()

Empty Constructor

Method Summary
Modifier
and Type

Method and Description


getAddresses()

Hashtable

long
String

Gets the Contact Addresses, the Hashtable contains key/value pairs where the
key is a String which represents the type of the Address, types can be: "home",
"work", "other" the value is an Address Object.
getBirthday()

Gets the Contact birthday


getDisplayName()

Gets the Contact Display Name


getEmails()

Hashtable

String
String
String
String

Gets the Contact Emails, the Hashtable contains key/value pairs where the key
is a String which represents the type of the Email, types can be: "home",
"mobile", "work", "other" the value is String of the email.
getFamilyName()

Gets Contact family name


getFirstName()

Gets Contact First Name


getId()

Gets the Contact unique id


getNote()

Gets Contact Note


getPhoneNumbers()

Hashtable

Image

Gets the Contact phone numbers, the Hashtable contains key/value pairs
where the key is a String which represents the type of the phone number, types
can be: "home", "mobile", "work", "fax", "other" the value is String of the phone
number.
getPhoto()

Gets the Contact photo


getPrimaryEmail()

String

Gets the primary email of this Contact, notice this can be null even though the
Contact has emails declared
getPrimaryPhoneNumber()

String

Class Contact

Gets the primary phone number of this Contact, notice this can be null even
though the Contact has phone numbers declared

2543

Overview (Codename One API)


String[]

getUrls()

Gets Contact urls


setAddresses(Hashtable addresses)

void

Sets the Contact Addresses


setBirthday(long birthday)

void

Sets the Contact birthday date


setDisplayName(String displayName)

void

Sets the Contact display name


setEmails(Hashtable emails)

void

Sets the Contact emails


setFamilyName(String familyName)

void

Sets Contact family name


setFirstName(String name)

void

Sets Contact first name


setId(String id)

void

Sets the Contact unique id


setNote(String note)

void

Sets Contact note


setPhoneNumbers(Hashtable phoneNumbers)

void

Sets Contact phone numbers


setPhoto(Image photo)

void

Sets Contact photo


setPrimaryEmail(String primaryEmail)

void

Sets Contact primary email


setPrimaryPhoneNumber(String primaryPhoneNumber)

void

Sets Contact primary phone number


setUrls(String[] urls)

void

Sets Contact urls

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Contact
public Contact()

Empty Constructor

Method Detail
getAddresses
public Hashtable getAddresses()

Gets the Contact Addresses, the Hashtable contains key/value pairs where the key is
a String which represents the type of the Address, types can be: "home", "work",
"other" the value is an Address Object.
Returns:
Hashtable of available addresses
getBirthday
public long getBirthday()

Gets the Contact birthday


Returns:
birth time

Method Summary

2544

Overview (Codename One API)


getDisplayName
public String getDisplayName()

Gets the Contact Display Name


Returns:
Display Name
getEmails
public Hashtable getEmails()

Gets the Contact Emails, the Hashtable contains key/value pairs where the key is a
String which represents the type of the Email, types can be: "home", "mobile", "work",
"other" the value is String of the email.
Returns:
Hashtable of available emails
getId
public String getId()

Gets the Contact unique id


Returns:
Contact unique id
getFirstName
public String getFirstName()

Gets Contact First Name


Returns:
Contact Name
getFamilyName
public String getFamilyName()

Gets Contact family name


Returns:
getNote
public String getNote()

Gets Contact Note


Returns:
Contact Note
getPhoneNumbers
public Hashtable getPhoneNumbers()

Gets the Contact phone numbers, the Hashtable contains key/value pairs where the
key is a String which represents the type of the phone number, types can be: "home",
"mobile", "work", "fax", "other" the value is String of the phone number.
Returns:
Hashtable of available phone numbers
getPhoto
public Image getPhoto()

Gets the Contact photo


Returns:
the Contact Photo or null if not available
getPrimaryEmail
public String getPrimaryEmail()

Gets the primary email of this Contact, notice this can be null even though the
Contact has emails declared
Returns:
the Contact primary email or null if not declared

Method Detail

2545

Overview (Codename One API)


getPrimaryPhoneNumber
public String getPrimaryPhoneNumber()

Gets the primary phone number of this Contact, notice this can be null even though
the Contact has phone numbers declared
Returns:
the Contact primary phone number or null if not declared
setAddresses
public void setAddresses(Hashtable addresses)

Sets the Contact Addresses


Parameters:
addresses - the Hashtable contains key/value pairs where the key is a String
which represents the type of the Address, types can be: "home", "work",
"other" the value is an Address Object.
setBirthday
public void setBirthday(long birthday)

Sets the Contact birthday date


Parameters:
birthday setDisplayName
public void setDisplayName(String displayName)

Sets the Contact display name


Parameters:
displayName setEmails
public void setEmails(Hashtable emails)

Sets the Contact emails


Parameters:
emails - the Hashtable contains key/value pairs where the key is a String
which represents the type of the Email, types can be: "home", "mobile",
"work", "other" the value is String of the email.
setId
public void setId(String id)

Sets the Contact unique id


Parameters:
id setFirstName
public void setFirstName(String name)

Sets Contact first name


Parameters:
name setFamilyName
public void setFamilyName(String familyName)

Sets Contact family name


Parameters:
familyName setNote
public void setNote(String note)

Sets Contact note


Parameters:

Method Detail

2546

Overview (Codename One API)


note setPhoneNumbers
public void setPhoneNumbers(Hashtable phoneNumbers)

Sets Contact phone numbers


Parameters:
phoneNumbers - the Hashtable contains key/value pairs where the key is a
String which represents the type of the phone number, types can be: "home",
"mobile", "work", "fax", "other" the value is String of the phone number.
setPhoto
public void setPhoto(Image photo)

Sets Contact photo


Parameters:
photo setPrimaryEmail
public void setPrimaryEmail(String primaryEmail)

Sets Contact primary email


Parameters:
primaryEmail setPrimaryPhoneNumber
public void setPrimaryPhoneNumber(String primaryPhoneNumber)

Sets Contact primary phone number


Parameters:
primaryPhoneNumber getUrls
public String[] getUrls()

Gets Contact urls


Returns:
setUrls
public void setUrls(String[] urls)

Sets Contact urls


Parameters:
urls -

Method Detail

2547

Overview (Codename One API)


com.codename1.contacts

Class Address
java.lang.Object

com.codename1.contacts.Address

public class
extends Object

This class represents a Contact Address

Constructor Summary
Constructor and Description
Address()

Empty Constructor

Method Summary
Modifier and Type

Method and Description


getCountry()

String

Gets Address Country


getLocality()

String

Gets Address Locality


getPostalCode()

String

Gets Address Postal Code


getRegion()

String

Gets Address Region


getStreetAddress()

String

Gets Address Street


setCountry(String country)

void

Sets Address Country


setLocality(String locality)

void

Sets Address Locality


setPostalCode(String postalCode)

void

Sets Address Postal Code


setRegion(String region)

void

Sets Address Region


setStreetAddress(String streetAddress)

void

Sets Address street

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Address
public Address()

Empty Constructor

Class Address

2548

Overview (Codename One API)


Method

Detail

getCountry
public String getCountry()

Gets Address Country


Returns:
getLocality
public String getLocality()

Gets Address Locality


Returns:
getPostalCode
public String getPostalCode()

Gets Address Postal Code


Returns:
getRegion
public String getRegion()

Gets Address Region


Returns:
getStreetAddress
public String getStreetAddress()

Gets Address Street


Returns:
setCountry
public void setCountry(String country)

Sets Address Country


setLocality
public void setLocality(String locality)

Sets Address Locality


setPostalCode
public void setPostalCode(String postalCode)

Sets Address Postal Code


setRegion
public void setRegion(String region)

Sets Address Region


setStreetAddress
public void setStreetAddress(String streetAddress)

Sets Address street

Method Detail

2549

Overview (Codename One API)


com.codename1.components

Class WebBrowser
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.WebBrowser
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A simple browser view that encapsulates a usable version of HTMLComponent or


BrowserComponent and automatically picks the right component for the platform preferring
BrowserComponent whenever it is supported.
On Android this component might show a native progress indicator dialog. You can disable that
functionality using the call.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
WebBrowser()

Default constructor

Method Summary
Modifier and Type

Method and Description


createDataURI(byte[] data, String mime)

static String

void

This method creates a data URI which allows developers creating HTML
into the HTML by appending them as a URI.
destroy()

Release WebBrowser native resources.


getBrowserNavigationCallback()

BrowserNavigationCallback

The browser navigation callback interface allows handling a case where


Java code.
getInternal()

Component

String

Since the internal component can be either an HTMLComponent or a Br


returned.
getPage()

Returns the page set by getPage for the GUI builder


getPropertyNames()

String[]

Class WebBrowser

A component may expose mutable property names for a UI designer to m


usage internally by the GUI builder code

2550

Overview (Codename One API)


getPropertyTypeNames()
String[]

Class[]
Object
String
String

This method is here to workaround an XMLVM array type bug where pro
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Imag
getPropertyTypes()

Matches the property names method (see that method for further details
getPropertyValue(String name)

Returns the current value of the property name, this method is used by t
getTitle()

Returns the title for the browser page


getURL()

The page URL


onError(String message, int errorCode)

void

This is a callback method to inform on an error.


onLoad(String url)

void

This is a callback method, this method is called after the url has been loa
onStart(String url)

void

This is a callback method, this method is called before the url has been l
reload()

void

Reload the current page

setBrowserNavigationCallback(BrowserNavigationCallback callback)

Set the browser navigation callback which allows handling a case where
Java code.

void

setPage(String html, String baseUrl)

void

Shows the given HTML in the native viewer

String

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed
setURL(String url)

void

Sets the page URL, jar: URL's must be supported by the implementation
stop()

void

Stop loading the current page

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,

Method Summary

2551

Overview (Codename One API)


getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
WebBrowser
public WebBrowser()

Default constructor

Method Detail
createDataURI
public static String createDataURI(byte[] data,
String mime)

This method creates a data URI which allows developers creating HTML for local use
to embed local images into the HTML by appending them as a URI. E.g. instead of
referencing a file or URL just load the image data and place the contents of this string
into the src attribute.
This is the easiest way to get an HTML with local images to work on all mobile
platforms.

Methods inherited from class com.codename1.ui.Component

2552

Overview (Codename One API)


Parameters:
data
mime

- data of an image
- the mime type of the image e.g. image/png

Returns:
a data URL that can be placed into the img src attribute in HTML e.g.
data:image/png;base64,encodedData
onStart
public void onStart(String url)

This is a callback method, this method is called before the url has been loaded
Parameters:
url onLoad
public void onLoad(String url)

This is a callback method, this method is called after the url has been loaded
Parameters:
url setBrowserNavigationCallback
public void setBrowserNavigationCallback(BrowserNavigationCallback callback)

Set the browser navigation callback which allows handling a case where a URL
invocation can be delegated to Java code. This allows binding Java side functionality
to JavaScript functionality in the same way PhoneGap/Cordova work
Parameters:
callback - the callback interface
getBrowserNavigationCallback
public BrowserNavigationCallback getBrowserNavigationCallback()

The browser navigation callback interface allows handling a case where a URL
invocation can be delegated to Java code. This allows binding Java side functionality
to JavaScript functionality in the same way PhoneGap/Cordova work
Returns:
the callback interface
onError
public void onError(String message,
int errorCode)

This is a callback method to inform on an error.


Parameters:
message errorCode getInternal
public Component getInternal()

Since the internal component can be either an HTMLComponent or a


BrowserComponent one of them will be returned. If you are targeting modern
smartphones only you can rely on this method returning a BrowserComponent
instance.
Returns:
BrowserComponent or HTMLComponent
getTitle
public String getTitle()

Returns the title for the browser page


Returns:
the title

Method Detail

2553

Overview (Codename One API)


getURL
public String getURL()

The page URL


Returns:
the URL
setURL
public void setURL(String url)

Sets the page URL, jar: URL's must be supported by the implementation
Parameters:
url - the URL
reload
public void reload()

Reload the current page


stop
public void stop()

Stop loading the current page


destroy
public void destroy()

Release WebBrowser native resources.


setPage
public void setPage(String html,
String baseUrl)

Shows the given HTML in the native viewer


Parameters:
html - HTML web page
baseUrl - base URL to associate with the HTML
getPage
public String getPage()

Returns the page set by getPage for the GUI builder


Returns:
the HTML page set manually
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties

Method Detail

2554

Overview (Codename One API)


getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2555

Overview (Codename One API)


com.codename1.components

Class ToastBar
java.lang.Object

com.codename1.components.ToastBar

public class
extends Object

An API to present status messages to the user in an unobtrusive manner. This is useful if there are
background tasks that need to display information to the user. E.g. If a network request fails, of let the
user know that "Jobs are being synchronized".

Example Usage
Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.show();
//... Some time later you must clear the status
status.clear();Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.setShowProgressIndicator(true);
status.show();
// ... Some time later you must clear it
status.clear();Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.showDelayed(300); // Wait 300 ms to show the status
// ... Some time later, clear the status... this may be before it shows at all
status.clear();Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.setExpires(3000); // only show the status for 3 seconds, then have it automatically clear
status.show();

Advanced Usage
See the StatusBarDemo

Screenshots
Status With Progress Bar

Class ToastBar

2556

Overview (Codename One API)

Status With Multi-Line Message

Video Demo
Note: the video above refers to the ToastBar based on its development name of StatusBar. This was
changed to avoid confusion with the iOS StatusBar.

Status With Progress Bar

2557

Overview (Codename One API)

Nested

Class Summary

Modifier and Type

Class and Description


ToastBar.Status

class

Represents a single status message.

Method Summary
Modifier and Type
ToastBar.Status

Method and Description


createStatus()

Creates a new Status.


getDefaultMessageUIID()

String

Gets the default UIID to be used for the style of the ToastBar text.
getDefaultUIID()

Gets the default UIID to be used for the style of the ToastBar
component.

String

static ToastBar

getInstance()

Gets reference to the singleton StatusBar instance


setDefaultMessageUIID(String defaultMessageUIID)
Sets the default UIID to be used for the style of the ToastBar

void

text.

setDefaultUIID(String defaultUIID)

Sets the defaults UIID to be used for the style of the ToastBar
component.

void

setVisible(boolean visible)
Shows or hides the ToastBar.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
getInstance
public static ToastBar getInstance()

Gets reference to the singleton StatusBar instance


Returns:
getDefaultUIID
public String getDefaultUIID()

Gets the default UIID to be used for the style of the ToastBar component. By default
this is "ToastBarComponent".
Returns:
the defaultUIID
setDefaultUIID
public void setDefaultUIID(String defaultUIID)

Sets the defaults UIID to be used for the style of the ToastBar component. By default
this is "ToastBarComponent"
Parameters:
defaultUIID - the defaultUIID to set

Nested Class Summary

2558

Overview (Codename One API)


getDefaultMessageUIID
public String getDefaultMessageUIID()

Gets the default UIID to be used for the style of the ToastBar text. By default this is
"ToastBarMessage"
Returns:
the defaultMessageUIID
setDefaultMessageUIID
public void setDefaultMessageUIID(String defaultMessageUIID)

Sets the default UIID to be used for the style of the ToastBar text. By default this is
"ToastBarMessage"
Parameters:
defaultMessageUIID - the defaultMessageUIID to set
createStatus
public ToastBar.Status createStatus()

Creates a new Status.


Returns:
setVisible
public void setVisible(boolean visible)

Shows or hides the ToastBar.


Parameters:
visible -

Method Detail

2559

Overview (Codename One API)


com.codename1.components

Class ToastBar.Status
java.lang.Object

com.codename1.components.ToastBar.Status
Enclosing class:
ToastBar

public class
extends Object

Represents a single status message.

Method Summary
Modifier
and Type
void
Image
String
String
int

Method and Description


clear()

Clears this status message.


getIcon()

Gets the icon (may be null) that is displayed with this status.
getMessage()

Returns the text that will be displayed for this status.


getMessageUIID()

Gets the UIID to use for styling the text of this status message.
getProgress()

Returns the progress of this status.


getUiid()

String

Gets the UIID that should be used for styling the status component while this
status is displayed.

boolean

isShowProgressIndicator()
setExpires(int millis)

void

void
void
void

Directs the status to be cleared (if it isn't already cleared() after a given number
of milliseconds.
setIcon(Image icon)

Sets the icon that is to be displayed with this status.


setMessage(String message)

Sets the message that should be displayed in the ToastBar.


setMessageUIID(String messageUIID)

Sets the UIID to use for styling the text of this status message.
setProgress(int progress)

void

Sets the progress (1..100) that should be displayed in the progress bar for this
status.
setShowProgressIndicator(boolean showProgressIndicator)

void

Sets whether this status message should include an infinite progress indicator
(e.g.
setUiid(String uiid)

void

void

Sets the UIID that should be used for styling the status component while this
status is displayed.
show()

Shows this status message.


showDelayed(int millis)

void

Class ToastBar.Status

Schedules this status message to be shown after a specified number of


milliseconds, if it hasn't been cleared or shown first.

2560

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
setExpires
public void setExpires(int millis)

Directs the status to be cleared (if it isn't already cleared() after a given number of
milliseconds.
Parameters:
millis - The maximum number of milliseconds that the status message
should be displayed for. Helpful for error messages that only need to be
displayed for a few seconds.
setMessage
public void setMessage(String message)

Sets the message that should be displayed in the ToastBar.


Parameters:
message setProgress
public void setProgress(int progress)

Sets the progress (1..100) that should be displayed in the progress bar for this status.
(Not tested or used yet).
Parameters:
progress show
public void show()

Shows this status message. Call this method after making any changes to the status
that you want to have displayed. This will always cause any currently-displayed
status to be replaced by this status.
If you don't want to show the status immediately, but rather to wait some delay, you
can use the showDelayed(int) method instead.
See Also:
showDelayed(int)

showDelayed
public void showDelayed(int millis)

Schedules this status message to be shown after a specified number of milliseconds,


if it hasn't been cleared or shown first.
This is handy if you want to show an status for an operation that usually completes
very quickly, but could potentially hang. In such a case you might decide not to
display a status message at all unless the operation takes more than 500ms to
complete.
If you want to show the status immediately, use the show() method instead.
Parameters:
millis

- Number of milliseconds to wait before showing the status.

Methods inherited from class java.lang.Object

2561

Overview (Codename One API)


clear
public void clear()

Clears this status message. This any pending "showDelayed" requests for this status.
getMessage
public String getMessage()

Returns the text that will be displayed for this status.


Returns:
the message
getProgress
public int getProgress()

Returns the progress of this status. A value of -1 indicates that the progress bar
should not be shown. Values between 0 and 100 inclusive will be rendered on a
progress bar (slider) in the status component.
Returns:
the progress
getIcon
public Image getIcon()

Gets the icon (may be null) that is displayed with this status.
Returns:
the icon
setIcon
public void setIcon(Image icon)

Sets the icon that is to be displayed with this status. Set this to null to not show an
icon.
Parameters:
icon - the icon to set
isShowProgressIndicator
public boolean isShowProgressIndicator()

Returns:
the showProgressIndicator
setShowProgressIndicator
public void setShowProgressIndicator(boolean showProgressIndicator)

Sets whether this status message should include an infinite progress indicator (e.g.
spinning beach ball).
Parameters:
showProgressIndicator - the showProgressIndicator to set
getMessageUIID
public String getMessageUIID()

Gets the UIID to use for styling the text of this status message.
Returns:
the messageUIID
setMessageUIID
public void setMessageUIID(String messageUIID)

Sets the UIID to use for styling the text of this status message.
Parameters:
messageUIID - the messageUIID to set

Method Detail

2562

Overview (Codename One API)


getUiid
public String getUiid()

Gets the UIID that should be used for styling the status component while this status is
displayed.
Returns:
the uiid
setUiid
public void setUiid(String uiid)

Sets the UIID that should be used for styling the status component while this status is
displayed.
Parameters:
uiid - the uiid to set

Method Detail

2563

Overview (Codename One API)


com.codename1.components

Class StorageImageAsync
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.components.StorageImageAsync

public class
extends EncodedImage

Asynchronous storage image that loads in the background and not during the paint cycle effectively
not blocking the EDT drawing speed.

Method Summary
Modifier and Type
boolean
static
StorageImageAsync

Method and Description


animate()
create(String fileName, Image placeholder)

Creates an encoded image that maps to a storage file thus allowing


to seamlessly cache images as needed.
getImageData()

Returns the byte array data backing the image allowing the image
to be stored and discarded completely from RAM.

byte[]

getInternal()
protected Image

boolean

Returns the actual image represented by the encoded image, this


image will be cached in a weak/soft reference internally.
isAnimation()

Returns true if this is an animated image


resetCache()

protected void

A subclass might choose to load asynchroniously and reset the


cache when the image is ready.

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getWidth, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha,
rotate, scale, scaled, scaledEncoded, scaledHeight, scaledSmallerRatio,
scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, createImage, createImage,
createImage, createImage, createImage, createImage, createImage,
createIndexed, createMask, createSVG, dispose, flipHorizontally,
flipVertically, getImageName, getRGB, getRGBCached, getSVGDocument,
isAlphaMutableImageSupported, isSVG, isSVGSupported, mirror,
modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

Class StorageImageAsync

2564

Overview (Codename One API)


resetCache
protected void resetCache()

A subclass might choose to load asynchroniously and reset the cache when the
image is ready.
Overrides:
resetCache in class EncodedImage
getInternal
protected Image getInternal()

Returns the actual image represented by the encoded image, this image will be
cached in a weak/soft reference internally. This method is useful to detect when the
system actually created an image instance. You shouldn't invoke this method
manually!
Overrides:
getInternal in class EncodedImage
Returns:
drawable image instance
getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
animate
public boolean animate()

Overrides:
animate

in class Image

isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class EncodedImage
Returns:
true if this image represents an animation
create
public static StorageImageAsync create(String fileName,
Image placeholder)

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
placeholder - an image that must be of the same size as the EncodedImage
Returns:
image that will load the file seamlessly

Method Detail

2565

Overview (Codename One API)


com.codename1.components

Class StorageImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.components.StorageImage

public class
extends EncodedImage

An encoded image that stores the actual data of the encoded image in storage.

Method Summary
Modifier and
Type
static
StorageImage

static
StorageImage

static
StorageImage
static
StorageImage
static
StorageImage

Method and Description


create(String fileName, byte[] data, int width, int height)

Creates an encoded image that maps to a storage file thus allowing to


seamlessly cache images as needed.
create(String fileName, byte[] data, int width, int height,
boolean keep)

Creates an encoded image that maps to a storage file thus allowing to


seamlessly cache images as needed.
create(String fileName, InputStream data, int width, int height)

Creates an encoded image that maps to a storage file thus allowing to


seamlessly cache images as needed.
create(String fileName, int width, int height)

Creates an encoded image that maps to a storage file thus allowing to


seamlessly cache images as needed.
create(String fileName, int width, int height, boolean keep)

Creates an encoded image that maps to a storage file thus allowing to


seamlessly cache images as needed.
getImageData()

byte[]

Returns the byte array data backing the image allowing the image to be
stored and discarded completely from RAM.

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getInternal, getWidth, isAnimation, isLocked, isOpaque, lock,
modifyAlpha, modifyAlpha, resetCache, rotate, scale, scaled, scaledEncoded,
scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


animate, applyMask, applyMask, applyMaskAutoScale, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, dispose,
flipHorizontally, flipVertically, getImageName, getRGB, getRGBCached,
getSVGDocument, isAlphaMutableImageSupported, isSVG, isSVGSupported,
mirror, modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class StorageImage

2566

Overview (Codename One API)

Method Detail
getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
create
public static StorageImage create(String fileName,
byte[] data,
int width,
int height)

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
data - the data
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
Returns:
image that will load the file seamlessly or null if the storage failed
create
public static StorageImage create(String fileName,
byte[] data,
int width,
int height,
boolean keep)

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
data - the data
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
keep - if set to true keeps the file in RAM once loaded
Returns:
image that will load the file seamlessly or null if the storage failed
create
public static StorageImage create(String fileName,
InputStream data,
int width,
int height)
throws IOException

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
data - the stream to cache
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)

Method Detail

2567

Overview (Codename One API)

Returns:
image that will load the file seamlessly
Throws:
IOException

create
public static StorageImage create(String fileName,
int width,
int height)

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
Returns:
image that will load the file seamlessly
create
public static StorageImage create(String fileName,
int width,
int height,
boolean keep)

Creates an encoded image that maps to a storage file thus allowing to seamlessly
cache images as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the storage file
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
keep - if set to true keeps the file in RAM once loaded
Returns:
image that will load the file seamlessly

Method Detail

2568

Overview (Codename One API)


com.codename1.components

Class SpanLabel
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.SpanLabel
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A multi line label component that can be easily localized, this is simply based on a text area combined
with a label.

SpanLabel d = new SpanLabel("Default SpanLabel that can seamlessly line break when the text is really long.");
d.setIcon(icon);
SpanLabel l = new SpanLabel("NORTH Positioned Icon SpanLabel that can seamlessly line break when the text is really lo
l.setIcon(icon);
l.setIconPosition(BorderLayout.NORTH);
SpanLabel r = new SpanLabel("SOUTH Positioned Icon SpanLabel that can seamlessly line break when the text is really lo
r.setIcon(icon);
r.setIconPosition(BorderLayout.SOUTH);
SpanLabel c = new SpanLabel("EAST Positioned Icon SpanLabel that can seamlessly line break when the text is really lon
c.setIcon(icon);
c.setIconPosition(BorderLayout.EAST);
hi.add(d).add(l).add(r).add(c);

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,

Class SpanLabel

2569

Overview (Codename One API)


DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
SpanLabel()

Default constructor will be useful when adding this to the GUI builder
SpanLabel(String txt)

Constructor accepting default text


SpanLabel(String txt, String textUiid)

Constructor accepting default text and uiid for the text

Method Summary
Modifier
and
Type
Image
String
String

Method and Description


getIcon()

Returns the image of the icon


getIconPosition()

Returns the icon position based on border layout constraints


getIconUIID()

Returns the UIID for the icon


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this AP
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
String
int
Style
String
Style
void
void
void
String
void

This method is here to workaround an XMLVM array type bug where property types aren't id
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListMod
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder
getText()

Returns the text of the label


getTextBlockAlign()

Returns the alignment of the whole text block and not the text within it!
getTextSelectedStyle()

Returns the text elements style object


getTextUIID()

Returns the uiid of the actual text


getTextUnselectedStyle()

Returns the text elements style object


setIcon(Image i)

Sets the icon for the label


setIconPosition(String t)

Sets the icon position based on border layout constraints


setIconUIID(String uiid)

Sets the uiid for the icon if present


setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if success
setText(String t)

Set the text of the label


setTextBlockAlign(int align)

void

Indicates the alignment of the whole text block, this is different from setting the alignment of
block since the UIID might have a border or other design element that won't be affected by

Fields inherited from class com.codename1.ui.Component

2570

Overview (Codename One API)


setTextSelectedStyle(Style t)

void

The text elements style object


setTextUIID(String uiid)

void

Sets the UIID for the actual text


setTextUnselectedStyle(Style t)

void

The text elements style object

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,

Method Summary

2571

Overview (Codename One API)


setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
SpanLabel
public SpanLabel()

Default constructor will be useful when adding this to the GUI builder
SpanLabel
public SpanLabel(String txt,
String textUiid)

Constructor accepting default text and uiid for the text


Parameters:
txt - the text
textUiid - the new text UIID
SpanLabel
public SpanLabel(String txt)

Constructor accepting default text

Method Detail
setTextUIID
public void setTextUIID(String uiid)

Sets the UIID for the actual text


Parameters:
uiid - the uiid
getTextUIID
public String getTextUIID()

Returns the uiid of the actual text


Returns:
the uiid
getTextUnselectedStyle
public Style getTextUnselectedStyle()

Returns the text elements style object


Returns:
the style object
setTextUnselectedStyle
public void setTextUnselectedStyle(Style t)

The text elements style object


Parameters:
t - the style object

Methods inherited from class com.codename1.ui.Component

2572

Overview (Codename One API)


getTextSelectedStyle
public Style getTextSelectedStyle()

Returns the text elements style object


Returns:
the style object
setTextSelectedStyle
public void setTextSelectedStyle(Style t)

The text elements style object


Parameters:
t - the style object
setIconUIID
public void setIconUIID(String uiid)

Sets the uiid for the icon if present


Parameters:
uiid - the uiid for the icon
getIconUIID
public String getIconUIID()

Returns the UIID for the icon


Returns:
the uiid
setText
public void setText(String t)

Set the text of the label


Parameters:
t - text of the label
setIcon
public void setIcon(Image i)

Sets the icon for the label


Parameters:
i - the icon
getText
public String getText()

Returns the text of the label


Returns:
the text
setTextBlockAlign
public void setTextBlockAlign(int align)

Indicates the alignment of the whole text block, this is different from setting the
alignment of the text within the block since the UIID might have a border or other
design element that won't be affected by such alignment. The default is none (-1)
which means no alignment takes place and the text block takes the whole width.
Parameters:
align - valid values are Component.LEFT, Component.RIGHT,
Component.CENTER. Anything else will stretch the text block
getTextBlockAlign
public int getTextBlockAlign()

Returns the alignment of the whole text block and not the text within it!
Returns:
-1 for unaligned otherwise one of Component.LEFT/RIGHT/CENTER

Method Detail

2573

Overview (Codename One API)


getIcon
public Image getIcon()

Returns the image of the icon


Returns:
the icon
setIconPosition
public void setIconPosition(String t)

Sets the icon position based on border layout constraints


Parameters:
t - position either North/South/East/West
getIconPosition
public String getIconPosition()

Returns the icon position based on border layout constraints


Returns:
position either North/South/East/West
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property

Method Detail

2574

Overview (Codename One API)


setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2575

Overview (Codename One API)


com.codename1.components

Class SpanButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.SpanButton
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A complex button similar to MultiButton that breaks lines automatically and looks like a regular button
(more or less). Unlike the multi button the span button has the UIID style of a button.

SpanButton sb = new SpanButton("SpanButton is a composite component (lead component) that looks/acts like a Button but
sb.setIcon(icon);
hi.add(sb);

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
SpanButton()

Default constructor will be useful when adding this to the GUI builder
SpanButton(String txt)

Constructor accepting default text


SpanButton(String txt, String textUiid)

Constructor accepting default text and uiid for the text

Method Summary
Modifier
and
Type
void
Command

Class SpanButton

Method and Description


addActionListener(ActionListener l)

Binds an action listener to button events


getCommand()

Returns the command instance of the button

2576

Overview (Codename One API)


getIcon()

Image

Returns the image of the icon


getIconPosition()

String

Returns the icon position based on border layout constraints


getIconUIID()

String

Returns the UIID for the icon


getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this AP
usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
String
String

This method is here to workaround an XMLVM array type bug where property types aren't id
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListMod
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI builder
getText()

Returns the text of the button


getTextUIID()

Returns the uiid of the actual text


removeActionListener(ActionListener l)

void

Removes the listener from tracking button events


setCommand(Command cmd)

void

Sets the command for the component


setIcon(Image i)

void

Sets the icon for the button


setIconPosition(String t)

void

Sets the icon position based on border layout constraints


setIconUIID(String uiid)

void

Sets the uiid for the icon if present

String

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if success
setText(String t)

void

Set the text of the button


setTextUIID(String uiid)

void

Sets the UIID for the actual text

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Method Summary

2577

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
SpanButton
public SpanButton()

Default constructor will be useful when adding this to the GUI builder
SpanButton
public SpanButton(String txt,
String textUiid)

Constructor accepting default text and uiid for the text


Parameters:
txt - the text

Methods inherited from class com.codename1.ui.Component

2578

Overview (Codename One API)


textUiid

- the new text UIID

SpanButton
public SpanButton(String txt)

Constructor accepting default text

Method Detail
setTextUIID
public void setTextUIID(String uiid)

Sets the UIID for the actual text


Parameters:
uiid - the uiid
getTextUIID
public String getTextUIID()

Returns the uiid of the actual text


Returns:
the uiid
setIconUIID
public void setIconUIID(String uiid)

Sets the uiid for the icon if present


Parameters:
uiid - the uiid for the icon
getIconUIID
public String getIconUIID()

Returns the UIID for the icon


Returns:
the uiid
setText
public void setText(String t)

Set the text of the button


Parameters:
t - text of the button
setIcon
public void setIcon(Image i)

Sets the icon for the button


Parameters:
i - the icon
getText
public String getText()

Returns the text of the button


Returns:
the text
getIcon
public Image getIcon()

Returns the image of the icon


Returns:
the icon

Constructor Detail

2579

Overview (Codename One API)


addActionListener
public void addActionListener(ActionListener l)

Binds an action listener to button events


Parameters:
l - the listener
removeActionListener
public void removeActionListener(ActionListener l)

Removes the listener from tracking button events


Parameters:
l - the listener
setIconPosition
public void setIconPosition(String t)

Sets the icon position based on border layout constraints


Parameters:
s - position either North/South/East/West
getIconPosition
public String getIconPosition()

Returns the icon position based on border layout constraints


Returns:
position either North/South/East/West
setCommand
public void setCommand(Command cmd)

Sets the command for the component


Parameters:
cmd - the command
getCommand
public Command getCommand()

Returns the command instance of the button


Returns:
the command instance of the button
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type

Method Detail

2580

Overview (Codename One API)

names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2581

Overview (Codename One API)


com.codename1.components

Class SliderBridge
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Slider

com.codename1.components.SliderBridge
All Implemented Interfaces:
Animation, StyleListener

public class
extends Slider

Binds a slider to network progress events so it shows the pro

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
SliderBridge()

Default constuctor
SliderBridge(ConnectionRequest source)

Displays progress only for the source object, every other object in the queue before
completion will produce an infinite progress.
SliderBridge(ConnectionRequest[] sources)

Allows displaying progress of multiple requests being sent

Method Summary
Modifier and Type
static void
static void

Method and Description


bindProgress(ConnectionRequest[] sources, Slider s)

Allows binding progress to an arbitrary slider


bindProgress(ConnectionRequest source, Slider s)

Allows binding progress to an arbitrary slider

Methods inherited from class com.codename1.ui.Slider


addActionListener, addDataChangedListener, animate, calcPreferredSize,
createInfinite, deinitialize, fireClicked, formattedValue, getIncrements,
getMaxValue, getMinValue, getProgress, getSliderEmptySelectedStyle,
getSliderEmptyUnselectedStyle, getSliderFullSelectedStyle,
getSliderFullUnselectedStyle, getStyle, getThumbImage, initComponent,
isEditable, isInfinite, isRenderPercentageOnTop, isRenderValueOnTop,
isSelectableInteraction, isStickyDrag, isVertical, keyPressed, keyReleased,
paintComponentBackground, pointerDragged, pointerPressed, pointerReleased,
refreshTheme, removeActionListener, removeDataChangedListener, setEditable,
setIncrements, setInfinite, setMaxValue, setMinValue, setProgress,
setRenderPercentageOnTop, setRenderValueOnTop, setThumbImage, setUIID,

Class SliderBridge

2582

Overview (Codename One API)


setVertical, shouldBlockSideSwipe

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getIcon, getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString, setAlignment,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setIcon, setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setText, setTextPosition, setTickerEnabled, setVerticalAlignment,
shouldTickerStart, startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit,
dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop,
focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles,
getAnimationManager, getBorder, getBottomGap, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX,
getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getTensileLength, getUIID, getUIManager,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from class com.codename1.ui.Slider

2583

Overview (Codename One API)

Constructor

Detail

SliderBridge
public SliderBridge()

Default constuctor
SliderBridge
public SliderBridge(ConnectionRequest source)

Displays progress only for the source object, every other object in the queue before
completion will produce an infinite progress. After 100% the progress will no longer
move.
Parameters:
source - the request whose progress should be followed
SliderBridge
public SliderBridge(ConnectionRequest[] sources)

Allows displaying progress of multiple requests being sent


Parameters:
sources - the requests whose progress should be followed

Method Detail
bindProgress
public static void bindProgress(ConnectionRequest source,
Slider s)

Allows binding progress to an arbitrary slider


Parameters:
source - the source connection request
s - the slider
bindProgress
public static void bindProgress(ConnectionRequest[] sources,
Slider s)

Allows binding progress to an arbitrary slider


Parameters:
sources - the source connection request (null for all network activity)
s - the slider

Constructor Detail

2584

Overview (Codename One API)


com.codename1.components

Class ShareButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.components.ShareButton
All Implemented Interfaces:
Animation, ActionListener, StyleListener

public class
extends Button
implements ActionListener

The share button allows sharing a String or an image either thru the defined sharing services or thru
the native OS sharing support. On Android & iOS the native sharing API is invoked for this class.
The code below demonstrates image sharing, notice that an image must be stored using the
FileSystemStorage API and shouldn't use a different API like Storage!
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");

Method Detail

2585

Overview (Codename One API)


Notice that share looks different on a device

Field Summary

Fields inherited from class com.codename1.ui.Button


STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ShareButton()

Default constructor

Class ShareButton

2586

Overview (Codename One API)

Method Summary
Modifier
and Type

Method and Description


actionPerformed(ActionEvent evt)

void

invoked when the button is pressed


addShareService(ShareService share)

void

Adds a sharing service.


getImagePathToShare()

String

Gets the image path to share


getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

String

Returns the current value of the property name, this method is used by the
GUI builder
getTextToShare()

Gets the text to share


setImageToShare(String imagePath, String imageMimeType)

void

Sets the image to share.


setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and
null if successful.
setTextToShare(String textToShare)

void

Sets the information to share

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, calcPreferredSize, dragInitiated, fireClicked,
getActionListeners, getBorder, getCommand, getDisabledIcon,
getIconFromState, getListeners, getPressedIcon, getReleaseRadius,
getRolloverIcon, getRolloverPressedIcon, getState, isAutoRelease,
isOppositeSide, isSelectableInteraction, isSelected, isToggle, keyPressed,
keyReleased, keyRepeated, pointerDragged, pointerHover,
pointerHoverReleased, pointerPressed, pointerReleased, pressed, released,
released, removeActionListener, resetFocusable, setAlignment,
setAutoRelease, setCommand, setDisabledIcon, setPressedIcon,
setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getIcon, getMask, getMaskedIcon, getMaskName, getPropertyTypeNames,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setIcon, setLegacyRenderer, setMask, setMaskName, setShiftMillimeters,
setShiftText, setShouldLocalize, setShowEvenIfBlank, setText,
setTextPosition, setTickerEnabled, setVerticalAlignment, shouldTickerStart,
startTicker, startTicker, stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,

Method Summary

2587

Overview (Codename One API)

getCloudDestinationProperty, getComponentForm, getComponentState,


getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ShareButton
public ShareButton()

Default constructor

Method Detail
setTextToShare
public void setTextToShare(String textToShare)

Sets the information to share


Parameters:
textToShare getTextToShare
public String getTextToShare()

Gets the text to share


Returns:

Methods inherited from class com.codename1.ui.Component

2588

Overview (Codename One API)


setImageToShare
public void setImageToShare(String imagePath,
String imageMimeType)

Sets the image to share. Notice some sharing services cannot share image and a
text, therefore if setTextToShare(...) is also used, the sharing service gives image
sharing higher priority.
Parameters:
imagePath - the full file path
imageMimeType - the image mime type e.g. image/png, image/jpeg
getImagePathToShare
public String getImagePathToShare()

Gets the image path to share


Returns:
addShareService
public void addShareService(ShareService share)

Adds a sharing service.


Parameters:
share - ShareService
actionPerformed
public void actionPerformed(ActionEvent evt)

invoked when the button is pressed


Specified by:
actionPerformed in interface ActionListener
Parameters:
evt getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Label
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Label
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Label
Parameters:
name - the name of the property
Returns:
the value of said property

Method Detail

2589

Overview (Codename One API)


setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Label
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2590

Overview (Codename One API)


com.codename1.components

Class ScaleImageLabel
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.components.ScaleImageLabel
All Implemented Interfaces:
Animation, StyleListener

public class
extends Label

Label that simplifies the usage of scale to fill/fit. This is effectively equivalent to just setting the style
image on a label but more convenient for some special circumstances. One major difference is that
preferred size equals the image in this case.
The default UIID for this component is "Label".
TableLayout tl = new TableLayout(2, 2);
Form hi = new Form("ScaleImageButton/Label", tl);
Style s = UIManager.getInstance().getComponentStyle("Button");
Image icon = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s);
ScaleImageLabel fillLabel = new ScaleImageLabel(icon);
fillLabel.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
ScaleImageButton fillButton = new ScaleImageButton(icon);
fillButton.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
hi.add(tl.createConstraint().widthPercentage(20), new ScaleImageButton(icon)).
add(tl.createConstraint().widthPercentage(80), new ScaleImageLabel(icon)).
add(fillLabel).
add(fillButton);
hi.show();

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ScaleImageLabel()

Default constructor

Class ScaleImageLabel

2591

Overview (Codename One API)


ScaleImageLabel(Image i)

Create a version with the given image

Method Summary
Modifier and
Type
protected
Dimension

Method and Description


calcPreferredSize()

Calculates the preferred size based on component content.


getBackgroundType()

byte

Returns the background type for the component


getIcon()

Image

Returns the background image


setBackgroundType(byte behavior)

Sets the behavior of the background to one of


Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL,
Style.BACKGROUND_IMAGE_SCALE

void

setIcon(Image i)

void

Instead of setting the icon sets the background image


setText(String text)

void

Scale image label doesn't support text this method is overriden to do nothing
setUIID(String id)

void

This method sets the Component the Unique identifier.

Methods inherited from class com.codename1.ui.Label


animate, bindProperty, getAlignment, getBaseline,
getBaselineResizeBehavior, getBindablePropertyNames,
getBindablePropertyTypes, getBoundPropertyValue, getGap, getMask,
getMaskedIcon, getMaskName, getPropertyNames, getPropertyTypeNames,
getPropertyTypes, getPropertyValue, getShiftMillimeters, getShiftText,
getStringWidth, getText, getTextPosition, getVerticalAlignment,
isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer,
isShouldLocalize, isShowEvenIfBlank, isTickerEnabled, isTickerRunning,
paint, paramString, setAlignment, setBoundPropertyValue,
setDefaultTickerEnabled, setEndsWith3Points, setGap, setLegacyRenderer,
setMask, setMaskName, setPropertyValue, setShiftMillimeters, setShiftText,
setShouldLocalize, setShowEvenIfBlank, setTextPosition, setTickerEnabled,
setVerticalAlignment, shouldTickerStart, startTicker, startTicker,
stopTicker, unbindProperty

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBorder, getBottomGap, getBounds,
getClientProperty, getCloudBoundProperty, getCloudDestinationProperty,
getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle,
getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed,
getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName,
getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp,
getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID,
getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY,
growShrink, handlesInput, hasFocus, initComponent, initCustomStyle,
initLaf, installDefaultPainter, isAlwaysTensile, isCellRenderer,
isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion,
isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents,
isHidden, isHideInPortrait, isInClippingRegion, isInitialized, isRTL,

Constructor Summary

2592

Overview (Codename One API)


isScrollable, isScrollableX, isScrollableY, isScrollVisible,
isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerPressed,
pointerReleased, pointerReleased, putClientProperty, refreshTheme,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ScaleImageLabel
public ScaleImageLabel()

Default constructor
ScaleImageLabel
public ScaleImageLabel(Image i)

Create a version with the given image


Parameters:
i - image

Method Detail
setBackgroundType
public void setBackgroundType(byte behavior)

Sets the behavior of the background to one of


Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL,
Style.BACKGROUND_IMAGE_SCALE
Parameters:
behavior - the background behavior
getBackgroundType
public byte getBackgroundType()

Returns the background type for the component


Returns:

Methods inherited from class com.codename1.ui.Component

2593

Overview (Codename One API)


One of Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL or
Style.BACKGROUND_IMAGE_SCALE
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Label
Returns:
the calculated preferred size based on component content
setIcon
public void setIcon(Image i)

Instead of setting the icon sets the background image


Overrides:
setIcon in class Label
Parameters:
i - the image
getIcon
public Image getIcon()

Returns the background image


Overrides:
getIcon in class Label
Returns:
the bg image
setText
public void setText(String text)

Scale image label doesn't support text this method is overriden to do nothing
Overrides:
setText in class Label
Parameters:
text - the string that the label presents.
setUIID
public void setUIID(String id)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized Overriden to prevent the setUIID from
replacing the code
Overrides:
setUIID in class Component
Parameters:
id - UIID unique identifier for component type

Method Detail

2594

Overview (Codename One API)


com.codename1.components

Class ScaleImageButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Label

com.codename1.ui.Button

com.codename1.components.ScaleImageButton
All Implemented Interfaces:
Animation, StyleListener

public class
extends Button

Button that simplifies the usage of scale to fill/fit. This is effectively equivalent to just setting the style
image on a button but more convenient for some special circumstances. One major difference is that
preferred size equals the image in this case.
The UIID of this class is ScaleImageButton, the original Button UIID isn't preserved since it might
cause an issue with the border.
TableLayout tl = new TableLayout(2, 2);
Form hi = new Form("ScaleImageButton/Label", tl);
Style s = UIManager.getInstance().getComponentStyle("Button");
Image icon = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s);
ScaleImageLabel fillLabel = new ScaleImageLabel(icon);
fillLabel.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
ScaleImageButton fillButton = new ScaleImageButton(icon);
fillButton.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
hi.add(tl.createConstraint().widthPercentage(20), new ScaleImageButton(icon)).
add(tl.createConstraint().widthPercentage(80), new ScaleImageLabel(icon)).
add(fillLabel).
add(fillButton);
hi.show();

Field Summary

Fields inherited from class com.codename1.ui.Button


STATE_DEFAULT, STATE_PRESSED, STATE_ROLLOVER

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Class ScaleImageButton

2595

Overview (Codename One API)


Constructor

Summary

Constructor and Description


ScaleImageButton()

Default constructor
ScaleImageButton(Image i)

Create a version with the given image

Method Summary
Modifier and
Type
protected
Dimension

Method and Description


calcPreferredSize()

Calculates the preferred size based on component content.


getBackgroundType()

byte

Returns the background type for the component


getIcon()

Image

Returns the background image


getIconFromState()

Image

Returns the icon for the button based on its current state
setBackgroundType(byte behavior)

Sets the behavior of the background to one of


Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL,
Style.BACKGROUND_IMAGE_SCALE

void

setIcon(Image i)

void

Instead of setting the icon sets the background image


setText(String text)

void

Scale image label doesn't support text this method is overriden to do nothing
setUIID(String id)

void

This method sets the Component the Unique identifier.

Methods inherited from class com.codename1.ui.Button


addActionListener, animate, dragInitiated, fireClicked, getActionListeners,
getBorder, getCommand, getDisabledIcon, getListeners, getPressedIcon,
getReleaseRadius, getRolloverIcon, getRolloverPressedIcon, getState,
isAutoRelease, isOppositeSide, isSelectableInteraction, isSelected,
isToggle, keyPressed, keyReleased, keyRepeated, pointerDragged,
pointerHover, pointerHoverReleased, pointerPressed, pointerReleased,
pressed, released, released, removeActionListener, resetFocusable,
setAlignment, setAutoRelease, setCommand, setDisabledIcon, setPressedIcon,
setReleaseRadius, setRolloverIcon, setRolloverPressedIcon, setToggle

Methods inherited from class com.codename1.ui.Label


bindProperty, getAlignment, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue,
getGap, getMask, getMaskedIcon, getMaskName, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getShiftMillimeters, getShiftText, getStringWidth, getText,
getTextPosition, getVerticalAlignment, isDefaultTickerEnabled,
isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank,
isTickerEnabled, isTickerRunning, paint, paramString,
setBoundPropertyValue, setDefaultTickerEnabled, setEndsWith3Points, setGap,
setLegacyRenderer, setMask, setMaskName, setPropertyValue,
setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank,
setTextPosition, setTickerEnabled, setVerticalAlignment, shouldTickerStart,
startTicker, startTicker, stopTicker, unbindProperty

Constructor Summary

2596

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
calcScrollSize, cancelRepaints, clearClientProperties, contains,
createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, drawDraggedImage, drop, focusGained,
focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager,
getBottomGap, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUnselectedStyle, setVisible,
setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
ScaleImageButton
public ScaleImageButton()

Default constructor
ScaleImageButton
public ScaleImageButton(Image i)

Create a version with the given image


Parameters:
i - image

Methods inherited from class com.codename1.ui.Component

2597

Overview (Codename One API)

Method Detail
setBackgroundType
public void setBackgroundType(byte behavior)

Sets the behavior of the background to one of


Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL,
Style.BACKGROUND_IMAGE_SCALE
Parameters:
behavior - the background behavior
getBackgroundType
public byte getBackgroundType()

Returns the background type for the component


Returns:
One of Style.BACKGROUND_IMAGE_SCALED_FIT,
Style.BACKGROUND_IMAGE_SCALED_FILL or
Style.BACKGROUND_IMAGE_SCALE
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Button
Returns:
the calculated preferred size based on component content
setUIID
public void setUIID(String id)

This method sets the Component the Unique identifier. This method should be used
before a component has been initialized Overriden to prevent the setUIID from
replacing the code
Overrides:
setUIID in class Component
Parameters:
id - UIID unique identifier for component type
setIcon
public void setIcon(Image i)

Instead of setting the icon sets the background image


Overrides:
setIcon in class Label
Parameters:
i - the image
getIcon
public Image getIcon()

Returns the background image


Overrides:
getIcon in class Label
Returns:
the bg image
setText
public void setText(String text)

Scale image label doesn't support text this method is overriden to do nothing

Method Detail

2598

Overview (Codename One API)

Overrides:
setText

in class Label

Parameters:
text - the string that the label presents.
getIconFromState
public Image getIconFromState()

Returns the icon for the button based on its current state Overriden to return getIcon
always.
Overrides:
getIconFromState in class Button
Returns:
the button icon based on its current state

Method Detail

2599

Overview (Codename One API)


com.codename1.components

Class ReplaceableImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.components.ReplaceableImage

public class
extends EncodedImage

Allows the image data to be replaced at runtime when a different image is available. The only
limitation is that the image width/height must be identical and opacity status can't change (an opaque
image can't be made translucent and visa versa).

Method Summary
Modifier and Type
boolean
static
ReplaceableImage

Method and Description


animate()
create(EncodedImage placeholder)

Creates an encoded image that can later be replaced with a different


image
getImageData()

Returns the byte array data backing the image allowing the image to
be stored and discarded completely from RAM.

byte[]

boolean
boolean

isAnimation()

Returns true if this is an animated image


isOpaque()

Indicates whether this image is opaque or not


replace(EncodedImage newImage)

Replaces the current image with the new image which must match
the dimensions etc.

void

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getInternal, getWidth, isLocked, lock, modifyAlpha, modifyAlpha,
resetCache, rotate, scale, scaled, scaledEncoded, scaledHeight,
scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, createImage, createImage,
createImage, createImage, createImage, createImage, createImage,
createIndexed, createMask, createSVG, dispose, flipHorizontally,
flipVertically, getImageName, getRGB, getRGBCached, getSVGDocument,
isAlphaMutableImageSupported, isSVG, isSVGSupported, mirror,
modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

Class ReplaceableImage

2600

Overview (Codename One API)


getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
replace
public void replace(EncodedImage newImage)

Replaces the current image with the new image which must match the dimensions
etc. of the previous image.
Parameters:
newImage - the image to apply
create
public static ReplaceableImage create(EncodedImage placeholder)

Creates an encoded image that can later be replaced with a different image
Parameters:
placeholder - a temporary image
Returns:
image that will be replaceable later on
animate
public boolean animate()

Overrides:
animate

in class Image

isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class EncodedImage
Returns:
true if this image represents an animation
isOpaque
public boolean isOpaque()

Indicates whether this image is opaque or not


Overrides:
isOpaque in class EncodedImage
Returns:
true if the image is completely opqaque which allows for some heavy
optimizations

Method Detail

2601

Overview (Codename One API)


com.codename1.components

Class RSSReader
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.List

com.codename1.components.RSSReader
All Implemented Interfaces:
Animation, StyleListener

public class
extends List

A List implementing an RSS reader that automatically populates itself with content from the RSS
chanel. When clicking an article it displays the HTML content of said article in a new Form.

Field Summary

Fields inherited from class com.codename1.ui.List


FIXED_CENTER, FIXED_LEAD, FIXED_NONE, FIXED_NONE_CYCLIC,
FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE, FIXED_TRAIL, HORIZONTAL, VERTICAL

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
RSSReader()

Creates an rss reader instance

Method Summary
Modifier
and Type
Image
int
String

Method and Description


getIconPlaceholder()
getLimit()

Places a limit on the number of RSS entries requested from the server
getProgressTitle()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Container

Class RSSReader

Returns the current value of the property name, this method is used by the
GUI builder
getTargetContainer()

The form/container to which the RSS will navigate when clicking a RSS entry

2602

Overview (Codename One API)


getURL()

String

The URL of the RSS stream

protected
void

initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready
for action" component state
isAddBackToTaget()

boolean

Indicates whether a back command should be added implicitly to the target


container

boolean

isBlockList()
sendRequest()

void

Send the request to the server, will only work once.


setAddBackToTaget(boolean addBackToTaget)

void

Indicates whether a back command should be added implicitly to the target


container

void

setBlockList(boolean blockList)

void

setIconPlaceholder(Image iconPlaceholder)
setLimit(int limit)

void

Places a limit on the number of RSS entries requested from the server

static void
static void
void

setMoreDescription(String d)

Set the description for the "more" request


setMoreTitle(String t)

Set the title for the "more" request


setProgressTitle(String progressTitle)
setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and
null if successful.

String

setTargetContainer(Container targetContainer)

void

The form/container to which the RSS will navigate when clicking a RSS entry
setURL(String url)

void

The URL of the RSS stream

protected
void

showRSSEntry(Hashtable h)

Shows a form containing the RSS entry

Methods inherited from class com.codename1.ui.List


addActionListener, addItem, addSelectionListener, animate,
calcPreferredSize, fireActionEvent, fireActionEvent, fireClicked,
getActionListeners, getCurrentSelected, getDragRegionStatus,
getFixedSelection, getGridPosX, getGridPosY, getHint, getHintIcon,
getItemGap, getListeners, getListSizeCalculationSampleCount,
getMaxElementHeight, getMinElementHeight, getModel, getOrientation,
getRenderer, getRenderingPrototype, getSelectedIndex, getSelectedItem,
getSelectedRect, getSideGap, getVisibleBounds, initLaf, isCommandList,
isDefaultFireOnClick, isDefaultIgnoreFocusComponentWhenUnfocused,
isIgnoreFocusComponentWhenUnfocused, isLongPointerPressActionEnabled,
isMutableRendererBackgrounds, isNumericKeyActions, isScrollableX,
isScrollableY, isSelectableInteraction, isTactileTouch, keyPressed,
keyReleased, laidOut, listSelectionChanged, longPointerPress, modelChanged,
paint, paramString, pointerDragged, pointerHover, pointerHoverReleased,
pointerPressed, pointerReleased, refreshTheme, removeActionListener,
removeSelectionListener, scrollRectToVisible, setCommandList,
setDefaultFireOnClick, setDefaultIgnoreFocusComponentWhenUnfocused,
setFireOnClick, setFixedSelection, setHandlesInput, setHint, setHint,
setHintIcon, setIgnoreFocusComponentWhenUnfocused, setInputOnFocus,
setItemGap, setListCellRenderer, setListSizeCalculationSampleCount,
setLongPointerPressActionEnabled, setMaxElementHeight, setMinElementHeight,
setModel, setMutableRendererBackgrounds, setNumericKeyActions,
setOrientation, setPaintFocusBehindList, setRenderer,
setRenderingPrototype, setScrollToSelected, setSelectedIndex,
setSelectedIndex, setSelectedItem, setShouldCalcPreferredSize,
shouldRenderSelection, size

Method Summary

2603

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitialize, deinitializeCustomStyle,
dragEnter, dragExit, dragFinished, draggingOver, dragInitiated,
drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedStyle, getStyle, getTensileLength,
getUIID, getUIManager, getUnselectedStyle, getWidth, getX, getY,
growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTensileDragEnabled,
isVisible, keyRepeated, longKeyPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
RSSReader
public RSSReader()

Creates an rss reader instance

Method Detail

Methods inherited from class com.codename1.ui.Component

2604

Overview (Codename One API)


setMoreDescription
public static void setMoreDescription(String d)

Set the description for the "more" request


Parameters:
d - the description
setMoreTitle
public static void setMoreTitle(String t)

Set the title for the "more" request


Parameters:
t - new title
setURL
public void setURL(String url)

The URL of the RSS stream


Parameters:
url - The URL of the RSS stream
sendRequest
public void sendRequest()

Send the request to the server, will only work once. This is called implicitly when the
list is initialized
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
getURL
public String getURL()

The URL of the RSS stream


Returns:
The URL of the RSS stream
getIconPlaceholder
public Image getIconPlaceholder()

Returns:
the iconPlaceholder
setIconPlaceholder
public void setIconPlaceholder(Image iconPlaceholder)

Parameters:
iconPlaceholder

- the iconPlaceholder to set

showRSSEntry
protected void showRSSEntry(Hashtable h)

Shows a form containing the RSS entry


Parameters:
h - the parsed entry
getLimit
public int getLimit()

Places a limit on the number of RSS entries requested from the server
Returns:

Method Detail

2605

Overview (Codename One API)


the limit
setLimit
public void setLimit(int limit)

Places a limit on the number of RSS entries requested from the server
Parameters:
limit - the limit to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
isBlockList
public boolean isBlockList()

Returns:
the blockList
setBlockList
public void setBlockList(boolean blockList)

Parameters:
blockList

Method Detail

- the blockList to set

2606

Overview (Codename One API)


getProgressTitle
public String getProgressTitle()

Returns:
the progressTitle
setProgressTitle
public void setProgressTitle(String progressTitle)

Parameters:
progressTitle

- the progressTitle to set

getTargetContainer
public Container getTargetContainer()

The form/container to which the RSS will navigate when clicking a RSS entry
Returns:
the targetContainer
setTargetContainer
public void setTargetContainer(Container targetContainer)

The form/container to which the RSS will navigate when clicking a RSS entry
Parameters:
targetContainer - the targetContainer to set
isAddBackToTaget
public boolean isAddBackToTaget()

Indicates whether a back command should be added implicitly to the target container
Returns:
the addBackToTaget
setAddBackToTaget
public void setAddBackToTaget(boolean addBackToTaget)

Indicates whether a back command should be added implicitly to the target container
Parameters:
addBackToTaget - the addBackToTaget to set

Method Detail

2607

Overview (Codename One API)


com.codename1.components

Class Progress
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.Form

com.codename1.ui.Dialog

com.codename1.components.Progress
All Implemented Interfaces:
Animation, ActionListener, StyleListener, Iterable<Component>

public class
extends Dialog
implements ActionListener

Displays a progress dialog with the ability to cancel an ongoing operation

Field Summary

Fields inherited from class com.codename1.ui.Dialog


TYPE_ALARM, TYPE_CONFIRMATION, TYPE_ERROR, TYPE_INFO, TYPE_NONE,
TYPE_WARNING

Fields inherited from class com.codename1.ui.Form


focusScrolling

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
Progress(String title, ConnectionRequest request)

Binds the progress UI to the completion of this request


Progress(String title, ConnectionRequest request, boolean showPercentage)

Binds the progress UI to the completion of this request

Method Summary
Modifier
and Type
protected
void
void
void

Class Progress

Method and Description


actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point


rather than implementing many command instances
actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component


dispose()

2608

Overview (Codename One API)


Closes the current form and returns to the previous form, releasing the EDT in
the process
boolean
boolean

isAutoShow()

Shows the progress automatically when the request processing is started


isDisposeOnCompletion()
setAutoShow(boolean autoShow)

void

Shows the progress automatically when the request processing is started

void

setDisposeOnCompletion(boolean disposeOnCompletion)

Methods inherited from class com.codename1.ui.Dialog


addComponent, addComponent, addComponent, addComponent, animate,
autoAdjust, getBlurBackgroundRadius, getContentPane,
getDefaultBlurBackgroundRadius, getDefaultDialogPosition,
getDefaultDialogType, getDialogComponent, getDialogPosition,
getDialogPreferredSize, getDialogStyle, getDialogType, getDialogUIID,
getLayout, getPopupDirectionBiasPortrait, getTitle, getTitleComponent,
getTitleStyle, growOrShrink, initLaf, isAutoAdjustDialogSize,
isAutoDispose, isCommandsAsButtons, isDisableStaticDialogScrolling,
isDisposeWhenPointerOutOfBounds, keyReleased, onShow, placeButtonCommands,
pointerPressed, pointerReleased, removeAll, removeComponent,
setAutoAdjustDialogSize, setAutoDispose, setBlurBackgroundRadius,
setCommandsAsButtons, setDefaultBlurBackgroundRadius,
setDefaultDialogPosition, setDefaultDialogType, setDialogPosition,
setDialogStyle, setDialogType, setDialogUIID,
setDisableStaticDialogScrolling, setDisposeWhenPointerOutOfBounds,
setLayout, setPopupDirectionBiasPortrait, setScrollable, setTimeout,
setTitle, setTitleComponent, setTitleComponent, show, show, show, show,
show, show, show, show, show, show, show, show, show, show, show, show,
showAtPosition, showBack, showDialog, showModeless, showPacked,
showPopupDialog, showPopupDialog, showStetched, showStretched,
wasDisposedDueToOutOfBoundsTouch, wasDisposedDueToRotation

Methods inherited from class com.codename1.ui.Form


addCommand, addCommand, addCommandListener, addGameKeyListener,
addKeyListener, addOrientationListener, addShowListener,
addSizeChangedListener, deregisterAnimated, dispatchCommand,
findNextFocusHorizontal, findNextFocusVertical, getAnimationManager,
getBackCommand, getClearCommand, getCommand, getCommandCount,
getComponentForm, getComponentIndex, getDefaultCommand,
getDragRegionStatus, getEditOnShow, getFocused, getGlassPane,
getLayeredPane, getLayeredPane, getMenuBar, getMenuStyle, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getScrollAnimationSpeed, getSoftButton, getSoftButtonCount, getTintColor,
getTitleArea, getToolbar, getTransitionInAnimator,
getTransitionOutAnimator, getUIManager, grabAnimationLock, hasMedia,
hideNotify, isAlwaysTensile, isCyclicFocus, isDragRegion, isFocusScrolling,
isFormBottomPaddingEditingMode, isMinimizeOnBack, isScrollable,
isSingleFocusMode, isSmoothScrolling, keyPressed, keyRepeated,
longKeyPress, longPointerPress, onShowCompleted, paint, paintBackground,
paramString, pointerDragged, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, refreshTheme, registerAnimated,
releaseAnimationLock, removeAllCommands, removeAllShowListeners,
removeCommand, removeCommandListener, removeGameKeyListener,
removeKeyListener, removeOrientationListener, removeShowListener,
removeSizeChangedListener, replace, replaceAndWait,
scrollComponentToVisible, setAlwaysTensile, setBackCommand, setBgImage,
setClearCommand, setCyclicFocus, setDefaultCommand, setEditOnShow,
setFocused, setFocusScrolling, setFormBottomPaddingEditingMode,
setGlassPane, setMenuBar, setMenuCellRenderer, setMenuTransitions,
setMinimizeOnBack, setPropertyValue, setRTL, setScrollableX,
setScrollableY, setScrollAnimationSpeed, setSmoothScrolling, setTintColor,
setTitleStyle, setToolbar, setToolBar, setTransitionInAnimator,
setTransitionOutAnimator, setUIManager, setVisible,
shouldSendPointerReleaseToOtherForm, showNotify, sizeChanged

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,

Method Summary

2609

Overview (Codename One API)


animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getGridPosX,
getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled,
isScrollableX, isScrollableY, isSelectableInteraction, iterator,
layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass,
replace, replaceAndWait, replaceAndWait, revalidate, setCellRenderer,
setEnabled, setLeadComponent, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentState, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragSpeed,
getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollVisible, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut,
onScrollX, onScrollY, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerPressed,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle,
setSameHeight, setSameWidth, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString,
unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Progress
public Progress(String title,
ConnectionRequest request)

Binds the progress UI to the completion of this request

Methods inherited from class com.codename1.ui.Container

2610

Overview (Codename One API)


Parameters:
title - the title of the progress dialog
request - the network request pending

Progress
public Progress(String title,
ConnectionRequest request,
boolean showPercentage)

Binds the progress UI to the completion of this request


Parameters:
title - the title of the progress dialog
request - the network request pending
showPercentage - shows percentage on the progress bar

Method Detail
actionCommand
protected void actionCommand(Command cmd)

Invoked to allow subclasses of form to handle a command from one point rather than
implementing many command instances
Overrides:
actionCommand in class Dialog
Parameters:
cmd - the action command
dispose
public void dispose()

Closes the current form and returns to the previous form, releasing the EDT in the
process
Overrides:
dispose in class Dialog
isDisposeOnCompletion
public boolean isDisposeOnCompletion()

Returns:
the disposeOnCompletion
setDisposeOnCompletion
public void setDisposeOnCompletion(boolean disposeOnCompletion)

Parameters:
disposeOnCompletion

- the disposeOnCompletion to set

actionPerformed
public void actionPerformed(ActionEvent evt)

Invoked when an action occurred on a component


Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - event object describing the source of the action as well as its trigger
isAutoShow
public boolean isAutoShow()

Shows the progress automatically when the request processing is started


Returns:
the autoShow

Constructor Detail

2611

Overview (Codename One API)


setAutoShow
public void setAutoShow(boolean autoShow)

Shows the progress automatically when the request processing is started


Parameters:
autoShow - the autoShow to set

Method Detail

2612

Overview (Codename One API)


com.codename1.components

Class OnOffSwitch
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.OnOffSwitch
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

The on/off switch is a checkbox of sort (although it derives container) that represents its state as a
switch each of which has a short label associated with it. It has two types: Android and iOS. The types
differ in the way that they are rendered. The Android type (the default) is just a button with a label that
can be moved/dragged between the two states. The iOS version is more elaborate due to the look of
that platform.

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
OnOffSwitch()

Class OnOffSwitch

2613

Overview (Codename One API)


Default constructor

Method Summary
Modifier and
Type
void
protected
Dimension
protected
void

Method and Description


addActionListener(ActionListener l)

Adds a listener to the switch which will cause an event to dispatch on click
calcPreferredSize()

Calculates the preferred size based on component content.


deinitialize()

Invoked to indicate that the component initialization is being reversed since


the component was detached from the container hierarchy.
getActionListeners()

Vector

Deprecated.
use the version that returns a collection
getComponentState()

Object

Collection
String
String

Some components may optionally generate a state which can then be


restored using setCompnentState().
getListeners()

Returns a collection containing the action listeners for this button


getOff()

Label for the off mode


getOn()

Label for the on mode


getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Image
Image
Image
protected
void
boolean
protected
boolean
boolean

Returns the current value of the property name, this method is used by the
GUI builder
getSwitchMaskImage()

Gets the image that is used for the mask.


getSwitchOffImage()

Gets the image that is used for the "Off" state of the switch.
getSwitchOnImage()

Gets the image that is used for the "On" state of the switch.
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and


"ready for action" component state
isNoTextMode()

iOS 7 changed the switch to not include any text


isStickyDrag()

Returns true if the component is interested in receiving drag/pointer release


events even after the gesture exceeded its boundaries.
isValue()

The value of the switch


paint(Graphics g)

void

void
void

Constructor Summary

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF
perform the rendering.
pointerDragged(int x, int y)

If this Component is focused, the pointer dragged event will call this method
pointerPressed(int x, int y)

If this Component is focused, the pointer pressed event will call this method

2614

Overview (Codename One API)


pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this method
removeActionListener(ActionListener l)

void

Removes the given action listener from the switch

protected
void

resetFocusable()

Restores the state of the focusable flag to its default state


setComponentState(Object state)

If getComponentState returned a value the setter can update the value and
restore the prior state.

void

setNoTextMode(boolean noTextMode)

void

iOS 7 changed the switch to not include any text


setOff(String off)

void

Label for the off mode


setOn(String on)

void

Label for the on mode


setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and
null if successful.
setSwitchMaskImage(Image switchMaskImage)

void

Sets the image that should be used for the "On" state.
setSwitchOffImage(Image switchOffImage)

void

Sets the image that should be used for the "Off" state.
setSwitchOnImage(Image switchOnImage)

void

Sets the image that should be used for the "Off" state.
setValue(boolean value)

void

The value of the switch

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paintComponentBackground, paintGlass,
paramString, pointerHover, refreshTheme, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getDirtyRegion,
getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,

Method Summary

2615

Overview (Codename One API)


getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerHoverPressed,
pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue,
setCloudBoundProperty, setCloudDestinationProperty, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
OnOffSwitch
public OnOffSwitch()

Default constructor

Method Detail
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content
resetFocusable
protected void resetFocusable()

Restores the state of the focusable flag to its default state


Overrides:
resetFocusable in class Component

Methods inherited from class com.codename1.ui.Component

2616

Overview (Codename One API)


isStickyDrag
protected boolean isStickyDrag()

Returns true if the component is interested in receiving drag/pointer release events


even after the gesture exceeded its boundaries. This is useful for spinners etc. where
the motion might continue beyond the size of the component
Overrides:
isStickyDrag in class Component
Returns:
false by default
addActionListener
public void addActionListener(ActionListener l)

Adds a listener to the switch which will cause an event to dispatch on click
Parameters:
l - implementation of the action listener interface
removeActionListener
public void removeActionListener(ActionListener l)

Removes the given action listener from the switch


Parameters:
l - implementation of the action listener interface
getActionListeners
public Vector getActionListeners()

Deprecated. use the version that returns a collection


Returns a vector containing the action listeners for this button
Returns:
the action listeners
getListeners
public Collection getListeners()

Returns a collection containing the action listeners for this button


Returns:
the action listeners
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Container
Parameters:
g - the component graphics
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to

Method Detail

2617

Overview (Codename One API)


deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Container
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
getOn
public String getOn()

Label for the on mode


Returns:
the on
setOn
public void setOn(String on)

Label for the on mode


Parameters:
on - the on to set
getOff
public String getOff()

Label for the off mode


Returns:
the off
setOff
public void setOff(String off)

Label for the off mode


Parameters:
off - the off to set

Method Detail

2618

Overview (Codename One API)


isValue
public boolean isValue()

The value of the switch


Returns:
the value
setValue
public void setValue(boolean value)

The value of the switch


Parameters:
value - the value to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getComponentState
public Object getComponentState()

Some components may optionally generate a state which can then be restored using
setCompnentState(). This method is used by the UIBuilder.
Overrides:
getComponentState in class Component
Returns:
the component state or null for undefined state.
setComponentState
public void setComponentState(Object state)

If getComponentState returned a value the setter can update the value and restore
the prior state.
Overrides:
setComponentState in class Component
Parameters:
state - the non-null state
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property

Method Detail

2619

Overview (Codename One API)


setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
isNoTextMode
public boolean isNoTextMode()

iOS 7 changed the switch to not include any text


Returns:
the noTextMode
setNoTextMode
public void setNoTextMode(boolean noTextMode)

iOS 7 changed the switch to not include any text


Parameters:
noTextMode - the noTextMode to set
getSwitchOnImage
public Image getSwitchOnImage()

Gets the image that is used for the "On" state of the switch.
Returns:
The image that will be used for the "On" state. If the "onOffIOSModeBool"
theme constant is false and the switchOnImage hasn't been explicitly set by
the setSwitchOnImage(com.codename1.ui.Image) method, then this will return
null.
See Also:
setSwitchOnImage(com.codename1.ui.Image), getSwitchOffImage(),
getSwitchMaskImage()

setSwitchOnImage
public void setSwitchOnImage(Image switchOnImage)

Sets the image that should be used for the "Off" state. Note: This option is only used
if the "onOffIOSModeBool" theme constant is enabled.
Note: If the "onOffIOSModeBool" theme constant is false and you set this image, you
must also set the "Off" image with setSwitchOffImage(com.codename1.ui.Image) and
the "Mask" image with setSwitchMaskImage(com.codename1.ui.Image).
Parameters:
switchOnImage

- the switchOnImage to set

See Also:
getSwitchOnImage(), setSwitchMaskImage(com.codename1.ui.Image),
setSwitchOffImage(com.codename1.ui.Image)

getSwitchOffImage
public Image getSwitchOffImage()

Gets the image that is used for the "Off" state of the switch.
Returns:
The image that will be used for the "Off" state. If the "onOffIOSModeBool"
theme constant is false and the switchOffImage hasn't been explicitly set by
the setSwitchOffImage(com.codename1.ui.Image) method, then this will

Method Detail

2620

Overview (Codename One API)


return null.
See Also:
setSwitchOffImage(com.codename1.ui.Image), getSwitchOnImage(),
getSwitchMaskImage()

setSwitchOffImage
public void setSwitchOffImage(Image switchOffImage)

Sets the image that should be used for the "Off" state. Note: This option is only used
if the "onOffIOSModeBool" theme constant is enabled.
Note: If the "onOffIOSModeBool" theme constant is false and you set this image, you
must also set the "On" image with setSwitchOnImage(com.codename1.ui.Image) and
the "Mask" image with setSwitchMaskImage(com.codename1.ui.Image).
Parameters:
switchOffImage

- the switchOffImage to set

See Also:
getSwitchOffImage(), setSwitchMaskImage(com.codename1.ui.Image),
setSwitchOnImage(com.codename1.ui.Image)

getSwitchMaskImage
public Image getSwitchMaskImage()

Gets the image that is used for the mask. Note: This option is only used if the
"onOffIOSModeBool" theme constant is enabled.
This image will generally consist of an opaque border/frame with a transparent center
such that the "on" and "off" images can be painted inside the transparent part, and
anything that is outside that center will be painted over by the frame, or clipped.
Returns:
the switchMaskImage image if the "onOffIOSModeBool" flag is set or the
mask image has been explicitly set on this OnOffSwitch using
setSwitchMaskImage(com.codename1.ui.Image)

See Also:
getSwitchOffImage(), getSwitchOffImage(),
setSwitchOnImage(com.codename1.ui.Image), getSwitchMaskImage(),
setSwitchMaskImage(com.codename1.ui.Image)

setSwitchMaskImage
public void setSwitchMaskImage(Image switchMaskImage)

Sets the image that should be used for the "On" state.
Note: If the "onOffIOSModeBool" is false and you set this mask, you must also set the
"On" image with setSwitchOnImage(com.codename1.ui.Image) and the "Off" image
with setSwitchOffImage(com.codename1.ui.Image).
Parameters:
switchMaskImage

- the switchMaskImage image to set as the mask for the

on-off switch.

Method Detail

2621

Overview (Codename One API)


com.codename1.components

Class MultiButton
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.MultiButton
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A powerful button like component that allows multiple rows/and an icon to be added every row/icon
can have its own UIID. Internally the multi-button is a container with a lead component. Up to 4 rows
are supported.
MultiButton twoLinesNoIcon = new MultiButton("MultiButton");
twoLinesNoIcon.setTextLine2("Line 2");
MultiButton oneLineIconEmblem = new MultiButton("Icon + Emblem");
oneLineIconEmblem.setIcon(icon);
oneLineIconEmblem.setEmblem(emblem);
MultiButton twoLinesIconEmblem = new MultiButton("Icon + Emblem");
twoLinesIconEmblem.setIcon(icon);
twoLinesIconEmblem.setEmblem(emblem);
twoLinesIconEmblem.setTextLine2("Line 2");
MultiButton twoLinesIconEmblemHorizontal = new MultiButton("Icon + Emblem");
twoLinesIconEmblemHorizontal.setIcon(icon);
twoLinesIconEmblemHorizontal.setEmblem(emblem);
twoLinesIconEmblemHorizontal.setTextLine2("Line 2 Horizontal");
twoLinesIconEmblemHorizontal.setHorizontalLayout(true);
MultiButton twoLinesIconCheckBox = new MultiButton("CheckBox");
twoLinesIconCheckBox.setIcon(icon);
twoLinesIconCheckBox.setCheckBox(true);
twoLinesIconCheckBox.setTextLine2("Line 2");
MultiButton fourLinesIcon = new MultiButton("With Icon");
fourLinesIcon.setIcon(icon);
fourLinesIcon.setTextLine2("Line 2");
fourLinesIcon.setTextLine3("Line 3");
fourLinesIcon.setTextLine4("Line 4");
hi.add(oneLineIconEmblem).
add(twoLinesNoIcon).
add(twoLinesIconEmblem).
add(twoLinesIconEmblemHorizontal).
add(twoLinesIconCheckBox).
add(fourLinesIcon);

Class MultiButton

2622

Overview (Codename One API)

See Also:
SpanButton

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
MultiButton()

Default constructor allowing the designer to create an instance of this class


MultiButton(String line1)

Initializes a multibutton with the first line of text

Method Summary
Modifier
and Type
void
Command
Image
String

Field Summary

Method and Description


addActionListener(ActionListener al)

Adds an action listener


getCommand()

Returns the command for the emblem


getEmblem()

Returns the emblem image


getEmblemName()

Returns the name of the emblem

2623

Overview (Codename One API)


String
String
String
Image

getEmblemPosition()

Returns the emblem position based on border layout constraints


getEmblemUIID()

Returns the UIID of the Emblem


getGroup()

Indicates the group for the radio button


getIcon()

Returns the icon image


getIconComponent()

Label

String
String
String
String
String
String
String
String

Allows us to gain direct access to the icon component so we can set it directly
without going via the other methods, this is especially useful for classes such as
the ImageDownloadService which can then update the icon seamlessly.
getIconName()

Returns the name of the icon


getIconPosition()

Returns the icon position based on border layout constraints


getIconUIID()

Returns the UIID of the Icon


getMaskName()

Set the mask name for the icon


getNameLine1()

Returns the name of the row


getNameLine2()

Returns the name of the row


getNameLine3()

Returns the name of the row


getNameLine4()

Returns the name of the row


getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

String
String
String
String
String
String
String
String
boolean
boolean
boolean

Method Summary

Returns the current value of the property name, this method is used by the GUI
builder
getTextLine1()

Returns the content of the row


getTextLine2()

Returns the content of the row


getTextLine3()

Returns the content of the row


getTextLine4()

Returns the content of the row


getUIIDLine1()

Returns the UIID of the row


getUIIDLine2()

Returns the UIID of the row


getUIIDLine3()

Returns the UIID of the row


getUIIDLine4()

Returns the UIID of the row


isCheckBox()

Returns true if this is a checkbox button


isHorizontalLayout()

Indicates whether the first two labels are be side by side


isInvertFirstTwoEntries()

Inverts the order of the first two entries so the second line appears first.

2624

Overview (Codename One API)


boolean
boolean
boolean
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

isLinesTogetherMode()

Indicates if the lines are grouped together on this button


isRadioButton()

Returns true if this is a radio button


isSelected()

Returns true if the checkbox/radio button is selected


removeActionListener(ActionListener al)

Removes an action listener


setCheckBox(boolean b)

Turns the multi-button into a checkbox multi-button


setCommand(Command c)

Sets the command for the component, it doesn't affe


setEmblem(Image i)

Sets the emblem


setEmblemName(String t)

Sets the name of the emblem (important for use in generic renderers
setEmblemPosition(String t)

Sets the emblem position based on border layout constraints


setEmblemUIID(String t)

Sets the UIID of the emblem


setGroup(String group)

Indicates the group for the radio button


setHorizontalLayout(boolean b)

Indicates the first two labels should be side by side


setIcon(Image i)

Sets the icon


setIconName(String t)

Sets the name of the icon (important for use in generic renderers
setIconPosition(String t)

Sets the icon position based on border layout constraints


setIconUIID(String t)

Sets the UIID of the icon


setInvertFirstTwoEntries(boolean b)

Inverts the order of the first two entries so the second line appears first.
setLinesTogetherMode(boolean l)

Changes the layout so the lines of the button are grouped together
setMaskName(String maskName)

The mask name for the icon


setNameLine1(String t)

Sets the name of the row (important for use in generic renderers)
setNameLine2(String t)

Sets the name of the row (important for use in generic renderers
setNameLine3(String t)

Sets the name of the row (important for use in generic renderers
setNameLine4(String t)

Sets the name of the row (important for use in generic renderers
setPropertyValue(String name, Object value)

String

void
void
void
void
void

Method Summary

Sets a new value to the given property, returns an error message if failed and
null if successful.
setRadioButton(boolean b)

Turns the multi-button into a radio multi-button


setSelected(boolean b)

Toggles the selected state for the radio button/check box modes
setTextLine1(String t)

Sets the content of the row


setTextLine2(String t)

Sets the content of the row


setTextLine3(String t)

2625

Overview (Codename One API)


Sets the content of the row
setTextLine4(String t)

void

Sets the content of the row


setUIIDLine1(String t)

void

Sets the UIID of the row


setUIIDLine2(String t)

void

Sets the UIID of the row


setUIIDLine3(String t)

void

Sets the UIID of the row


setUIIDLine4(String t)

void

Sets the UIID of the row

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initComponent,
initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer,
isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion,
isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHidden,
isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable,
isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag,
isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible,
keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged,
pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed,
pointerReleased, pointerReleased, putClientProperty, refreshTheme,
refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,

Methods inherited from class com.codename1.ui.Container

2626

Overview (Codename One API)


scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHeight, setHidden, setHidden, setHideInPortrait,
setInitialized, setIsScrollVisible, setLabelForComponent, setName,
setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp,
setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,
setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,
setScrollY, setSelectCommandText, setSelectedStyle, setSize,
setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled,
setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX,
setY, shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
MultiButton
public MultiButton(String line1)

Initializes a multibutton with the first line of text


Parameters:
line1 - first line of text
MultiButton
public MultiButton()

Default constructor allowing the designer to create an instance of this class

Method Detail
setLinesTogetherMode
public void setLinesTogetherMode(boolean l)

Changes the layout so the lines of the button are grouped together
Parameters:
l - true to group the lines together
isLinesTogetherMode
public boolean isLinesTogetherMode()

Indicates if the lines are grouped together on this button


Returns:
getIconComponent
public Label getIconComponent()

Allows us to gain direct access to the icon component so we can set it directly without
going via the other methods, this is especially useful for classes such as the
ImageDownloadService which can then update the icon seamlessly.
Returns:
the component used internally to represent the icon
setCheckBox
public void setCheckBox(boolean b)

Turns the multi-button into a checkbox multi-button


Parameters:
b - true for a checkbox multi-button

Methods inherited from class com.codename1.ui.Component

2627

Overview (Codename One API)


addActionListener
public void addActionListener(ActionListener al)

Adds an action listener


Parameters:
al - the action listener
removeActionListener
public void removeActionListener(ActionListener al)

Removes an action listener


Parameters:
al - the action listener
setCommand
public void setCommand(Command c)

Sets the command for the component, it doesn't affe


Parameters:
c - the command
getCommand
public Command getCommand()

Returns the command for the emblem


Returns:
the command instance
isCheckBox
public boolean isCheckBox()

Returns true if this is a checkbox button


Returns:
true for a checkbox button
setRadioButton
public void setRadioButton(boolean b)

Turns the multi-button into a radio multi-button


Parameters:
b - true for a radio multi-button
isRadioButton
public boolean isRadioButton()

Returns true if this is a radio button


Returns:
true for a radio button
isSelected
public boolean isSelected()

Returns true if the checkbox/radio button is selected


Returns:
true if the checkbox/radio button is selected
setSelected
public void setSelected(boolean b)

Toggles the selected state for the radio button/check box modes
Parameters:
b - true for checked false for unchecked

Method Detail

2628

Overview (Codename One API)


setHorizontalLayout
public void setHorizontalLayout(boolean b)

Indicates the first two labels should be side by side


Parameters:
b - true to place the first two labels side by side
isHorizontalLayout
public boolean isHorizontalLayout()

Indicates whether the first two labels are be side by side


Returns:
true if the first two labels are side by side
setInvertFirstTwoEntries
public void setInvertFirstTwoEntries(boolean b)

Inverts the order of the first two entries so the second line appears first. This only
works in horizontal mode!
Parameters:
b - true to place the second row entry as the first entry
isInvertFirstTwoEntries
public boolean isInvertFirstTwoEntries()

Inverts the order of the first two entries so the second line appears first. This only
works in horizontal mode!
Returns:
true when the second row entry should be placed before the first entry
setTextLine1
public void setTextLine1(String t)

Sets the content of the row


Parameters:
t - text to set
getTextLine1
public String getTextLine1()

Returns the content of the row


Returns:
the text
setNameLine1
public void setNameLine1(String t)

Sets the name of the row (important for use in generic renderers)
Parameters:
t - name to set
getNameLine1
public String getNameLine1()

Returns the name of the row


Returns:
the name
setUIIDLine1
public void setUIIDLine1(String t)

Sets the UIID of the row


Parameters:
t - UIID to set

Method Detail

2629

Overview (Codename One API)


getUIIDLine1
public String getUIIDLine1()

Returns the UIID of the row


Returns:
the UIID
setTextLine2
public void setTextLine2(String t)

Sets the content of the row


Parameters:
t - text to set
getTextLine2
public String getTextLine2()

Returns the content of the row


Returns:
the text
setNameLine2
public void setNameLine2(String t)

Sets the name of the row (important for use in generic renderers
Parameters:
t - name to set
getNameLine2
public String getNameLine2()

Returns the name of the row


Returns:
the name
setUIIDLine2
public void setUIIDLine2(String t)

Sets the UIID of the row


Parameters:
t - UIID to set
getUIIDLine2
public String getUIIDLine2()

Returns the UIID of the row


Returns:
the UIID
setTextLine3
public void setTextLine3(String t)

Sets the content of the row


Parameters:
t - text to set
getTextLine3
public String getTextLine3()

Returns the content of the row


Returns:
the text

Method Detail

2630

Overview (Codename One API)


setNameLine3
public void setNameLine3(String t)

Sets the name of the row (important for use in generic renderers
Parameters:
t - name to set
getNameLine3
public String getNameLine3()

Returns the name of the row


Returns:
the name
setUIIDLine3
public void setUIIDLine3(String t)

Sets the UIID of the row


Parameters:
t - UIID to set
getUIIDLine3
public String getUIIDLine3()

Returns the UIID of the row


Returns:
the UIID
setTextLine4
public void setTextLine4(String t)

Sets the content of the row


Parameters:
t - text to set
getTextLine4
public String getTextLine4()

Returns the content of the row


Returns:
the text
setNameLine4
public void setNameLine4(String t)

Sets the name of the row (important for use in generic renderers
Parameters:
t - name to set
getNameLine4
public String getNameLine4()

Returns the name of the row


Returns:
the name
setUIIDLine4
public void setUIIDLine4(String t)

Sets the UIID of the row


Parameters:
t - UIID to set

Method Detail

2631

Overview (Codename One API)


getUIIDLine4
public String getUIIDLine4()

Returns the UIID of the row


Returns:
the UIID
setIcon
public void setIcon(Image i)

Sets the icon


Parameters:
i - the icon
getIcon
public Image getIcon()

Returns the icon image


Returns:
the image instance
setEmblem
public void setEmblem(Image i)

Sets the emblem


Parameters:
i - the icon
getEmblem
public Image getEmblem()

Returns the emblem image


Returns:
the image instance
setIconPosition
public void setIconPosition(String t)

Sets the icon position based on border layout constraints


Parameters:
t - position either North/South/East/West
getIconPosition
public String getIconPosition()

Returns the icon position based on border layout constraints


Returns:
position either North/South/East/West
setEmblemPosition
public void setEmblemPosition(String t)

Sets the emblem position based on border layout constraints


Parameters:
t - position either North/South/East/West
getEmblemPosition
public String getEmblemPosition()

Returns the emblem position based on border layout constraints


Returns:
position either North/South/East/West

Method Detail

2632

Overview (Codename One API)


setIconName
public void setIconName(String t)

Sets the name of the icon (important for use in generic renderers
Parameters:
t - name to set
getIconName
public String getIconName()

Returns the name of the icon


Returns:
the name
setIconUIID
public void setIconUIID(String t)

Sets the UIID of the icon


Parameters:
t - UIID to set
getIconUIID
public String getIconUIID()

Returns the UIID of the Icon


Returns:
the UIID
setEmblemName
public void setEmblemName(String t)

Sets the name of the emblem (important for use in generic renderers
Parameters:
t - name to set
getEmblemName
public String getEmblemName()

Returns the name of the emblem


Returns:
the name
setEmblemUIID
public void setEmblemUIID(String t)

Sets the UIID of the emblem


Parameters:
t - UIID to set
getEmblemUIID
public String getEmblemUIID()

Returns the UIID of the Emblem


Returns:
the UIID
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation

Method Detail

2633

Overview (Codename One API)


getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getGroup
public String getGroup()

Indicates the group for the radio button


Returns:
the group
setGroup
public void setGroup(String group)

Indicates the group for the radio button


Parameters:
group - the group to set
getMaskName
public String getMaskName()

Set the mask name for the icon


Returns:
the maskName
setMaskName
public void setMaskName(String maskName)

The mask name for the icon


Parameters:
maskName - the maskName to set

Method Detail

2634

Overview (Codename One API)


com.codename1.components

Class MediaPlayer
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.MediaPlayer
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

Video playback component with control buttons for back, play/pause and forward buttons. In the
simulator those controls are implemented locally but on the device the native playback controls are
used.
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) {
{@literal @}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();

Class MediaPlayer

2635

Overview (Codename One API)


Field

Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
MediaPlayer()

Empty constructor
MediaPlayer(Media video)

Empty constructor

Method Summary
Modifier and
Type

Method and Description

protected
Dimension

calcPreferredSize()

Image

getBackIcon()

String
Image
Media

Calculates the preferred size based on component content.


getDataSource()

Convenience JavaBean method, see other version of this method


getFwdIcon()
getMedia()

Returns the Media Object of this MediaPlayer

Image

getPauseIcon()

Image

getPlayIcon()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder
code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

protected
void
boolean
boolean
void
void
void

void

Returns the current value of the property name, this method is used by the
GUI builder
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and


"ready for action" component state
isAutoplay()

Sets playback to start automatically


isLoop()

Sets playback to loop


run()
setAutoplay(boolean autoplay)

Sets playback to start automatically


setBackIcon(Image backIcon)

Sets the back Button Icon


setDataSource(InputStream is, String mimeType,
Runnable onCompletion)

Sets the data source of this video player

Field Summary

2636

Overview (Codename One API)


setDataSource(String uri)

void

Convenience JavaBean method, see other version of this method


setDataSource(String uri, Runnable onCompletion)

void

Sets the data source of this video player


setFwdIcon(Image fwdIcon)

void

Sets the forward Button Icon


setLoop(boolean loop)

void

Sets playback to loop


setPauseIcon(Image pauseIcon)

void

Sets the pause Button Icon


setPlayIcon(Image playIcon)

void

Sets the play Button Icon


setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed
and null if successful.

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,
clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth,
getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle,
getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,

Method Summary

2637

Overview (Codename One API)

pointerReleased, putClientProperty, refreshTheme, refreshTheme,


removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
MediaPlayer
public MediaPlayer()

Empty constructor
MediaPlayer
public MediaPlayer(Media video)

Empty constructor

Method Detail
getMedia
public Media getMedia()

Returns the Media Object of this MediaPlayer


Returns:
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Container
Returns:
the calculated preferred size based on component content

Methods inherited from class com.codename1.ui.Component

2638

Overview (Codename One API)


setBackIcon
public void setBackIcon(Image backIcon)

Sets the back Button Icon


Parameters:
backIcon setFwdIcon
public void setFwdIcon(Image fwdIcon)

Sets the forward Button Icon


Parameters:
fwdIcon setPauseIcon
public void setPauseIcon(Image pauseIcon)

Sets the pause Button Icon


Parameters:
pauseIcon setPlayIcon
public void setPlayIcon(Image playIcon)

Sets the play Button Icon


Parameters:
playIcon setDataSource
public void setDataSource(String uri,
Runnable onCompletion)
throws IOException

Sets the data source of this video player


Parameters:
uri - the uri of the media can start with file://, http:// (can also use rtsp://
although may not be supported on all target platforms)
Throws:
IOException - if creation of media from the given URI has failed
setDataSource
public void setDataSource(String uri)

Convenience JavaBean method, see other version of this method


Parameters:
uri - the URL for the media
getDataSource
public String getDataSource()

Convenience JavaBean method, see other version of this method


Returns:
the data source uri
setDataSource
public void setDataSource(InputStream is,
String mimeType,
Runnable onCompletion)
throws IOException

Sets the data source of this video player


Parameters:
is - the stream containing the media data
mimeType - the type of the data in the stream
Throws:
IOException - if the creation of the Media has failed

Method Detail

2639

Overview (Codename One API)


run
public void run()

getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
getPlayIcon
public Image getPlayIcon()

Returns:
the playIcon
getPauseIcon
public Image getPauseIcon()

Returns:
the pauseIcon
getBackIcon
public Image getBackIcon()

Returns:
the backIcon

Method Detail

2640

Overview (Codename One API)


getFwdIcon
public Image getFwdIcon()

Returns:
the fwdIcon
isAutoplay
public boolean isAutoplay()

Sets playback to start automatically


Returns:
the autoplay
setAutoplay
public void setAutoplay(boolean autoplay)

Sets playback to start automatically


Parameters:
autoplay - the autoplay to set
isLoop
public boolean isLoop()

Sets playback to loop


Returns:
the loop
setLoop
public void setLoop(boolean loop)

Sets playback to loop


Parameters:
loop - the loop to set

Method Detail

2641

Overview (Codename One API)


com.codename1.components

Class MasterDetail
java.lang.Object

com.codename1.components.MasterDetail

public class
extends Object

Master-detail utility class simplifying the process of defining a master/detail

Constructor Summary
Constructor and Description
MasterDetail()

Method Summary
Modifier
and Type

Method and Description

bindTabletLandscapeMaster(Form rootForm, Container parentContainer,


static void Component landscapeUI, Component portraitUI, String commandTitle,
Image commandIcon)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MasterDetail
public MasterDetail()

Method Detail
bindTabletLandscapeMaster
public static void bindTabletLandscapeMaster(Form rootForm,
Container parentContainer,
Component landscapeUI,
Component portraitUI,
String commandTitle,
Image commandIcon)

Class MasterDetail

2642

Overview (Codename One API)


com.codename1.components

Class InteractionDialog
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.InteractionDialog
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

Unlike a regular dialog the interaction dialog only looks like a dialog, it resides in the layered pane and
can be used to implement features where interaction with the background form is still required.
Since this code is designed for interaction all "dialogs" created thru here are modless and never
block.
InteractionDialog dlg = new InteractionDialog("Hello");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, new Label("Hello Dialog"));
Button close = new Button("Close");
close.addActionListener((ee) -> dlg.dispose());
dlg.addComponent(BorderLayout.SOUTH, close);
Dimension pre = dlg.getContentPane().getPreferredSize();
dlg.show(0, 0, Display.getInstance().getDisplayWidth() - (pre.getWidth() + pre.getWidth() / 6), 0);

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Method Detail

2643

Overview (Codename One API)


Constructor

Summary

Constructor and Description


InteractionDialog()

Default constructor with no title


InteractionDialog(String title)

Constructor with dialog title

Method Summary
Modifier
and Type
void

Method and Description


addComponent(Component cmp)

Adds a Component to the Container


addComponent(int index, Component cmp)

void

void
void
void
Container
Style
String
Layout

This method adds the Component at a specific index location in the Container
Components array.
addComponent(int index, Object constraints, Component cmp)

Adds a Component to the Container


addComponent(Object constraints, Component cmp)

Adds a Component to the Container


dispose()
getContentPane()

Returns the body of the interaction dialog


getDialogStyle()

Simple getter to get the Dialog Style


getDialogUIID()

Returns the uiid of the dialog


getLayout()

Returns the layout manager responsible for arranging this container

String

getTitle()

Label

getTitleComponent()

boolean
boolean

isAnimateShow()

Indicates whether show/dispose should be animated or not


isShowing()

Will return true if the dialog is currently showing


removeAll()

void

remove all Components from container, notice that removed component might
still have a pending repaint in the queue that won't be removed.
removeComponent(Component cmp)

void

void
void
void
void
void

removes a Component from the Container, notice that removed component


might still have a pending repaint in the queue that won't be removed.
setAnimateShow(boolean animateShow)

Indicates whether show/dispose should be animated or not


setDialogUIID(String uiid)

Simple setter to set the Dialog uiid


setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


setTitle(String title)
show(int top, int bottom, int left, int right)

void

This method shows the form as a modal alert allowing us to produce a


behavior of an alert/dialog box.

void

showPopupDialog(Component c)

Constructor Summary

2644

Overview (Codename One API)


A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches
outside its bounds.
showPopupDialog(Rectangle rect)

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches
outside its bounds.

void

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLeadComponent, setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,

Method Summary

2645

Overview (Codename One API)


setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
InteractionDialog
public InteractionDialog()

Default constructor with no title


InteractionDialog
public InteractionDialog(String title)

Constructor with dialog title


Parameters:
title - the title of the dialog

Method Detail
getContentPane
public Container getContentPane()

Returns the body of the interaction dialog


Returns:
the container where the elements of the interaction dialog are added.
setScrollable
public void setScrollable(boolean scrollable)

The equivalent of calling both setScrollableY and setScrollableX


Overrides:
setScrollable in class Container
Parameters:
scrollable - whether the component should/could scroll on the X and Y axis
getLayout
public Layout getLayout()

Returns the layout manager responsible for arranging this container


Overrides:
getLayout in class Container
Returns:
the container layout manager
getTitle
public String getTitle()

addComponent
public void addComponent(Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Container

Methods inherited from class com.codename1.ui.Component

2646

Overview (Codename One API)


Parameters:
cmp - the component to be added
addComponent
public void addComponent(Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Container
Parameters:
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Object constraints,
Component cmp)

Adds a Component to the Container


Overrides:
addComponent in class Container
Parameters:
index - location to insert the Component
constraints - this method is useful when the Layout requires a constraint
such as the BorderLayout. In this case you need to specify an additional data
when you add a Component, such as "CENTER", "NORTH"...
cmp - component to add
addComponent
public void addComponent(int index,
Component cmp)

This method adds the Component at a specific index location in the Container
Components array.
Overrides:
addComponent in class Container
Parameters:
index - location to insert the Component
cmp - the Component to add
removeAll
public void removeAll()

remove all Components from container, notice that removed component might still
have a pending repaint in the queue that won't be removed. Calling form.repaint() will
workaround such an issue.
Overrides:
removeAll in class Container
removeComponent
public void removeComponent(Component cmp)

removes a Component from the Container, notice that removed component might still
have a pending repaint in the queue that won't be removed. Calling form.repaint() will
workaround such an issue.
Overrides:
removeComponent in class Container
Parameters:
cmp - the removed component
getTitleComponent
public Label getTitleComponent()

Method Detail

2647

Overview (Codename One API)


setLayout
public void setLayout(Layout layout)

Sets the layout manager responsible for arranging this container


Overrides:
setLayout in class Container
Parameters:
layout - the specified layout manager
setTitle
public void setTitle(String title)

show
public void show(int
int
int
int

top,
bottom,
left,
right)

This method shows the form as a modal alert allowing us to produce a behavior of an
alert/dialog box. This method will block the calling thread even if the calling thread is
the EDT. Notice that this method will not release the block until dispose is called even
if show() from another form is called!
Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful
for dialogs where you would want the underlying form to "peek" from behind the form.
Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
dispose
public void dispose()

isShowing
public boolean isShowing()

Will return true if the dialog is currently showing


Returns:
true if showing
isAnimateShow
public boolean isAnimateShow()

Indicates whether show/dispose should be animated or not


Returns:
the animateShow
setAnimateShow
public void setAnimateShow(boolean animateShow)

Indicates whether show/dispose should be animated or not


Parameters:
animateShow - the animateShow to set
showPopupDialog
public void showPopupDialog(Component c)

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside its
bounds. It can optionally provide an arrow in the theme to point at the context
component. The popup dialog has the PopupDialog style by default.
Parameters:
c - the context component which is used to position the dialog and can also
be pointed at

Method Detail

2648

Overview (Codename One API)


showPopupDialog
public void showPopupDialog(Rectangle rect)

A popup dialog is shown with the context of a component and its selection, it is
disposed seamlessly if the back button is pressed or if the user touches outside its
bounds. It can optionally provide an arrow in the theme to point at the context
component. The popup dialog has the PopupDialog style by default.
Parameters:
rect - the screen rectangle to which the popup should point
setDialogUIID
public void setDialogUIID(String uiid)

Simple setter to set the Dialog uiid


Parameters:
uiid - the id for the dialog
getDialogUIID
public String getDialogUIID()

Returns the uiid of the dialog


Returns:
the uiid of the dialog
getDialogStyle
public Style getDialogStyle()

Simple getter to get the Dialog Style


Returns:
the style of the dialog

Method Detail

2649

Overview (Codename One API)


com.codename1.components

Class InfiniteScrollAdapter
java.lang.Object

com.codename1.components.InfiniteScrollAdapter

public class
extends Object

Allows adapting a scroll container to scroll indefinitely (or at least until running out of data), this
effectively works by showing an infinite progress indicator when reaching scroll end then allowing
code to fetch additional components.
The sample code shows the usage of the nestoria API to fill out an infinitely scrolling list.
Form hi = new Form("InfiniteScrollAdapter", new BoxLayout(BoxLayout.Y_AXIS));
Style s = UIManager.getInstance().getComponentStyle("MultiLine1");
FontImage p = FontImage.createMaterial(FontImage.MATERIAL_PORTRAIT, s);
EncodedImage placeholder = EncodedImage.createFromImage(p.scaled(p.getWidth() * 3, p.getHeight() * 3), false);
InfiniteScrollAdapter.createInfiniteScroll(hi.getContentPane(), () -> {
java.util.List<Map<String, Object>> data = fetchPropertyData("Leeds");
MultiButton[] cmps = new MultiButton[data.size()];
for(int iter = 0 ; iter < cmps.length ; iter++) {
Map<String, Object> currentListing = data.get(iter);
if(currentListing == null) {
InfiniteScrollAdapter.addMoreComponents(hi.getContentPane(), new Component[0], false);
return;
}
String thumb_url = (String)currentListing.get("thumb_url");
String guid = (String)currentListing.get("guid");
String summary = (String)currentListing.get("summary");
cmps[iter] = new MultiButton(summary);
cmps[iter].setIcon(URLImage.createToStorage(placeholder, guid, thumb_url));
}
InfiniteScrollAdapter.addMoreComponents(hi.getContentPane(), cmps, true);
}, true);

int pageNumber = 1;
java.util.List<Map<String, Object>> fetchPropertyData(String text) {
try {

Class InfiniteScrollAdapter

2650

Overview (Codename One API)

ConnectionRequest r = new ConnectionRequest();


r.setPost(false);
r.setUrl("http://api.nestoria.co.uk/api");
r.addArgument("pretty", "0");
r.addArgument("action", "search_listings");
r.addArgument("encoding", "json");
r.addArgument("listing_type", "buy");
r.addArgument("page", "" + pageNumber);
pageNumber++;
r.addArgument("country", "uk");
r.addArgument("place_name", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getRes
Map<String, Object> response = (Map<String, Object>)result.get("response");
return (java.util.List<Map<String, Object>>)response.get("listings");
} catch(Exception err) {
Log.e(err);
return null;
}
}

Method Summary
Modifier and Type

Method and Description


addMoreComponents(Component[] components,
boolean areThereMore)

Invoke this method to add additional components to the


container, if you use addComponent/removeComponent you will
get undefined behavior.

void

addMoreComponents(Container cnt, Component[] components,


boolean areThereMore)
static void

Invoke this method to add additional components to the


container, if you use addComponent/removeComponent you will
get undefined behavior.
createInfiniteScroll(Container cont, Runnable fetchMore)

static
InfiniteScrollAdapter

Creates an instance of the InfiniteScrollAdapter that will invoke


the fetch more callback to fetch additional components, once that
method completes its task it should add the components via the
addMoreComponents() invocation.
createInfiniteScroll(Container cont, Runnable fetchMore,
boolean fetchOnCreate)

static
InfiniteScrollAdapter

Creates an instance of the InfiniteScrollAdapter that will invoke


the fetch more callback to fetch additional components, once that
method completes its task it should add the components via the
addMoreComponents() invocation.
getComponentLimit()

The component limit defines the number of components that


should be within the infinite scroll adapter, if more than
component limit is added then the appropriate number of
components is removed from the top.

int

InfiniteProgress

getInfiniteProgress()

Lets us manipulate the infinite progress object e.g.


setComponentLimit(int componentLimit)

The component limit defines the number of components that


should be within the infinite scroll adapter, if more than
component limit is added then the appropriate number of
components is removed from the top.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

Method Summary

2651

Overview (Codename One API)


createInfiniteScroll
public static InfiniteScrollAdapter createInfiniteScroll(Container cont,
Runnable fetchMore)

Creates an instance of the InfiniteScrollAdapter that will invoke the fetch more
callback to fetch additional components, once that method completes its task it
should add the components via the addMoreComponents() invocation. Notice that the
container MUST be empty when invoking this method, fetchMore will be invoked
immediately and you can add your data when ready.
Parameters:
cont - the container to bind, it MUST be empty and must be scrollable on the
Y axis
fetchMore - a callback that will be invoked on the EDT to fetch more data (do
not block this method)
Returns:
an instance of this class that can be used to add components
createInfiniteScroll
public static InfiniteScrollAdapter createInfiniteScroll(Container cont,
Runnable fetchMore,
boolean fetchOnCreate)

Creates an instance of the InfiniteScrollAdapter that will invoke the fetch more
callback to fetch additional components, once that method completes its task it
should add the components via the addMoreComponents() invocation. Notice that the
container MUST be empty when invoking this method, fetchMore will be invoked
immediately and you can add your data when ready.
Parameters:
cont - the container to bind, it MUST be empty and must be scrollable on the
Y axis
fetchMore - a callback that will be invoked on the EDT to fetch more data (do
not block this method)
fetchOnCreate - if true the fetchMore callback is called upon calling this
method
Returns:
an instance of this class that can be used to add components
addMoreComponents
public static void addMoreComponents(Container cnt,
Component[] components,
boolean areThereMore)

Invoke this method to add additional components to the container, if you use
addComponent/removeComponent you will get undefined behavior. This is a
convenience method saving the need to keep the InfiniteScrollAdapter as a variable
Parameters:
cnt - container to add the components to
components - the components to add
areThereMore - whether additional components exist
addMoreComponents
public void addMoreComponents(Component[] components,
boolean areThereMore)

Invoke this method to add additional components to the container, if you use
addComponent/removeComponent you will get undefined behavior.
Parameters:
components - the components to add
areThereMore - whether additional components exist
getComponentLimit
public int getComponentLimit()

The component limit defines the number of components that should be within the
infinite scroll adapter, if more than component limit is added then the appropriate
number of components is removed from the top. This prevents running out of memory

Method Detail

2652

Overview (Codename One API)


or performance overhead with too many components... Notice that -1 is a special
case value for no component limit.
Returns:
the componentLimit
setComponentLimit
public void setComponentLimit(int componentLimit)

The component limit defines the number of components that should be within the
infinite scroll adapter, if more than component limit is added then the appropriate
number of components is removed from the top. This prevents running out of memory
or performance overhead with too many components... Notice that -1 is a special
case value for no component limit.
Parameters:
componentLimit - the componentLimit to set
getInfiniteProgress
public InfiniteProgress getInfiniteProgress()

Lets us manipulate the infinite progress object e.g. set the animation image etc.
Returns:
the infinite progress component underlying this adapter

Method Detail

2653

Overview (Codename One API)


com.codename1.components

Class InfiniteProgress
java.lang.Object

com.codename1.ui.Component

com.codename1.components.InfiniteProgress
All Implemented Interfaces:
Animation, StyleListener

public class
extends Component

Shows a "Washing Machine" infinite progress indication animation, to customize the image you can
either use the infiniteImage theme constant or the setAnimation method. The image is rotated
automatically so don't use an animated image or anything like that as it would fail with the rotation
logic.
This class can be used in one of two ways either by embedding the component into the UI thru
something like this:
myContainer.add(new InfiniteProgress());

Notice that this can be used within a custom dialog too.


A second approach allows showing the infinite progress over the entire screen which blocks all input.
This tints the background while the infinite progress rotates:
Dialog ip = new InfiniteProgress().showInifiniteBlocking();
// do some long operation here using invokeAndBlock or do something in a separate thread and callback later
// when you are done just call
ip.dispose();

Field Summary

Class InfiniteProgress

2654

Overview (Codename One API)


Fields

inherited from class com.codename1.ui.Component

BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,


BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
InfiniteProgress()

Default constructor to define the UIID

Method Summary
Modifier and
Type
boolean
protected
Dimension
protected
void

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


deinitialize()

Invoked to indicate that the component initialization is being reversed since


the component was detached from the container hierarchy.
getAngleIncrease()

int

Image

The angle to increase (in degrees naturally) in every tick count, reduce to 1
to make the animation perfectly slow and smooth, increase to 45 to make it
fast and jumpy.
getAnimation()
getPropertyNames()

String[]

Class[]

A component may expose mutable property names for a UI designer to


manipulate, this API is designed for usage internally by the GUI builder code
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

int

Returns the current value of the property name, this method is used by the
GUI builder
getTickCount()

The animation rotates with EDT ticks, but not for every tick.
getTintColor()

int

protected
void

The tinting color of the screen when the showInifiniteBlocking method is


invoked
initComponent()

Allows subclasses to bind functionality that relies on fully initialized and


"ready for action" component state
paint(Graphics g)

void

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF
perform the rendering.
setAngleIncrease(int angleIncrease)

void

void
String

The angle to increase (in degrees naturally) in every tick count, reduce to 1
to make the animation perfectly slow and smooth, increase to 45 to make it
fast and jumpy.
setAnimation(Image animation)

Allows setting the image that will be rotated as part of this effect
setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed

Fields inherited from class com.codename1.ui.Component

2655

Overview (Codename One API)


and null if successful.
setTickCount(int tickCount)

void

The animation rotates with EDT ticks, but not for every tick.
setTintColor(int tintColor)

The tinting color of the screen when the showInifiniteBlocking method is


invoked

void

showInifiniteBlocking()
Dialog

Shows the infinite progress over the whole screen, the blocking can be
competed by calling dispose() on the returned Dialog.

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX,
getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,
getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getPropertyTypeNames, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength,
getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getWidth,
getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, initLaf,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled,
isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX,
isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated,
laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY,
paintBackground, paintBackgrounds, paintBorder, paintBorderBackground,
paintComponent, paintComponent, paintLock, paintLockRelease,
paintScrollbars, paintScrollbarX, paintScrollbarY, paramString, pinch,
pointerDragged, pointerDragged, pointerHover, pointerHoverPressed,
pointerHoverReleased, pointerPressed, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
refreshTheme, removeDragOverListener, removeDropListener,
removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCellRenderer, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten,
setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight,
setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize,
setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch,
setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle,
setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged,
toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Method Summary

2656

Overview (Codename One API)


Constructor

Detail

InfiniteProgress
public InfiniteProgress()

Default constructor to define the UIID

Method Detail
showInifiniteBlocking
public Dialog showInifiniteBlocking()

Shows the infinite progress over the whole screen, the blocking can be competed by
calling dispose() on the returned Dialog.
Dialog ip = new InfiniteProgress().showInifiniteBlocking();

// do some long operation here using invokeAndBlock or do something in a separate thread and callback
// when you are done just call
ip.dispose();

Returns:
the dialog created for the blocking effect, disposing it will return to the
previous form and remove the input block.
initComponent
protected void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:

Constructor Detail

2657

Overview (Codename One API)


the calculated preferred size based on component content
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
getAnimation
public Image getAnimation()

Returns:
the animation
setAnimation
public void setAnimation(Image animation)

Allows setting the image that will be rotated as part of this effect
Parameters:
animation - the animation to set
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:

Method Detail

2658

Overview (Codename One API)

setPropertyValue

in class Component

Parameters:
name - the name of the property
value - new value for the property

Returns:
error message or null
getTintColor
public int getTintColor()

The tinting color of the screen when the showInifiniteBlocking method is invoked
Returns:
the tintColor
setTintColor
public void setTintColor(int tintColor)

The tinting color of the screen when the showInifiniteBlocking method is invoked
Parameters:
tintColor - the tintColor to set
getTickCount
public int getTickCount()

The animation rotates with EDT ticks, but not for every tick. To slow down the
animation increase this number and to speed it up reduce it to 1. It can't be 0 or
lower.
Returns:
the tickCount
setTickCount
public void setTickCount(int tickCount)

The animation rotates with EDT ticks, but not for every tick. To slow down the
animation increase this number and to speed it up reduce it to 1. It can't be 0 or
lower.
Parameters:
tickCount - the tickCount to set
getAngleIncrease
public int getAngleIncrease()

The angle to increase (in degrees naturally) in every tick count, reduce to 1 to make
the animation perfectly slow and smooth, increase to 45 to make it fast and jumpy. Its
probably best to use a number that divides well with 360 but that isn't a requirement.
Valid numbers are anything between 1 and 359.
Returns:
the angleIncrease
setAngleIncrease
public void setAngleIncrease(int angleIncrease)

The angle to increase (in degrees naturally) in every tick count, reduce to 1 to make
the animation perfectly slow and smooth, increase to 45 to make it fast and jumpy. Its
probably best to use a number that divides well with 360 but that isn't a requirement.
Valid numbers are anything between 1 and 359.
Parameters:
angleIncrease - the angleIncrease to set

Method Detail

2659

Overview (Codename One API)


com.codename1.components

Class ImageViewer
java.lang.Object

com.codename1.ui.Component

com.codename1.components.ImageViewer
All Implemented Interfaces:
Animation, StyleListener

public class
extends Component

ImageViewer allows zooming/panning an image and potentially flicking between multiple images
within a list of images.
E.g. the trivial usage works like this:
Form hi = new Form("ImageViewer", new BorderLayout());
ImageViewer iv = new ImageViewer(duke);
hi.add(BorderLayout.CENTER, iv);

You can simulate pinch to zoom on the simulator by dragging the right button away from the top left
corner to zoom in and towards the top left corner to zoom out. On Mac touchpads you can drag two
fingers to achieve that.
A more elaborate usage includes flicking between multiple images e.g.:
Form hi = new Form("ImageViewer", new BorderLayout());
Image
Image
Image
Image

red = Image.createImage(100, 100, 0xffff0000);


green = Image.createImage(100, 100, 0xff00ff00);
blue = Image.createImage(100, 100, 0xff0000ff);
gray = Image.createImage(100, 100, 0xffcccccc);

ImageViewer iv = new ImageViewer(red);


iv.setImageList(new DefaultListModel<>(red, green, blue, gray));
hi.add(BorderLayout.CENTER, iv);

Class ImageViewer

2660

Overview (Codename One API)

You can even download image URL's dynamically into the ImageViewer thanks to the usage of the
ListModel. E.g. in this model book cover images are downloaded dynamically:
Form hi = new Form("ImageViewer", new BorderLayout());
final EncodedImage placeholder = EncodedImage.createFromImage(
FontImage.createMaterial(FontImage.MATERIAL_SYNC, s).
scaled(300, 300), false);
class ImageList implements ListModel<Image> {
private int selection;
private String[] imageURLs = {
"http://awoiaf.westeros.org/images/thumb/9/93/AGameOfThrones.jpg/300px-AGameOfThrones.jpg",
"http://awoiaf.westeros.org/images/thumb/3/39/AClashOfKings.jpg/300px-AClashOfKings.jpg",
"http://awoiaf.westeros.org/images/thumb/2/24/AStormOfSwords.jpg/300px-AStormOfSwords.jpg",
"http://awoiaf.westeros.org/images/thumb/a/a3/AFeastForCrows.jpg/300px-AFeastForCrows.jpg",
"http://awoiaf.westeros.org/images/7/79/ADanceWithDragons.jpg"
};
private Image[] images;
private EventDispatcher listeners = new EventDispatcher();
public ImageList() {
this.images = new EncodedImage[imageURLs.length];
}
public Image getItemAt(final int index) {
if(images[index] == null) {
images[index] = placeholder;
Util.downloadUrlToStorageInBackground(imageURLs[index], "list" + index, (e) -> {
try {
images[index] = EncodedImage.create(Storage.getInstance().createInputStream("list" + index));
listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
} catch(IOException err) {
err.printStackTrace();
}
});
}
return images[index];
}
public int getSize() {
return imageURLs.length;
}
public int getSelectedIndex() {
return selection;
}
public void setSelectedIndex(int index) {
selection = index;
}
public void addDataChangedListener(DataChangedListener l) {
listeners.addListener(l);
}

Class ImageViewer

2661

Overview (Codename One API)


public void removeDataChangedListener(DataChangedListener l) {
listeners.removeListener(l);
}
public void addSelectionListener(SelectionListener l) {
}
public void removeSelectionListener(SelectionListener l) {
}
public void addItem(Image item) {
}
public void removeItem(int index) {
}
};
ImageList imodel = new ImageList();
ImageViewer iv = new ImageViewer(imodel.getItemAt(0));
iv.setImageList(imodel);
hi.add(BorderLayout.CENTER, iv);

Field Summary
Modifier and
Type

Field and Description


IMAGE_FILL

static int

Indicates the initial position of the image in the viewer to FILL the
component size.
IMAGE_FIT

static int

Indicates the initial position of the image in the viewer to FIT to the
component size

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Field Summary

2662

Overview (Codename One API)


Constructor

Summary

Constructor and Description


ImageViewer()

Default constructor
ImageViewer(Image i)

Initializes the component with an image

Method Summary
Modifier and
Type
boolean
protected
Dimension

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


calcPreferredSize()

Calculates the preferred size based on component content.


deinitialize()

void

Image
ListModel<Image>
int
int

Invoked to indicate that the component initialization is being reversed since the co
the container hierarchy.
getImage()

Returns the currently showing image


getImageList()

Returns the list model containing the images in the we can swipe through
getImageX()

Returns the x position of the image viewport which can be useful when it is being p
getImageY()

Returns the y position of the image viewport which can be useful when it is being p
getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulat


usage internally by the GUI builder code
getPropertyTypeNames()

String[]

Class[]
Object
Image

This method is here to workaround an XMLVM array type bug where property type
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Objec
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI bu
getSwipePlaceholder()

This image is shown briefly during swiping while the full size image is loaded
getSwipeThreshold()

float

float
void

The swipe threshold is a number between 0 and 1 that indicates the threshold afte
moves to the next image.
getZoom()

Manipulate the zoom level of the application


initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
isCycleLeft()

boolean

By default the ImageViewer cycles from the beginning to the end of the list when g
false prevents this behaviour
isCycleRight()

boolean

boolean
void

Constructor Summary

By default the ImageViewer cycles from the end to the beginning of the list when g
to false prevents this behaviour
isEagerLock()

Eager locking effectively locks the right/left images as well as the main image, as
keyReleased(int key)

If this Component is focused, the key released event will call this method

2663

Overview (Codename One API)


protected void

laidOut()

This is a callback method to inform the Component when it's been laidout on the p
paint(Graphics g)

This method paints the Component on the screen, it should be overriden by subcla
drawing or invoke the UI API's to let the PLAF perform the rendering.

void

paintBackground(Graphics g)
protected void

protected
boolean

This method paints the Component background, it should be overriden by subclas


background drawing.
pinch(float scale)

Invoked by subclasses interested in handling pinch to zoom events, if true is return


be broadcast
pointerDragged(int x, int y)

void

If this Component is focused, the pointer dragged event will call this method
pointerPressed(int x, int y)

void

If this Component is focused, the pointer pressed event will call this method
pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this method

protected void

resetFocusable()

Restores the state of the focusable flag to its default state


setCycleLeft(boolean cycleLeft)

By default the ImageViewer cycles from the beginning to the end of the list when g
false prevents this behaviour

void

setCycleRight(boolean cycleRight)

By default the ImageViewer cycles from the end to the beginning of the list when g
to false prevents this behaviour

void

setEagerLock(boolean eagerLock)

void

Eager locking effectively locks the right/left images as well as the main image, as
setImage(Image image)

void

Sets the currently showing image


setImageInitialPosition(int imageInitialPosition)

void

Sets the viewer initial image position to fill or to fit.


setImageList(ListModel<Image> model)

void

By providing this optional list of images you can allows swiping between multiple im
setPropertyValue(String name, Object value)

String

Sets a new value to the given property, returns an error message if failed and null
setSwipePlaceholder(Image swipePlaceholder)

void

This image is shown briefly during swiping while the full size image is loaded
setSwipeThreshold(float swipeThreshold)

The swipe threshold is a number between 0 and 1 that indicates the threshold afte
moves to the next image.

void

setZoom(float zoom)

void

Manipulate the zoom level of the application

protected
boolean

shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from bei
purpose when on top of said component.

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitializeCustomStyle, dragEnter,
dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage,
drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBottomGap, getBoundPropertyValue, getBounds, getClientProperty,
getCloudBoundProperty, getCloudDestinationProperty, getComponentForm,
getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx,
getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getGridPosX,
getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown,
getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent,

Method Summary

2664

Overview (Codename One API)


getPreferredH, getPreferredSize, getPreferredW, getPressedStyle,
getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed,
getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed,
getScrollX, getScrollY, getSelectCommandText, getSelectedRect,
getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID,
getUIManager, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY,
growShrink, handlesInput, hasFocus, initCustomStyle, initLaf,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled,
isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollableX,
isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyPressed, keyRepeated, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder,
paintBorderBackground, paintComponent, paintComponent, paintLock,
paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY,
paramString, pointerDragged, pointerHover, pointerHoverPressed,
pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty,
refreshTheme, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, scrollRectToVisible,
scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue,
setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setEnabled, setFlatten, setFocus, setFocusable,
setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden,
setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail
IMAGE_FIT
public static final int IMAGE_FIT

Indicates the initial position of the image in the viewer to FIT to the component size
See Also:
Constant Field Values
IMAGE_FILL
public static final int IMAGE_FILL

Indicates the initial position of the image in the viewer to FILL the component size.
Notice this type might drop edges of the images in order to stretch the image to the
full size of the Component.
See Also:
Constant Field Values

Constructor Detail
ImageViewer
public ImageViewer()

Default constructor

Methods inherited from class com.codename1.ui.Component

2665

Overview (Codename One API)


ImageViewer
public ImageViewer(Image i)

Initializes the component with an image


Parameters:
i - image to show

Method Detail
resetFocusable
protected void resetFocusable()

Restores the state of the focusable flag to its default state


Overrides:
resetFocusable in class Component
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()

A component that might need side swipe such as the slider could block it from being
used for some other purpose when on top of said component.
Overrides:
shouldBlockSideSwipe in class Component
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties
getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:

Constructor Detail

2666

Overview (Codename One API)


name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null
initComponent
public void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
getImageX
public int getImageX()

Returns the x position of the image viewport which can be useful when it is being
panned by the user
Returns:
x position within the image for the top left corner
getImageY
public int getImageY()

Returns the y position of the image viewport which can be useful when it is being
panned by the user
Returns:
y position within the image for the top left corner
deinitialize
public void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
keyReleased
public void keyReleased(int key)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Component
Parameters:
key - the key code value to indicate a physical key.
pointerPressed
public void pointerPressed(int x,
int y)

If this Component is focused, the pointer pressed event will call this method

Method Detail

2667

Overview (Codename One API)


Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
pointerDragged
public void pointerDragged(int x,
int y)

If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
laidOut
protected void laidOut()

This is a callback method to inform the Component when it's been laidout on the
parent Container
Overrides:
laidOut in class Component
pinch
protected boolean pinch(float scale)

Invoked by subclasses interested in handling pinch to zoom events, if true is returned


other drag events will not be broadcast
Overrides:
pinch in class Component
Parameters:
scale - the scaling of the pinch operation a number larger than 1 means
scaling up and smaller than 1 means scaling down. It is recommended that
code would threshold the number (so a change between 1.0 and 1.02
shouldn't necessarily trigger zoom). Notice that this number is relevant to
current zoom levels and unaware of them so you should also enforce limits of
maximum/minimum zoom levels.
Returns:
false by default
calcPreferredSize
protected Dimension calcPreferredSize()

Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content
animate
public boolean animate()

Method Detail

2668

Overview (Codename One API)


Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public void paint(Graphics g)

This method paints the Component on the screen, it should be overriden by


subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform
the rendering.
Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics
paintBackground
protected void paintBackground(Graphics g)

This method paints the Component background, it should be overriden by subclasses


to perform custom background drawing.
Overrides:
paintBackground in class Component
Parameters:
g - the component graphics
getImage
public Image getImage()

Returns the currently showing image


Returns:
the image
setImage
public void setImage(Image image)

Sets the currently showing image


Parameters:
image - the image to set
setImageList
public void setImageList(ListModel<Image> model)

By providing this optional list of images you can allows swiping between multiple
images
Parameters:
list - a list of images
getImageList
public ListModel<Image> getImageList()

Returns the list model containing the images in the we can swipe through
Returns:
the list model
getZoom
public float getZoom()

Manipulate the zoom level of the application


Returns:
the zoom

Method Detail

2669

Overview (Codename One API)


setZoom
public void setZoom(float zoom)

Manipulate the zoom level of the application


Parameters:
zoom - the zoom to set
getSwipePlaceholder
public Image getSwipePlaceholder()

This image is shown briefly during swiping while the full size image is loaded
Returns:
the swipePlaceholder
setSwipePlaceholder
public void setSwipePlaceholder(Image swipePlaceholder)

This image is shown briefly during swiping while the full size image is loaded
Parameters:
swipePlaceholder - the swipePlaceholder to set
isEagerLock
public boolean isEagerLock()

Eager locking effectively locks the right/left images as well as the main image, as a
result more heap is taken
Returns:
the eagerLock
setEagerLock
public void setEagerLock(boolean eagerLock)

Eager locking effectively locks the right/left images as well as the main image, as a
result more heap is taken
Parameters:
eagerLock - the eagerLock to set
isCycleLeft
public boolean isCycleLeft()

By default the ImageViewer cycles from the beginning to the end of the list when
going to the left, setting this to false prevents this behaviour
Returns:
true if it should cycle left from beginning
setCycleLeft
public void setCycleLeft(boolean cycleLeft)

By default the ImageViewer cycles from the beginning to the end of the list when
going to the left, setting this to false prevents this behaviour
Parameters:
cycleLeft - the cycle left to set
isCycleRight
public boolean isCycleRight()

By default the ImageViewer cycles from the end to the beginning of the list when
going to the right, setting this to false prevents this behaviour
Returns:
true if it should cycle right from the end
setCycleRight
public void setCycleRight(boolean cycleRight)

By default the ImageViewer cycles from the end to the beginning of the list when
going to the right, setting this to false prevents this behaviour

Method Detail

2670

Overview (Codename One API)


Parameters:
cycleRight - the cycle right to set
getSwipeThreshold
public float getSwipeThreshold()

The swipe threshold is a number between 0 and 1 that indicates the threshold after
which the swiped image moves to the next image. Below that number the image will
bounce back
Returns:
the threshold
setSwipeThreshold
public void setSwipeThreshold(float swipeThreshold)

The swipe threshold is a number between 0 and 1 that indicates the threshold after
which the swiped image moves to the next image. Below that number the image will
bounce back
Parameters:
swipeThreshold - the swipeThreshold to set
setImageInitialPosition
public void setImageInitialPosition(int imageInitialPosition)

Sets the viewer initial image position to fill or to fit.


Parameters:
imageInitialPosition - values can be IMAGE_FILL or IMAGE_FIT

Method Detail

2671

Overview (Codename One API)


com.codename1.components

Class FloatingHint
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.FloatingHint
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Container

A floating hint is similar to a text field with a hint. However, when the text field has text in it the hint
appears above the text field instead including an animation when focus hits the text field see:
http://www.google.com/design/spec/components/text-fields.html#text-fields-floating-labels

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
FloatingHint(TextField tf)

Wraps a text field in a floating hint

Method Summary

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,
dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Class FloatingHint

2672

Overview (Codename One API)


Methods

inherited from class com.codename1.ui.Component

addDragOverListener, addDropListener, addFocusListener,


addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes,
getPropertyValue, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setPropertyValue, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
FloatingHint
public FloatingHint(TextField tf)

Wraps a text field in a floating hint


Parameters:
tf - the text field

Methods inherited from class com.codename1.ui.Component

2673

Overview (Codename One API)


com.codename1.components

Class FileTreeModel
java.lang.Object

com.codename1.components.FileTreeModel
All Implemented Interfaces:
TreeModel

public class
extends Object
implements TreeModel

A tree model representing the file system as a whole, notice that this class returns absolute file names
which would result in an unreadable tree. To fix this you can create a Tree object and override
functionality such as the childToDisplayLabel method like this: Tree fileTree = new Tree(new
FileTreeModel(true)) { protected String childToDisplayLabel(Object child) { if (((String)
child).endsWith("/")) { return ((String) child).substring(((String)
child).lastIndexOf('/', ((String) child).length() - 2)); } return ((String)
child).substring(((String) child).lastIndexOf('/')); } };

Constructor Summary
Constructor and Description
FileTreeModel(boolean showFiles)

Construct a filesystem tree model

Method Summary
Modifier and
Type

Method and Description


addExtensionFilter(String extension)

void

Shows only files with the given extension


getChildren(Object parent)

Returns the child objects representing the given parent, null should return
the root objects

Vector

boolean

isLeaf(Object node)

Is the node a leaf or a folder

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FileTreeModel
public FileTreeModel(boolean showFiles)

Construct a filesystem tree model


Parameters:
showFiles - indicates whether this is a directory only view or a whole
filesystem view

Constructor Detail

2674

Overview (Codename One API)


Method

Detail

addExtensionFilter
public void addExtensionFilter(String extension)

Shows only files with the given extension


Parameters:
extension - the file extension to display
getChildren
public Vector getChildren(Object parent)

Returns the child objects representing the given parent, null should return the root
objects
Specified by:
getChildren in interface TreeModel
Parameters:
parent - the parent object whose children should be returned, null would
return the tree roots
Returns:
the children of the given node within the tree
isLeaf
public boolean isLeaf(Object node)

Is the node a leaf or a folder


Specified by:
isLeaf in interface TreeModel
Parameters:
node - a node within the tree
Returns:
true if the node is a leaf that can't be expanded

Method Detail

2675

Overview (Codename One API)


com.codename1.components

Class FileTree
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.ui.tree.Tree

com.codename1.components.FileTree
All Implemented Interfaces:
Animation, StyleListener, Iterable<Component>

public class
extends Tree

Simple class showing off the filesystem as a tree component

Field Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
FileTree()

Default constructor
FileTree(FileTreeModel model)

Constructor with a model

Method Summary
Modifier and
Type
protected
String

Method and Description


childToDisplayLabel(Object child)

Converts a tree child to a label, this method can be overriden for simple
rendering effects

Methods inherited from class com.codename1.ui.tree.Tree


addLeafListener, bindNodeListener, calcPreferredSize, collapsePath,
createNode, createNodeComponent, expandPath, expandPath, getModel,
getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue,
getSelectedItem, isMultilineMode, removeLeafListener, setFolderIcon,
setFolderOpenIcon, setModel, setMultilineMode, setNodeIcon, setNodeIcon,
setPropertyValue

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints,

Class FileTree

2676

Overview (Codename One API)


clearClientProperties, contains, createAnimateMotion, dragInitiated, drop,
encloseIn, encloseIn, findFirstFocusable, fireClicked, flushReplace,
forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt,
getComponentAt, getComponentCount, getComponentIndex, getGridPosX,
getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent,
getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf,
invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, keyReleased,
layoutContainer, morph, morphAndWait, paint, paintComponentBackground,
paintGlass, paramString, pointerHover, pointerPressed, refreshTheme,
removeAll, removeComponent, replace, replace, replaceAndWait,
replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible,
setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable,
setScrollableX, setScrollableY, setScrollIncrement,
setShouldCalcPreferredSize, setShouldLayout, setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, contains, createStyleAnimation, deinitialize,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initComponent, initCustomStyle,
installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated,
isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten,
isFocusable, isGrabsPointerEvents, isHidden, isHideInPortrait,
isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible,
isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch,
isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut,
longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground,
paintBackgrounds, paintBorder, paintBorderBackground, paintComponent,
paintComponent, paintLock, paintLockRelease, paintScrollbars,
paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
pointerReleased, putClientProperty, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty,
setCloudDestinationProperty, setComponentState, setDirtyRegion,
setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus,
setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden,
setHidden, setHideInPortrait, setInitialized, setIsScrollVisible,
setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft,
setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize,
setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth,
setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize,
setScrollVisible, setScrollX, setScrollY, setSelectCommandText,
setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods inherited from class com.codename1.ui.Container

2677

Overview (Codename One API)

Constructor

Detail

FileTree
public FileTree()

Default constructor
FileTree
public FileTree(FileTreeModel model)

Constructor with a model

Method Detail
childToDisplayLabel
protected String childToDisplayLabel(Object child)

Description copied from class: Tree


Converts a tree child to a label, this method can be overriden for simple rendering
effects
Overrides:
childToDisplayLabel in class Tree
Returns:
a string representing the given tree node

Constructor Detail

2678

Overview (Codename One API)


com.codename1.components

Class FileEncodedImageAsync
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.components.FileEncodedImageAsync

public class
extends EncodedImage

This class is identical to FileEncodedImage with the difference of using asynchronous loading for files
(and the animation framework) which will not work for all cases (e.g. renderers) but could improve
some performance/RAM aspects.

Method Summary
Modifier and Type
boolean
static
FileEncodedImageAsync

static
FileEncodedImageAsync

Method and Description


animate()
create(String fileName, byte[] placeholder, int width,
int height)

Deprecated.
use the version that accepts a name and a placeholderImage
create(String fileName, Image placeholder)

Creates an encoded image that maps to a local file thus


allowing to seamlessly fetch files as needed.
getImageData()

Returns the byte array data backing the image allowing the
image to be stored and discarded completely from RAM.

byte[]

getInternal()
protected Image

boolean

Returns the actual image represented by the encoded image,


this image will be cached in a weak/soft reference internally.
isAnimation()

Returns true if this is an animated image


resetCache()

protected void

A subclass might choose to load asynchroniously and reset the


cache when the image is ready.

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getWidth, isLocked, isOpaque, lock, modifyAlpha, modifyAlpha,
rotate, scale, scaled, scaledEncoded, scaledHeight, scaledSmallerRatio,
scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


applyMask, applyMask, applyMaskAutoScale, createImage, createImage,
createImage, createImage, createImage, createImage, createImage,
createIndexed, createMask, createSVG, dispose, flipHorizontally,
flipVertically, getImageName, getRGB, getRGBCached, getSVGDocument,
isAlphaMutableImageSupported, isSVG, isSVGSupported, mirror,
modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Method Detail

2679

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
resetCache
protected void resetCache()

A subclass might choose to load asynchroniously and reset the cache when the
image is ready.
Overrides:
resetCache in class EncodedImage
getInternal
protected Image getInternal()

Returns the actual image represented by the encoded image, this image will be
cached in a weak/soft reference internally. This method is useful to detect when the
system actually created an image instance. You shouldn't invoke this method
manually!
Overrides:
getInternal in class EncodedImage
Returns:
drawable image instance
getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
animate
public boolean animate()

Overrides:
animate

in class Image

isAnimation
public boolean isAnimation()

Returns true if this is an animated image


Overrides:
isAnimation in class EncodedImage
Returns:
true if this image represents an animation
create
public static FileEncodedImageAsync create(String fileName,
byte[] placeholder,
int width,
int height)

Deprecated. use the version that accepts a name and a placeholderImage


Creates an encoded image that maps to a local file thus allowing to seamlessly fetch
files as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the file
placeholder - a placeholder image until the actual image loads

Methods inherited from class java.lang.Object

2680

Overview (Codename One API)


- the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
Returns:
image that will load the file seamlessly
create
width

public static FileEncodedImageAsync create(String fileName,


Image placeholder)

Creates an encoded image that maps to a local file thus allowing to seamlessly fetch
files as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the file
placeholder - an image that will occupy the space
Returns:
image that will load the file seamlessly

Method Detail

2681

Overview (Codename One API)


com.codename1.components

Class FileEncodedImage
java.lang.Object

com.codename1.ui.Image

com.codename1.ui.EncodedImage

com.codename1.components.FileEncodedImage

public class
extends EncodedImage

An encoded image that stores the actual data of the encoded image in a disk file or resource and
loads it only when necessary. The huge advantage is that RAM usage is practically none-existant, it is
potentially very slow in worst case scenarios and has the other drawback of requiring the width/height
in advanced to work properly.

Method Summary
Modifier and Type
static
FileEncodedImage

static
FileEncodedImage
static
FileEncodedImage

Method and Description


create(String fileName, InputStream i, int width,
int height)

Creates an encoded image that maps to a local file thus allowing to


seamlessly fetch files as needed.
create(String fileName, int width, int height)

Creates an encoded image that maps to a local file thus allowing to


seamlessly fetch files as needed.
create(String fileName, int width, int height, boolean keep)

Creates an encoded image that maps to a local file thus allowing to


seamlessly fetch files as needed.
getImageData()

Returns the byte array data backing the image allowing the image to
be stored and discarded completely from RAM.

byte[]

Methods inherited from class com.codename1.ui.EncodedImage


asyncLock, create, create, create, create, create, createFromImage,
createFromRGB, createMulti, drawImage, drawImage, getGraphics, getHeight,
getImage, getInternal, getWidth, isAnimation, isLocked, isOpaque, lock,
modifyAlpha, modifyAlpha, resetCache, rotate, scale, scaled, scaledEncoded,
scaledHeight, scaledSmallerRatio, scaledWidth, subImage, toRGB, unlock

Methods inherited from class com.codename1.ui.Image


animate, applyMask, applyMask, applyMaskAutoScale, createImage,
createImage, createImage, createImage, createImage, createImage,
createImage, createIndexed, createMask, createSVG, dispose,
flipHorizontally, flipVertically, getImageName, getRGB, getRGBCached,
getSVGDocument, isAlphaMutableImageSupported, isSVG, isSVGSupported,
mirror, modifyAlphaWithTranslucency, requiresDrawImage, rotate180Degrees,
rotate270Degrees, rotate90Degrees, scaledLargerRatio, setImageName

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

Class FileEncodedImage

2682

Overview (Codename One API)


getImageData
public byte[] getImageData()

Returns the byte array data backing the image allowing the image to be stored and
discarded completely from RAM.
Overrides:
getImageData in class EncodedImage
Returns:
byte array used to create the image, e.g. encoded PNG, JPEG etc.
create
public static FileEncodedImage create(String fileName,
int width,
int height)

Creates an encoded image that maps to a local file thus allowing to seamlessly fetch
files as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the file
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
Returns:
image that will load the file seamlessly
create
public static FileEncodedImage create(String fileName,
InputStream i,
int width,
int height)
throws IOException

Creates an encoded image that maps to a local file thus allowing to seamlessly fetch
files as needed. This only works reasonably well for very small files. This version of
the method creates the file from an input stream
Parameters:
fileName - the name of the file
i - input stream from which to create the file
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
Returns:
image that will load the file seamlessly
Throws:
IOException

create
public static FileEncodedImage create(String fileName,
int width,
int height,
boolean keep)

Creates an encoded image that maps to a local file thus allowing to seamlessly fetch
files as needed. This only works reasonably well for very small files.
Parameters:
fileName - the name of the file
width - the width of the file or -1 if unknown (notice that this will improve
performance)
height - the height of the file or -1 if unknown (notice that this will improve
performance)
keep - if set to true keeps the file in RAM once loaded
Returns:
image that will load the file seamlessly

Method Detail

2683

Overview (Codename One API)


com.codename1.components

Class Ads
java.lang.Object

com.codename1.ui.Component

com.codename1.ui.Container

com.codename1.components.Ads
All Implemented Interfaces:
Animation, StyleListener, HTMLCallback, ParserCallback, Iterable<Component>

public class
extends Container
implements HTMLCallback

This is an Ads Component, this Component can displays banner/text ads on a Form. This is a generic
Ads Component that can support different type of Ads Network Services, at the Moment Codename
One supports innerActive ads, to gain an appId please refer to
http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne

Field Summary
Modifier
and Type
static
int
static
int

Field and Description


ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
ERROR_CSS_NO_BASE_URL

static
int

static
int

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not
via setPage) In this case the return value of parsingError is not considered parsing continues and the resource at the URL (CSS file/image) is ignored
ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Fields inherited from


interface com.codename1.ui.html.HTMLCallback
ERROR_CONNECTING, ERROR_IMAGE_BAD_FORMAT, ERROR_IMAGE_NOT_FOUND,
ERROR_INVALID_TAG_HIERARCHY, ERROR_NO_BASE_URL, FIELD_PASSWORD, FIELD_TEXT,
LINK_FORBIDDEN, LINK_REGULAR, LINK_VISTED, STATUS_CANCELLED,
STATUS_COMPLETED, STATUS_CONNECTED, STATUS_DISPLAYED, STATUS_ERROR,
STATUS_NONE, STATUS_PARSED, STATUS_REDIRECTED, STATUS_REQUESTED

Fields inherited from


interface com.codename1.xml.ParserCallback
ERROR_ATTIBUTE_VALUE_INVALID, ERROR_ATTRIBUTE_NOT_SUPPORTED,
ERROR_ENCODING, ERROR_MULTIPLE_ROOTS, ERROR_NO_CLOSE_TAG, ERROR_NO_ROOTS,
ERROR_TAG_NOT_SUPPORTED, ERROR_UNEXPECTED_CHARACTER,

Class Ads

2684

Overview (Codename One API)


ERROR_UNEXPECTED_TAG_CLOSING, ERROR_UNRECOGNIZED_CHAR_ENTITY

Constructor Summary
Constructor and Description
Ads()

Default constructor for GUI builder


Ads(String appId)

Simple constructor to create an Ad Component


Ads(String appId, boolean refreshAd)

Method Summary
Modifier
and Type

Method and Description


actionPerformed(ActionEvent evt, HTMLComponent htmlC, HTMLElement element)

void

boolean

Called whenever an ActionEvent is triggered in one of the controls in the HTMLComponent


press, checkbox/radiobutton check etc.
animate()

Allows the animation to reduce "repaint" calls when it returns false.

dataChanged(int type, int index, HTMLComponent htmlC, TextField textField, HTMLEl


void

protected
void

String

Called when the user types in a TextField inside the HTMLComponent This method will be
HTMLComponent.isEventsEnabled() is true
deinitialize()

Invoked to indicate that the component initialization is being reversed since the component
the container hierarchy.

fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL, String id, Str


int type, String errorMsg)

Called whenever a field is submitted to a form.


focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)
void

Called when one of the controls in the HTMLComponent obtained focus This method will b
HTMLComponent.isEventsEnabled() is true
focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)

void

String
String
String
String
String
String
String[]

Called when one of the controls in the HTMLComponent lost focus This method will be call
HTMLComponent.isEventsEnabled() is true
getAd()

HTML ad received from the server


getAge()

Users age
getAppID()

Simple getter of the unique identifier of the app on the ads service network.
getAutoComplete(HTMLComponent htmlC, String actionURL, String id)

Called on form creation and enabled implementations of this method to return a value to pr
getCategory()

Category is a single word description of the application.


getGender()

The user gender can be: M/m, F/f, Male, Female.


getKeywords()

Keywords relevant to this user specific session


getLinkProperties(HTMLComponent htmlC, String url)

int

String

Returns properties about the given link to indicate to HTMLComponent how to render it No
always called NOT on the EDT thread.
getLocation()

Location string is a comma separated list of country, state/province, city For example: US,
getPropertyNames()

String[]

A component may expose mutable property names for a UI designer to manipulate, this AP
usage internally by the GUI builder code

Fields inherited frominterface com.codename1.xml.ParserCallback

2685

Overview (Codename One API)


getPropertyTypeNames()
String[]

Class[]

This method is here to workaround an XMLVM array type bug where property types aren't
returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListMo
getPropertyTypes()

Matches the property names method (see that method for further details).
getPropertyValue(String name)

Object

Returns the current value of the property name, this method is used by the GUI builder
getUpdateDuration()

int

The amount of time needed to update the ad


initComponent()

void

Allows subclasses to bind functionality that relies on fully initialized and "ready for action" c
keyReleased(int code)

void

If this Component is focused, the key released event will call this method

boolean

linkClicked(HTMLComponent htmlC, String url)

Called when a link is clicked.


pageStatusChanged(HTMLComponent htmlC, int status, String url)

void

Called when the page status has been changed

boolean

parsingError(int errorId, String tag, String attribute, String value, String desc

Called when encountering an error while parsing the XML document.


pointerReleased(int x, int y)

void

If this Component is focused, the pointer released event will call this method

selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC, List list


HTMLElement element)

Called when the user selects an item in a List inside the HTMLComponent Note: Selection
the items - once the user has actually decided, an ActionEvent will be sent as well This me
only if HTMLComponent.isEventsEnabled() is true

void

setAd(String ad)

void

HTML ad received from the server


setAge(String age)

void

Sets the users age


setAppID(String appId)

Simple setter of the unique identifier of the app on the ads service network, no need to man
createAdsService uses this.

void

setCategory(String category)

void

Category is a single word description of the application.


setGender(String gender)

void

Sets Gender if applicable can be one of the following: 'F', 'f', 'M', 'm', 'Female', 'female', 'Ma
setHeight(int height)

Sets the Component height, this method is exposed for the purpose of external layout man
be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.

void

setKeywords(String[] keywords)

void

Keywords relevant to this user specific session


setLocation(String location)

void

Location string is a comma separated list of country, state/province, city For example: US,

String

setPropertyValue(String name, Object value)

Sets a new value to the given property, returns an error message if failed and null if succes
setUpdateDuration(int updateDuration)

void

The amount of time needed to update the ad


titleUpdated(HTMLComponent htmlC, String title)

void

Called when the page's title is updated

Methods inherited from class com.codename1.ui.Container


add, add, add, add, add, add, addComponent, addComponent, addComponent,
addComponent, animateHierarchy, animateHierarchyAndWait,
animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout,
animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait,
animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize,
cancelRepaints, clearClientProperties, contains, createAnimateMotion,

Method Summary

2686

Overview (Codename One API)


dragInitiated, drop, encloseIn, encloseIn, findFirstFocusable, fireClicked,
flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo,
getComponentAt, getComponentAt, getComponentCount, getComponentIndex,
getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth,
getLeadComponent, getLeadParent, getScrollIncrement, getSideGap,
getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY,
isSelectableInteraction, iterator, keyPressed, layoutContainer, morph,
morphAndWait, paint, paintComponentBackground, paintGlass, paramString,
pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent,
replace, replace, replaceAndWait, replaceAndWait, replaceAndWait,
revalidate, scrollComponentToVisible, setCellRenderer, setEnabled,
setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY,
setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout,
setUIManager

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener,
bindProperty, calcScrollSize, contains, createStyleAnimation,
deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver,
drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY,
getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior,
getBindablePropertyNames, getBindablePropertyTypes, getBorder,
getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent,
getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight,
getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW,
getPressedStyle, getSameHeight, getSameWidth, getScrollable,
getScrollAnimationSpeed, getScrollDimension, getScrollOpacity,
getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText,
getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID,
getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink,
handlesInput, hasFocus, initCustomStyle, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling,
isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch,
isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, pinch, pointerDragged, pointerDragged,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, removeDragOverListener,
removeDropListener, removeFocusListener, removePointerDraggedListener,
removePointerPressedListener, removePointerReleasedListener,
removeScrollListener, repaint, repaint, requestFocus, resetFocusable,
scrollRectToVisible, scrollRectToVisible, setAlwaysTensile,
setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty,
setComponentState, setDirtyRegion, setDisabledStyle, setDraggable,
setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents,
setHandlesInput, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight,
setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed,
setScrollSize, setScrollVisible, setScrollX, setScrollY,
setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling,
setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength,
setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY,
shouldBlockSideSwipe, styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail

Methods inherited from class com.codename1.ui.Container

2687

Overview (Codename One API)


ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED
public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0
standards) was found in the HTML or external CSS files
See Also:
Constant Field Values
ERROR_CSS_ATTIBUTE_VALUE_INVALID
public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID

Error code denoting that an invalid attribute value was found in the CSS
See Also:
Constant Field Values
ERROR_CSS_NOT_FOUND
public static final int ERROR_CSS_NOT_FOUND

Error code denoting that a CSS file referenced from the HTML or from another
external CSS file was not found
See Also:
Constant Field Values
ERROR_CSS_NO_BASE_URL
public static final int ERROR_CSS_NO_BASE_URL

Error code denoting that a relative URL was referenced from a document with no
base URL (A document that was loaded via setBody/setHTML/setDOM and not via
setPage) In this case the return value of parsingError is not considered - parsing
continues and the resource at the URL (CSS file/image) is ignored
See Also:
Constant Field Values

Constructor Detail
Ads
public Ads()

Default constructor for GUI builder


Ads
public Ads(String appId)

Simple constructor to create an Ad Component


Parameters:
appId - unique identifier of the app, to gain an appId please refer to
http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
Ads
public Ads(String appId,
boolean refreshAd)

Parameters:

- unique identifier of the app, to gain an appId please refer to


http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
refreshAd - if true this Component will refresh the Ad every 60 seconds, if
false no refresh will occur
appId

Method Detail

Field Detail

2688

Overview (Codename One API)


initComponent
public void initComponent()

Allows subclasses to bind functionality that relies on fully initialized and "ready for
action" component state
Overrides:
initComponent in class Component
deinitialize
protected void deinitialize()

Invoked to indicate that the component initialization is being reversed since the
component was detached from the container hierarchy. This allows the component to
deregister animators and cleanup after itself. This method is the opposite of the
initComponent() method.
Overrides:
deinitialize in class Component
animate
public boolean animate()

Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary
keyReleased
public void keyReleased(int code)

If this Component is focused, the key released event will call this method
Overrides:
keyReleased in class Container
Parameters:
code - the key code value to indicate a physical key.
pointerReleased
public void pointerReleased(int x,
int y)

If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
getAd
public String getAd()

HTML ad received from the server


Returns:
the ad
setAd
public void setAd(String ad)

HTML ad received from the server


Parameters:
ad - the ad to set

Method Detail

2689

Overview (Codename One API)


getUpdateDuration
public int getUpdateDuration()

The amount of time needed to update the ad


Returns:
the updateDuration
setUpdateDuration
public void setUpdateDuration(int updateDuration)

The amount of time needed to update the ad


Parameters:
updateDuration - the updateDuration to set
titleUpdated
public void titleUpdated(HTMLComponent htmlC,
String title)

Called when the page's title is updated


Specified by:
titleUpdated in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent that triggered the event
title - The new title
pageStatusChanged
public void pageStatusChanged(HTMLComponent htmlC,
int status,
String url)

Called when the page status has been changed


Specified by:
pageStatusChanged in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which the status change occured
status - The new status, one of the STATUS_* constants
url - The URL of the page
fieldSubmitted
public String fieldSubmitted(HTMLComponent htmlC,
TextArea ta,
String actionURL,
String id,
String value,
int type,
String errorMsg)

Called whenever a field is submitted to a form. This can be used to perform sanity
checks and/or to store values for auto complete.
Specified by:
fieldSubmitted in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which this event occured
ta - The TextArea/TextField of this field
actionURL - The action URL of the form
id - The ID of the field
value - The value entered
type - The type of the field, one of the FIELD_* constants
errorMsg - The error message if any error occured (i.e. input validation error)
or null if no error occured
Returns:
The string to submit to the form (Should return value if nothing changed)
getAutoComplete
public String getAutoComplete(HTMLComponent htmlC,
String actionURL,
String id)

Method Detail

2690

Overview (Codename One API)


Called on form creation and enabled implementations of this method to return a value
to preset in a form field. This can be used to auto complete previously entered value
Note that this method is always called NOT on the EDT thread.
Specified by:
getAutoComplete in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent in which this event occured
actionURL - The action URL of the form
id - The ID of the field
Returns:
The string to place in the indicated field
getLinkProperties
public int getLinkProperties(HTMLComponent htmlC,
String url)

Returns properties about the given link to indicate to HTMLComponent how to render
it Note that this method is always called NOT on the EDT thread.
Specified by:
getLinkProperties in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent
url - The Link URL
Returns:
LINK_REGULAR or LINK_VISITED or LINK_FORBIDDEN or a mask of
those
linkClicked
public boolean linkClicked(HTMLComponent htmlC,
String url)

Called when a link is clicked. This can be used to process links that needs
additional/alternate handling than fetching an HTML.
Specified by:
linkClicked in interface HTMLCallback
Parameters:
htmlC - The HTMLComponent
url - The Link URL
Returns:
true if regular link processing should continue, false otherwise
actionPerformed
public void actionPerformed(ActionEvent evt,
HTMLComponent htmlC,
HTMLElement element)

Called whenever an ActionEvent is triggered in one of the controls in the


HTMLComponent For example, button press, checkbox/radiobutton check etc. This
method will be called only if HTMLComponent.isEventsEnabled() is true
Specified by:
actionPerformed in interface HTMLCallback
Parameters:
evt - The event triggered, the component can be extracted using getSource
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
focusGained
public void focusGained(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

Called when one of the controls in the HTMLComponent obtained focus This method
will be called only if HTMLComponent.isEventsEnabled() is true
Specified by:
focusGained in interface HTMLCallback
Parameters:

Method Detail

2691

Overview (Codename One API)


cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component

that triggered the

event
focusLost
public void focusLost(Component cmp,
HTMLComponent htmlC,
HTMLElement element)

Called when one of the controls in the HTMLComponent lost focus This method will
be called only if HTMLComponent.isEventsEnabled() is true
Specified by:
focusLost in interface HTMLCallback
Parameters:
cmp - The component that triggered the event
htmlC - The HTMLComponent
element - The element associated with the component that triggered the
event
dataChanged
public void dataChanged(int type,
int index,
HTMLComponent htmlC,
TextField textField,
HTMLElement element)

Called when the user types in a TextField inside the HTMLComponent This method
will be called only if HTMLComponent.isEventsEnabled() is true
Specified by:
dataChanged in interface HTMLCallback
Parameters:
type - the type data change; REMOVED, ADDED or CHANGED
index - item index in a list model
htmlC - The HTMLComponent
textField - The TextField that triggerd the event
element - The element associated with the component that triggered the
event (Should be TAG_INPUT with type text/password)
parsingError
public boolean parsingError(int errorId,
String tag,
String attribute,
String value,
String description)

Called when encountering an error while parsing the XML document. When
implementing this, the developer should return true if the error should be ignored and
the document needs to be further parsed, or false to stop parsing and issue an error
to the user Note that this method is always called NOT on the EDT thread.
Specified by:
parsingError in interface ParserCallback
Parameters:
errorId - The error ID, one of the ERROR_* constants
tag - The tag in which the error occured (Can be null for non-tag related
errors)
attribute - The attribute in which the error occured (Can be null for
non-attribute related errors)
value - The value in which the error occured (Can be null for non-value
related errors)
description - A verbal description of the error
Returns:
true to continue parsing, false to stop
selectionChanged
public void selectionChanged(int oldSelected,
int newSelected,
HTMLComponent htmlC,

Method Detail

2692

Overview (Codename One API)


List list,
HTMLElement element)

Called when the user selects an item in a List inside the HTMLComponent Note:
Selection is traversing through the items - once the user has actually decided, an
ActionEvent will be sent as well This method will be called only if
HTMLComponent.isEventsEnabled() is true
Specified by:
selectionChanged in interface HTMLCallback
Parameters:
oldSelected - old selected index in list model
newSelected - new selected index in list model
htmlC - The HTMLComponent
list - The list that triggered the event (Usually a ComboBox but not always)
element - The element associated with the component that triggered the
event (Should be TAG_SELECT)
setHeight
public void setHeight(int height)

Sets the Component height, this method is exposed for the purpose of external layout
managers and should not be invoked directly.
If a user wishes to effect the component size setPreferredSize should be used.
Overrides:
setHeight in class Component
Parameters:
height - the height of the component
See Also:
Component.setPreferredSize(com.codename1.ui.geom.Dimension)

setAppID
public void setAppID(String appId)

Simple setter of the unique identifier of the app on the ads service network, no need
to manually use this the createAdsService uses this.
Parameters:
appId - unique identifier of the app, to gain an appId please refer to
http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
getAppID
public String getAppID()

Simple getter of the unique identifier of the app on the ads service network.
Returns:
the app unique identifier.
setGender
public void setGender(String gender)

Sets Gender if applicable can be one of the following: 'F', 'f', 'M', 'm', 'Female',
'female', 'Male', 'male'
Parameters:
gender setKeywords
public void setKeywords(String[] keywords)

Keywords relevant to this user specific session


Parameters:
keywords getAge
public String getAge()

Users age
Returns:
the user age

Method Detail

2693

Overview (Codename One API)


getGender
public String getGender()

The user gender can be: M/m, F/f, Male, Female.


Returns:
getKeywords
public String[] getKeywords()

Keywords relevant to this user specific session


Returns:
setAge
public void setAge(String age)

Sets the users age


Parameters:
age setCategory
public void setCategory(String category)

Category is a single word description of the application.


Parameters:
category getCategory
public String getCategory()

Category is a single word description of the application.


Returns:
a single word description of the application.
setLocation
public void setLocation(String location)

Location string is a comma separated list of country, state/province, city For example:
US, NY, NY
Parameters:
location getLocation
public String getLocation()

Location string is a comma separated list of country, state/province, city For example:
US, NY, NY
Returns:
getPropertyNames
public String[] getPropertyNames()

A component may expose mutable property names for a UI designer to manipulate,


this API is designed for usage internally by the GUI builder code
Overrides:
getPropertyNames in class Component
Returns:
the property names allowing mutation
getPropertyTypes
public Class[] getPropertyTypes()

Matches the property names method (see that method for further details).
Overrides:
getPropertyTypes in class Component
Returns:
the types of the properties

Method Detail

2694

Overview (Codename One API)


getPropertyTypeNames
public String[] getPropertyTypeNames()

This method is here to workaround an XMLVM array type bug where property types
aren't identified properly, it returns the names of the types using the following type
names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,
Overrides:
getPropertyTypeNames in class Component
Returns:
Array of type names
getPropertyValue
public Object getPropertyValue(String name)

Returns the current value of the property name, this method is used by the GUI
builder
Overrides:
getPropertyValue in class Component
Parameters:
name - the name of the property
Returns:
the value of said property
setPropertyValue
public String setPropertyValue(String name,
Object value)

Sets a new value to the given property, returns an error message if failed and null if
successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
Overrides:
setPropertyValue in class Component
Parameters:
name - the name of the property
value - new value for the property
Returns:
error message or null

Method Detail

2695

Overview (Codename One API)


com.codename1.codescan

Interface ScanResult

Deprecated.
Use the cn1-codescanner cn1lib.
public interface

Deprecated!!: Please use the cn1-codescan library instead.


Callback for the code scanner indicating the result of a scan operation, the methods of this call will
always be invoked on the EDT!

Method Summary
Modifier and
Type

Method and Description


scanCanceled()

Deprecated.
Invoked if the user canceled the scan

void

scanCompleted(String contents, String formatName,


byte[] rawBytes)

void

Deprecated.
Called upon a successful scan operation
scanError(int errorCode, String message)

Deprecated.
Invoked if an error occurred during the scanning process

void

Method Detail
scanCompleted
void scanCompleted(String contents,
String formatName,
byte[] rawBytes)

Deprecated.
Called upon a successful scan operation
Parameters:
contents - the contents of the data
formatName - the format of the scan
rawBytes - the bytes of data
scanCanceled
void scanCanceled()

Deprecated.
Invoked if the user canceled the scan
scanError
void scanError(int errorCode,
String message)

Deprecated.
Invoked if an error occurred during the scanning process
Parameters:
errorCode - code
message - descriptive message

Interface ScanResult

2696

Overview (Codename One API)


com.codename1.codescan

Class CodeScanner
java.lang.Object

com.codename1.codescan.CodeScanner

Deprecated.
Use the cn1-codescanner cn1lib.
public abstract class
extends Object

Deprecated!!: Please use the cn1-codescan library instead.


A barcode/qrcode scanner API, this class is a singleton, notice that this API might not be implemented
for all platforms in which case the getInstance() method will return null!

Constructor Summary
Constructor and Description
CodeScanner()

Deprecated.

Method Summary
Modifier and
Type

Method and Description


getInstance()

static
CodeScanner

Deprecated.
Returns the instance of the code scanner, notice that this method is
equivalent to Display.getInstance().getCodeScanner().
scanBarCode(ScanResult callback)

abstract void

Deprecated.
Scans based on the settings in this class and returns the results
scanQRCode(ScanResult callback)

abstract void

Deprecated.
Scans based on the settings in this class and returns the results

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CodeScanner
public CodeScanner()

Deprecated.

Method Detail

Method Detail

2697

Overview (Codename One API)


getInstance
public static CodeScanner getInstance()

Deprecated.
Returns the instance of the code scanner, notice that this method is equivalent to
Display.getInstance().getCodeScanner().
Returns:
instance of the code scanner
scanQRCode
public abstract void scanQRCode(ScanResult callback)

Deprecated.
Scans based on the settings in this class and returns the results
Parameters:
callback - scan results
scanBarCode
public abstract void scanBarCode(ScanResult callback)

Deprecated.
Scans based on the settings in this class and returns the results
Parameters:
callback - scan results

Method Detail

2698

Overview (Codename One API)


com.codename1.cloud

Interface CustomProperty
All Known Implementing Classes:
CloudImageProperty
Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public interface

Allows adding a custom property to cloud objects, this effectively allows to simulate missing properties
or create properties that don't represent a database entry (e.g. fullName which can be comprised of
joining the firstname and surname together).
Important: The custom property only takes effect if there is no value assigned to the given property!

Method Summary
Modifier and Type

Method and Description


propertyValue(CloudObject obj, String propertyName)

Deprecated.
Returns a property value for the given property name

Object

Method Detail
propertyValue
Object propertyValue(CloudObject obj,
String propertyName)

Deprecated.
Returns a property value for the given property name
Parameters:
obj - the cloud object
propertyName - the name of the property
Returns:
the property value

Interface CustomProperty

2699

Overview (Codename One API)


com.codename1.cloud

Class CloudStorage
java.lang.Object

com.codename1.cloud.CloudStorage

Deprecated.
this API is targeted for removal due to changes in Google App Engine API support
public class
extends Object

The cloud storage class allows developers to use the Codename One cloud based storage API as a
shared database for your application. The database will be visible only to a specific application (based
on author/package definitions).
The calls to this class only become effective as a single batch when commit is sent. The commit can
be synchronous or asynchronous.
Important due to the nature of the underlying object data store queries can only be performed against
an indexed field of which there are 10 hardcoded indexes! Basic data is case sensitive and
queries/sort will be performed in a case sensitive way! In order to work around this create a property
with an identical name that contains the field as lower or upper case in order to query/sort against.

Field Summary
Modifier and
Type

Field and Description


RETURN_CODE_EMPTY_QUEUE

static int

Deprecated.
Return code for methods in this class indicating an empty queue
RETURN_CODE_FAIL_OBJECT_MODIFIED

static int

Deprecated.
Return code for methods in this class indicating a failure due to server side
modification of an object (e.g.
RETURN_CODE_FAIL_PERMISSION_VIOLATION

static int

Deprecated.
Return code for methods in this class indicating a failure due to exceeding
server storage quotas
RETURN_CODE_FAIL_QUOTA_EXCEEDED

static int

Deprecated.
Return code for methods in this class indicating a failure due to exceeding
server storage quotas
RETURN_CODE_FAIL_SERVER_ERROR

static int

Deprecated.
Return code for methods in this class indicating a failure due to generic
server side error
RETURN_CODE_SUCCESS

static int

Deprecated.
Return code for methods in this class indicating a successful operation

Method Summary
Modifier and
Type

Method and Description


commit()

int

Method Detail

Deprecated.
Commit works synchronously and returns one of the return codes above to
indicate the status.

2700

Overview (Codename One API)


commit(CloudResponse<Integer> response)
void

Deprecated.
A commit version that works asynchronously and returns one of the return
codes above to indicate the status.
delete(CloudObject cl)

void

void

Deprecated.
Deletes the following object from the cloud storage upon commit
deleteAllCloudFilesBefore(long timestamp, String developerAccount,
String developerPassword)

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection
deleteAllCloudFilesForUser()

void

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection
deleteCloudFile(String fileId)

boolean

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection
fetch(String[] cloudIds)

CloudObject[]

Deprecated.
Fetches the objects from the server.
fetch(String[] cloudIds, CloudResponse<CloudObject[]> response)

void

Deprecated.
Fetches the objects from the server asynchronously.
getInstance()

static
CloudStorage

Deprecated.
Creates an instance of the cloud storage object, only one instance should
be used per application.
getUrlForCloudFileId(String fileId)

String

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection
queryEquals(String type, int index, String value, int page,
int limit, int visibilityScope)

CloudObject[]

Deprecated.
Performs a query to the server finding the objects where the key value is
equal to the given value.
queryEquals(String type, int index, String value, int page,
int limit, int visibilityScope,
CloudResponse<CloudObject[]> response)

void

Deprecated.
Performs a query to the server finding the objects where the key value is
equal to the given value.
queryEqualsCount(String type, int index, String value,
int visibilityScope)

int

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
queryEqualsCount(String type, int index, String value,
int visibilityScope, CloudResponse<Integer> response)

void

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
queryEqualsKeys(String type, int index, String value, int page,
int limit, int visibilityScope)

String[]

Deprecated.
Equivalent to the standard query but just returns the keys matching the
given query
queryEqualsKeys(String type, int index, String value, int page,
int limit, int visibilityScope, CloudResponse<String[]> response)

void

Deprecated.
Equivalent to the standard query but just returns the keys matching the
given query

CloudObject[]

queryGreaterThan(String type, int index, String value, int page,


int limit, int visibilityScope)

Method Summary

2701

Overview (Codename One API)


Deprecated.
Performs a query to the server finding the objects where the key value is
greater than the given value.
queryGreaterThan(String type, int index, String value, int page,
int limit, int visibilityScope,
CloudResponse<CloudObject[]> response)
void

Deprecated.
Performs a query to the server finding the objects where the key value is
greater than the given value.
queryGreaterThanCount(String type, int index, String value,
int visibilityScope)

int

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
queryGreaterThanCount(String type, int index, String value,
int visibilityScope, CloudResponse<Integer> response)

void

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
queryLessThan(String type, int index, String value, int page,
int limit, int visibilityScope)

CloudObject[]

Deprecated.
Performs a query to the server finding the objects where the key value is
smaller than the given value.
queryLessThan(String type, int index, String value, int page,
int limit, int visibilityScope,
CloudResponse<CloudObject[]> response)

void

Deprecated.
Performs a query to the server finding the objects where the key value is
smaller than the given value.
queryLessThanCount(String type, int index, String value,
int visibilityScope)

int

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
queryLessThanCount(String type, int index, String value,
int visibilityScope, CloudResponse<Integer> response)

void

Deprecated.
Equivalent to the standard query but just returns the total count of entries
that will be returned
querySorted(String type, int index, boolean ascending, int page,
int limit, int visibilityScope)

CloudObject[]

Deprecated.
Performs a query to the server finding the objects where the sort is equal
to the given value.
querySorted(String type, int index, boolean ascending, int page,
int limit, int visibilityScope,
CloudResponse<CloudObject[]> response)

void

Deprecated.
Performs a query to the server finding the objects where the sort is equal
to the given value.
querySortedKeys(String type, int index, boolean ascending,
int page, int limit, int visibilityScope)

String[]

Deprecated.
Performs a query to the server finding the objects where the sort is equal
to the given value and returning the cloud key of these objects.
querySortedKeys(String type, int index, boolean ascending,
int page, int limit, int visibilityScope,
CloudResponse<String[]> response)

void

Deprecated.
Performs a query to the server finding the objects where the sort is equal
to the given value and returning the cloud key of these objects.

int

refresh(CloudObject[] objects)

Deprecated.

Method Summary

2702

Overview (Codename One API)


Refresh the given objects with data from the server if they were modified
on the server.
refresh(CloudObject[] objects, CloudResponse<Integer> response)

Deprecated.
Refresh the given objects with data from the server if they were modified
on the server (this is the asynchronous version of the method).

void

refreshAsync(CloudObject obj)

Deprecated.
Adds the given object to a set of refresh operations in which we don't
really care if the operation is successful

void

rollback()

Deprecated.
Cancels current pending changes

void

save(CloudObject object)

Deprecated.
Adds the given object to the save queue, the operation will only take place
once committed

void

uploadCloudFile(String mimeType, String file)

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection

String

uploadCloudFile(String mimeType, String filename,


InputStream data, int dataSize)

String

Deprecated.
this API is currently deprecated due to Googles cloud storage deprection

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
RETURN_CODE_SUCCESS
public static final int RETURN_CODE_SUCCESS

Deprecated.
Return code for methods in this class indicating a successful operation
See Also:
Constant Field Values
RETURN_CODE_FAIL_OBJECT_MODIFIED
public static final int RETURN_CODE_FAIL_OBJECT_MODIFIED

Deprecated.
Return code for methods in this class indicating a failure due to server side
modification of an object (e.g. different user changed the object)
See Also:
Constant Field Values
RETURN_CODE_FAIL_SERVER_ERROR
public static final int RETURN_CODE_FAIL_SERVER_ERROR

Deprecated.
Return code for methods in this class indicating a failure due to generic server side
error
See Also:
Constant Field Values
RETURN_CODE_FAIL_QUOTA_EXCEEDED
public static final int RETURN_CODE_FAIL_QUOTA_EXCEEDED

Deprecated.

Methods inherited from class java.lang.Object

2703

Overview (Codename One API)


Return code for methods in this class indicating a failure due to exceeding server
storage quotas
See Also:
Constant Field Values
RETURN_CODE_EMPTY_QUEUE
public static final int RETURN_CODE_EMPTY_QUEUE

Deprecated.
Return code for methods in this class indicating an empty queue
See Also:
Constant Field Values
RETURN_CODE_FAIL_PERMISSION_VIOLATION
public static final int RETURN_CODE_FAIL_PERMISSION_VIOLATION

Deprecated.
Return code for methods in this class indicating a failure due to exceeding server
storage quotas
See Also:
Constant Field Values

Method Detail
getInstance
public static CloudStorage getInstance()

Deprecated.
Creates an instance of the cloud storage object, only one instance should be used
per application. This method is important since it may block to complete/cleanup a
previous transaction that wasn't fully completed before exiting the application.
Returns:
the instance of the class
save
public void save(CloudObject object)

Deprecated.
Adds the given object to the save queue, the operation will only take place once
committed
Parameters:
object - the object to save into the cloud, new objects are inserted. existing
objects are updated
delete
public void delete(CloudObject cl)

Deprecated.
Deletes the following object from the cloud storage upon commit
Parameters:
cl - the cloud object to delete
refresh
public void refresh(CloudObject[] objects,
CloudResponse<Integer> response)

Deprecated.
Refresh the given objects with data from the server if they were modified on the
server (this is the asynchronous version of the method). This operation executes
immeditely without waiting for commit.
Parameters:
objects - objects to refresh
response - object for the response

Field Detail

2704

Overview (Codename One API)


refreshAsync
public void refreshAsync(CloudObject obj)

Deprecated.
Adds the given object to a set of refresh operations in which we don't really care if the
operation is successful
Parameters:
obj - the object to refresh
refresh
public int refresh(CloudObject[] objects)

Deprecated.
Refresh the given objects with data from the server if they were modified on the
server. This operation executes immeditely without waiting for commit.
Parameters:
objects - objects to refresh
Returns:
status code matching the situation, one of: RETURN_CODE_SUCCESS,
RETURN_CODE_FAIL_SERVER_ERROR
fetch
public CloudObject[] fetch(String[] cloudIds)
throws CloudException

Deprecated.
Fetches the objects from the server. This operation executes immeditely without
waiting for commit.
Parameters:
cloudIds - the object id's to fetch
Returns:
the cloud objects or null if a server error occurred
Throws:
CloudException - thrown for a server side/connection error
fetch
public void fetch(String[] cloudIds,
CloudResponse<CloudObject[]> response)

Deprecated.
Fetches the objects from the server asynchronously. This operation executes
immeditely without waiting for commit.
Parameters:
cloudIds - the object id's to fetch
response - returns the response from the server
queryEquals
public CloudObject[] queryEquals(String type,
int index,
String value,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Performs a query to the server finding the objects where the key value is equal to the
given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:

Method Detail

2705

Overview (Codename One API)


array of objects matching the query
Throws:
CloudException

- thrown for a server side/connection error

querySorted
public CloudObject[] querySorted(String type,
int index,
boolean ascending,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Performs a query to the server finding the objects where the sort is equal to the given
value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index on which the sort is based
ascending - indicates if the sort order is ascending or descending
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
array of objects matching the query
Throws:
CloudException - thrown for a server side/connection error
querySortedKeys
public String[] querySortedKeys(String type,
int index,
boolean ascending,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Performs a query to the server finding the objects where the sort is equal to the given
value and returning the cloud key of these objects. This operation executes
immeditely without waiting for commit.
Parameters:
type - the object type
index - the index on which the sort is based
ascending - indicates if the sort order is ascending or descending
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
the keys for the cloud objects matching the query
Throws:
CloudException - thrown for a server side/connection error
queryEqualsKeys
public String[] queryEqualsKeys(String type,
int index,
String value,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Equivalent to the standard query but just returns the keys matching the given query
Parameters:
type - the object type
index - the index to query for the given value

Method Detail

2706

Overview (Codename One API)


value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of

the

CloudObject constants ACCESS_*


Returns:
the keys for the cloud objects matching the query
Throws:
CloudException - thrown for a server side/connection error
queryEqualsCount
public int queryEqualsCount(String type,
int index,
String value,
int visibilityScope)
throws CloudException

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
the number of elements
Throws:
CloudException - thrown for a server side/connection error
queryGreaterThanCount
public int queryGreaterThanCount(String type,
int index,
String value,
int visibilityScope)
throws CloudException

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
the number of elements
Throws:
CloudException - thrown for a server side/connection error
queryLessThanCount
public int queryLessThanCount(String type,
int index,
String value,
int visibilityScope)
throws CloudException

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*

Method Detail

2707

Overview (Codename One API)


Returns:
the number of elements
Throws:
CloudException - thrown for a server side/connection error
queryGreaterThan
public CloudObject[] queryGreaterThan(String type,
int index,
String value,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Performs a query to the server finding the objects where the key value is greater than
the given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
array of objects matching the query
Throws:
CloudException - thrown for a server side/connection error
queryLessThan
public CloudObject[] queryLessThan(String type,
int index,
String value,
int page,
int limit,
int visibilityScope)
throws CloudException

Deprecated.
Performs a query to the server finding the objects where the key value is smaller than
the given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
Returns:
array of objects matching the query
Throws:
CloudException - thrown for a server side/connection error
querySorted
public void querySorted(String type,
int index,
boolean ascending,
int page,
int limit,
int visibilityScope,
CloudResponse<CloudObject[]> response)

Deprecated.
Performs a query to the server finding the objects where the sort is equal to the given
value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type

Method Detail

2708

Overview (Codename One API)


index - the index on which the sort is based
ascending - indicates if the sort order is ascending or descending
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the

CloudObject constants ACCESS_*


queryEquals
public void queryEquals(String type,
int index,
String value,
int page,
int limit,
int visibilityScope,
CloudResponse<CloudObject[]> response)

Deprecated.
Performs a query to the server finding the objects where the key value is equal to the
given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryEqualsCount
public void queryEqualsCount(String type,
int index,
String value,
int visibilityScope,
CloudResponse<Integer> response)

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryGreaterThanCount
public void queryGreaterThanCount(String type,
int index,
String value,
int visibilityScope,
CloudResponse<Integer> response)

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
querySortedKeys
public void querySortedKeys(String type,
int index,
boolean ascending,
int page,
int limit,
int visibilityScope,
CloudResponse<String[]> response)

Method Detail

2709

Overview (Codename One API)


Deprecated.
Performs a query to the server finding the objects where the sort is equal to the given
value and returning the cloud key of these objects. This operation executes
immeditely without waiting for commit.
Parameters:
type - the object type
index - the index on which the sort is based
ascending - indicates if the sort order is ascending or descending
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryEqualsKeys
public void queryEqualsKeys(String type,
int index,
String value,
int page,
int limit,
int visibilityScope,
CloudResponse<String[]> response)

Deprecated.
Equivalent to the standard query but just returns the keys matching the given query
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryLessThanCount
public void queryLessThanCount(String type,
int index,
String value,
int visibilityScope,
CloudResponse<Integer> response)

Deprecated.
Equivalent to the standard query but just returns the total count of entries that will be
returned
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryGreaterThan
public void queryGreaterThan(String type,
int index,
String value,
int page,
int limit,
int visibilityScope,
CloudResponse<CloudObject[]> response)

Deprecated.
Performs a query to the server finding the objects where the key value is greater than
the given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch

Method Detail

2710

Overview (Codename One API)


- indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
queryLessThan
visibilityScope

public void queryLessThan(String type,


int index,
String value,
int page,
int limit,
int visibilityScope,
CloudResponse<CloudObject[]> response)

Deprecated.
Performs a query to the server finding the objects where the key value is smaller than
the given value. This operation executes immeditely without waiting for commit.
Parameters:
type - the object type
index - the index to query for the given value
value - the value of said index to include in the response object
page - the page of responses (allows for paging)
limit - number of responses to fetch
visibilityScope - indicates the scope in which to look as one of the
CloudObject constants ACCESS_*
response - array of objects matching the query
uploadCloudFile
public String uploadCloudFile(String mimeType,
String file)
throws CloudException,
IOException

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Allows uploading of images etc. to the cloud which can later on be referenced as
URL's.
Parameters:
mimeType - the mimetype of the uploaded file
file - the URL of the local file
Returns:
an ID for the given file that can be used to delete the file or construct a URL
of the file
Throws:
CloudException - in case of a server side error
IOException - when a problem occurs with the file
uploadCloudFile
public String uploadCloudFile(String mimeType,
String filename,
InputStream data,
int dataSize)
throws CloudException,
IOException

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Allows uploading of images etc. to the cloud which can later on be referenced as
URL's.
Parameters:
mimeType - the mimetype of the uploaded file
filename - a short name for the file uploaded (not a full path)
data - input stream from which to read the file
dataSize - the size in bytes of the input stream (this is essential for file upload
to work on all devices!)
Returns:
an ID for the given file that can be used to delete the file or construct a URL
of the file
Throws:
CloudException - in case of a server side error
IOException - when a problem occurs with the file

Method Detail

2711

Overview (Codename One API)


deleteCloudFile
public boolean deleteCloudFile(String fileId)

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Deletes a file from the cloud storage
Parameters:
fileId - the file id to delete
Returns:
true if the operation was successful
deleteAllCloudFilesForUser
public void deleteAllCloudFilesForUser()

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Deletes all the cloud files under this user, notice that this method is asynchronous
and a background server process performs the actual deletion
deleteAllCloudFilesBefore
public void deleteAllCloudFilesBefore(long timestamp,
String developerAccount,
String developerPassword)

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Deletes all the cloud files before the given time stamp for the given development
account. Notice that this method is meant for internal use and not for distributable
apps since it includes your developer account. This method works in a background
server process and returns immediately.
Parameters:
timestamp - the timestamp since epoch (as in System.currentTimemillis).
developerAccount - your developer email
developerPassword - your developer password
getUrlForCloudFileId
public String getUrlForCloudFileId(String fileId)

Deprecated. this API is currently deprecated due to Googles cloud storage deprection
Converts a file id to a URL with which the file can be downloaded, notice that the file
URL is world readable!
Parameters:
fileId - the file ID
Returns:
a URL that allows downloading the file
commit
public int commit()

Deprecated.
Commit works synchronously and returns one of the return codes above to indicate
the status.
Returns:
status code from the constants in this class
commit
public void commit(CloudResponse<Integer> response)

Deprecated.
A commit version that works asynchronously and returns one of the return codes
above to indicate the status.
Parameters:
response - response code with status code from the constants in this class
rollback
public void rollback()

Deprecated.
Cancels current pending changes

Method Detail

2712

Overview (Codename One API)


com.codename1.cloud

Interface CloudResponse<T>

Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public interface

Used as a callback for the asynchronous version of the cloud storage API, these methods are invoked
on the EDT!

Method Summary
Modifier and Type

Method and Description


onError(CloudException err)

Deprecated.
Invoked if there was a server error

void

onSuccess(T returnValue)

Deprecated.
Invoked to return a value from the asynchronous version of the API

void

Method Detail

onSuccess
void onSuccess(T returnValue)

Deprecated.
Invoked to return a value from the asynchronous version of the API
Parameters:
returnValue - the return value of the metho
onError
void onError(CloudException err)

Deprecated.
Invoked if there was a server error
Parameters:
err - the exception containing the error details

Interface CloudResponse<T>

2713

Overview (Codename One API)


com.codename1.cloud

Class CloudPersona
java.lang.Object

com.codename1.cloud.CloudPersona

Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public class
extends Object

A persona represents a user of the cloud, this is an optional feature that allows data to be limited to a
specific user on the server side.

Method Summary
Modifier and
Type

Method and Description


createAnonymous()

static boolean

Deprecated.
Creates an anonymous persona that will be unique in the cloud, NEVER
logout an anonymous user!
createFromToken(String token)

static void

Deprecated.
Initializes the persona based on a token, since this method assumes binary
transfer of a completed token the token isn't verified in any way and the
user is considered logged in.
createOrLogin(String login, String password)

static boolean

Deprecated.
Creates a new user if a user isn't occupying the given login already, if the
user exists performs a login operation.
getCurrentPersona()

static
CloudPersona

Deprecated.
This method returns the currently logged in persona or a blank persona
(token would be null)
getToken()

Deprecated.
Returns a unique login token that represents the current user and his
password, while this login token shouldn't be user visible (it's a password
too!) it can be transfered to a different device to give them both identical
user role and joined access.

String

logout()

Deprecated.
Logs out the current user, notice that with an anonymous user this will
effectively KILL all the data in the cloud!

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

Method Detail

2714

Overview (Codename One API)


getCurrentPersona
public static CloudPersona getCurrentPersona()

Deprecated.
This method returns the currently logged in persona or a blank persona (token would
be null)
Returns:
the current persona
getToken
public String getToken()

Deprecated.
Returns a unique login token that represents the current user and his password, while
this login token shouldn't be user visible (it's a password too!) it can be transfered to a
different device to give them both identical user role and joined access.
Returns:
a persona UID
createFromToken
public static void createFromToken(String token)

Deprecated.
Initializes the persona based on a token, since this method assumes binary transfer
of a completed token the token isn't verified in any way and the user is considered
logged in.
Parameters:
token - the token
createAnonymous
public static boolean createAnonymous()

Deprecated.
Creates an anonymous persona that will be unique in the cloud, NEVER logout an
anonymous user!
Returns:
false in case login failed e.g. due to bad network connection
createOrLogin
public static boolean createOrLogin(String login,
String password)

Deprecated.
Creates a new user if a user isn't occupying the given login already, if the user exists
performs a login operation.
Parameters:
login - a user name
password - a password
Returns:
true if the login is successful false otherwise
logout
public void logout()

Deprecated.
Logs out the current user, notice that with an anonymous user this will effectively
KILL all the data in the cloud!

Method Detail

2715

Overview (Codename One API)


com.codename1.cloud

Class CloudObject
java.lang.Object

com.codename1.cloud.CloudObject
All Implemented Interfaces:
Externalizable
Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public final class
extends Object
implements Externalizable

A cloud object can be persisted to the cloud or locally it is a set of key/value pairs that can be either
strings or numbers. There is a 512 character limit on string length! Notice: keys starting with CN1 are
reserved for internal usage!

Field Summary
Modifier
and Type

Field and Description


ACCESS_APPLICATION

static int

Deprecated.
An application visible/modifiable object!
ACCESS_APPLICATION_READ_ONLY

static int

Deprecated.
An application scope readable object! Can only be modified by its creator
ACCESS_PRIVATE

static int

Deprecated.
An object that can only be viewed or modified by its creator
ACCESS_PUBLIC

static int

Deprecated.
A world visible/modifiable object!
ACCESS_PUBLIC_READ_ONLY

static int

Deprecated.
A world visible object! Can only be modified by its creator.
BINDING_AUTO_SAVE

static int

Deprecated.
Changes to the bound property will be reflected instantly into the cloud object
and the object would be saved immediately (not committed!).
BINDING_DEFERRED

static int

Deprecated.
Changes to the bound property won't be reflected into the bound cloud object
until commit binding is invoked
BINDING_IMMEDIATE

static int

Deprecated.
Changes to the bound property will be reflected instantly into the cloud object
STATUS_COMMIT_IN_PROGRESS

static int

Deprecated.
Indicates the state of the current object, an object in the process of committing
STATUS_COMMITTED

static int

static int

Class CloudObject

Deprecated.
Indicates the state of the current object, an object that is in sync with the
database as far as the client code is aware (the client code doesn't check!)
STATUS_DELETE_IN_PROGRESS

2716

Overview (Codename One API)


Deprecated.
Indicates the state of the current object, an object that is in the process of
deletion
STATUS_DELETED

Deprecated.
Indicates the state of the current object, a deleted object

static int

STATUS_MODIFIED

Deprecated.
Indicates the state of the current object, a locally modified object that wasn't
committed yet

static int

STATUS_NEW

Deprecated.
Indicates the state of the current object, a new object never persisted

static int

STATUS_REFRESH_IN_PROGRESS

Deprecated.
Indicates the state of the current object, an object in the process of refresh

static int

Constructor Summary
Constructor and Description
CloudObject()

Deprecated.
Default constructor for externalization purposes only!
CloudObject(String type)

Deprecated.
Constructor
CloudObject(String type, int permissions)

Deprecated.
Create an object with different permissions settings

Method Summary
Modifier
and Type

Method and Description


bindProperty(Component cmp, String propertyName, String attributeName,
int defer, boolean objectLead)

void

Deprecated.
Binds a property value within the given component to this cloud object, this
means that when the component changes the cloud object changes unless
deferred.
bindTree(Container ui, int defer, boolean objectLead)

void

Deprecated.
Binds a UI tree to the cloud object so its values automatically update in the
cloud object
cancelBinding()

void

Deprecated.
If deferred changes exist this method discards such values
commitBinding()

void

Deprecated.
If deferred changes exist this method applies these changes to the data
equals(Object o)

boolean

Deprecated.
Indicates whether some other object is "equal to" this one.
externalize(DataOutputStream out)

void

int

Field Summary

Deprecated.
Allows us to store an object state, this method must be implemented in order to
save the state of an object
getAccessPermissions()

2717

Overview (Codename One API)


Deprecated.
The access permissions for an object can only be changed for an object in
which the current user is the owner
getBoolean(String key)
Boolean

Deprecated.
Returns the value for the given key
getCloudId()

String

Deprecated.
The object id is a unique key that allows you to find an object that was persisted
in the store (a primary key).
getDouble(String key)

Double

Deprecated.
Returns the value for the given key
getFloat(String key)

Float

Deprecated.
Returns the value for the given key
getIndexDouble(int index)

Double

Deprecated.
Returns the index value for the given index number
getIndexLong(int index)

Long

Deprecated.
Returns the index value for the given index number
getIndexString(int index)

String

Deprecated.
Returns the index value for the given index number
getInteger(String key)

Integer

Deprecated.
Returns the value for the given key
getLastModified()

long

Deprecated.
Indicates the last modification date for the object
getLong(String key)

Long

Deprecated.
Returns the value for the given key
getObject(String key)

Object

Deprecated.
Allows us to extract an object from the cloud object without knowing its type in
advance or whether it exists
getObjectId()

String

Deprecated.
The object id must be unique, it is used to identify the object when loaded even
when it is obfuscated.
getStatus()

int

Deprecated.
Returns one of the status constants in this class
getString(String key)

String

Deprecated.
Returns the value for the given key
getType()

String

Deprecated.
Returns the type of the object
getVersion()

int

Deprecated.
Returns the version for the current persistance code, the version will be pased
to internalized thus allowing the internalize method to recognize classes
persisted in older revisions
hashCode()

int

Deprecated.
Returns a hash code value for the object.

void

internalize(int version, DataInputStream in)

Method Summary

2718

Overview (Codename One API)


Deprecated.
Loads the object from the input stream and allows deserialization
isOwner()
boolean

Deprecated.
Returns true if this object is owned by me or is world writeable
remove(String key)

void

Deprecated.
Delete an entry within the object
setBoolean(String key, boolean value)

void

Deprecated.
Sets a value
setBoolean(String key, Boolean value)

void

static
void

Deprecated.
Sets a value
setCustomProperty(String key, CustomProperty cp)

Deprecated.
Install a custom property on the given property name
setDouble(String key, double value)

void

Deprecated.
Sets a value
setDouble(String key, Double value)

void

Deprecated.
Sets a value
setFloat(String key, float value)

void

Deprecated.
Sets a value
setFloat(String key, Float value)

void

Deprecated.
Sets a value
setIndexDouble(int index, double value)

void

Deprecated.
Only indexed values can be queried and sorted
setIndexLong(int index, long value)

void

Deprecated.
Only indexed values can be queried and sorted
setIndexString(int index, String value)

void

Deprecated.
Only indexed values can be queried and sorted
setInteger(String key, int value)

void

Deprecated.
Sets a value
setInteger(String key, Integer value)

void

Deprecated.
Sets a value
setLong(String key, long value)

void

Deprecated.
Sets a value
setLong(String key, Long value)

void

Deprecated.
Sets a value
setString(String key, String value)

void

Deprecated.
Sets a value that can be no more than 512 characters
setType(String type)

void

Deprecated.
Set the type of the object
unbindProperty(Component cmp, String propertyName)

void

Deprecated.
Releases the binding for the specific property name

void

unbindTree(Container ui)

Method Summary

2719

Overview (Codename One API)


Deprecated.
Clears the binding to this component tree

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Field Detail
STATUS_NEW
public static final int STATUS_NEW

Deprecated.
Indicates the state of the current object, a new object never persisted
See Also:
Constant Field Values
STATUS_COMMITTED
public static final int STATUS_COMMITTED

Deprecated.
Indicates the state of the current object, an object that is in sync with the database as
far as the client code is aware (the client code doesn't check!)
See Also:
Constant Field Values
STATUS_MODIFIED
public static final int STATUS_MODIFIED

Deprecated.
Indicates the state of the current object, a locally modified object that wasn't
committed yet
See Also:
Constant Field Values
STATUS_COMMIT_IN_PROGRESS
public static final int STATUS_COMMIT_IN_PROGRESS

Deprecated.
Indicates the state of the current object, an object in the process of committing
See Also:
Constant Field Values
STATUS_DELETE_IN_PROGRESS
public static final int STATUS_DELETE_IN_PROGRESS

Deprecated.
Indicates the state of the current object, an object that is in the process of deletion
See Also:
Constant Field Values
STATUS_DELETED
public static final int STATUS_DELETED

Deprecated.
Indicates the state of the current object, a deleted object
See Also:
Constant Field Values
STATUS_REFRESH_IN_PROGRESS
public static final int STATUS_REFRESH_IN_PROGRESS

Deprecated.

Methods inherited from class java.lang.Object

2720

Overview (Codename One API)


Indicates the state of the current object, an object in the process of refresh
See Also:
Constant Field Values
ACCESS_PUBLIC
public static final int ACCESS_PUBLIC

Deprecated.
A world visible/modifiable object!
See Also:
Constant Field Values
ACCESS_PUBLIC_READ_ONLY
public static final int ACCESS_PUBLIC_READ_ONLY

Deprecated.
A world visible object! Can only be modified by its creator.
See Also:
Constant Field Values
ACCESS_APPLICATION
public static final int ACCESS_APPLICATION

Deprecated.
An application visible/modifiable object!
See Also:
Constant Field Values
ACCESS_APPLICATION_READ_ONLY
public static final int ACCESS_APPLICATION_READ_ONLY

Deprecated.
An application scope readable object! Can only be modified by its creator
See Also:
Constant Field Values
ACCESS_PRIVATE
public static final int ACCESS_PRIVATE

Deprecated.
An object that can only be viewed or modified by its creator
See Also:
Constant Field Values
BINDING_DEFERRED
public static final int BINDING_DEFERRED

Deprecated.
Changes to the bound property won't be reflected into the bound cloud object until
commit binding is invoked
See Also:
Constant Field Values
BINDING_IMMEDIATE
public static final int BINDING_IMMEDIATE

Deprecated.
Changes to the bound property will be reflected instantly into the cloud object
See Also:
Constant Field Values
BINDING_AUTO_SAVE
public static final int BINDING_AUTO_SAVE

Deprecated.
Changes to the bound property will be reflected instantly into the cloud object and the
object would be saved immediately (not committed!).

Field Detail

2721

Overview (Codename One API)


See Also:
Constant Field Values

Constructor Detail
CloudObject
public CloudObject()

Deprecated.
Default constructor for externalization purposes only!
CloudObject
public CloudObject(String type)

Deprecated.
Constructor
Parameters:
type - the type of the object
CloudObject
public CloudObject(String type,
int permissions)

Deprecated.
Create an object with different permissions settings
Parameters:
type - the type of the object
permissions - one of the ACCESS_* values

Method Detail
getStatus
public int getStatus()

Deprecated.
Returns one of the status constants in this class
Returns:
the status of the object against the cloud
setType
public void setType(String type)

Deprecated.
Set the type of the object
Parameters:
type - the type of the field
getType
public String getType()

Deprecated.
Returns the type of the object
Returns:
the type of the object
setIndexString
public void setIndexString(int index,
String value)

Deprecated.
Only indexed values can be queried and sorted
Parameters:
index - the index which must be a value between 1 and 10.

Constructor Detail

2722

Overview (Codename One API)


value - the value for the given index
getIndexString
public String getIndexString(int index)

Deprecated.
Returns the index value for the given index number
Parameters:
index - the index number
Returns:
the value of this entry for that index as a String
setIndexLong
public void setIndexLong(int index,
long value)

Deprecated.
Only indexed values can be queried and sorted
Parameters:
index - the index which must be a value between 1 and 10.
value - the value for the given index
getIndexLong
public Long getIndexLong(int index)

Deprecated.
Returns the index value for the given index number
Parameters:
index - the index number
Returns:
the value of this entry for that index as a Long value
setIndexDouble
public void setIndexDouble(int index,
double value)

Deprecated.
Only indexed values can be queried and sorted
Parameters:
index - the index which must be a value between 1 and 10.
value - the value for the given index
getIndexDouble
public Double getIndexDouble(int index)

Deprecated.
Returns the index value for the given index number
Parameters:
index - the index number
Returns:
the value of this entry for that index as a Double value
isOwner
public boolean isOwner()

Deprecated.
Returns true if this object is owned by me or is world writeable
Returns:
ownership status
getCloudId
public String getCloudId()

Deprecated.
The object id is a unique key that allows you to find an object that was persisted in
the store (a primary key). When it is null the object is effectively unsynchronized!
Returns:

Method Detail

2723

Overview (Codename One API)


the object id or null for an object that isn't fully persisted yet
getLastModified
public long getLastModified()

Deprecated.
Indicates the last modification date for the object
Returns:
the last modification date
getObject
public Object getObject(String key)

Deprecated.
Allows us to extract an object from the cloud object without knowing its type in
advance or whether it exists
Parameters:
key - the key for the object
Returns:
the value of the object
setCustomProperty
public static void setCustomProperty(String key,
CustomProperty cp)

Deprecated.
Install a custom property on the given property name
Parameters:
key - the key on which to install the custom property
cp - the custom property implementation
setString
public void setString(String key,
String value)

Deprecated.
Sets a value that can be no more than 512 characters
Parameters:
key - the key for the given value
value - the value
getString
public String getString(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a string value
remove
public void remove(String key)

Deprecated.
Delete an entry within the object
Parameters:
key - the key to remove from the object
setLong
public void setLong(String key,
long value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value

Method Detail

2724

Overview (Codename One API)


value

- the value

setLong
public void setLong(String key,
Long value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
getLong
public Long getLong(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a long value
setInteger
public void setInteger(String key,
int value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
setInteger
public void setInteger(String key,
Integer value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
getInteger
public Integer getInteger(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a value
setDouble
public void setDouble(String key,
double value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
setDouble
public void setDouble(String key,
Double value)

Deprecated.
Sets a value

Method Detail

2725

Overview (Codename One API)


Parameters:
key - the key for the given value
value - the value
getDouble
public Double getDouble(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a value
setFloat
public void setFloat(String key,
float value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
setFloat
public void setFloat(String key,
Float value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
getFloat
public Float getFloat(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a value
setBoolean
public void setBoolean(String key,
boolean value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value
setBoolean
public void setBoolean(String key,
Boolean value)

Deprecated.
Sets a value
Parameters:
key - the key for the given value
value - the value

Method Detail

2726

Overview (Codename One API)


getBoolean
public Boolean getBoolean(String key)

Deprecated.
Returns the value for the given key
Parameters:
key - the key
Returns:
a value
getVersion
public int getVersion()

Deprecated.
Returns the version for the current persistance code, the version will be pased to
internalized thus allowing the internalize method to recognize classes persisted in
older revisions
Specified by:
getVersion in interface Externalizable
Returns:
version number for the persistant code
externalize
public void externalize(DataOutputStream out)
throws IOException

Deprecated.
Allows us to store an object state, this method must be implemented in order to save
the state of an object
Specified by:
externalize in interface Externalizable
Parameters:
out - the stream into which the object must be serialized
Throws:
IOException - the method may throw an exception
getObjectId
public String getObjectId()

Deprecated.
Description copied from interface: Externalizable
The object id must be unique, it is used to identify the object when loaded even when
it is obfuscated.
Specified by:
getObjectId in interface Externalizable
Returns:
a unique id
internalize
public void internalize(int version,
DataInputStream in)
throws IOException

Deprecated.
Loads the object from the input stream and allows deserialization
Specified by:
internalize in interface Externalizable
Parameters:
version - the version the class returned during the externalization processs
in - the input stream used to load the class
Throws:
IOException - the method may throw an exception

Method Detail

2727

Overview (Codename One API)


getAccessPermissions
public int getAccessPermissions()

Deprecated.
The access permissions for an object can only be changed for an object in which the
current user is the owner
Returns:
the accessPermissions
equals
public boolean equals(Object o)

Deprecated.
Indicates whether some other object is "equal to" this one. The equals method
implements an equivalence relation: It is reflexive: for any reference value x,
x.equals(x) should return true. It is symmetric: for any reference values x and y,
x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for
any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns
true, then x.equals(z) should return true. It is consistent: for any reference values x
and y, multiple invocations of x.equals(y) consistently return true or consistently
return false, provided no information used in equals comparisons on the object is
modified. For any non-null reference value x, x.equals(null) should return false. The
equals method for class Object implements the most discriminating possible
equivalence relation on objects; that is, for any reference values x and y, this method
returns true if and only if x and y refer to the same object (x==y has the value true).
Overrides:
equals in class Object
hashCode
public int hashCode()

Deprecated.
Returns a hash code value for the object. This method is supported for the benefit of
hashtables such as those provided by java.util.Hashtable. The general contract of
hashCode is: Whenever it is invoked on the same object more than once during an
execution of a Java application, the hashCode method must consistently return the
same integer, provided no information used in equals comparisons on the object is
modified. This integer need not remain consistent from one execution of an
application to another execution of the same application. If two objects are equal
according to the equals(Object) method, then calling the hashCode method on each
of the two objects must produce the same integer result. It is not required that if two
objects are unequal according to the equals(java.lang.Object) method, then calling
the hashCode method on each of the two objects must produce distinct integer
results. However, the programmer should be aware that producing distinct integer
results for unequal objects may improve the performance of hashtables. As much as
is reasonably practical, the hashCode method defined by class Object does return
distinct integers for distinct objects. (This is typically implemented by converting the
internal address of the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
Overrides:
hashCode in class Object
bindTree
public void bindTree(Container ui,
int defer,
boolean objectLead)

Deprecated.
Binds a UI tree to the cloud object so its values automatically update in the cloud
object
Parameters:
ui - the component tree to bind
defer - bind settings whether to defer the binding which requires developers
to explicitly commit the binding to perform the changes
objectLead - if set to true the UI property is initialized from values in the
CloudObject, if false the cloud object property is initialized from the UI

Method Detail

2728

Overview (Codename One API)


unbindTree
public void unbindTree(Container ui)

Deprecated.
Clears the binding to this component tree
Parameters:
ui - the container whose children might be bound
bindProperty
public void bindProperty(Component cmp,
String propertyName,
String attributeName,
int defer,
boolean objectLead)

Deprecated.
Binds a property value within the given component to this cloud object, this means
that when the component changes the cloud object changes unless deferred. If the
defer flag is false all changes are stored in a temporary location and only "committed"
once commitBindings() is invoked.
Parameters:
cmp - the component to bind
propertyName - the name of the property in the bound component
attributeName - the key within the cloud object
defer - bind settings whether to defer the binding which requires developers
to explicitly commit the binding to perform the changes
objectLead - if set to true the UI property is initialized from values in the
CloudObject, if false the cloud object property is initialized from the UI
unbindProperty
public void unbindProperty(Component cmp,
String propertyName)

Deprecated.
Releases the binding for the specific property name
Parameters:
cmp - the component
propertyName - the name of the property
commitBinding
public void commitBinding()

Deprecated.
If deferred changes exist this method applies these changes to the data
cancelBinding
public void cancelBinding()

Deprecated.
If deferred changes exist this method discards such values

Method Detail

2729

Overview (Codename One API)


com.codename1.cloud

Class CloudListModel
java.lang.Object

com.codename1.cloud.CloudListModel
All Implemented Interfaces:
ListModel
Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public class
extends Object
implements ListModel

Seamlessly creates a cloud based searchable list model

Constructor Summary
Constructor and Description
CloudListModel(String type, int visibilityScope, int sortProperty,
boolean ascending)

Deprecated.
Creates a list model that shows all the cloud elements that have the given key matching the
given value at the visibility scope listed bellow.
CloudListModel(String type, int visibilityScope, int index, String queryValue,
boolean ascending)

Deprecated.
Creates a list model that shows all the cloud elements that have the given key matching the
given value at the visibility scope listed bellow.

Method Summary
Modifier
and Type

Method and Description


addDataChangedListener(DataChangedListener l)

void

Deprecated.
Invoked to indicate interest in future change events
addItem(Object item)

void

Deprecated.
Notice this method does NOT commit the data, after committing the data the
cache MUST be cleared! Adds the specified item to the end of this list.
addSelectionListener(SelectionListener l)

void

Deprecated.
Invoked to indicate interest in future selection events
clearCache()

void

Deprecated.
Flushes the cache which might be essential when adding new elements
getBatchSize()

int

Deprecated.
Returns the batch size fetched from the server
getCacheSize()

int

Deprecated.
Returns the elements cached within the implementation

Object

getItemAt(int index)

Deprecated.

Class CloudListModel

2730

Overview (Codename One API)


Returns the item at the given offset
getLoadingPlaceholder()
Hashtable

Deprecated.
When loading the element from the cloud a placehold is shown to indicate to
the user that the content isn't fully here
getRefreshRateMillis()

Deprecated.
Indicates the rate in milliseconds in which to poll the server for the current data
of elements that are visible at the moment.

int

getSelectedIndex()

Deprecated.
Returns the selected list offset

int

getSize()

Deprecated.
Returns the number of items in the list

int

getStorageCacheSize()

Deprecated.
Returns the elements cached within the persistent storage

int

protected
void

onError(CloudException err)

Deprecated.
Invoked when a cloud error occurs
refresh()

Deprecated.
Refreshes the list from the server, this method blocks the EDT until completion.

void

removeDataChangedListener(DataChangedListener l)

Deprecated.
Invoked to indicate no further interest in future change events

void

removeItem(int index)

Deprecated.
Notice this method does NOT commit the data, after committing the data the
cache MUST be cleared! Removes the item at the specified position in this list.

void

removeSelectionListener(SelectionListener l)

Deprecated.
Invoked to indicate no further interest in future selection events

void

setBatchSize(int batchSize)

Deprecated.
Updates the number of elements fetched from the server in a single batch

void

setCacheSize(int elements)

Deprecated.
Sets the size of the local cache

void

setLoadingPlaceholder(Hashtable loadingPlaceholder)

Deprecated.
When loading the element from the cloud a placehold is shown to indicate to
the user that the content isn't fully here

void

setRefreshRateMillis(int refreshRateMillis)

Deprecated.
Indicates the rate in milliseconds in which to poll the server for the current data
of elements that are visible at the moment.

void

setSelectedIndex(int index)

Deprecated.
Sets the selected list offset can be set to -1 to clear selection

void

setStorageCacheSize(int elements)

Deprecated.
Sets the size of the cache in persistent storage

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Summary

2731

Overview (Codename One API)


Constructor

Detail

CloudListModel
public CloudListModel(String type,
int visibilityScope,
int sortProperty,
boolean ascending)

Deprecated.
Creates a list model that shows all the cloud elements that have the given key
matching the given value at the visibility scope listed bellow. This model can be
further narrowed down by using the filter functionality bellow.
This is effectively equivalent to issuing a queryEquals method, however it polls in
batches and caches data as needed.
Parameters:
type - the type of object shown on the list
visibilityScope - the scope of the list (CloudObject.ACCESS_* values)
sortProperty - the index by which we sort the entries, 0 for unsorted
ascending - whether the sort is ascending or descending
CloudListModel
public CloudListModel(String type,
int visibilityScope,
int index,
String queryValue,
boolean ascending)

Deprecated.
Creates a list model that shows all the cloud elements that have the given key
matching the given value at the visibility scope listed bellow. This model can be
further narrowed down by using the filter functionality bellow.
This is effectively equivalent to issuing a queryEquals method, however it polls in
batches and caches data as needed.
Parameters:
type - the type of object shown on the list
visibilityScope - the scope of the list (CloudObject.ACCESS_* values)
index - the index by which we limit the entries
queryValue - the queryValue for the given index
ascending - whether the sort is ascending or descending

Method Detail
refresh
public void refresh()

Deprecated.
Refreshes the list from the server, this method blocks the EDT until completion.
clearCache
public void clearCache()

Deprecated.
Flushes the cache which might be essential when adding new elements
setCacheSize
public void setCacheSize(int elements)

Deprecated.
Sets the size of the local cache
Parameters:
elements - elements to store in cache

Constructor Detail

2732

Overview (Codename One API)


getCacheSize
public int getCacheSize()

Deprecated.
Returns the elements cached within the implementation
Returns:
the cache size
setStorageCacheSize
public void setStorageCacheSize(int elements)

Deprecated.
Sets the size of the cache in persistent storage
Parameters:
elements - elements to store in cache
getStorageCacheSize
public int getStorageCacheSize()

Deprecated.
Returns the elements cached within the persistent storage
Returns:
the cache size
setLoadingPlaceholder
public void setLoadingPlaceholder(Hashtable loadingPlaceholder)

Deprecated.
When loading the element from the cloud a placehold is shown to indicate to the user
that the content isn't fully here
Parameters:
loadingPlaceholder - shows blank content to the user
getLoadingPlaceholder
public Hashtable getLoadingPlaceholder()

Deprecated.
When loading the element from the cloud a placehold is shown to indicate to the user
that the content isn't fully here
Returns:
the element shown when content isn't available for a specific entry
getBatchSize
public int getBatchSize()

Deprecated.
Returns the batch size fetched from the server
Returns:
the size
setBatchSize
public void setBatchSize(int batchSize)

Deprecated.
Updates the number of elements fetched from the server in a single batch
Parameters:
batchSize - the batch size
getItemAt
public Object getItemAt(int index)

Deprecated.
Returns the item at the given offset
Specified by:
getItemAt in interface ListModel
Parameters:

Method Detail

2733

Overview (Codename One API)


index - an index into this list
Returns:
the item at the specified index
getSize
public int getSize()

Deprecated.
Returns the number of items in the list
Specified by:
getSize in interface ListModel
Returns:
the number of items in the list
onError
protected void onError(CloudException err)

Deprecated.
Invoked when a cloud error occurs
Parameters:
err - the exception representing the error in cloud communications
getSelectedIndex
public int getSelectedIndex()

Deprecated.
Returns the selected list offset
Specified by:
getSelectedIndex in interface ListModel
Returns:
the selected list index
setSelectedIndex
public void setSelectedIndex(int index)

Deprecated.
Sets the selected list offset can be set to -1 to clear selection
Specified by:
setSelectedIndex in interface ListModel
Parameters:
index - an index into this list
addDataChangedListener
public void addDataChangedListener(DataChangedListener l)

Deprecated.
Invoked to indicate interest in future change events
Specified by:
addDataChangedListener in interface ListModel
Parameters:
l - a data changed listener
removeDataChangedListener
public void removeDataChangedListener(DataChangedListener l)

Deprecated.
Invoked to indicate no further interest in future change events
Specified by:
removeDataChangedListener in interface ListModel
Parameters:
l - a data changed listener
addSelectionListener
public void addSelectionListener(SelectionListener l)

Deprecated.
Invoked to indicate interest in future selection events

Method Detail

2734

Overview (Codename One API)

Specified by:
addSelectionListener

in interface ListModel

Parameters:
l - a selection listener
removeSelectionListener
public void removeSelectionListener(SelectionListener l)

Deprecated.
Invoked to indicate no further interest in future selection events
Specified by:
removeSelectionListener in interface ListModel
Parameters:
l - a selection listener
addItem
public void addItem(Object item)

Deprecated.
Notice this method does NOT commit the data, after committing the data the cache
MUST be cleared! Adds the specified item to the end of this list. An optional operation
for mutable lists, it can throw an unsupported operation exception if a list model is not
mutable.
Specified by:
addItem in interface ListModel
Parameters:
item - the item to be added
removeItem
public void removeItem(int index)

Deprecated.
Notice this method does NOT commit the data, after committing the data the cache
MUST be cleared! Removes the item at the specified position in this list.
Specified by:
removeItem in interface ListModel
Parameters:
index - the index of the item to removed
getRefreshRateMillis
public int getRefreshRateMillis()

Deprecated.
Indicates the rate in milliseconds in which to poll the server for the current data of
elements that are visible at the moment.
Returns:
the refreshRateMillis
setRefreshRateMillis
public void setRefreshRateMillis(int refreshRateMillis)

Deprecated.
Indicates the rate in milliseconds in which to poll the server for the current data of
elements that are visible at the moment.
Parameters:
refreshRateMillis - the refreshRateMillis to set

Method Detail

2735

Overview (Codename One API)


com.codename1.cloud

Class CloudImageProperty
java.lang.Object

com.codename1.cloud.CloudImageProperty
All Implemented Interfaces:
CustomProperty
Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public class
extends Object
implements CustomProperty

A custom property that converts a cloud file id value to an image that is cached locally
asynchronously.

Constructor Summary
Constructor and Description
CloudImageProperty(String idProperty, EncodedImage placeholderImage)

Deprecated.
Create an image property for the given id that will hold the place holder image while
downloading the actual image

Method Summary
Modifier and Type

Method and Description


propertyValue(CloudObject obj, String propertyName)

Deprecated.
Returns a property value for the given property name

Object

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CloudImageProperty
public CloudImageProperty(String idProperty,
EncodedImage placeholderImage)

Deprecated.
Create an image property for the given id that will hold the place holder image while
downloading the actual image
Parameters:
idProperty - the id
placeholderImage - placeholder shown while id is downloaded

Method Detail

Class CloudImageProperty

2736

Overview (Codename One API)


propertyValue
public Object propertyValue(CloudObject obj,
String propertyName)

Deprecated.
Returns a property value for the given property name
Specified by:
propertyValue in interface CustomProperty
Parameters:
obj - the cloud object
propertyName - the name of the property
Returns:
the property value

Method Detail

2737

Overview (Codename One API)


com.codename1.cloud

Class CloudException
java.lang.Object

java.lang.Throwable

java.lang.Exception

com.codename1.cloud.CloudException

Deprecated.
the cloud storage API is no longer supported, we recommend switching to a solution such as
parse4cn1
public class
extends Exception

Thrown in case of a server error or failure in connection

Method Summary
Modifier and
Type

Method and Description


getErrorCode()

Deprecated.
Returns the error code for the cloud exception, see the cloud storage for
return codes

int

Methods inherited from class java.lang.Throwable


addSuppressed, getMessage, initCause, printStackTrace, toString

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Method Detail
getErrorCode
public int getErrorCode()

Deprecated.
Returns the error code for the cloud exception, see the cloud storage for return codes
Returns:
the error code

Class CloudException

2738

Overview (Codename One API)


com.codename1.cloud

Interface BindTarget

public interface

Allows binding arbitrary components to data storage

Method Summary
Modifier and Type

Method and Description


propertyChanged(Component source, String propertyName,
Object oldValue, Object newValue)

void

Fired when a property of the component changes to a new value

Method Detail
propertyChanged
void propertyChanged(Component source,
String propertyName,
Object oldValue,
Object newValue)

Fired when a property of the component changes to a new value


Parameters:
source - the source component
propertyName - the name of the property
oldValue - the old value of the property
newValue - the new value for the property

Method Detail

2739

Overview (Codename One API)


com.codename1.charts.views

Class XYChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart
Direct Known Subclasses:
BarChart, BubbleChart, CombinedXYChart, LineChart, ScatterChart

public abstract class


extends AbstractChart

The XY chart rendering class.

Field Summary
Modifier and Type

Field and Description

protected XYMultipleSeriesDataset
protected XYMultipleSeriesRenderer

mDataset

The multiple series dataset.


mRenderer

The multiple series renderer.

Constructor Summary
Modifier

Constructor and Description

protected XYChart()
XYChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new XY chart instance.

Method Summary
Modifier and Type
protected abstract
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


void

draw(com.codename1.charts.compat.Canvas canvas, int x,


int y, int width, int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the XY chart.

protected void

drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series, XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint,
List<Float> points, int seriesIndex, int startIndex)

The graphical representation of the series values as text.

protected void

drawPoints(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer, float yAxisValue,
int seriesIndex, int startIndex)

Draws the series points.


abstract void

Method Detail

drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points, XYSeriesRenderer seriesRenderer,
float yAxisValue, int seriesIndex, int startIndex)

2740

Overview (Codename One API)


The graphical representation of a series.

protected void

drawSeries(XYSeries series,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer, float yAxisValue,
int seriesIndex,
XYMultipleSeriesRenderer.Orientation or,
int startIndex)

Draws the series.

protected void

protected void

drawText(com.codename1.charts.compat.Canvas canvas,
String text, float x, float y,
com.codename1.charts.compat.Paint paint,
float extraAngle)

The graphical representation of a text, to handle both


HORIZONTAL and VERTICAL orientations and extra rotation
angles.
drawXLabels(List<Double> xLabels,
Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, int left,
int top, int bottom, double xPixelsPerUnit,
double minX, double maxX)

The graphical representation of the labels on the X axis.

protected void

drawXTextLabels(Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
boolean showLabels, int left, int top, int bottom,
double xPixelsPerUnit, double minX, double maxX)

The graphical representation of the text labels on the X axis.

protected void

drawYLabels(Map<Integer,List<Double>> allYLabels,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
int maxScaleNumber, int left, int right, int bottom,
double[] yPixelsPerUnit, double[] minY)

The graphical representation of the labels on the Y axis.


double[]
abstract String
XYMultipleSeriesDataset
double

getCalcRange(int scale)
getChartType()

Returns the chart type identifier.


getDataset()
getDefaultMinimum()

Returns the default axis minimum.


getPointsChart()

ScatterChart

Returns the scatter chart to be used for drawing the data


points.

XYMultipleSeriesRenderer

getRenderer()

protected Rectangle

getScreenR()
getSeriesAndPointForScreenCoordinate(Point screenPoint)

SeriesSelection

Given screen coordinates, returns the series and point indexes


of a chart element.

protected List<Double>

getXLabels(double min, double max, int count)

protected
Map<Integer,List<Double>>

getYLabels(double[] minY, double[] maxY,


int maxScaleNumber)

protected boolean

isRenderNullValues()

Returns if the chart should display the null values.


isRenderPoints(SimpleSeriesRenderer renderer)

boolean

Returns if the chart should display the points as a certain


shape.

void

setCalcRange(double[] range, int scale)

protected void

setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

protected void

setScreenR(Rectangle screenR)

Method Summary

2741

Overview (Codename One API)


double[]
double[]

toRealPoint(float screenX, float screenY)


toRealPoint(float screenX, float screenY, int scale)

Transforms a screen point to a real coordinates point.

double[]

toScreenPoint(double[] realPoint)

double[]

toScreenPoint(double[] realPoint, int scale)

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawLegendShape, drawPath, drawPath,
drawString, getExceed, getLabel, getLegendShapeWidth, getLegendSize,
isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
mDataset
protected XYMultipleSeriesDataset mDataset

The multiple series dataset.


mRenderer
protected XYMultipleSeriesRenderer mRenderer

The multiple series renderer.

Constructor Detail
XYChart
protected XYChart()

XYChart
public XYChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new XY chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer

Method Detail
setDatasetRenderer
protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

draw
public void draw(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the XY chart.


Specified by:

Methods inherited from class com.codename1.charts.views.AbstractChart

2742

Overview (Codename One API)


draw

in class AbstractChart

Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw
y - the top left y value of the view to draw
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint

to
to

getXLabels
protected List<Double> getXLabels(double min,
double max,
int count)

getYLabels
protected Map<Integer,List<Double>> getYLabels(double[] minY,
double[] maxY,
int maxScaleNumber)

getScreenR
protected Rectangle getScreenR()

setScreenR
protected void setScreenR(Rectangle screenR)

drawSeries
protected void drawSeries(XYSeries series,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
XYMultipleSeriesRenderer.Orientation or,
int startIndex)

Draws the series.


Parameters:
series - the series
canvas - the canvas
paint - the paint object
pointsList - the points to be rendered
seriesRenderer - the series renderer
yAxisValue - the y axis value in pixels
seriesIndex - the series index
or - the orientation
startIndex - the start index of the rendering points
drawPoints
protected void drawPoints(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

Draws the series points.


Parameters:
canvas - the canvas
paint - the paint object
pointsList - the points to be rendered
seriesRenderer - the series renderer
yAxisValue - the y axis value in pixels
seriesIndex - the series index
startIndex - the start index of the rendering points

Method Detail

2743

Overview (Codename One API)


drawChartValuesText
protected void drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series,
XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint,
List<Float> points,
int seriesIndex,
int startIndex)

The graphical representation of the series values as text.


Parameters:
canvas - the canvas to paint to
series - the series to be painted
renderer - the series renderer
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points
drawText
protected void drawText(com.codename1.charts.compat.Canvas canvas,
String text,
float x,
float y,
com.codename1.charts.compat.Paint paint,
float extraAngle)

The graphical representation of a text, to handle both HORIZONTAL and VERTICAL


orientations and extra rotation angles.
Parameters:
canvas - the canvas to paint to
text - the text to be rendered
x - the X axis location of the text
y - the Y axis location of the text
paint - the paint to be used for drawing
extraAngle - the text angle
drawXLabels
protected void drawXLabels(List<Double> xLabels,
Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
int left,
int top,
int bottom,
double xPixelsPerUnit,
double minX,
double maxX)

The graphical representation of the labels on the X axis.


Parameters:
xLabels - the X labels values
xTextLabelLocations - the X text label locations
canvas - the canvas to paint to
paint - the paint to be used for drawing
left - the left value of the labels area
top - the top value of the labels area
bottom - the bottom value of the labels area
xPixelsPerUnit - the amount of pixels per one unit in the chart labels
minX - the minimum value on the X axis in the chart
maxX - the maximum value on the X axis in the chart
drawYLabels
protected void drawYLabels(Map<Integer,List<Double>> allYLabels,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
int maxScaleNumber,
int left,
int right,
int bottom,

Method Detail

2744

Overview (Codename One API)


double[] yPixelsPerUnit,
double[] minY)

The graphical representation of the labels on the Y axis.


Parameters:
allYLabels - the Y labels values
canvas - the canvas to paint to
paint - the paint to be used for drawing
maxScaleNumber - the maximum scale number
left - the left value of the labels area
right - the right value of the labels area
bottom - the bottom value of the labels area
yPixelsPerUnit - the amount of pixels per one unit in the chart labels
minY - the minimum value on the Y axis in the chart
drawXTextLabels
protected void drawXTextLabels(Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
boolean showLabels,
int left,
int top,
int bottom,
double xPixelsPerUnit,
double minX,
double maxX)

The graphical representation of the text labels on the X axis.


Parameters:
xTextLabelLocations - the X text label locations
canvas - the canvas to paint to
paint - the paint to be used for drawing
left - the left value of the labels area
top - the top value of the labels area
bottom - the bottom value of the labels area
xPixelsPerUnit - the amount of pixels per one unit in the chart labels
minX - the minimum value on the X axis in the chart
maxX - the maximum value on the X axis in the chart
getRenderer
public XYMultipleSeriesRenderer getRenderer()

getDataset
public XYMultipleSeriesDataset getDataset()

getCalcRange
public double[] getCalcRange(int scale)

setCalcRange
public void setCalcRange(double[] range,
int scale)

toRealPoint
public double[] toRealPoint(float screenX,
float screenY)

toScreenPoint
public double[] toScreenPoint(double[] realPoint)

toRealPoint
public double[] toRealPoint(float screenX,
float screenY,
int scale)

Transforms a screen point to a real coordinates point.


Parameters:
screenX - the screen x axis value
screenY - the screen y axis value
Returns:

Method Detail

2745

Overview (Codename One API)


the real coordinates point
toScreenPoint
public double[] toScreenPoint(double[] realPoint,
int scale)

getSeriesAndPointForScreenCoordinate
public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)

Description copied from class: AbstractChart


Given screen coordinates, returns the series and point indexes of a chart element. If
there is no chart element (line, point, bar, etc) at those coordinates, null is returned.
Overrides:
getSeriesAndPointForScreenCoordinate in class AbstractChart
Returns:
the series and point indexes
drawSeries
public abstract void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points
clickableAreasForPoints
protected abstract ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
isRenderNullValues
protected boolean isRenderNullValues()

Returns if the chart should display the null values.


Returns:
if null values should be rendered
isRenderPoints
public boolean isRenderPoints(SimpleSeriesRenderer renderer)

Returns if the chart should display the points as a certain shape.


Parameters:
renderer - the series renderer

Method Detail

2746

Overview (Codename One API)


getDefaultMinimum
public double getDefaultMinimum()

Returns the default axis minimum.


Returns:
the default axis minimum
getPointsChart
public ScatterChart getPointsChart()

Returns the scatter chart to be used for drawing the data points.
Returns:
the data points scatter chart
getChartType
public abstract String getChartType()

Returns the chart type identifier.


Returns:
the chart type

Method Detail

2747

Overview (Codename One API)


com.codename1.charts.views

Class TimeChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.LineChart

com.codename1.charts.views.TimeChart

public class
extends LineChart

The time chart rendering class.

Field Summary
Modifier and Type
static long
static String

Field and Description


DAY

The number of milliseconds in a day.


TYPE

/** The constant to identify this chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
TimeChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)

Builds a new time chart instance.

Method Summary
Modifier and
Type

protected void

Method and Description


drawXLabels(List<Double> xLabels, Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, int left, int top,
int bottom, double xPixelsPerUnit, double minX, double maxX)

The graphical representation of the labels on the X axis.


getChartType()

String

Returns the chart type identifier.


getDateFormat()

String

Returns the date format pattern to be used for formatting the X axis labels.

protected
List<Double>

getXLabels(double min, double max, int count)


setDateFormat(String format)

void

Sets the date format pattern to be used for formatting the X axis labels.

Methods inherited from


class com.codename1.charts.views.LineChart
clickableAreasForPoints, drawLegendShape, drawSeries, getLegendShapeWidth,
getPointsChart, isRenderPoints, setDatasetRenderer

Class TimeChart

2748

Overview (Codename One API)


Methods

inherited from
class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawPoints, drawSeries, drawText,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getRenderer, getScreenR, getSeriesAndPointForScreenCoordinate, getYLabels,
isRenderNullValues, setCalcRange, setScreenR, toRealPoint, toRealPoint,
toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

/** The constant to identify this chart type.


See Also:
Constant Field Values
DAY
public static final long DAY

The number of milliseconds in a day.


See Also:
Constant Field Values

Constructor Detail
TimeChart
public TimeChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new time chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer

Method Detail
getDateFormat
public String getDateFormat()

Returns the date format pattern to be used for formatting the X axis labels.
Returns:
the date format pattern for the X axis labels
setDateFormat
public void setDateFormat(String format)

Sets the date format pattern to be used for formatting the X axis labels.

Methods inherited from class com.codename1.charts.views.XYChart

2749

Overview (Codename One API)


Parameters:
- the date format pattern for the X axis labels. If null, an appropriate
default format will be used.
drawXLabels
format

protected void drawXLabels(List<Double> xLabels,


Double[] xTextLabelLocations,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
int left,
int top,
int bottom,
double xPixelsPerUnit,
double minX,
double maxX)

The graphical representation of the labels on the X axis.


Overrides:
drawXLabels in class XYChart
Parameters:
xLabels - the X labels values
xTextLabelLocations - the X text label locations
canvas - the canvas to paint to
paint - the paint to be used for drawing
left - the left value of the labels area
top - the top value of the labels area
bottom - the bottom value of the labels area
xPixelsPerUnit - the amount of pixels per one unit in the chart labels
minX - the minimum value on the X axis in the chart
maxX - the maximum value on the X axis in the chart
getChartType
public String getChartType()

Returns the chart type identifier.


Overrides:
getChartType in class LineChart
Returns:
the chart type
getXLabels
protected List<Double> getXLabels(double min,
double max,
int count)

Overrides:
getXLabels

Method Detail

in class XYChart

2750

Overview (Codename One API)


com.codename1.charts.views

Class ScatterChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.ScatterChart

public class
extends XYChart

The scatter chart rendering class.

Field Summary
Modifier and Type
static String

Field and Description


TYPE

The constant to identify this chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
ScatterChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)

Builds a new scatter chart instance.

Method Summary
Modifier and Type
protected
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


void

drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.

void

drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer renderer, float yAxisValue, int seriesIndex,
int startIndex)

The graphical representation of a series.


String
int
protected void

Class ScatterChart

getChartType()

Returns the chart type identifier.


getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

2751

Overview (Codename One API)


Methods

inherited from
class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawPoints, drawSeries, drawText, drawXLabels,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getPointsChart, getRenderer, getScreenR,
getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderNullValues, isRenderPoints, setCalcRange, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The constant to identify this chart type.


See Also:
Constant Field Values

Constructor Detail
ScatterChart
public ScatterChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new scatter chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer

Method Detail
setDatasetRenderer
protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Overrides:
setDatasetRenderer

in class XYChart

drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer renderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Specified by:

Methods inherited from class com.codename1.charts.views.XYChart

2752

Overview (Codename One API)


drawSeries

in class XYChart

Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

clickableAreasForPoints
protected ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Description copied from class: XYChart


Returns the clickable areas for all passed points
Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing
getChartType
public String getChartType()

Returns the chart type identifier.


Specified by:
getChartType in class XYChart
Returns:
the chart type

Method Detail

2753

Overview (Codename One API)


com.codename1.charts.views

Class RoundChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.RoundChart
Direct Known Subclasses:
DialChart, DoughnutChart, PieChart

public abstract class


extends AbstractChart

An abstract class to be extended by round like chart rendering classes.

Field Summary
Modifier and Type
protected boolean

Field and Description


autoCalculateCenter
mCenterX

protected int

The chart center X axis.


mCenterY

protected int

The chart center y axis.

protected CategorySeries
protected DefaultRenderer
protected static int
protected static int

mDataset

The series dataset.


mRenderer

The series renderer.


NO_VALUE

A no value constant.
SHAPE_WIDTH

The legend shape width.

Constructor Summary
Constructor and Description
RoundChart(CategorySeries dataset, DefaultRenderer renderer)

Round chart.

Method Summary
Modifier and
Type
void

Method and Description


drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y, int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


void

drawTitle(com.codename1.charts.compat.Canvas canvas, int x,


int y, int width, com.codename1.charts.compat.Paint paint)

The graphical representation of the round chart title.


int
int
int

Class RoundChart

getCenterX()

Returns the center on X axis.


getCenterY()

Returns the center on Y axis.


getLegendShapeWidth(int seriesIndex)

2754

Overview (Codename One API)


Returns the legend shape width.
DefaultRenderer

getRenderer()

Returns the renderer.

boolean

isAutocalculateCenter()

void

setAutocalculateCenter(boolean a)
setCenterX(int centerX)

void

Sets a new center on X axis.


setCenterY(int centerY)

void

Sets a new center on Y axis.

Methods inherited from


class com.codename1.charts.views.AbstractChart
draw, drawBackground, drawLabel, drawLegend, drawPath, drawPath,
drawString, getExceed, getLabel, getLegendSize,
getSeriesAndPointForScreenCoordinate, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
SHAPE_WIDTH
protected static final int SHAPE_WIDTH

The legend shape width.


See Also:
Constant Field Values
mDataset
protected CategorySeries mDataset

The series dataset.


mRenderer
protected DefaultRenderer mRenderer

The series renderer.


NO_VALUE
protected static final int NO_VALUE

A no value constant.
See Also:
Constant Field Values
mCenterX
protected int mCenterX

The chart center X axis.


mCenterY
protected int mCenterY

The chart center y axis.


autoCalculateCenter
protected boolean autoCalculateCenter

Method Summary

2755

Overview (Codename One API)


Constructor

Detail

RoundChart
public RoundChart(CategorySeries dataset,
DefaultRenderer renderer)

Round chart.
Parameters:
dataset - the series dataset
renderer - the series renderer

Method Detail
drawTitle
public void drawTitle(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
com.codename1.charts.compat.Paint paint)

The graphical representation of the round chart title.


Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
paint - the paint
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing
getRenderer
public DefaultRenderer getRenderer()

Returns the renderer.


Returns:
the renderer

Constructor Detail

2756

Overview (Codename One API)


getCenterX
public int getCenterX()

Returns the center on X axis.


Returns:
the center on X axis
getCenterY
public int getCenterY()

Returns the center on Y axis.


Returns:
the center on Y axis
setCenterX
public void setCenterX(int centerX)

Sets a new center on X axis.


Parameters:
centerX - center on X axis
setCenterY
public void setCenterY(int centerY)

Sets a new center on Y axis.


Parameters:
centerY - center on Y axis
setAutocalculateCenter
public void setAutocalculateCenter(boolean a)

isAutocalculateCenter
public boolean isAutocalculateCenter()

Method Detail

2757

Overview (Codename One API)


com.codename1.charts.views

Class RangeStackedBarChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.BarChart

com.codename1.charts.views.RangeBarChart

com.codename1.charts.views.RangeStackedBarChart

public class
extends RangeBarChart

Nested Class Summary

Nested classes/interfaces inherited from


class com.codename1.charts.views.BarChart
BarChart.Type

Field Summary
Modifier and Type Field and Description
static String

TYPE

The chart type.

Fields inherited from


class com.codename1.charts.views.BarChart
mType

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Method Summary
Modifier and Type

Method and Description


getChartType()

String

Returns the chart type identifier.

Methods inherited from


class com.codename1.charts.views.RangeBarChart
drawChartValuesText, drawSeries, getCoeficient

Methods inherited from


class com.codename1.charts.views.BarChart
clickableAreasForPoints, drawBar, drawBar, drawLegendShape,
getDefaultMinimum, getGradientPartialColor, getHalfDiffX,
getLegendShapeWidth, isRenderNullValues

Class RangeStackedBarChart

2758

Overview (Codename One API)


Methods

inherited from
class com.codename1.charts.views.XYChart
draw, drawPoints, drawSeries, drawText, drawXLabels, drawXTextLabels,
drawYLabels, getCalcRange, getDataset, getPointsChart, getRenderer,
getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderPoints, setCalcRange, setDatasetRenderer, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The chart type.


See Also:
Constant Field Values

Method Detail
getChartType
public String getChartType()

Description copied from class: RangeBarChart


Returns the chart type identifier.
Overrides:
getChartType in class RangeBarChart
Returns:
the chart type

Methods inherited from class com.codename1.charts.views.XYChart

2759

Overview (Codename One API)


com.codename1.charts.views

Class RangeBarChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.BarChart

com.codename1.charts.views.RangeBarChart
Direct Known Subclasses:
RangeStackedBarChart

public class
extends BarChart

The range bar chart rendering class.

Nested Class Summary

Nested classes/interfaces inherited from


class com.codename1.charts.views.BarChart
BarChart.Type

Field Summary
Modifier and Type Field and Description
static String

TYPE

The chart type.

Fields inherited from


class com.codename1.charts.views.BarChart
mType

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
RangeBarChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer,
BarChart.Type type)

Builds a new range bar chart instance.

Method Summary
Modifier
and Type
protected
void

Method and Description


drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series, XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint, List<Float> points,
int seriesIndex, int startIndex)

The graphical representation of the series values as text.

Method Detail

2760

Overview (Codename One API)


drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex,
int startIndex)

void

The graphical representation of a series.


getChartType()

String

Returns the chart type identifier.

protected
float

getCoeficient()

Returns the value of a constant used to calculate the half-distance.

Methods inherited from


class com.codename1.charts.views.BarChart
clickableAreasForPoints, drawBar, drawBar, drawLegendShape,
getDefaultMinimum, getGradientPartialColor, getHalfDiffX,
getLegendShapeWidth, isRenderNullValues

Methods inherited from


class com.codename1.charts.views.XYChart
draw, drawPoints, drawSeries, drawText, drawXLabels, drawXTextLabels,
drawYLabels, getCalcRange, getDataset, getPointsChart, getRenderer,
getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderPoints, setCalcRange, setDatasetRenderer, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The chart type.


See Also:
Constant Field Values

Constructor Detail
RangeBarChart
public RangeBarChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer,
BarChart.Type type)

Builds a new range bar chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer
type - the range bar chart type

Method Summary

2761

Overview (Codename One API)


Method

Detail

drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Overrides:
drawSeries in class BarChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points
drawChartValuesText
protected void drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series,
XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint,
List<Float> points,
int seriesIndex,
int startIndex)

The graphical representation of the series values as text.


Overrides:
drawChartValuesText in class BarChart
Parameters:
canvas - the canvas to paint to
series - the series to be painted
renderer - the series renderer
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points
getCoeficient
protected float getCoeficient()

Returns the value of a constant used to calculate the half-distance.


Overrides:
getCoeficient in class BarChart
Returns:
the constant value
getChartType
public String getChartType()

Returns the chart type identifier.


Overrides:
getChartType in class BarChart
Returns:
the chart type

Method Detail

2762

Overview (Codename One API)


com.codename1.charts.views

Enum PointStyle
java.lang.Object

java.lang.Enum<PointStyle>

com.codename1.charts.views.PointStyle
All Implemented Interfaces:
Comparable<PointStyle>

public enum
extends Enum<PointStyle>

The chart point style enumerator.

Enum Constant Summary


Enum Constant and Description
CIRCLE
DIAMOND
POINT
SQUARE
TRIANGLE
X

Method Summary
Modifier and Type
static int

Method and Description


getIndexForName(String name)

Returns the point shape index based on the given name.


getName()

String

Returns the point shape name.

static PointStyle

getPointStyleForName(String name)

Return the point shape that has the provided symbol.


toString()

String

Returns the point shape name.

static PointStyle
static
PointStyle[]

valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in the


order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum PointStyle

2763

Overview (Codename One API)


Enum

Constant Detail

X
public static final PointStyle X

CIRCLE
public static final PointStyle CIRCLE

TRIANGLE
public static final PointStyle TRIANGLE

SQUARE
public static final PointStyle SQUARE

DIAMOND
public static final PointStyle DIAMOND

POINT
public static final PointStyle POINT

Method Detail
values
public static PointStyle[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (PointStyle c : PointStyle.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static PointStyle valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null
getName
public String getName()

Returns the point shape name.


Returns:
the point shape name
toString
public String toString()

Returns the point shape name.


Overrides:
toString in class Enum<PointStyle>

Enum Constant Detail

2764

Overview (Codename One API)

Returns:
the point shape name
getPointStyleForName
public static PointStyle getPointStyleForName(String name)

Return the point shape that has the provided symbol.


Parameters:
name - the point style name
Returns:
the point shape
getIndexForName
public static int getIndexForName(String name)

Returns the point shape index based on the given name.


Returns:
the point shape index

Method Detail

2765

Overview (Codename One API)


com.codename1.charts.views

Class PieSegment
java.lang.Object

com.codename1.charts.views.PieSegment

public class
extends Object

Holds An PieChart Segment

Constructor Summary
Constructor and Description
PieSegment(int dataIndex, float value, float startAngle, float angle)

Method Summary
Modifier and Type

Method and Description

protected int

getDataIndex()

protected float

getEndAngle()

Shape

getShape(float cX, float cY, float radius)

protected float

getStartAngle()

protected float

getValue()

boolean

isInSegment(double angle)

Checks if angle falls in segment.


toString()

String

Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
PieSegment
public PieSegment(int dataIndex,
float value,
float startAngle,
float angle)

Method Detail
isInSegment
public boolean isInSegment(double angle)

Checks if angle falls in segment.


Parameters:
angle Returns:

Class PieSegment

2766

Overview (Codename One API)


true if in segment, false otherwise.
getStartAngle
protected float getStartAngle()

getEndAngle
protected float getEndAngle()

getDataIndex
protected int getDataIndex()

getValue
protected float getValue()

toString
public String toString()

Description copied from class: Object


Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object
getShape
public Shape getShape(float cX,
float cY,
float radius)

Method Detail

2767

Overview (Codename One API)


com.codename1.charts.views

Class PieMapper
java.lang.Object

com.codename1.charts.views.PieMapper

public class
extends Object

PieChart Segment Selection Management.

Constructor Summary
Constructor and Description
PieMapper()

Method Summary
Modifier and
Type

Method and Description


addPieSegment(int dataIndex, float value, float startAngle,
float angle)

void

Add configuration for a PieChart Segment


boolean

areAllSegmentPresent(int datasetSize)

If we have all PieChart Config then there is no point in reloading it


clearPieSegments()

void

Clears the pie segments list.


getAngle(Point screenPoint)

double

Fetches angle relative to pie chart center point where 3 O'Clock is 0 and
12 O'Clock is 270degrees

Shape

getSegmentShape(int dataIndex)

SeriesSelection
boolean

getSeriesAndPointForScreenCoordinate(Point screenPoint)

Fetches the SeriesSelection for the PieSegment selected.


isOnPieChart(Point screenPoint)

Checks if Point falls within PieChart


setDimensions(int pieRadius, int centerX, int centerY)

void

Set PieChart location on screen.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
PieMapper
public PieMapper()

Method Detail

Class PieMapper

2768

Overview (Codename One API)


setDimensions
public void setDimensions(int pieRadius,
int centerX,
int centerY)

Set PieChart location on screen.


Parameters:
pieRadius centerX centerY areAllSegmentPresent
public boolean areAllSegmentPresent(int datasetSize)

If we have all PieChart Config then there is no point in reloading it


Parameters:
datasetSize Returns:
true if cfg for each segment is present
addPieSegment
public void addPieSegment(int dataIndex,
float value,
float startAngle,
float angle)

Add configuration for a PieChart Segment


Parameters:
dataIndex value startAngle angle clearPieSegments
public void clearPieSegments()

Clears the pie segments list.


getAngle
public double getAngle(Point screenPoint)

Fetches angle relative to pie chart center point where 3 O'Clock is 0 and 12 O'Clock
is 270degrees
Parameters:
screenPoint Returns:
angle in degress from 0-360.
isOnPieChart
public boolean isOnPieChart(Point screenPoint)

Checks if Point falls within PieChart


Parameters:
screenPoint Returns:
true if in PieChart
getSeriesAndPointForScreenCoordinate
public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)

Fetches the SeriesSelection for the PieSegment selected.


Parameters:
screenPoint - - the user tap location
Returns:
null if screen point is not in PieChart or its config if it is

Method Detail

2769

Overview (Codename One API)


getSegmentShape
public Shape getSegmentShape(int dataIndex)

Method Detail

2770

Overview (Codename One API)


com.codename1.charts.views

Class PieChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.RoundChart

com.codename1.charts.views.PieChart

public class
extends RoundChart

The pie chart rendering class.

Field Summary

Fields inherited from


class com.codename1.charts.views.RoundChart
autoCalculateCenter, mCenterX, mCenterY, mDataset, mRenderer, NO_VALUE,
SHAPE_WIDTH

Constructor Summary
Constructor and Description
PieChart(CategorySeries dataset, DefaultRenderer renderer)

Builds a new pie chart instance.

Method Summary
Modifier and
Type

Method and Description


draw(com.codename1.charts.compat.Canvas canvas, int x, int y,
int width, int height, com.codename1.charts.compat.Paint paint)

void

The graphical representation of the pie chart.


getSegmentShape(int pointIndex)

Shape

Gets the shape of a pie segment given its point index.


getSeriesAndPointForScreenCoordinate(Point screenPoint)

SeriesSelection

Given screen coordinates, returns the series and point indexes of a chart
element.

Methods inherited from


class com.codename1.charts.views.RoundChart
drawLegendShape, drawTitle, getCenterX, getCenterY, getLegendShapeWidth,
getRenderer, isAutocalculateCenter, setAutocalculateCenter, setCenterX,
setCenterY

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Class PieChart

2771

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
PieChart
public PieChart(CategorySeries dataset,
DefaultRenderer renderer)

Builds a new pie chart instance.


Parameters:
dataset - the series dataset
renderer - the series renderer

Method Detail
draw
public void draw(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the pie chart.


Specified by:
draw in class AbstractChart
Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint
getSeriesAndPointForScreenCoordinate
public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)

Description copied from class: AbstractChart


Given screen coordinates, returns the series and point indexes of a chart element. If
there is no chart element (line, point, bar, etc) at those coordinates, null is returned.
Overrides:
getSeriesAndPointForScreenCoordinate in class AbstractChart
Returns:
the series and point indexes
getSegmentShape
public Shape getSegmentShape(int pointIndex)

Gets the shape of a pie segment given its point index.


Parameters:
pointIndex - The point index representing the pie segment.
Returns:
A shape of the outline of the segment.

Methods inherited from class java.lang.Object

2772

Overview (Codename One API)


com.codename1.charts.views

Class LineChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.LineChart
Direct Known Subclasses:
CubicLineChart, TimeChart

public class
extends XYChart

The line chart rendering class.

Field Summary
Modifier and Type
static String

Field and Description


TYPE

The constant to identify this chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
LineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)

Builds a new line chart instance.

Method Summary
Modifier and Type
protected
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


void

drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.

void

drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer renderer, float yAxisValue, int seriesIndex,
int startIndex)

The graphical representation of a series.


String
int
ScatterChart
boolean

Method Detail

getChartType()

Returns the chart type identifier.


getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


getPointsChart()

Returns the scatter chart to be used for drawing the data points.
isRenderPoints(SimpleSeriesRenderer renderer)

Returns if the chart should display the points as a certain shape.

2773

Overview (Codename One API)


protected void

setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Sets the series and the renderer.

Methods inherited from


class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawPoints, drawSeries, drawText, drawXLabels,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getRenderer, getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels,
getYLabels, isRenderNullValues, setCalcRange, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The constant to identify this chart type.


See Also:
Constant Field Values

Constructor Detail
LineChart
public LineChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new line chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer

Method Detail
setDatasetRenderer
protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Sets the series and the renderer.


Overrides:
setDatasetRenderer in class XYChart
Parameters:
dataset - the series dataset
renderer - the series renderer

Method Summary

2774

Overview (Codename One API)


drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer renderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Specified by:
drawSeries in class XYChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points
clickableAreasForPoints
protected ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Description copied from class: XYChart


Returns the clickable areas for all passed points
Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at

Method Detail

2775

Overview (Codename One API)


seriesIndex - the series index
paint - the paint to be used for

drawing

isRenderPoints
public boolean isRenderPoints(SimpleSeriesRenderer renderer)

Returns if the chart should display the points as a certain shape.


Overrides:
isRenderPoints in class XYChart
Parameters:
renderer - the series renderer
getPointsChart
public ScatterChart getPointsChart()

Returns the scatter chart to be used for drawing the data points.
Overrides:
getPointsChart in class XYChart
Returns:
the data points scatter chart
getChartType
public String getChartType()

Returns the chart type identifier.


Specified by:
getChartType in class XYChart
Returns:
the chart type

Method Detail

2776

Overview (Codename One API)


com.codename1.charts.views

Class DoughnutChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.RoundChart

com.codename1.charts.views.DoughnutChart

public class
extends RoundChart

The doughnut chart rendering class.

Field Summary

Fields inherited from


class com.codename1.charts.views.RoundChart
autoCalculateCenter, mCenterX, mCenterY, mRenderer, NO_VALUE, SHAPE_WIDTH

Constructor Summary
Constructor and Description
DoughnutChart(MultipleCategorySeries dataset, DefaultRenderer renderer)

Builds a new doughnut chart instance.

Method Summary
Modifier
and Type

Method and Description


draw(com.codename1.charts.compat.Canvas canvas, int x, int y,
int width, int height, com.codename1.charts.compat.Paint paint)

void

The graphical representation of the doughnut chart.


drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y, int seriesIndex,
com.codename1.charts.compat.Paint paint)

void

The graphical representation of the legend shape.


getLegendShapeWidth(int seriesIndex)

int

Returns the legend shape width.

Methods inherited from


class com.codename1.charts.views.RoundChart
drawTitle, getCenterX, getCenterY, getRenderer, isAutocalculateCenter,
setAutocalculateCenter, setCenterX, setCenterY

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, getSeriesAndPointForScreenCoordinate,
isNullValue, isVertical

Class DoughnutChart

2777

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DoughnutChart
public DoughnutChart(MultipleCategorySeries dataset,
DefaultRenderer renderer)

Builds a new doughnut chart instance.


Parameters:
dataset - the series dataset
renderer - the series renderer

Method Detail
draw
public void draw(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the doughnut chart.


Specified by:
draw in class AbstractChart
Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Overrides:
getLegendShapeWidth in class RoundChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Overrides:
drawLegendShape in class RoundChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at

Methods inherited from class java.lang.Object

2778

Overview (Codename One API)


seriesIndex - the series index
paint - the paint to be used for

Method Detail

drawing

2779

Overview (Codename One API)


com.codename1.charts.views

Class DialChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.RoundChart

com.codename1.charts.views.DialChart

public class
extends RoundChart

The dial chart rendering class.

Field Summary

Fields inherited from


class com.codename1.charts.views.RoundChart
autoCalculateCenter, mCenterX, mCenterY, mDataset, NO_VALUE, SHAPE_WIDTH

Constructor Summary
Constructor and Description
DialChart(CategorySeries dataset, DialRenderer renderer)

Builds a new dial chart instance.

Method Summary
Modifier
and Type

Method and Description


draw(com.codename1.charts.compat.Canvas canvas, int x, int y,
int width, int height, com.codename1.charts.compat.Paint paint)

void

The graphical representation of the dial chart.

Methods inherited from


class com.codename1.charts.views.RoundChart
drawLegendShape, drawTitle, getCenterX, getCenterY, getLegendShapeWidth,
getRenderer, isAutocalculateCenter, setAutocalculateCenter, setCenterX,
setCenterY

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, getSeriesAndPointForScreenCoordinate,
isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Class DialChart

2780

Overview (Codename One API)

Constructor

Detail

DialChart
public DialChart(CategorySeries dataset,
DialRenderer renderer)

Builds a new dial chart instance.


Parameters:
dataset - the series dataset
renderer - the dial renderer

Method Detail
draw
public void draw(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the dial chart.


Specified by:
draw in class AbstractChart
Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint

Constructor Detail

2781

Overview (Codename One API)


com.codename1.charts.views

Class CubicLineChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.LineChart

com.codename1.charts.views.CubicLineChart

public class
extends LineChart

The interpolated (cubic) line chart rendering class.

Field Summary
Modifier and Type Field and Description
static String

TYPE

The chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
CubicLineChart()
CubicLineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer,
float smoothness)

Builds a cubic line chart.

Method Summary
Modifier
and Type
protected
void

Method and Description


drawPath(com.codename1.charts.compat.Canvas canvas,
List<Float> points, com.codename1.charts.compat.Paint paint,
boolean circular)

The graphical representation of a path.


protected
void

drawPoints(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> pointsList,
XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex,
int startIndex)

Draws the series points.


String

getChartType()

Returns the chart type identifier.

Methods inherited from


class com.codename1.charts.views.LineChart
clickableAreasForPoints, drawLegendShape, drawSeries, getLegendShapeWidth,
getPointsChart, isRenderPoints, setDatasetRenderer

Method Detail

2782

Overview (Codename One API)


Methods

inherited from
class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawSeries, drawText, drawXLabels,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getRenderer, getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels,
getYLabels, isRenderNullValues, setCalcRange, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawString, getExceed,
getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The chart type.


See Also:
Constant Field Values

Constructor Detail
CubicLineChart
public CubicLineChart()

CubicLineChart
public CubicLineChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer,
float smoothness)

Builds a cubic line chart.


Parameters:
dataset - the dataset
renderer - the renderer
smoothness - smoothness determines how smooth the curve should be, range
[0->0.5] super smooth, 0.5, means that it might not get close to control points
if you have random data // less smooth, (close to 0) means that it will most
likely touch all control // points

Method Detail
drawPath
protected void drawPath(com.codename1.charts.compat.Canvas canvas,
List<Float> points,
com.codename1.charts.compat.Paint paint,
boolean circular)

Description copied from class: AbstractChart


The graphical representation of a path.
Overrides:
drawPath in class AbstractChart
Parameters:

Methods inherited from class com.codename1.charts.views.XYChart

2783

Overview (Codename One API)


canvas - the canvas to paint to
points - the points that are contained in the path
paint - the paint to be used for painting
circular - if the path ends with the start point

to paint

drawPoints
protected void drawPoints(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

Draws the series points.


Overrides:
drawPoints in class XYChart
Parameters:
canvas - the canvas
paint - the paint object
pointsList - the points to be rendered
seriesRenderer - the series renderer
yAxisValue - the y axis value in pixels
seriesIndex - the series index
startIndex - the start index of the rendering points
getChartType
public String getChartType()

Returns the chart type identifier.


Overrides:
getChartType in class LineChart
Returns:
the chart type

Method Detail

2784

Overview (Codename One API)


com.codename1.charts.views

Class CombinedXYChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.CombinedXYChart

public class
extends XYChart

The combined XY chart rendering class.

Nested Class Summary


Modifier and Type
static class

Class and Description


CombinedXYChart.XYCombinedChartDef

Definition of a chart inside a combined XY chart.

Field Summary

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
CombinedXYChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer,
CombinedXYChart.XYCombinedChartDef[] chartDefinitions)

Builds a new combined XY chart instance.

Method Summary
Modifier and Type
protected
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


void

drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.

void

drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer seriesRenderer, float yAxisValue,
int seriesIndex, int startIndex)

The graphical representation of a series.

protected void

drawSeries(XYSeries series,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList, XYSeriesRenderer seriesRenderer,
float yAxisValue, int seriesIndex,
XYMultipleSeriesRenderer.Orientation or, int startIndex)

Draws the series.

Class CombinedXYChart

2785

Overview (Codename One API)


getChartType()

String

Returns the chart type identifier.


getLegendShapeWidth(int seriesIndex)

int

Returns the legend shape width.

Methods inherited from


class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawPoints, drawText, drawXLabels,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getPointsChart, getRenderer, getScreenR,
getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderNullValues, isRenderPoints, setCalcRange, setDatasetRenderer,
setScreenR, toRealPoint, toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
CombinedXYChart
public CombinedXYChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer,
CombinedXYChart.XYCombinedChartDef[] chartDefinitions)

Builds a new combined XY chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer
chartDefinitions - the XY chart definitions

Method Detail
drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Specified by:
drawSeries in class XYChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

Method Summary

2786

Overview (Codename One API)


clickableAreasForPoints
protected ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Description copied from class: XYChart


Returns the clickable areas for all passed points
Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
drawSeries
protected void drawSeries(XYSeries series,
com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> pointsList,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
XYMultipleSeriesRenderer.Orientation or,
int startIndex)

Description copied from class: XYChart


Draws the series.
Overrides:
drawSeries in class XYChart
Parameters:
series - the series
canvas - the canvas
paint - the paint object
pointsList - the points to be rendered
seriesRenderer - the series renderer
yAxisValue - the y axis value in pixels
seriesIndex - the series index
or - the orientation
startIndex - the start index of the rendering points
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart

Method Detail

2787

Overview (Codename One API)


Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should
y - the y value of the point the shape should
seriesIndex - the series index
paint - the paint to be used for drawing

be drawn at
be drawn at

getChartType
public String getChartType()

Returns the chart type identifier.


Specified by:
getChartType in class XYChart
Returns:
the chart type

Method Detail

2788

Overview (Codename One API)


com.codename1.charts.views

Class CombinedXYChart.XYCombinedChartDef
java.lang.Object

com.codename1.charts.views.CombinedXYChart.XYCombinedChartDef
Enclosing class:
CombinedXYChart

public static class


extends Object

Definition of a chart inside a combined XY chart.

Constructor Summary
Constructor and Description
XYCombinedChartDef(String type, int... seriesIndex)

Constructs a chart definition.

Method Summary
Modifier and Type

Method and Description

boolean

containsSeries(int seriesIndex)

int

getChartSeriesIndex(int seriesIndex)

int[]

getSeriesIndex()

String

getType()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XYCombinedChartDef
public XYCombinedChartDef(String type,
int... seriesIndex)

Constructs a chart definition.


Parameters:
type - XY chart type
seriesIndex - corresponding data series indexes

Method Detail
containsSeries
public boolean containsSeries(int seriesIndex)

getChartSeriesIndex
public int getChartSeriesIndex(int seriesIndex)

Class CombinedXYChart.XYCombinedChartDef

2789

Overview (Codename One API)


getType
public String getType()

getSeriesIndex
public int[] getSeriesIndex()

Method Detail

2790

Overview (Codename One API)


com.codename1.charts.views

Class ClickableArea
java.lang.Object

com.codename1.charts.views.ClickableArea

public class
extends Object

Constructor Summary
Constructor and Description
ClickableArea(Rectangle2D rect, double x, double y)

Method Summary
Method and
Description

Modifier and Type


Rectangle2D

getRect()

double

getX()

double

getY()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ClickableArea
public ClickableArea(Rectangle2D rect,
double x,
double y)

Method Detail
getRect
public Rectangle2D getRect()

getX
public double getX()

getY
public double getY()

Class ClickableArea

2791

Overview (Codename One API)


com.codename1.charts.views

Class BubbleChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.BubbleChart

public class
extends XYChart

The bubble chart rendering class.

Field Summary
Modifier and Type
static String

Field and Description


TYPE

The constant to identify this chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
BubbleChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)

Builds a new bubble chart instance.

Method Summary
Modifier and Type
protected
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points


drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, com.codename1.charts.compat.Paint paint)

void

The graphical representation of the legend shape.


drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer renderer, float yAxisValue, int seriesIndex,
int startIndex)

void

The graphical representation of a series.


String

getChartType()

Returns the chart type identifier.


getLegendShapeWidth(int seriesIndex)

int

Returns the legend shape width.

Methods inherited from


class com.codename1.charts.views.XYChart
draw, drawChartValuesText, drawPoints, drawSeries, drawText, drawXLabels,
drawXTextLabels, drawYLabels, getCalcRange, getDataset, getDefaultMinimum,
getPointsChart, getRenderer, getScreenR,

Method Detail

2792

Overview (Codename One API)


getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderNullValues, isRenderPoints, setCalcRange, setDatasetRenderer,
setScreenR, toRealPoint, toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The constant to identify this chart type.


See Also:
Constant Field Values

Constructor Detail
BubbleChart
public BubbleChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer)

Builds a new bubble chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer

Method Detail
drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer renderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Specified by:
drawSeries in class XYChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

Methods inherited fromclass com.codename1.charts.views.XYChart

2793

Overview (Codename One API)


clickableAreasForPoints
protected ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Description copied from class: XYChart


Returns the clickable areas for all passed points
Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing
getChartType
public String getChartType()

Returns the chart type identifier.


Specified by:
getChartType in class XYChart
Returns:
the chart type

Method Detail

2794

Overview (Codename One API)


com.codename1.charts.views

Class BarChart
java.lang.Object

com.codename1.charts.views.AbstractChart

com.codename1.charts.views.XYChart

com.codename1.charts.views.BarChart
Direct Known Subclasses:
RangeBarChart

public class
extends XYChart

The bar chart rendering class.

Nested Class Summary


Modifier and Type
static class

Class and Description


BarChart.Type

The bar chart type enum.

Field Summary
Modifier and Type
protected BarChart.Type

Field and Description


mType

The chart type.


TYPE

static String

The constant to identify this chart type.

Fields inherited from class com.codename1.charts.views.XYChart


mDataset, mRenderer

Constructor Summary
Constructor and Description
BarChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer,
BarChart.Type type)

Builds a new bar chart instance.

Method Summary
Modifier and Type
protected
ClickableArea[]

Method and Description


clickableAreasForPoints(List<Float> points,
List<Double> values, float yAxisValue, int seriesIndex,
int startIndex)

Returns the clickable areas for all passed points

protected void

drawBar(com.codename1.charts.compat.Canvas canvas, float xMin,


float yMin, float xMax, float yMax, float halfDiffX,
int seriesNr, int seriesIndex,
com.codename1.charts.compat.Paint paint)

Draws a bar.
protected void

Class BarChart

drawBar(com.codename1.charts.compat.Canvas canvas, float xMin,


float yMin, float xMax, float yMax, int scale, int seriesIndex,

2795

Overview (Codename One API)


com.codename1.charts.compat.Paint paint)

Draws a bar.

protected void

drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series, XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint, List<Float> points,
int seriesIndex, int startIndex)

The graphical representation of the series values as text.


drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, com.codename1.charts.compat.Paint paint)

void

The graphical representation of the legend shape.


drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint, List<Float> points,
XYSeriesRenderer seriesRenderer, float yAxisValue,
int seriesIndex, int startIndex)

void

The graphical representation of a series.


getChartType()

String

Returns the chart type identifier.

protected float

getCoeficient()

Returns the value of a constant used to calculate the half-distance.


getDefaultMinimum()

double

Returns the default axis minimum.

protected int

getGradientPartialColor(int minColor, int maxColor,


float fraction)
getHalfDiffX(List<Float> points, int length, int seriesNr)

protected float

Calculates and returns the half-distance in the graphical representation


of 2 consecutive points.
getLegendShapeWidth(int seriesIndex)

int

Returns the legend shape width.

protected boolean

isRenderNullValues()

Returns if the chart should display the null values.

Methods inherited from


class com.codename1.charts.views.XYChart
draw, drawPoints, drawSeries, drawText, drawXLabels, drawXTextLabels,
drawYLabels, getCalcRange, getDataset, getPointsChart, getRenderer,
getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels,
isRenderPoints, setCalcRange, setDatasetRenderer, setScreenR, toRealPoint,
toRealPoint, toScreenPoint, toScreenPoint

Methods inherited from


class com.codename1.charts.views.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString,
getExceed, getLabel, getLegendSize, isNullValue, isVertical

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
TYPE
public static final String TYPE

The constant to identify this chart type.


See Also:
Constant Field Values

Method Summary

2796

Overview (Codename One API)


mType
protected BarChart.Type mType

The chart type.

Constructor Detail
BarChart
public BarChart(XYMultipleSeriesDataset dataset,
XYMultipleSeriesRenderer renderer,
BarChart.Type type)

Builds a new bar chart instance.


Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer
type - the bar chart type

Method Detail
clickableAreasForPoints
protected ClickableArea[] clickableAreasForPoints(List<Float> points,
List<Double> values,
float yAxisValue,
int seriesIndex,
int startIndex)

Description copied from class: XYChart


Returns the clickable areas for all passed points
Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area
drawSeries
public void drawSeries(com.codename1.charts.compat.Canvas canvas,
com.codename1.charts.compat.Paint paint,
List<Float> points,
XYSeriesRenderer seriesRenderer,
float yAxisValue,
int seriesIndex,
int startIndex)

The graphical representation of a series.


Specified by:
drawSeries in class XYChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

Field Detail

2797

Overview (Codename One API)


drawBar
protected void drawBar(com.codename1.charts.compat.Canvas canvas,
float xMin,
float yMin,
float xMax,
float yMax,
float halfDiffX,
int seriesNr,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

Draws a bar.
Parameters:
canvas - the canvas
xMin - the X axis minimum
yMin - the Y axis minimum
xMax - the X axis maximum
yMax - the Y axis maximum
halfDiffX - half the size of a bar
seriesNr - the total number of series
seriesIndex - the current series index
paint - the paint

drawBar
protected void drawBar(com.codename1.charts.compat.Canvas canvas,
float xMin,
float yMin,
float xMax,
float yMax,
int scale,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

Draws a bar.
Parameters:
canvas - the canvas
xMin - the X axis minimum
yMin - the Y axis minimum
xMax - the X axis maximum
yMax - the Y axis maximum
scale - the scale index
seriesIndex - the current series
paint - the paint

index

getGradientPartialColor
protected int getGradientPartialColor(int minColor,
int maxColor,
float fraction)

drawChartValuesText
protected void drawChartValuesText(com.codename1.charts.compat.Canvas canvas,
XYSeries series,
XYSeriesRenderer renderer,
com.codename1.charts.compat.Paint paint,
List<Float> points,
int seriesIndex,
int startIndex)

The graphical representation of the series values as text.


Overrides:
drawChartValuesText in class XYChart
Parameters:
canvas - the canvas to paint to
series - the series to be painted
renderer - the series renderer
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

Method Detail

2798

Overview (Codename One API)


getLegendShapeWidth
public int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing
getHalfDiffX
protected float getHalfDiffX(List<Float> points,
int length,
int seriesNr)

Calculates and returns the half-distance in the graphical representation of 2


consecutive points.
Parameters:
points - the points
length - the points length
seriesNr - the series number
Returns:
the calculated half-distance value
getCoeficient
protected float getCoeficient()

Returns the value of a constant used to calculate the half-distance.


Returns:
the constant value
isRenderNullValues
protected boolean isRenderNullValues()

Returns if the chart should display the null values.


Overrides:
isRenderNullValues in class XYChart
Returns:
if null values should be rendered
getDefaultMinimum
public double getDefaultMinimum()

Returns the default axis minimum.


Overrides:
getDefaultMinimum in class XYChart
Returns:

Method Detail

2799

Overview (Codename One API)


the default axis minimum
getChartType
public String getChartType()

Returns the chart type identifier.


Specified by:
getChartType in class XYChart
Returns:
the chart type

Method Detail

2800

Overview (Codename One API)


com.codename1.charts.views

Enum BarChart.Type
java.lang.Object

java.lang.Enum<BarChart.Type>

com.codename1.charts.views.BarChart.Type
All Implemented Interfaces:
Comparable<BarChart.Type>
Enclosing class:
BarChart

public static enum


extends Enum<BarChart.Type>

The bar chart type enum.

Enum Constant Summary


Enum Constant and Description
DEFAULT
HEAPED
STACKED

Method Summary
Modifier and Type
static BarChart.Type
static
BarChart.Type[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in the


order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


DEFAULT
public static final BarChart.Type DEFAULT

STACKED
public static final BarChart.Type STACKED

HEAPED
public static final BarChart.Type HEAPED

Enum BarChart.Type

2801

Overview (Codename One API)


Method

Detail

values
public static BarChart.Type[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (BarChart.Type c : BarChart.Type.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static BarChart.Type valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Method Detail

2802

Overview (Codename One API)


com.codename1.charts.views

Class AbstractChart
java.lang.Object

com.codename1.charts.views.AbstractChart
Direct Known Subclasses:
RoundChart, XYChart

public abstract class


extends Object

An abstract class to be implemented by the chart rendering classes.

Constructor Summary
Constructor and Description
AbstractChart()

Method Summary
Modifier and
Type
abstract void

Method and Description


draw(com.codename1.charts.compat.Canvas canvas, int x, int y,
int width, int height, com.codename1.charts.compat.Paint paint)

The graphical representation of the chart.

protected void

drawBackground(DefaultRenderer renderer,
com.codename1.charts.compat.Canvas canvas, int x, int y,
int width, int height, com.codename1.charts.compat.Paint paint,
boolean newColor, int color)

Draws the chart background.

protected void

drawLabel(com.codename1.charts.compat.Canvas canvas,
String labelText, DefaultRenderer renderer,
List<Rectangle2D> prevLabelsBounds, int centerX, int centerY,
float shortRadius, float longRadius, float currentAngle,
float angle, int left, int right, int color,
com.codename1.charts.compat.Paint paint, boolean line,
boolean display)

Draws a text label.

protected int

drawLegend(com.codename1.charts.compat.Canvas canvas,
DefaultRenderer renderer, String[] titles, int left, int right,
int y, int width, int height, int legendSize,
com.codename1.charts.compat.Paint paint, boolean calculate)

Draws the chart legend.


abstract void

drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer, float x, float y, int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


protected void

drawPath(com.codename1.charts.compat.Canvas canvas,
float[] points, com.codename1.charts.compat.Paint paint,
boolean circular)

The graphical representation of a path.


protected void

drawPath(com.codename1.charts.compat.Canvas canvas,
List<Float> points, com.codename1.charts.compat.Paint paint,
boolean circular)

The graphical representation of a path.


protected void

drawString(com.codename1.charts.compat.Canvas canvas,
String text, float x, float y,
com.codename1.charts.compat.Paint paint)

Draw a multiple lines string.

Class AbstractChart

2803

Overview (Codename One API)


protected
boolean
protected
String
abstract int

protected int

getExceed(float currentWidth, DefaultRenderer renderer,


int right, int width)

Calculates if the current width exceeds the total width.


getLabel(NumberFormat format, double label)

Makes sure the fraction digit is not displayed, if not needed.


getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


getLegendSize(DefaultRenderer renderer, int defaultHeight,
float extraHeight)

Calculates the current legend size.


getSeriesAndPointForScreenCoordinate(Point screenPoint)
SeriesSelection

Given screen coordinates, returns the series and point indexes of a chart
element.

boolean

isNullValue(double value)

boolean

isVertical(DefaultRenderer renderer)

Checks if the current chart is rendered as vertical.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
AbstractChart
public AbstractChart()

Method Detail
draw
public abstract void draw(com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint)

The graphical representation of the chart.


Parameters:
canvas - the canvas to paint to
x - the top left x value of the view to draw to
y - the top left y value of the view to draw to
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint
drawBackground
protected void drawBackground(DefaultRenderer renderer,
com.codename1.charts.compat.Canvas canvas,
int x,
int y,
int width,
int height,
com.codename1.charts.compat.Paint paint,
boolean newColor,
int color)

Draws the chart background.


Parameters:
renderer - the chart renderer
canvas - the canvas to paint to
x - the top left x value of the view to draw to

Method Summary

2804

Overview (Codename One API)


y - the top left y value of the view to draw
width - the width of the view to draw to
height - the height of the view to draw to
paint - the paint used for drawing
newColor - if a new color is to be used
color - the color to be used

to

drawLegend
protected int drawLegend(com.codename1.charts.compat.Canvas canvas,
DefaultRenderer renderer,
String[] titles,
int left,
int right,
int y,
int width,
int height,
int legendSize,
com.codename1.charts.compat.Paint paint,
boolean calculate)

Draws the chart legend.


Parameters:
canvas - the canvas to paint to
renderer - the series renderer
titles - the titles to go to the legend
left - the left X value of the area to draw to
right - the right X value of the area to draw to
y - the y value of the area to draw to
width - the width of the area to draw to
height - the height of the area to draw to
legendSize - the legend size
paint - the paint to be used for drawing
calculate - if only calculating the legend size
Returns:
the legend height
drawString
protected void drawString(com.codename1.charts.compat.Canvas canvas,
String text,
float x,
float y,
com.codename1.charts.compat.Paint paint)

Draw a multiple lines string.


Parameters:
canvas - the canvas to paint to
text - the text to be painted
x - the x value of the area to draw to
y - the y value of the area to draw to
paint - the paint to be used for drawing
getExceed
protected boolean getExceed(float currentWidth,
DefaultRenderer renderer,
int right,
int width)

Calculates if the current width exceeds the total width.


Parameters:
currentWidth - the current width
renderer - the renderer
right - the right side pixel value
width - the total width
Returns:
if the current width exceeds the total width

Method Detail

2805

Overview (Codename One API)


isVertical
public boolean isVertical(DefaultRenderer renderer)

Checks if the current chart is rendered as vertical.


Parameters:
renderer - the renderer
Returns:
if the chart is rendered as a vertical one
getLabel
protected String getLabel(NumberFormat format,
double label)

Makes sure the fraction digit is not displayed, if not needed.


Parameters:
format - the number format for the label
label - the input label value
Returns:
the label without the useless fraction digit
drawPath
protected void drawPath(com.codename1.charts.compat.Canvas canvas,
List<Float> points,
com.codename1.charts.compat.Paint paint,
boolean circular)

The graphical representation of a path.


Parameters:
canvas - the canvas to paint to
points - the points that are contained in the path to paint
paint - the paint to be used for painting
circular - if the path ends with the start point
drawPath
protected void drawPath(com.codename1.charts.compat.Canvas canvas,
float[] points,
com.codename1.charts.compat.Paint paint,
boolean circular)

The graphical representation of a path.


Parameters:
canvas - the canvas to paint to
points - the points that are contained in the path to paint
paint - the paint to be used for painting
circular - if the path ends with the start point
getLegendShapeWidth
public abstract int getLegendShapeWidth(int seriesIndex)

Returns the legend shape width.


Parameters:
seriesIndex - the series index
Returns:
the legend shape width
drawLegendShape
public abstract void drawLegendShape(com.codename1.charts.compat.Canvas canvas,
SimpleSeriesRenderer renderer,
float x,
float y,
int seriesIndex,
com.codename1.charts.compat.Paint paint)

The graphical representation of the legend shape.


Parameters:
canvas - the canvas to paint to
renderer - the series renderer

Method Detail

2806

Overview (Codename One API)


x - the x value of the point the shape should
y - the y value of the point the shape should
seriesIndex - the series index
paint - the paint to be used for drawing

be drawn at
be drawn at

getLegendSize
protected int getLegendSize(DefaultRenderer renderer,
int defaultHeight,
float extraHeight)

Calculates the current legend size.


Parameters:
renderer - the renderer
defaultHeight - the default height
extraHeight - the added extra height
Returns:
the legend size
drawLabel
protected void drawLabel(com.codename1.charts.compat.Canvas canvas,
String labelText,
DefaultRenderer renderer,
List<Rectangle2D> prevLabelsBounds,
int centerX,
int centerY,
float shortRadius,
float longRadius,
float currentAngle,
float angle,
int left,
int right,
int color,
com.codename1.charts.compat.Paint paint,
boolean line,
boolean display)

Draws a text label.


Parameters:
canvas - the canvas
labelText - the label text
renderer - the renderer
prevLabelsBounds - the previous rendered label bounds
centerX - the round chart center on X axis
centerY - the round chart center on Y axis
shortRadius - the short radius for the round chart
longRadius - the long radius for the round chart
currentAngle - the current angle
angle - the label extra angle
left - the left side
right - the right side
color - the label color
paint - the paint
line - if a line to the label should be drawn
display - display the label anyway
isNullValue
public boolean isNullValue(double value)

getSeriesAndPointForScreenCoordinate
public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)

Given screen coordinates, returns the series and point indexes of a chart element. If
there is no chart element (line, point, bar, etc) at those coordinates, null is returned.
Parameters:
screenPoint Returns:
the series and point indexes

Method Detail

2807

Overview (Codename One API)


com.codename1.charts.util

Class NumberFormat
java.lang.Object

com.codename1.charts.util.NumberFormat

public class
extends Object

Constructor Summary
Constructor and Description
NumberFormat()

Method Summary
Modifier and Type
String

Method and Description


format(double label)

static NumberFormat getNumberInstance()


double

parseDouble(String format)

void

setMaximumFractionDigits(int i)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
NumberFormat
public NumberFormat()

Method Detail
getNumberInstance
public static NumberFormat getNumberInstance()

format
public String format(double label)

setMaximumFractionDigits
public void setMaximumFractionDigits(int i)

parseDouble
public double parseDouble(String format)
throws ParseException

Throws:
ParseException

Class NumberFormat

2808

Overview (Codename One API)


com.codename1.charts.util

Class MathHelper
java.lang.Object

com.codename1.charts.util.MathHelper

public class
extends Object

Utility class for math operations.

Field Summary
Modifier and Type
static double

Field and Description


NULL_VALUE

A value that is used a null value.

Method Summary
Modifier and Type
static
List<Double>
static double[]

Method and Description


getLabels(double start, double end, int approxNumLabels)

Computes a reasonable set of labels for a data interval and number of


labels.
minmax(List<Double> values)

Calculate the minimum and maximum values out of a list of doubles.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
NULL_VALUE
public static final double NULL_VALUE

A value that is used a null value.


See Also:
Constant Field Values

Method Detail
minmax
public static double[] minmax(List<Double> values)

Calculate the minimum and maximum values out of a list of doubles.


Parameters:
values - the input values
Returns:
an array with the minimum and maximum values

Method Detail

2809

Overview (Codename One API)


getLabels
public static List<Double> getLabels(double start,
double end,
int approxNumLabels)

Computes a reasonable set of labels for a data interval and number of labels.
Parameters:
start - start value
end - final value
approxNumLabels - desired number of labels
Returns:
collection containing the label values

Method Detail

2810

Overview (Codename One API)


com.codename1.charts.util

Class ColorUtil
java.lang.Object

com.codename1.charts.util.ColorUtil

public class
extends Object

Field Summary
Modifier and Type Field and Description
static int

BLACK

static int

BLUE

static int

CYAN

static int

GRAY

static int

GREEN

static int

LTGRAY

static int

MAGENTA

static int

WHITE

static int

YELLOW

Constructor Summary
Constructor and Description
ColorUtil()

Method Summary
Modifier and Type

Method and Description

static int

alpha(int c)

static int

argb(int a, int r, int g, int b)

static int

blue(int c)

static int

green(int c)

static int

red(int c)

static int

rgb(int r, int g, int b)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

Class ColorUtil

2811

Overview (Codename One API)


LTGRAY
public static int LTGRAY

BLUE
public static int BLUE

BLACK
public static int BLACK

WHITE
public static int WHITE

CYAN
public static int CYAN

GREEN
public static int GREEN

YELLOW
public static int YELLOW

MAGENTA
public static int MAGENTA

GRAY
public static int GRAY

Constructor Detail
ColorUtil
public ColorUtil()

Method Detail
argb
public static int argb(int
int
int
int

a,
r,
g,
b)

alpha
public static int alpha(int c)

red
public static int red(int c)

green
public static int green(int c)

blue
public static int blue(int c)

rgb
public static int rgb(int r,
int g,
int b)

Field Detail

2812

Overview (Codename One API)


com.codename1.charts.transitions

Class XYValueSeriesTransition
java.lang.Object

com.codename1.charts.transitions.SeriesTransition

com.codename1.charts.transitions.XYValueSeriesTransition
All Implemented Interfaces:
Animation

public class
extends SeriesTransition

A transition for enabling animations between different values in an XYSeries.

Field Summary

Fields inherited from


class com.codename1.charts.transitions.SeriesTransition
EASING_IN, EASING_IN_OUT, EASING_LINEAR, EASING_OUT

Constructor Summary
Constructor and Description
XYValueSeriesTransition(ChartComponent chart, XYValueSeries series)

Creates a new transition on the given chart and associated series.

Method Summary
Modifier and Type
protected void
XYValueSeries
XYValueSeries

Method and Description


cleanup()

Cleans up after the transition is complete.


getBuffer()

Gets the "buffer" series where values can be set.


getSeries()

Gets the series whose values are to be animated by this transition.


initTransition()

void

Initializes the transition.


update(int progress)

protected void

Updates the series and renderer at the given progress position (0 to


100).

Methods inherited from


class com.codename1.charts.transitions.SeriesTransition
animate, animateChart, getChart, getDuration, getEasing, paint, setChart,
setDuration, setEasing, updateChart

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

2813

Overview (Codename One API)

Constructor

Detail

XYValueSeriesTransition
public XYValueSeriesTransition(ChartComponent chart,
XYValueSeries series)

Creates a new transition on the given chart and associated series. The series should
be one of the series rendered by the given chart.
Parameters:
chart - The ChartComponent that is being used to render the series.
series - The series whose data you wish to animate.

Method Detail
initTransition
public void initTransition()

Initializes the transition. This can be overridden by subclasses to provide their own
functionality to be executed just before the transition occurs.
Overrides:
initTransition in class SeriesTransition
cleanup
protected void cleanup()

Cleans up after the transition is complete.


Overrides:
cleanup in class SeriesTransition
update
protected void update(int progress)

Updates the series and renderer at the given progress position (0 to 100).
Specified by:
update in class SeriesTransition
Parameters:
progress - The progress position in the motion. (0-100).
getBuffer
public XYValueSeries getBuffer()

Gets the "buffer" series where values can be set. Any values set on the buffer will be
applied to the target series during the course of the transition.
Returns:
getSeries
public XYValueSeries getSeries()

Gets the series whose values are to be animated by this transition.


Returns:

Constructor Detail

2814

Overview (Codename One API)


com.codename1.charts.transitions

Class XYSeriesTransition
java.lang.Object

com.codename1.charts.transitions.SeriesTransition

com.codename1.charts.transitions.XYSeriesTransition
All Implemented Interfaces:
Animation

public class
extends SeriesTransition

A transition for enabling animations between different values in an XYSeries.

Field Summary

Fields inherited from


class com.codename1.charts.transitions.SeriesTransition
EASING_IN, EASING_IN_OUT, EASING_LINEAR, EASING_OUT

Constructor Summary
Constructor and Description
XYSeriesTransition(ChartComponent chart, XYSeries series)

Creates a new transition on the given chart and associated series.

Method Summary
Modifier and
Type
protected void
XYSeries
XYSeries

Method and Description


cleanup()

Cleans up after the transition is complete.


getBuffer()

Gets the "buffer" series where values can be set.


getSeries()

Gets the series whose values are to be animated by this transition.


initTransition()

void

Initializes the transition.


update(int progress)

protected void

Updates the series and renderer at the given progress position (0 to


100).

Methods inherited from


class com.codename1.charts.transitions.SeriesTransition
animate, animateChart, getChart, getDuration, getEasing, paint, setChart,
setDuration, setEasing, updateChart

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

2815

Overview (Codename One API)

Constructor

Detail

XYSeriesTransition
public XYSeriesTransition(ChartComponent chart,
XYSeries series)

Creates a new transition on the given chart and associated series. The series should
be one of the series rendered by the given chart.
Parameters:
chart - The ChartComponent that is being used to render the series.
series - The series whose data you wish to animate.

Method Detail
initTransition
public void initTransition()

Initializes the transition. This can be overridden by subclasses to provide their own
functionality to be executed just before the transition occurs.
Overrides:
initTransition in class SeriesTransition
cleanup
protected void cleanup()

Cleans up after the transition is complete.


Overrides:
cleanup in class SeriesTransition
update
protected void update(int progress)

Updates the series and renderer at the given progress position (0 to 100).
Specified by:
update in class SeriesTransition
Parameters:
progress - The progress position in the motion. (0-100).
getBuffer
public XYSeries getBuffer()

Gets the "buffer" series where values can be set. Any values set on the buffer will be
applied to the target series during the course of the transition.
Returns:
getSeries
public XYSeries getSeries()

Gets the series whose values are to be animated by this transition.


Returns:

Constructor Detail

2816

Overview (Codename One API)


com.codename1.charts.transitions

Class XYMultiSeriesTransition
java.lang.Object

com.codename1.charts.transitions.SeriesTransition

com.codename1.charts.transitions.XYMultiSeriesTransition
All Implemented Interfaces:
Animation

public class
extends SeriesTransition

A transition to animate the values of a MultipleSeriesDataset (used by BarChart).

Field Summary

Fields inherited from


class com.codename1.charts.transitions.SeriesTransition
EASING_IN, EASING_IN_OUT, EASING_LINEAR, EASING_OUT

Constructor Summary
Constructor and Description
XYMultiSeriesTransition(ChartComponent chart, XYMultipleSeriesDataset dataset)

Creates a new transition for the given chart and dataset.

Method Summary
Modifier and Type
protected void
XYMultipleSeriesDataset
protected void

Method and Description


cleanup()

Cleans up any settings in the transition.


getBuffer()

Gets the buffer/cache for values.


initTransition()

Initializes the transition for another iteration.


update(int progress)

protected void

Updates the renderer and model at the specified progress


position of the animation.

Methods inherited from


class com.codename1.charts.transitions.SeriesTransition
animate, animateChart, getChart, getDuration, getEasing, paint, setChart,
setDuration, setEasing, updateChart

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Method Detail

2817

Overview (Codename One API)


XYMultiSeriesTransition
public XYMultiSeriesTransition(ChartComponent chart,
XYMultipleSeriesDataset dataset)

Creates a new transition for the given chart and dataset. The dataset must be
rendered by the given chart for this to work correctly.
Parameters:
chart dataset

Method Detail
initTransition
protected void initTransition()

Description copied from class: SeriesTransition


Initializes the transition for another iteration. This can be overridden by subclasses to
provide their own initialization. This method will be called just prior to the transition
taking place. IMPORTANT: Subclasses must make sure to call super.initTransition()
so that the animation will be initialized properly.
Overrides:
initTransition in class SeriesTransition
update
protected void update(int progress)

Description copied from class: SeriesTransition


Updates the renderer and model at the specified progress position of the animation.
Meant to be overridden by subclasses.
Specified by:
update in class SeriesTransition
Parameters:
progress cleanup
protected void cleanup()

Description copied from class: SeriesTransition


Cleans up any settings in the transition. Called after a transition is complete. This is
meant to be overridden by subclasses.
Overrides:
cleanup in class SeriesTransition
getBuffer
public XYMultipleSeriesDataset getBuffer()

Gets the buffer/cache for values. Values set in the buffer will be applied to the target
dataset when the transition takes place.
Returns:

Constructor Detail

2818

Overview (Codename One API)


com.codename1.charts.transitions

Class SeriesTransition
java.lang.Object

com.codename1.charts.transitions.SeriesTransition
All Implemented Interfaces:
Animation
Direct Known Subclasses:
XYMultiSeriesTransition, XYSeriesTransition, XYValueSeriesTransition

public abstract class


extends Object
implements Animation

A base class for series transitions of ChartComponent. This should be overridden by concrete classes
that implement the update(int) method to update the chart's model and renderer appropriately. This
class can serve as a buffer for changes to the model so that they don't affect the ChartComponent
immediately. Changes can either be eased in using animateChart() or updated in one shot using
updateChart().

Field Summary
Modifier and Type Field and Description
static int

EASING_IN

static int

EASING_IN_OUT

static int

EASING_LINEAR

static int

EASING_OUT

Constructor Summary
Constructor and Description
SeriesTransition(ChartComponent chart)
SeriesTransition(ChartComponent chart, int easing)
SeriesTransition(ChartComponent chart, int easing, int duration)

Method Summary
Modifier and Type
boolean

Method and Description


animate()

Allows the animation to reduce "repaint" calls when it returns false.


animateChart()

void

protected void
ChartComponent
int
int

Method Detail

Applies all pending changes to the chart model and renderer using the
current animation settings.
cleanup()

Cleans up any settings in the transition.


getChart()

Gets the ChartComponent that is the subject of the transition.


getDuration()

Gets the duration of the transition.


getEasing()

Gets the type of easing used in the transition.

2819

Overview (Codename One API)


protected void

initTransition()

Initializes the transition for another iteration.


paint(Graphics g)

Draws the animation, within a component the standard paint method


would be invoked since it bares the exact same signature.

void

setChart(ChartComponent chart)

void

Sets the ChartComponent that is the subject of the transition.


setDuration(int duration)

void

Sets the duration of the transition in milliseconds.


setEasing(int easing)

void

Sets the type of easing used in the transition.

protected
abstract void

update(int progress)

Updates the renderer and model at the specified progress position of


the animation.
updateChart()

Applies all pending changes to the chart model and renderer and
repaints the chart.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
EASING_LINEAR
public static final int EASING_LINEAR

See Also:
Constant Field Values
EASING_IN
public static final int EASING_IN

See Also:
Constant Field Values
EASING_OUT
public static final int EASING_OUT

See Also:
Constant Field Values
EASING_IN_OUT
public static final int EASING_IN_OUT

See Also:
Constant Field Values

Constructor Detail
SeriesTransition
public SeriesTransition(ChartComponent chart)

SeriesTransition
public SeriesTransition(ChartComponent chart,
int easing)

Method Summary

2820

Overview (Codename One API)


SeriesTransition
public SeriesTransition(ChartComponent chart,
int easing,
int duration)

Method Detail
initTransition
protected void initTransition()

Initializes the transition for another iteration. This can be overridden by subclasses to
provide their own initialization. This method will be called just prior to the transition
taking place. IMPORTANT: Subclasses must make sure to call super.initTransition()
so that the animation will be initialized properly.
cleanup
protected void cleanup()

Cleans up any settings in the transition. Called after a transition is complete. This is
meant to be overridden by subclasses.
update
protected abstract void update(int progress)

Updates the renderer and model at the specified progress position of the animation.
Meant to be overridden by subclasses.
Parameters:
progress - The progress of the animation (between 0 and 100).
animate
public boolean animate()

Description copied from interface: Animation


Allows the animation to reduce "repaint" calls when it returns false. It is called once
for every frame. Frames are defined by the Display class.
Specified by:
animate in interface Animation
Returns:
true if a repaint is desired or false if no repaint is necessary
paint
public void paint(Graphics g)

Description copied from interface: Animation


Draws the animation, within a component the standard paint method would be
invoked since it bares the exact same signature.
Specified by:
paint in interface Animation
Parameters:
g - graphics context
getChart
public ChartComponent getChart()

Gets the ChartComponent that is the subject of the transition.


Returns:
the chart
setChart
public void setChart(ChartComponent chart)

Sets the ChartComponent that is the subject of the transition.


Parameters:
chart - the chart to set

Constructor Detail

2821

Overview (Codename One API)


getDuration
public int getDuration()

Gets the duration of the transition. (in milliseconds)


Returns:
the duration
setDuration
public void setDuration(int duration)

Sets the duration of the transition in milliseconds.


Parameters:
duration - the duration to set
getEasing
public int getEasing()

Gets the type of easing used in the transition. Should be one of EASING_LINEAR,
EASING_IN, EASING_OUT, or EASING_IN_OUT.
Returns:
the easing
setEasing
public void setEasing(int easing)

Sets the type of easing used in the transition. Should be one of EASING_LINEAR,
EASING_IN, EASING_OUT, or EASING_IN_OUT.
Parameters:
easing - the easing to set
animateChart
public void animateChart()

Applies all pending changes to the chart model and renderer using the current
animation settings.
updateChart
public void updateChart()

Applies all pending changes to the chart model and renderer and repaints the chart.
This is basically like calling animateChart() with a duration of 0.

Method Detail

2822

Overview (Codename One API)


com.codename1.charts.renderers

Class XYSeriesRenderer
java.lang.Object

com.codename1.charts.renderers.SimpleSeriesRenderer

com.codename1.charts.renderers.XYSeriesRenderer

public class
extends SimpleSeriesRenderer

A renderer for the XY type series.

Nested Class Summary


Modifier and Type
static class

Class and Description


XYSeriesRenderer.FillOutsideLine

A descriptor for the line fill behavior.

Constructor Summary
Constructor and Description
XYSeriesRenderer()

Method Summary
Modifier and Type
void
int
int
float
float
int
float
int
XYSeriesRenderer.FillOutsideLine[]
float
float
PointStyle
boolean

Class XYSeriesRenderer

Method and Description

addFillOutsideLine(XYSeriesRenderer.FillOutsideLine fil

Sets if the line chart should be filled outside its line.


getAnnotationsColor()

Returns the annotations color.


getAnnotationsTextAlign()

Returns the annotations text align.


getAnnotationsTextSize()

Returns the annotations text size.


getChartValuesSpacing()

Returns the chart values spacing from the data point.


getChartValuesTextAlign()

Returns the chart values text align.


getChartValuesTextSize()

Returns the chart values text size.


getDisplayChartValuesDistance()

Returns the chart values minimum distance.


getFillOutsideLine()

Returns the type of the outside fill of the line.


getLineWidth()

Returns the chart line width.


getPointStrokeWidth()

Returns the point stroke width in pixels.


getPointStyle()

Returns the point style.


isDisplayChartValues()

Returns if the chart point values should be displayed as text.

2823

Overview (Codename One API)


isFillBelowLine()
boolean

boolean

Deprecated.
Use getFillOutsideLine() instead.
isFillPoints()

Returns if the chart points should be filled.


setAnnotationsColor(int color)

void

Sets the annotations color.


setAnnotationsTextAlign(int align)

void

Sets the annotations text align.


setAnnotationsTextFont(Font font)

Sets the annotations text font size using a Font object instead
a point size.

void

setAnnotationsTextSize(float textSize)

void

Sets the annotations text size.


setChartValuesSpacing(float spacing)

void

Sets the chart values spacing from the data point.


setChartValuesTextAlign(int align)

void

Sets the chart values text align.


setChartValuesTextFont(Font font)

Sets the chart values title text font size using a Font object
instead of a point size.

void

setChartValuesTextSize(float textSize)

void

Sets the chart values text size.


setDisplayChartValues(boolean display)

void

Sets if the chart point values should be displayed as text.


setDisplayChartValuesDistance(int distance)

void

Sets chart values minimum distance.


setFillBelowLine(boolean fill)

Deprecated.
Use addFillOutsideLine(FillOutsideLine) instead.

void

setFillBelowLineColor(int color)

Deprecated.
Use FillOutsideLine.setColor instead

void

setFillPoints(boolean fill)

void

Sets if the chart points should be filled.


setLineWidth(float lineWidth)

void

Sets the chart line width.


setPointStrokeWidth(float strokeWidth)

void

Sets the point stroke width in pixels.


setPointStyle(PointStyle style)

void

Sets the point style.

Methods inherited from


class com.codename1.charts.renderers.SimpleSeriesRenderer
getChartValuesFormat, getColor, getGradientStartColor,
getGradientStartValue, getGradientStopColor, getGradientStopValue,
getStroke, isDisplayBoundingPoints, isGradientEnabled, isHighlighted,
isShowLegendItem, setChartValuesFormat, setColor, setDisplayBoundingPoints,
setGradientEnabled, setGradientStart, setGradientStop, setHighlighted,
setShowLegendItem, setStroke

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Method Summary

2824

Overview (Codename One API)


XYSeriesRenderer
public XYSeriesRenderer()

Method Detail
isFillBelowLine
@Deprecated
public boolean isFillBelowLine()

Deprecated. Use getFillOutsideLine() instead.


Returns if the chart should be filled below the line.
Returns:
the fill below line status
setFillBelowLine
@Deprecated
public void setFillBelowLine(boolean fill)

Deprecated. Use addFillOutsideLine(FillOutsideLine) instead.


Sets if the line chart should be filled below its line. Filling below the line transforms a
line chart into an area chart.
Parameters:
fill - the fill below line flag value
getFillOutsideLine
public XYSeriesRenderer.FillOutsideLine[] getFillOutsideLine()

Returns the type of the outside fill of the line.


Returns:
the type of the outside fill of the line.
addFillOutsideLine
public void addFillOutsideLine(XYSeriesRenderer.FillOutsideLine fill)

Sets if the line chart should be filled outside its line. Filling outside with
FillOutsideLine.INTEGRAL the line transforms a line chart into an area chart.
Parameters:
fill - the type of the filling
isFillPoints
public boolean isFillPoints()

Returns if the chart points should be filled.


Returns:
the points fill status
setFillPoints
public void setFillPoints(boolean fill)

Sets if the chart points should be filled.


Parameters:
fill - the points fill flag value
setFillBelowLineColor
@Deprecated
public void setFillBelowLineColor(int color)

Deprecated. Use FillOutsideLine.setColor instead


Sets the fill below the line color.
Parameters:
color - the fill below line color

Constructor Detail

2825

Overview (Codename One API)


getPointStyle
public PointStyle getPointStyle()

Returns the point style.


Returns:
the point style
setPointStyle
public void setPointStyle(PointStyle style)

Sets the point style.


Parameters:
style - the point style
getPointStrokeWidth
public float getPointStrokeWidth()

Returns the point stroke width in pixels.


Returns:
the point stroke width in pixels
setPointStrokeWidth
public void setPointStrokeWidth(float strokeWidth)

Sets the point stroke width in pixels.


Parameters:
strokeWidth - the point stroke width in pixels
getLineWidth
public float getLineWidth()

Returns the chart line width.


Returns:
the line width
setLineWidth
public void setLineWidth(float lineWidth)

Sets the chart line width.


Parameters:
lineWidth - the line width
isDisplayChartValues
public boolean isDisplayChartValues()

Returns if the chart point values should be displayed as text.


Returns:
if the chart point values should be displayed as text
setDisplayChartValues
public void setDisplayChartValues(boolean display)

Sets if the chart point values should be displayed as text.


Parameters:
display - if the chart point values should be displayed as text
getDisplayChartValuesDistance
public int getDisplayChartValuesDistance()

Returns the chart values minimum distance.


Returns:
the chart values minimum distance

Method Detail

2826

Overview (Codename One API)


setDisplayChartValuesDistance
public void setDisplayChartValuesDistance(int distance)

Sets chart values minimum distance.


Parameters:
distance - the chart values minimum distance
getChartValuesTextSize
public float getChartValuesTextSize()

Returns the chart values text size.


Returns:
the chart values text size
setChartValuesTextSize
public void setChartValuesTextSize(float textSize)

Sets the chart values text size. Consider using


setChartValuesTextFont(com.codename1.ui.Font)

instead to allow the font size to to

be adjusted appropriately for the display resolution.


Parameters:
textSize - the chart values text size
setChartValuesTextFont
public void setChartValuesTextFont(Font font)

Sets the chart values title text font size using a Font object instead of a point size.
This method is the preferred way to set font size because it allows you to more easily
have fonts appear in an appropriate size for the target device. Alternatively check out
setChartValuesTextSize(float) to set the text size in pixels.
Parameters:
font getChartValuesTextAlign
public int getChartValuesTextAlign()

Returns the chart values text align.


Returns:
the chart values text align
setChartValuesTextAlign
public void setChartValuesTextAlign(int align)

Sets the chart values text align.


Parameters:
align - the chart values text align
getChartValuesSpacing
public float getChartValuesSpacing()

Returns the chart values spacing from the data point.


Returns:
the chart values spacing
setChartValuesSpacing
public void setChartValuesSpacing(float spacing)

Sets the chart values spacing from the data point.


Parameters:
spacing - the chart values spacing (in pixels) from the chart data point
getAnnotationsTextSize
public float getAnnotationsTextSize()

Returns the annotations text size.


Returns:

Method Detail

2827

Overview (Codename One API)


the annotations text size
setAnnotationsTextSize
public void setAnnotationsTextSize(float textSize)

Sets the annotations text size. Consider using


setAnnotationsTextFont(com.codename1.ui.Font)

instead to allow the font size to to

be adjusted appropriately for the display resolution.


Parameters:
textSize - the annotations text size
setAnnotationsTextFont
public void setAnnotationsTextFont(Font font)

Sets the annotations text font size using a Font object instead of a point size. This
method is the preferred way to set font size because it allows you to more easily have
fonts appear in an appropriate size for the target device. Alternatively check out
setAnnotationsTextSize(float) to set the text size in pixels.
Parameters:
font getAnnotationsTextAlign
public int getAnnotationsTextAlign()

Returns the annotations text align.


Returns:
the annotations text align
setAnnotationsTextAlign
public void setAnnotationsTextAlign(int align)

Sets the annotations text align.


Parameters:
align - the chart values text align
getAnnotationsColor
public int getAnnotationsColor()

Returns the annotations color.


Returns:
the annotations color
setAnnotationsColor
public void setAnnotationsColor(int color)

Sets the annotations color.


Parameters:
color - the annotations color

Method Detail

2828

Overview (Codename One API)


com.codename1.charts.renderers

Class XYSeriesRenderer.FillOutsideLine
java.lang.Object

com.codename1.charts.renderers.XYSeriesRenderer.FillOutsideLine
Enclosing class:
XYSeriesRenderer

public static class


extends Object

A descriptor for the line fill behavior.

Nested Class Summary


Modifier and Type
static class

Class and Description


XYSeriesRenderer.FillOutsideLine.Type

Constructor Summary
Constructor and Description
FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type type)

The line fill behavior.

Method Summary
Modifier and Type

Method and Description


getColor()

int

Returns the fill color.


getFillRange()

Returns the fill range which is the minimum and


maximum data index values for the fill.

int[]

XYSeriesRenderer.FillOutsideLine.Type

getType()

Returns the fill type.


setColor(int color)

void

Sets the fill color


setFillRange(int[] range)

Sets the fill range which is the minimum and


maximum data index values for the fill.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FillOutsideLine
public FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type type)

The line fill behavior.


Parameters:

Class XYSeriesRenderer.FillOutsideLine

2829

Overview (Codename One API)


type

- the fill type

Method Detail
getColor
public int getColor()

Returns the fill color.


Returns:
the fill color
setColor
public void setColor(int color)

Sets the fill color


Parameters:
color - the fill color
getType
public XYSeriesRenderer.FillOutsideLine.Type getType()

Returns the fill type.


Returns:
the fill type
getFillRange
public int[] getFillRange()

Returns the fill range which is the minimum and maximum data index values for the
fill.
Returns:
the fill range
setFillRange
public void setFillRange(int[] range)

Sets the fill range which is the minimum and maximum data index values for the fill.
Parameters:
range - the fill range

Constructor Detail

2830

Overview (Codename One API)


com.codename1.charts.renderers

Enum XYSeriesRenderer.FillOutsideLine.Type
java.lang.Object

java.lang.Enum<XYSeriesRenderer.FillOutsideLine.Type>

com.codename1.charts.renderers.XYSeriesRenderer.FillOutsideLine.Type
All Implemented Interfaces:
Comparable<XYSeriesRenderer.FillOutsideLine.Type>
Enclosing class:
XYSeriesRenderer.FillOutsideLine

public static enum


extends Enum<XYSeriesRenderer.FillOutsideLine.Type>

Enum Constant Summary


Enum Constant and Description
ABOVE
BELOW
BOUNDS_ABOVE
BOUNDS_ALL
BOUNDS_BELOW
NONE

Method Summary
Modifier and Type
static
XYSeriesRenderer.FillOutsideLine.Type

Method and Description


valueOf(String name)

Returns the enum constant of this type with


the specified name.
values()

static
XYSeriesRenderer.FillOutsideLine.Type[]

Returns an array containing the constants


of this enum type, in the order they are
declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


NONE
public static final XYSeriesRenderer.FillOutsideLine.Type NONE

Method Detail

2831

Overview (Codename One API)


BOUNDS_ALL
public static final XYSeriesRenderer.FillOutsideLine.Type BOUNDS_ALL

BOUNDS_BELOW
public static final XYSeriesRenderer.FillOutsideLine.Type BOUNDS_BELOW

BOUNDS_ABOVE
public static final XYSeriesRenderer.FillOutsideLine.Type BOUNDS_ABOVE

BELOW
public static final XYSeriesRenderer.FillOutsideLine.Type BELOW

ABOVE
public static final XYSeriesRenderer.FillOutsideLine.Type ABOVE

Method Detail
values
public static XYSeriesRenderer.FillOutsideLine.Type[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:

for (XYSeriesRenderer.FillOutsideLine.Type c : XYSeriesRenderer.FillOutsideLine.Type


System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static XYSeriesRenderer.FillOutsideLine.Type valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Enum Constant Detail

2832

Overview (Codename One API)


com.codename1.charts.renderers

Class XYMultipleSeriesRenderer
java.lang.Object

com.codename1.charts.renderers.DefaultRenderer

com.codename1.charts.renderers.XYMultipleSeriesRenderer

public class
extends DefaultRenderer

Multiple XY series renderer.

Nested Class Summary


Modifier and Type
static class

Class and Description


XYMultipleSeriesRenderer.Orientation

An enum for the XY chart orientation of the X axis.

Field Summary

Fields inherited from


class com.codename1.charts.renderers.DefaultRenderer
BACKGROUND_COLOR, NO_COLOR, TEXT_COLOR

Constructor Summary
Constructor and Description
XYMultipleSeriesRenderer()
XYMultipleSeriesRenderer(int scaleNumber)

Method Summary
Modifier and Type

Method and Description


addTextLabel(double x, String text)

void

void
void
void

Deprecated.
use addXTextLabel instead
addXTextLabel(double x, String text)

Adds a new text label for the specified X axis value.


addYTextLabel(double y, String text)

Adds a new text label for the specified Y axis value.


addYTextLabel(double y, String text, int scale)

Adds a new text label for the specified Y axis value.


clearTextLabels()

void

void
void
void

Method Detail

Deprecated.
use clearXTextLabels instead
clearXTextLabels()

Clears the existing text labels on the X axis.


clearYTextLabels()

Clears the existing text labels on the Y axis.


clearYTextLabels(int scale)

Clears the existing text labels on the Y axis.

2833

Overview (Codename One API)


float
double

getAxisTitleTextSize()

Returns the axis title text size.


getBarSpacing()

Returns the spacing between bars, in bar charts.


getBarsSpacing()

double

float
int
double[]
double[]

Deprecated.
use getBarSpacing instead
getBarWidth()

Returns the constant bar chart item width in pixels.


getGridColor(int scale)

Returns the grid color.


getInitialRange()

Returns the initial range.


getInitialRange(int scale)

Returns the initial range.


getLabelFormat()

NumberFormat

int
XYMultipleSeriesRenderer.Orientation
double[]
float
int
double
double
double
double
NumberFormat
int
int
float
int
float
String
Double[]
String
int
double
double

Method Summary

Deprecated.
use getXLabelFormat and getYLabelFormat instead
getMarginsColor()

Returns the margins color.


getOrientation()

Returns the current orientation of the chart X axis.


getPanLimits()

Returns the pan limits.


getPointSize()

Returns the size of the points, for charts displaying points.


getScalesCount()
getXAxisMax()

Returns the end value of the X axis range.


getXAxisMax(int scale)

Returns the end value of the X axis range.


getXAxisMin()

Returns the start value of the X axis range.


getXAxisMin(int scale)

Returns the start value of the X axis range.


getXLabelFormat()

Returns the number format for displaying X axis labels.


getXLabels()

Returns the approximate number of labels for the X axis.


getXLabelsAlign()

Returns the X axis labels alignment.


getXLabelsAngle()

Returns the rotation angle of labels for the X axis.


getXLabelsColor()

Returns the X axis labels color.


getXLabelsPadding()

Returns the X labels padding.


getXTextLabel(Double x)

Returns the X axis text label at the specified X axis value.


getXTextLabelLocations()

Returns the X text label locations.


getXTitle()

Returns the title for the X axis.


getYAxisAlign(int scale)
getYAxisMax()

Returns the end value of the Y axis range.


getYAxisMax(int scale)

2834

Overview (Codename One API)


Returns the end value of the Y axis range.
double
double
NumberFormat
int
int
float
int
float
float
String
String
Double[]
Double[]
String
String
double
double
double[]

getYAxisMin()

Returns the start value of the Y axis range.


getYAxisMin(int scale)

Returns the start value of the Y axis range.


getYLabelFormat(int scale)

Returns the number format for Y axis displaying labels.


getYLabels()

Returns the approximate number of labels for the Y axis.


getYLabelsAlign(int scale)

Returns the Y axis labels alignment.


getYLabelsAngle()

Returns the rotation angle of labels for the Y axis.


getYLabelsColor(int scale)

Returns the Y axis labels color.


getYLabelsPadding()

Returns the Y labels padding.


getYLabelsVerticalPadding()

Returns the Y labels vertical padding.


getYTextLabel(Double y)

Returns the Y axis text label at the specified Y axis value.


getYTextLabel(Double y, int scale)

Returns the Y axis text label at the specified Y axis value.


getYTextLabelLocations()

Returns the Y text label locations.


getYTextLabelLocations(int scale)

Returns the Y text label locations.


getYTitle()

Returns the title for the Y axis.


getYTitle(int scale)

Returns the title for the Y axis.


getZoomInLimitX()

Returns the zoom in limit permitted in the axis X.


getZoomInLimitY()

Returns the zoom in limit permitted in the axis Y.


getZoomLimits()

Returns the zoom limits.

void

initAxesRange(int scales)

void

initAxesRangeForScale(int i)

boolean

isInitialRangeSet()

boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

Method Summary

isInitialRangeSet(int scale)

Returns if the initial range is set.


isMaxXSet()

Returns if the maximum X value was set.


isMaxXSet(int scale)

Returns if the maximum X value was set.


isMaxYSet()

Returns if the maximum Y value was set.


isMaxYSet(int scale)

Returns if the maximum Y value was set.


isMinXSet()

Returns if the minimum X value was set.


isMinXSet(int scale)

Returns if the minimum X value was set.


isMinYSet()

Returns if the minimum Y value was set.

2835

Overview (Codename One API)


boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
void
void

isMinYSet(int scale)

Returns if the minimum Y value was set.


isPanEnabled()

Returns the enabled state of the pan on at least one axis.


isPanXEnabled()

Returns the enabled state of the pan on X axis.


isPanYEnabled()

Returns the enabled state of the pan on Y axis.


isXRoundedLabels()

If X axis labels should be rounded.


isZoomEnabled()

Returns the enabled state of the zoom on at least one axis.


isZoomXEnabled()

Returns the enabled state of the zoom on X axis.


isZoomYEnabled()

Returns the enabled state of the zoom on Y axis.


removeXTextLabel(double x)

Removes text label for the specified X axis value.


removeYTextLabel(double y)

Removes text label for the specified Y axis value.


removeYTextLabel(double y, int scale)

Removes text label for the specified Y axis value.


setAxisTitleTextFont(Font font)

void

void
void
void
void
void
void
void
void
void

void

void
void
void
void
void
void

Method Summary

Sets the Axis title text font size using a Font object instead o
size.
setAxisTitleTextSize(float textSize)

Sets the axis title text size.


setBarSpacing(double spacing)

Sets the spacing between bars, in bar charts.


setBarWidth(float width)

Sets the bar chart item constant width in pixels.


setGridColor(int color)

Sets the color of the grid.


setGridColor(int color, int scale)

Sets the color of the grid.


setInitialRange(double[] range)

Sets the axes initial range values.


setInitialRange(double[] range, int scale)

Sets the axes initial range values.


setMarginsColor(int color)

Sets the color of the margins.

setOrientation(XYMultipleSeriesRenderer.Orientation o

Sets the current orientation of the chart X axis.


setPanEnabled(boolean enabled)
Override DefaultRenderer.setPanEnabled(boolean)
delegated to setPanEnabled(boolean, boolean).

so it ca

setPanEnabled(boolean enabledX, boolean enabledY)

Sets the enabled state of the pan.


setPanLimits(double[] panLimits)

Sets the pan limits as an array of 4 values.


setPointSize(float size)

Sets the size of the points, for charts displaying points.


setRange(double[] range)
setRange(double[] range, int scale)

Sets the axes range values.


setXAxisMax(double max)

Sets the end value of the X axis range.

2836

Overview (Codename One API)


void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

Method Summary

setXAxisMax(double max, int scale)

Sets the end value of the X axis range.


setXAxisMin(double min)

Sets the start value of the X axis range.


setXAxisMin(double min, int scale)

Sets the start value of the X axis range.


setXLabelFormat(NumberFormat format)

Sets the number format for X axis displaying labels.


setXLabels(int xLabels)

Sets the approximate number of labels for the X axis.


setXLabelsAlign(int align)

Sets the X axis labels alignment.


setXLabelsAngle(float angle)

Sets the rotation angle (in degrees) of labels for the X axis.
setXLabelsColor(int color)

Sets the X axis labels color.


setXLabelsPadding(float padding)

Sets the X labels padding


setXRoundedLabels(boolean rounded)

Sets if X axis rounded time values to be used.


setXTitle(String title)

Sets the title for the X axis.


setYAxisAlign(int align, int scale)
setYAxisMax(double max)

Sets the end value of the Y axis range.


setYAxisMax(double max, int scale)

Sets the end value of the Y axis range.


setYAxisMin(double min)

Sets the start value of the Y axis range.


setYAxisMin(double min, int scale)

Sets the start value of the Y axis range.


setYLabelFormat(NumberFormat format, int scale)

Sets the number format for Y axis displaying labels.


setYLabels(int yLabels)

Sets the approximate number of labels for the Y axis.


setYLabelsAlign(int align)
setYLabelsAlign(int align, int scale)

Sets the Y axis labels alignment.


setYLabelsAngle(float angle)

Sets the rotation angle (in degrees) of labels for the Y axis.
setYLabelsColor(int scale, int color)

Sets the Y axis labels color.


setYLabelsPadding(float padding)

Sets the Y labels padding


setYLabelsVerticalPadding(float padding)

Sets the Y labels vertical padding


setYTitle(String title)

Sets the title for the Y axis.


setYTitle(String title, int scale)

Sets the title for the Y axis.


setZoomEnabled(boolean enabledX, boolean enabledY)

Sets the enabled state of the zoom.


setZoomInLimitX(double zoomInLimitX)

Sets the zoom in limit permitted in the axis X.


setZoomInLimitY(double zoomInLimitY)

Sets zoom in limit permitted in the axis Y.


setZoomLimits(double[] zoomLimits)

2837

Overview (Codename One API)


Sets the zoom limits as an array of 4 values.

Methods inherited from


class com.codename1.charts.renderers.DefaultRenderer
addSeriesRenderer, addSeriesRenderer, getAxesColor, getBackgroundColor,
getChartTitle, getChartTitleTextSize, getLabelsColor, getLabelsTextSize,
getLegendHeight, getLegendTextSize, getMargins, getOriginalScale, getScale,
getSelectableBuffer, getSeriesRendererAt, getSeriesRendererCount,
getSeriesRenderers, getStartAngle, getTextTypeface, getTextTypefaceName,
getTextTypefaceStyle, getXAxisColor, getYAxisColor, getZoomRate,
isAntialiasing, isApplyBackgroundColor, isClickEnabled, isDisplayValues,
isExternalZoomEnabled, isFitLegend, isInScroll, isShowAxes,
isShowCustomTextGridX, isShowCustomTextGridY, isShowGridX, isShowGridY,
isShowLabels, isShowLegend, isShowTickMarks, isZoomButtonsVisible,
removeAllRenderers, removeSeriesRenderer, setAntialiasing,
setApplyBackgroundColor, setAxesColor, setBackgroundColor, setChartTitle,
setChartTitleTextFont, setChartTitleTextSize, setClickEnabled,
setDisplayValues, setExternalZoomEnabled, setFitLegend, setInScroll,
setLabelsColor, setLabelsTextFont, setLabelsTextSize, setLegendHeight,
setLegendTextFont, setLegendTextSize, setMargins, setScale,
setSelectableBuffer, setShowAxes, setShowCustomTextGrid,
setShowCustomTextGridX, setShowCustomTextGridY, setShowGrid, setShowGridX,
setShowGridY, setShowLabels, setShowLegend, setShowTickMarks,
setStartAngle, setTextTypeface, setTextTypeface, setXAxisColor,
setYAxisColor, setZoomButtonsVisible, setZoomEnabled, setZoomRate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XYMultipleSeriesRenderer
public XYMultipleSeriesRenderer()

XYMultipleSeriesRenderer
public XYMultipleSeriesRenderer(int scaleNumber)

Method Detail
initAxesRange
public void initAxesRange(int scales)

initAxesRangeForScale
public void initAxesRangeForScale(int i)

getOrientation
public XYMultipleSeriesRenderer.Orientation getOrientation()

Returns the current orientation of the chart X axis.


Returns:
the chart orientation
setOrientation
public void setOrientation(XYMultipleSeriesRenderer.Orientation orientation)

Sets the current orientation of the chart X axis.


Parameters:
orientation - the chart orientation

Methods inherited from class com.codename1.charts.renderers.DefaultRenderer

2838

Overview (Codename One API)


getXTitle
public String getXTitle()

Returns the title for the X axis.


Returns:
the X axis title
setXTitle
public void setXTitle(String title)

Sets the title for the X axis.


Parameters:
title - the X axis title
getYTitle
public String getYTitle()

Returns the title for the Y axis.


Returns:
the Y axis title
getYTitle
public String getYTitle(int scale)

Returns the title for the Y axis.


Parameters:
scale - the renderer scale
Returns:
the Y axis title
setYTitle
public void setYTitle(String title)

Sets the title for the Y axis.


Parameters:
title - the Y axis title
setYTitle
public void setYTitle(String title,
int scale)

Sets the title for the Y axis.


Parameters:
title - the Y axis title
scale - the renderer scale
getAxisTitleTextSize
public float getAxisTitleTextSize()

Returns the axis title text size.


Returns:
the axis title text size
setAxisTitleTextSize
public void setAxisTitleTextSize(float textSize)

Sets the axis title text size. Consider using


instead to allow the font size to to
be adjusted appropriately for the display resolution.
Parameters:
textSize - the chart axis text size
setAxisTitleTextFont
setAxisTitleTextFont(com.codename1.ui.Font)

public void setAxisTitleTextFont(Font font)

Method Detail

2839

Overview (Codename One API)


Sets the Axis title text font size using a Font object instead of a point size. This
method is the preferred way to set font size because it allows you to more easily have
fonts appear in an appropriate size for the target device. Alternatively check out
setAxisTitleTextSize(float) to set the text size in pixels.
Parameters:
font getXAxisMin
public double getXAxisMin()

Returns the start value of the X axis range.


Returns:
the X axis range start value
setXAxisMin
public void setXAxisMin(double min)

Sets the start value of the X axis range.


Parameters:
min - the X axis range start value
isMinXSet
public boolean isMinXSet()

Returns if the minimum X value was set.


Returns:
the minX was set or not
getXAxisMax
public double getXAxisMax()

Returns the end value of the X axis range.


Returns:
the X axis range end value
setXAxisMax
public void setXAxisMax(double max)

Sets the end value of the X axis range.


Parameters:
max - the X axis range end value
isMaxXSet
public boolean isMaxXSet()

Returns if the maximum X value was set.


Returns:
the maxX was set or not
getYAxisMin
public double getYAxisMin()

Returns the start value of the Y axis range.


Returns:
the Y axis range end value
setYAxisMin
public void setYAxisMin(double min)

Sets the start value of the Y axis range.


Parameters:
min - the Y axis range start value
isMinYSet
public boolean isMinYSet()

Returns if the minimum Y value was set.

Method Detail

2840

Overview (Codename One API)


Returns:
the minY was set or not
getYAxisMax
public double getYAxisMax()

Returns the end value of the Y axis range.


Returns:
the Y axis range end value
setYAxisMax
public void setYAxisMax(double max)

Sets the end value of the Y axis range.


Parameters:
max - the Y axis range end value
isMaxYSet
public boolean isMaxYSet()

Returns if the maximum Y value was set.


Returns:
the maxY was set or not
getXAxisMin
public double getXAxisMin(int scale)

Returns the start value of the X axis range.


Parameters:
scale - the renderer scale
Returns:
the X axis range start value
setXAxisMin
public void setXAxisMin(double min,
int scale)

Sets the start value of the X axis range.


Parameters:
min - the X axis range start value
scale - the renderer scale
isMinXSet
public boolean isMinXSet(int scale)

Returns if the minimum X value was set.


Parameters:
scale - the renderer scale
Returns:
the minX was set or not
getXAxisMax
public double getXAxisMax(int scale)

Returns the end value of the X axis range.


Parameters:
scale - the renderer scale
Returns:
the X axis range end value
setXAxisMax
public void setXAxisMax(double max,
int scale)

Sets the end value of the X axis range.


Parameters:
max - the X axis range end value

Method Detail

2841

Overview (Codename One API)


scale

- the renderer scale

isMaxXSet
public boolean isMaxXSet(int scale)

Returns if the maximum X value was set.


Parameters:
scale - the renderer scale
Returns:
the maxX was set or not
getYAxisMin
public double getYAxisMin(int scale)

Returns the start value of the Y axis range.


Parameters:
scale - the renderer scale
Returns:
the Y axis range end value
setYAxisMin
public void setYAxisMin(double min,
int scale)

Sets the start value of the Y axis range.


Parameters:
min - the Y axis range start value
scale - the renderer scale
isMinYSet
public boolean isMinYSet(int scale)

Returns if the minimum Y value was set.


Parameters:
scale - the renderer scale
Returns:
the minY was set or not
getYAxisMax
public double getYAxisMax(int scale)

Returns the end value of the Y axis range.


Parameters:
scale - the renderer scale
Returns:
the Y axis range end value
setYAxisMax
public void setYAxisMax(double max,
int scale)

Sets the end value of the Y axis range.


Parameters:
max - the Y axis range end value
scale - the renderer scale
isMaxYSet
public boolean isMaxYSet(int scale)

Returns if the maximum Y value was set.


Parameters:
scale - the renderer scale
Returns:
the maxY was set or not

Method Detail

2842

Overview (Codename One API)


getXLabels
public int getXLabels()

Returns the approximate number of labels for the X axis.


Returns:
the approximate number of labels for the X axis
setXLabels
public void setXLabels(int xLabels)

Sets the approximate number of labels for the X axis.


Parameters:
xLabels - the approximate number of labels for the X axis
addTextLabel
public void addTextLabel(double x,
String text)

Deprecated. use addXTextLabel instead


Adds a new text label for the specified X axis value.
Parameters:
x - the X axis value
text - the text label
addXTextLabel
public void addXTextLabel(double x,
String text)

Adds a new text label for the specified X axis value.


Parameters:
x - the X axis value
text - the text label
removeXTextLabel
public void removeXTextLabel(double x)

Removes text label for the specified X axis value.


Parameters:
x - the X axis value
getXTextLabel
public String getXTextLabel(Double x)

Returns the X axis text label at the specified X axis value.


Parameters:
x - the X axis value
Returns:
the X axis text label
getXTextLabelLocations
public Double[] getXTextLabelLocations()

Returns the X text label locations.


Returns:
the X text label locations
clearTextLabels
public void clearTextLabels()

Deprecated. use clearXTextLabels instead


Clears the existing text labels.
clearXTextLabels
public void clearXTextLabels()

Clears the existing text labels on the X axis.

Method Detail

2843

Overview (Codename One API)


isXRoundedLabels
public boolean isXRoundedLabels()

If X axis labels should be rounded.


Returns:
if rounded time values to be used
setXRoundedLabels
public void setXRoundedLabels(boolean rounded)

Sets if X axis rounded time values to be used.


Parameters:
rounded - rounded values to be used
addYTextLabel
public void addYTextLabel(double y,
String text)

Adds a new text label for the specified Y axis value.


Parameters:
y - the Y axis value
text - the text label
removeYTextLabel
public void removeYTextLabel(double y)

Removes text label for the specified Y axis value.


Parameters:
y - the Y axis value
addYTextLabel
public void addYTextLabel(double y,
String text,
int scale)

Adds a new text label for the specified Y axis value.


Parameters:
y - the Y axis value
text - the text label
scale - the renderer scale
removeYTextLabel
public void removeYTextLabel(double y,
int scale)

Removes text label for the specified Y axis value.


Parameters:
y - the Y axis value
scale - the renderer scale
getYTextLabel
public String getYTextLabel(Double y)

Returns the Y axis text label at the specified Y axis value.


Parameters:
y - the Y axis value
Returns:
the Y axis text label
getYTextLabel
public String getYTextLabel(Double y,
int scale)

Returns the Y axis text label at the specified Y axis value.


Parameters:
y - the Y axis value
scale - the renderer scale

Method Detail

2844

Overview (Codename One API)


Returns:
the Y axis text label
getYTextLabelLocations
public Double[] getYTextLabelLocations()

Returns the Y text label locations.


Returns:
the Y text label locations
getYTextLabelLocations
public Double[] getYTextLabelLocations(int scale)

Returns the Y text label locations.


Parameters:
scale - the renderer scale
Returns:
the Y text label locations
clearYTextLabels
public void clearYTextLabels()

Clears the existing text labels on the Y axis.


clearYTextLabels
public void clearYTextLabels(int scale)

Clears the existing text labels on the Y axis.


Parameters:
scale - the renderer scale
getYLabels
public int getYLabels()

Returns the approximate number of labels for the Y axis.


Returns:
the approximate number of labels for the Y axis
setYLabels
public void setYLabels(int yLabels)

Sets the approximate number of labels for the Y axis.


Parameters:
yLabels - the approximate number of labels for the Y axis
getBarWidth
public float getBarWidth()

Returns the constant bar chart item width in pixels.


Returns:
the bar width
setBarWidth
public void setBarWidth(float width)

Sets the bar chart item constant width in pixels.


Parameters:
width - width in pixels
isPanEnabled
public boolean isPanEnabled()

Returns the enabled state of the pan on at least one axis.


Overrides:
isPanEnabled in class DefaultRenderer
Returns:
if pan is enabled

Method Detail

2845

Overview (Codename One API)


isPanXEnabled
public boolean isPanXEnabled()

Returns the enabled state of the pan on X axis.


Returns:
if pan is enabled on X axis
isPanYEnabled
public boolean isPanYEnabled()

Returns the enabled state of the pan on Y axis.


Returns:
if pan is enabled on Y axis
setPanEnabled
public void setPanEnabled(boolean enabledX,
boolean enabledY)

Sets the enabled state of the pan.


Parameters:
enabledX - pan enabled on X axis
enabledY - pan enabled on Y axis
setPanEnabled
public void setPanEnabled(boolean enabled)

Override DefaultRenderer.setPanEnabled(boolean) so it can be delegated to


setPanEnabled(boolean, boolean).
Overrides:
setPanEnabled in class DefaultRenderer
Parameters:
enabled - pan enabled
isZoomEnabled
public boolean isZoomEnabled()

Returns the enabled state of the zoom on at least one axis.


Overrides:
isZoomEnabled in class DefaultRenderer
Returns:
if zoom is enabled
isZoomXEnabled
public boolean isZoomXEnabled()

Returns the enabled state of the zoom on X axis.


Returns:
if zoom is enabled on X axis
isZoomYEnabled
public boolean isZoomYEnabled()

Returns the enabled state of the zoom on Y axis.


Returns:
if zoom is enabled on Y axis
setZoomEnabled
public void setZoomEnabled(boolean enabledX,
boolean enabledY)

Sets the enabled state of the zoom.


Parameters:
enabledX - zoom enabled on X axis
enabledY - zoom enabled on Y axis

Method Detail

2846

Overview (Codename One API)


getBarsSpacing
public double getBarsSpacing()

Deprecated. use getBarSpacing instead


Returns the spacing between bars, in bar charts.
Returns:
the spacing between bars
getBarSpacing
public double getBarSpacing()

Returns the spacing between bars, in bar charts.


Returns:
the spacing between bars
setBarSpacing
public void setBarSpacing(double spacing)

Sets the spacing between bars, in bar charts. Only available for bar charts. This is a
coefficient of the bar width. For instance, if you want the spacing to be a half of the
bar width, set this value to 0.5.
Parameters:
spacing - the spacing between bars coefficient
getMarginsColor
public int getMarginsColor()

Returns the margins color.


Returns:
the margins color
setMarginsColor
public void setMarginsColor(int color)

Sets the color of the margins.


Parameters:
color - the margins color
getGridColor
public int getGridColor(int scale)

Returns the grid color.


Parameters:
scale - the renderer index
Returns:
the grid color
setGridColor
public void setGridColor(int color)

Sets the color of the grid.


Parameters:
color - the grid color
setGridColor
public void setGridColor(int color,
int scale)

Sets the color of the grid.


Parameters:
color - the grid color
scale - the renderer scale

Method Detail

2847

Overview (Codename One API)


getPanLimits
public double[] getPanLimits()

Returns the pan limits.


Returns:
the pan limits
setPanLimits
public void setPanLimits(double[] panLimits)

Sets the pan limits as an array of 4 values. Setting it to null or a different size array
will disable the panning limitation. Values: [panMinimumX, panMaximumX,
panMinimumY, panMaximumY]
Parameters:
panLimits - the pan limits
getZoomLimits
public double[] getZoomLimits()

Returns the zoom limits.


Returns:
the zoom limits
setZoomLimits
public void setZoomLimits(double[] zoomLimits)

Sets the zoom limits as an array of 4 values. Setting it to null or a different size array
will disable the zooming limitation. Values: [zoomMinimumX, zoomMaximumX,
zoomMinimumY, zoomMaximumY]
Parameters:
zoomLimits - the zoom limits
getXLabelsAngle
public float getXLabelsAngle()

Returns the rotation angle of labels for the X axis.


Returns:
the rotation angle of labels for the X axis
setXLabelsAngle
public void setXLabelsAngle(float angle)

Sets the rotation angle (in degrees) of labels for the X axis.
Parameters:
angle - the rotation angle of labels for the X axis
getYLabelsAngle
public float getYLabelsAngle()

Returns the rotation angle of labels for the Y axis.


Returns:
the approximate number of labels for the Y axis
setYLabelsAngle
public void setYLabelsAngle(float angle)

Sets the rotation angle (in degrees) of labels for the Y axis.
Parameters:
angle - the rotation angle of labels for the Y axis
getPointSize
public float getPointSize()

Returns the size of the points, for charts displaying points.


Returns:
the point size

Method Detail

2848

Overview (Codename One API)


setPointSize
public void setPointSize(float size)

Sets the size of the points, for charts displaying points.


Parameters:
size - the point size
setRange
public void setRange(double[] range)

setRange
public void setRange(double[] range,
int scale)

Sets the axes range values.


Parameters:
range - an array having the values in this order: minX, maxX, minY, maxY
scale - the renderer scale
isInitialRangeSet
public boolean isInitialRangeSet()

isInitialRangeSet
public boolean isInitialRangeSet(int scale)

Returns if the initial range is set.


Parameters:
scale - the renderer scale
Returns:
the initial range was set or not
getInitialRange
public double[] getInitialRange()

Returns the initial range.


Returns:
the initial range
getInitialRange
public double[] getInitialRange(int scale)

Returns the initial range.


Parameters:
scale - the renderer scale
Returns:
the initial range
setInitialRange
public void setInitialRange(double[] range)

Sets the axes initial range values. This will be used in the zoom fit tool.
Parameters:
range - an array having the values in this order: minX, maxX, minY, maxY
setInitialRange
public void setInitialRange(double[] range,
int scale)

Sets the axes initial range values. This will be used in the zoom fit tool.
Parameters:
range - an array having the values in this order: minX, maxX, minY, maxY
scale - the renderer scale

Method Detail

2849

Overview (Codename One API)


getXLabelsColor
public int getXLabelsColor()

Returns the X axis labels color.


Returns:
the X axis labels color
getYLabelsColor
public int getYLabelsColor(int scale)

Returns the Y axis labels color.


Returns:
the Y axis labels color
setXLabelsColor
public void setXLabelsColor(int color)

Sets the X axis labels color.


Parameters:
color - the X axis labels color
setYLabelsColor
public void setYLabelsColor(int scale,
int color)

Sets the Y axis labels color.


Parameters:
scale - the renderer scale
color - the Y axis labels color
getXLabelsAlign
public int getXLabelsAlign()

Returns the X axis labels alignment. One of Component.CENTER, Component.LEFT,


Component.RIGHT
Returns:
X labels alignment
setXLabelsAlign
public void setXLabelsAlign(int align)

Sets the X axis labels alignment. One of Component.CENTER, Component.LEFT,


Component.RIGHT
Parameters:
align - the X labels alignment
getYLabelsAlign
public int getYLabelsAlign(int scale)

Returns the Y axis labels alignment.


Parameters:
scale - the renderer scale
Returns:
Y labels alignment
setYLabelsAlign
public void setYLabelsAlign(int align)

getYAxisAlign
public int getYAxisAlign(int scale)

setYAxisAlign
public void setYAxisAlign(int align,
int scale)

Method Detail

2850

Overview (Codename One API)


setYLabelsAlign
public void setYLabelsAlign(int align,
int scale)

Sets the Y axis labels alignment.


Parameters:
align - the Y labels alignment
getXLabelsPadding
public float getXLabelsPadding()

Returns the X labels padding.


Returns:
X labels padding
setXLabelsPadding
public void setXLabelsPadding(float padding)

Sets the X labels padding


Parameters:
padding - the amount of padding between the axis and the label
getYLabelsPadding
public float getYLabelsPadding()

Returns the Y labels padding.


Returns:
Y labels padding
setYLabelsVerticalPadding
public void setYLabelsVerticalPadding(float padding)

Sets the Y labels vertical padding


Parameters:
padding - the amount of vertical padding
getYLabelsVerticalPadding
public float getYLabelsVerticalPadding()

Returns the Y labels vertical padding.


Returns:
Y labels vertical padding
setYLabelsPadding
public void setYLabelsPadding(float padding)

Sets the Y labels padding


Parameters:
padding - the amount of padding between the axis and the label
getLabelFormat
public NumberFormat getLabelFormat()

Deprecated. use getXLabelFormat and getYLabelFormat instead


Returns the number format for displaying labels.
Returns:
the number format for labels
getXLabelFormat
public NumberFormat getXLabelFormat()

Returns the number format for displaying X axis labels.


Returns:
the number format for X axis labels

Method Detail

2851

Overview (Codename One API)


setXLabelFormat
public void setXLabelFormat(NumberFormat format)

Sets the number format for X axis displaying labels.


Parameters:
format - the number format for X axis labels
getYLabelFormat
public NumberFormat getYLabelFormat(int scale)

Returns the number format for Y axis displaying labels.


Parameters:
scale - the renderer scale
Returns:
the number format for Y axis labels
setYLabelFormat
public void setYLabelFormat(NumberFormat format,
int scale)

Sets the number format for Y axis displaying labels.


Parameters:
format - the number format for labels
scale - the renderer scale
getZoomInLimitX
public double getZoomInLimitX()

Returns the zoom in limit permitted in the axis X.


Returns:
the maximum zoom in permitted in the axis X
See Also:
setZoomInLimitX(double)

setZoomInLimitX
public void setZoomInLimitX(double zoomInLimitX)

Sets the zoom in limit permitted in the axis X. This function prevent that the distance
between getXAxisMin() and getXAxisMax() can't be greater or equal than
getZoomInLimitX()

Parameters:
zoomInLimitX - the
getXAxisMax().

maximum distance permitted between getXAxisMin() and

getZoomInLimitY
public double getZoomInLimitY()

Returns the zoom in limit permitted in the axis Y.


Returns:
the maximum in zoom permitted in the axis Y
See Also:
setZoomInLimitY(double)

setZoomInLimitY
public void setZoomInLimitY(double zoomInLimitY)

Sets zoom in limit permitted in the axis Y. This function prevent that the distance
between getYAxisMin() and getYAxisMax() can't be greater or equal than
getZoomInLimitY()

Parameters:
zoomInLimitY getYAxisMax()

Method Detail

the maximum distance permitted between getYAxisMin() and

2852

Overview (Codename One API)


getScalesCount
public int getScalesCount()

Method Detail

2853

Overview (Codename One API)


com.codename1.charts.renderers

Enum XYMultipleSeriesRenderer.Orientation
java.lang.Object

java.lang.Enum<XYMultipleSeriesRenderer.Orientation>

com.codename1.charts.renderers.XYMultipleSeriesRenderer.Orientation
All Implemented Interfaces:
Comparable<XYMultipleSeriesRenderer.Orientation>
Enclosing class:
XYMultipleSeriesRenderer

public static enum


extends Enum<XYMultipleSeriesRenderer.Orientation>

An enum for the XY chart orientation of the X axis.

Enum Constant Summary


Enum Constant and Description
HORIZONTAL
VERTICAL

Method Summary
Modifier and Type

Method and Description


getAngle()

int

Return the orientation rotate angle.

static
XYMultipleSeriesRenderer.Orientation

valueOf(String name)

Returns the enum constant of this type with


the specified name.
values()

static
XYMultipleSeriesRenderer.Orientation[]

Returns an array containing the constants of


this enum type, in the order they are
declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


HORIZONTAL
public static final XYMultipleSeriesRenderer.Orientation HORIZONTAL

VERTICAL
public static final XYMultipleSeriesRenderer.Orientation VERTICAL

Enum XYMultipleSeriesRenderer.Orientation

2854

Overview (Codename One API)


Method

Detail

values
public static XYMultipleSeriesRenderer.Orientation[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:

for (XYMultipleSeriesRenderer.Orientation c : XYMultipleSeriesRenderer.Orientation.v


System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static XYMultipleSeriesRenderer.Orientation valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null
getAngle
public int getAngle()

Return the orientation rotate angle.


Returns:
the orientaion rotate angle

Method Detail

2855

Overview (Codename One API)


com.codename1.charts.renderers

Class SimpleSeriesRenderer
java.lang.Object

com.codename1.charts.renderers.SimpleSeriesRenderer
Direct Known Subclasses:
XYSeriesRenderer

public class
extends Object

A simple series renderer.

Constructor Summary
Constructor and Description
SimpleSeriesRenderer()

Method Summary
Modifier and
Type
NumberFormat
int
int
double
int
double
BasicStroke

Method and Description


getChartValuesFormat()

Returns the number format for displaying chart values.


getColor()

Returns the series color.


getGradientStartColor()

Returns the gradient start color.


getGradientStartValue()

Returns the gradient start value.


getGradientStopColor()

Returns the gradient stop color.


getGradientStopValue()

Returns the gradient stop value.


getStroke()

Returns the stroke style.


isDisplayBoundingPoints()

boolean

boolean
boolean
boolean
void
void

Returns if the bounding points of the first and last visible ones should be
displayed.
isGradientEnabled()

Returns the gradient is enabled value.


isHighlighted()

Returns if the item is displayed highlighted.


isShowLegendItem()

Returns if the legend item for this renderer should be visible.


setChartValuesFormat(NumberFormat format)

Sets the number format for displaying chart values.


setColor(int color)

Sets the series color.


setDisplayBoundingPoints(boolean display)

void

void

Class SimpleSeriesRenderer

Sets if the bounding points of the first and last visible ones should be
displayed.
setGradientEnabled(boolean enabled)

Sets the gradient enabled value.

2856

Overview (Codename One API)


setGradientStart(double start, int color)

void

Sets the gradient start value and color.


setGradientStop(double start, int color)

void

Sets the gradient stop value and color.


setHighlighted(boolean highlighted)

void

Sets if the item for this renderer should be highlighted.


setShowLegendItem(boolean showLegend)

void

Sets if the legend item for this renderer should be visible.


setStroke(BasicStroke stroke)

void

Sets the stroke style.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SimpleSeriesRenderer
public SimpleSeriesRenderer()

Method Detail
getColor
public int getColor()

Returns the series color.


Returns:
the series color
setColor
public void setColor(int color)

Sets the series color.


Parameters:
color - the series color
getStroke
public BasicStroke getStroke()

Returns the stroke style.


Returns:
the stroke style
setStroke
public void setStroke(BasicStroke stroke)

Sets the stroke style.


Parameters:
stroke - the stroke style
isGradientEnabled
public boolean isGradientEnabled()

Returns the gradient is enabled value.


Returns:
the gradient enabled

Method Summary

2857

Overview (Codename One API)


setGradientEnabled
public void setGradientEnabled(boolean enabled)

Sets the gradient enabled value.


Parameters:
enabled - the gradient enabled
getGradientStartValue
public double getGradientStartValue()

Returns the gradient start value.


Returns:
the gradient start value
getGradientStartColor
public int getGradientStartColor()

Returns the gradient start color.


Returns:
the gradient start color
setGradientStart
public void setGradientStart(double start,
int color)

Sets the gradient start value and color.


Parameters:
start - the gradient start value
color - the gradient start color
getGradientStopValue
public double getGradientStopValue()

Returns the gradient stop value.


Returns:
the gradient stop value
getGradientStopColor
public int getGradientStopColor()

Returns the gradient stop color.


Returns:
the gradient stop color
setGradientStop
public void setGradientStop(double start,
int color)

Sets the gradient stop value and color.


Parameters:
start - the gradient stop value
color - the gradient stop color
isShowLegendItem
public boolean isShowLegendItem()

Returns if the legend item for this renderer should be visible.


Returns:
the visibility flag for the legend item for this renderer
setShowLegendItem
public void setShowLegendItem(boolean showLegend)

Sets if the legend item for this renderer should be visible.


Parameters:
showLegend - the visibility flag for the legend item for this renderer

Method Detail

2858

Overview (Codename One API)


isHighlighted
public boolean isHighlighted()

Returns if the item is displayed highlighted.


Returns:
the highlighted flag for the item for this renderer
setHighlighted
public void setHighlighted(boolean highlighted)

Sets if the item for this renderer should be highlighted. Pie chart is supported for now.
Parameters:
highlighted - the highlighted flag for the item for this renderer
isDisplayBoundingPoints
public boolean isDisplayBoundingPoints()

Returns if the bounding points of the first and last visible ones should be displayed.
Returns:
the bounding points display
setDisplayBoundingPoints
public void setDisplayBoundingPoints(boolean display)

Sets if the bounding points of the first and last visible ones should be displayed.
Parameters:
display - the bounding points display
getChartValuesFormat
public NumberFormat getChartValuesFormat()

Returns the number format for displaying chart values.


Returns:
the number format for chart values
setChartValuesFormat
public void setChartValuesFormat(NumberFormat format)

Sets the number format for displaying chart values.


Parameters:
format - the number format for chart values

Method Detail

2859

Overview (Codename One API)


com.codename1.charts.renderers

Class DialRenderer
java.lang.Object

com.codename1.charts.renderers.DefaultRenderer

com.codename1.charts.renderers.DialRenderer

public class
extends DefaultRenderer

Dial chart renderer.

Nested Class Summary


Modifier and Type Class and Description
static class

DialRenderer.Type

Field Summary

Fields inherited from


class com.codename1.charts.renderers.DefaultRenderer
BACKGROUND_COLOR, NO_COLOR, TEXT_COLOR

Constructor Summary
Constructor and Description
DialRenderer()

Method Summary
Modifier and Type
double
double
double
double
double
double
DialRenderer.Type
boolean
boolean
void

Class DialRenderer

Method and Description


getAngleMax()

Returns the end angle value of the dial.


getAngleMin()

Returns the start angle value of the dial.


getMajorTicksSpacing()

Returns the major ticks spacing.


getMaxValue()

Returns the end value to be rendered on the dial.


getMinorTicksSpacing()

Returns the minor ticks spacing.


getMinValue()

Returns the start value to be rendered on the dial.


getVisualTypeForIndex(int index)

Returns the visual type at the specified index.


isMaxValueSet()

Returns if the maximum dial value was set.


isMinValueSet()

Returns if the minimum dial value was set.


setAngleMax(double max)

2860

Overview (Codename One API)


Sets the end angle value of the dial.
setAngleMin(double min)

void

Sets the start angle value of the dial.


setMajorTicksSpacing(double spacing)

void

Sets the major ticks spacing.


setMaxValue(double max)

void

Sets the end value to be rendered on the dial.


setMinorTicksSpacing(double spacing)

void

Sets the minor ticks spacing.


setMinValue(double min)

void

Sets the start value to be rendered on the dial.


setVisualTypes(DialRenderer.Type[] types)

void

Sets the visual types.

Methods inherited from


class com.codename1.charts.renderers.DefaultRenderer
addSeriesRenderer, addSeriesRenderer, getAxesColor, getBackgroundColor,
getChartTitle, getChartTitleTextSize, getLabelsColor, getLabelsTextSize,
getLegendHeight, getLegendTextSize, getMargins, getOriginalScale, getScale,
getSelectableBuffer, getSeriesRendererAt, getSeriesRendererCount,
getSeriesRenderers, getStartAngle, getTextTypeface, getTextTypefaceName,
getTextTypefaceStyle, getXAxisColor, getYAxisColor, getZoomRate,
isAntialiasing, isApplyBackgroundColor, isClickEnabled, isDisplayValues,
isExternalZoomEnabled, isFitLegend, isInScroll, isPanEnabled, isShowAxes,
isShowCustomTextGridX, isShowCustomTextGridY, isShowGridX, isShowGridY,
isShowLabels, isShowLegend, isShowTickMarks, isZoomButtonsVisible,
isZoomEnabled, removeAllRenderers, removeSeriesRenderer, setAntialiasing,
setApplyBackgroundColor, setAxesColor, setBackgroundColor, setChartTitle,
setChartTitleTextFont, setChartTitleTextSize, setClickEnabled,
setDisplayValues, setExternalZoomEnabled, setFitLegend, setInScroll,
setLabelsColor, setLabelsTextFont, setLabelsTextSize, setLegendHeight,
setLegendTextFont, setLegendTextSize, setMargins, setPanEnabled, setScale,
setSelectableBuffer, setShowAxes, setShowCustomTextGrid,
setShowCustomTextGridX, setShowCustomTextGridY, setShowGrid, setShowGridX,
setShowGridY, setShowLabels, setShowLegend, setShowTickMarks,
setStartAngle, setTextTypeface, setTextTypeface, setXAxisColor,
setYAxisColor, setZoomButtonsVisible, setZoomEnabled, setZoomRate

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
DialRenderer
public DialRenderer()

Method Detail
getAngleMin
public double getAngleMin()

Returns the start angle value of the dial.


Returns:
the angle start value
setAngleMin
public void setAngleMin(double min)

Sets the start angle value of the dial.


Parameters:

Method Summary

2861

Overview (Codename One API)


min - the dial angle start value
getAngleMax
public double getAngleMax()

Returns the end angle value of the dial.


Returns:
the angle end value
setAngleMax
public void setAngleMax(double max)

Sets the end angle value of the dial.


Parameters:
max - the dial angle end value
getMinValue
public double getMinValue()

Returns the start value to be rendered on the dial.


Returns:
the start value on dial
setMinValue
public void setMinValue(double min)

Sets the start value to be rendered on the dial.


Parameters:
min - the start value on the dial
isMinValueSet
public boolean isMinValueSet()

Returns if the minimum dial value was set.


Returns:
the minimum dial value was set or not
getMaxValue
public double getMaxValue()

Returns the end value to be rendered on the dial.


Returns:
the end value on the dial
setMaxValue
public void setMaxValue(double max)

Sets the end value to be rendered on the dial.


Parameters:
max - the end value on the dial
isMaxValueSet
public boolean isMaxValueSet()

Returns if the maximum dial value was set.


Returns:
the maximum dial was set or not
getMinorTicksSpacing
public double getMinorTicksSpacing()

Returns the minor ticks spacing.


Returns:
the minor ticks spacing

Method Detail

2862

Overview (Codename One API)


setMinorTicksSpacing
public void setMinorTicksSpacing(double spacing)

Sets the minor ticks spacing.


Parameters:
spacing - the minor ticks spacing
getMajorTicksSpacing
public double getMajorTicksSpacing()

Returns the major ticks spacing.


Returns:
the major ticks spacing
setMajorTicksSpacing
public void setMajorTicksSpacing(double spacing)

Sets the major ticks spacing.


Parameters:
spacing - the major ticks spacing
getVisualTypeForIndex
public DialRenderer.Type getVisualTypeForIndex(int index)

Returns the visual type at the specified index.


Parameters:
index - the index
Returns:
the visual type
setVisualTypes
public void setVisualTypes(DialRenderer.Type[] types)

Sets the visual types.


Parameters:
types - the visual types

Method Detail

2863

Overview (Codename One API)


com.codename1.charts.renderers

Enum DialRenderer.Type
java.lang.Object

java.lang.Enum<DialRenderer.Type>

com.codename1.charts.renderers.DialRenderer.Type
All Implemented Interfaces:
Comparable<DialRenderer.Type>
Enclosing class:
DialRenderer

public static enum


extends Enum<DialRenderer.Type>

Enum Constant Summary


Enum Constant and Description
ARROW
NEEDLE

Method Summary
Modifier and Type
static DialRenderer.Type
static
DialRenderer.Type[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in


the order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


NEEDLE
public static final DialRenderer.Type NEEDLE

ARROW
public static final DialRenderer.Type ARROW

Method Detail
values
public static DialRenderer.Type[] values()

Enum DialRenderer.Type

2864

Overview (Codename One API)


Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (DialRenderer.Type c : DialRenderer.Type.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static DialRenderer.Type valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Method Detail

2865

Overview (Codename One API)


com.codename1.charts.renderers

Class DefaultRenderer
java.lang.Object

com.codename1.charts.renderers.DefaultRenderer
Direct Known Subclasses:
DialRenderer, XYMultipleSeriesRenderer

public class
extends Object

An abstract renderer to be extended by the multiple series classes.

Field Summary
Modifier and Type
static int
static int
static int

Field and Description


BACKGROUND_COLOR

The default background color.


NO_COLOR

A no color constant.
TEXT_COLOR

The default color for text.

Constructor Summary
Constructor and Description
DefaultRenderer()

Method Summary
Modifier and Type
void

Method and Description


addSeriesRenderer(int index,
SimpleSeriesRenderer renderer)

Adds a simple renderer to the multiple renderer.


void
int
int
String
float
int
float
int
float

Class DefaultRenderer

addSeriesRenderer(SimpleSeriesRenderer renderer)

Adds a simple renderer to the multiple renderer.


getAxesColor()

Returns the axes color.


getBackgroundColor()

Returns the background color.


getChartTitle()

Returns the chart title.


getChartTitleTextSize()

Returns the chart title text size.


getLabelsColor()

Returns the labels color.


getLabelsTextSize()

Returns the labels text size.


getLegendHeight()

Returns the legend height.


getLegendTextSize()

Returns the legend text size.

2866

Overview (Codename One API)


int[]
float
float
int
SimpleSeriesRenderer
int

getMargins()

Returns the margin sizes.


getOriginalScale()

Returns the original value to be used for scaling the chart.


getScale()

Returns the value to be used for scaling the chart.


getSelectableBuffer()

Returns the selectable radius value around clickable points.


getSeriesRendererAt(int index)

Returns the simple renderer from the multiple renderer list.


getSeriesRendererCount()

Returns the simple renderers count in the multiple renderer list.


getSeriesRenderers()

SimpleSeriesRenderer[]

float
Font
int
int
int
int
float
boolean
boolean
boolean
boolean
boolean
boolean

Returns an array of the simple renderers in the multiple renderer


list.
getStartAngle()

Returns the start angle for circular charts such as pie, doughnut.
getTextTypeface()

Returns the text typeface.


getTextTypefaceName()

Returns the text typeface name.


getTextTypefaceStyle()

Returns the text typeface style.


getXAxisColor()

Returns the color of the X axis


getYAxisColor()

Returns the color of the Y axis


getZoomRate()

Deprecated.
isAntialiasing()

Returns the antialiasing flag value.


isApplyBackgroundColor()

Returns if the background color should be applied.


isClickEnabled()

Deprecated.
isDisplayValues()

Returns if the values should be displayed as text.


isExternalZoomEnabled()

Deprecated.
isFitLegend()

Returns if the legend should size to fit.


isInScroll()

boolean

boolean
boolean
boolean
boolean
boolean
boolean
boolean

Method Summary

Returns if the chart is inside a scroll view and doesn't need to


shrink.
isPanEnabled()

Deprecated.
isShowAxes()

Returns if the axes should be visible.


isShowCustomTextGridX()

Returns if the X axis custom text grid should be visible.


isShowCustomTextGridY()

Returns if the Y axis custom text grid should be visible.


isShowGridX()

Returns if the X axis grid should be visible.


isShowGridY()

Returns if the Y axis grid should be visible.


isShowLabels()

Returns if the labels should be visible.

2867

Overview (Codename One API)


boolean
boolean
boolean
boolean
void
void
void
void
void
void
void

isShowLegend()

Returns if the legend should be visible.


isShowTickMarks()

Returns if the tick marks should be visible.


isZoomButtonsVisible()

Deprecated.
isZoomEnabled()

Deprecated.
removeAllRenderers()

Removes all renderers from the multiple renderer.


removeSeriesRenderer(SimpleSeriesRenderer renderer)

Removes a simple renderer from the multiple renderer.


setAntialiasing(boolean antialiasing)

Sets the antialiasing value.


setApplyBackgroundColor(boolean apply)

Sets if the background color should be applied.


setAxesColor(int color)

Sets the axes color.


setBackgroundColor(int color)

Sets the background color.


setChartTitle(String title)

Sets the chart title.


setChartTitleTextFont(Font font)

void

void
void

Sets the chart title font size using a Font object instead of a point
size.
setChartTitleTextSize(float textSize)

Sets the chart title text size in pixels.


setClickEnabled(boolean enabled)

Deprecated.
setDisplayValues(boolean display)

void

void
void

Sets if the values should be displayed as text (supported by pie


chart).
setExternalZoomEnabled(boolean enabled)

Deprecated.
setFitLegend(boolean fit)

Sets if the legend should size to fit.


setInScroll(boolean inScroll)

void

void

To be set if the chart is inside a scroll view and doesn't need to


shrink when not enough space.
setLabelsColor(int color)

Sets the labels color.


setLabelsTextFont(Font font)

void

void
void

Sets the label title font size using a Font object instead of a point
size.
setLabelsTextSize(float textSize)

Sets the labels text size.


setLegendHeight(int height)

Sets the legend height, in pixels.


setLegendTextFont(Font font)

void

void
void
void
void

Method Summary

Sets the legend text font size using a Font object instead of a
point size.
setLegendTextSize(float textSize)

Sets the legend text size.


setMargins(int[] margins)

Sets the margins, in pixels.


setPanEnabled(boolean enabled)

Deprecated.
setScale(float scale)

2868

Overview (Codename One API)


Sets the value to be used for scaling the chart.
setSelectableBuffer(int buffer)

void

Sets the selectable radius value around clickable points.


setShowAxes(boolean showAxes)

void

Sets if the axes should be visible.


setShowCustomTextGrid(boolean showGrid)

void

Sets if the grid for custom X or Y labels should be visible.


setShowCustomTextGridX(boolean showGrid)

void

Sets if the X axis custom text grid should be visible.


setShowCustomTextGridY(boolean showGrid)

void

Sets if the Y axis custom text grid should be visible.


setShowGrid(boolean showGrid)

void

Sets if the grid should be visible.


setShowGridX(boolean showGrid)

void

Sets if the X axis grid should be visible.


setShowGridY(boolean showGrid)

void

Sets if the Y axis grid should be visible.


setShowLabels(boolean showLabels)

void

Sets if the labels should be visible.


setShowLegend(boolean showLegend)

void

Sets if the legend should be visible.


setShowTickMarks(boolean mShowTickMarks)

void

Sets if the tick marks should be visible.


setStartAngle(float startAngle)

void

Sets the start angle for circular charts such as pie, doughnut, etc.
setTextTypeface(Font typeface)

void

Sets the text typeface.


setTextTypeface(int typefaceName, int style)

void

Sets the text typeface name and style.


setXAxisColor(int color)

void

Sets the X axis color.


setYAxisColor(int color)

void

Sets the Y axis color.


setZoomButtonsVisible(boolean visible)

void

Deprecated.
setZoomEnabled(boolean enabled)

void

Deprecated.
setZoomRate(float rate)

void

Deprecated.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
NO_COLOR
public static final int NO_COLOR

A no color constant.
See Also:
Constant Field Values
BACKGROUND_COLOR
public static final int BACKGROUND_COLOR

The default background color.

Methods inherited from class java.lang.Object

2869

Overview (Codename One API)


See Also:
Constant Field Values
TEXT_COLOR
public static final int TEXT_COLOR

The default color for text.


See Also:
Constant Field Values

Constructor Detail
DefaultRenderer
public DefaultRenderer()

Method Detail
getChartTitle
public String getChartTitle()

Returns the chart title.


Returns:
the chart title
setChartTitle
public void setChartTitle(String title)

Sets the chart title.


Parameters:
title - the chart title
getChartTitleTextSize
public float getChartTitleTextSize()

Returns the chart title text size.


Returns:
the chart title text size
setChartTitleTextSize
public void setChartTitleTextSize(float textSize)

Sets the chart title text size in pixels. Consider using


setChartTitleTextFont(com.codename1.ui.Font) instead of this method to allow the
text to be sized appropriately for the device resolution.
Parameters:
textSize - the chart title text size
setChartTitleTextFont
public void setChartTitleTextFont(Font font)

Sets the chart title font size using a Font object instead of a point size. This method is
the preferred way to set font size because it allows you to more easily have fonts
appear in an appropriate size for the target device. Alternatively check out
setChartTitleTextSize(float) to set the text size in pixels.
Parameters:
font addSeriesRenderer
public void addSeriesRenderer(SimpleSeriesRenderer renderer)

Adds a simple renderer to the multiple renderer.


Parameters:

Field Detail

2870

Overview (Codename One API)


renderer - the renderer to be added
addSeriesRenderer
public void addSeriesRenderer(int index,
SimpleSeriesRenderer renderer)

Adds a simple renderer to the multiple renderer.


Parameters:
index - the index in the renderers list
renderer - the renderer to be added
removeSeriesRenderer
public void removeSeriesRenderer(SimpleSeriesRenderer renderer)

Removes a simple renderer from the multiple renderer.


Parameters:
renderer - the renderer to be removed
removeAllRenderers
public void removeAllRenderers()

Removes all renderers from the multiple renderer.


getSeriesRendererAt
public SimpleSeriesRenderer getSeriesRendererAt(int index)

Returns the simple renderer from the multiple renderer list.


Parameters:
index - the index in the simple renderers list
Returns:
the simple renderer at the specified index
getSeriesRendererCount
public int getSeriesRendererCount()

Returns the simple renderers count in the multiple renderer list.


Returns:
the simple renderers count
getSeriesRenderers
public SimpleSeriesRenderer[] getSeriesRenderers()

Returns an array of the simple renderers in the multiple renderer list.


Returns:
the simple renderers array
getBackgroundColor
public int getBackgroundColor()

Returns the background color.


Returns:
the background color
setBackgroundColor
public void setBackgroundColor(int color)

Sets the background color.


Parameters:
color - the background color
isApplyBackgroundColor
public boolean isApplyBackgroundColor()

Returns if the background color should be applied.


Returns:
the apply flag for the background color.

Method Detail

2871

Overview (Codename One API)


setApplyBackgroundColor
public void setApplyBackgroundColor(boolean apply)

Sets if the background color should be applied.


Parameters:
apply - the apply flag for the background color
getAxesColor
public int getAxesColor()

Returns the axes color.


Returns:
the axes color
setAxesColor
public void setAxesColor(int color)

Sets the axes color.


Parameters:
color - the axes color
getYAxisColor
public int getYAxisColor()

Returns the color of the Y axis


Returns:
the Y axis color
setYAxisColor
public void setYAxisColor(int color)

Sets the Y axis color.


Parameters:
color - the Y axis color
getXAxisColor
public int getXAxisColor()

Returns the color of the X axis


Returns:
the X axis color
setXAxisColor
public void setXAxisColor(int color)

Sets the X axis color.


Parameters:
color - the X axis color
getLabelsColor
public int getLabelsColor()

Returns the labels color.


Returns:
the labels color
setLabelsColor
public void setLabelsColor(int color)

Sets the labels color.


Parameters:
color - the labels color

Method Detail

2872

Overview (Codename One API)


getLabelsTextSize
public float getLabelsTextSize()

Returns the labels text size.


Returns:
the labels text size
setLabelsTextSize
public void setLabelsTextSize(float textSize)

Sets the labels text size. Consider using


instead to allow the font size to to be
adjusted appropriately for the display resolution.
Parameters:
textSize - the labels text size
setLabelsTextFont
setLabelsTextFont(com.codename1.ui.Font)

public void setLabelsTextFont(Font font)

Sets the label title font size using a Font object instead of a point size. This method is
the preferred way to set font size because it allows you to more easily have fonts
appear in an appropriate size for the target device. Alternatively check out
setLabelsTextSize(float) to set the text size in pixels.
Parameters:
font isShowAxes
public boolean isShowAxes()

Returns if the axes should be visible.


Returns:
the visibility flag for the axes
setShowAxes
public void setShowAxes(boolean showAxes)

Sets if the axes should be visible.


Parameters:
showAxes - the visibility flag for the axes
isShowLabels
public boolean isShowLabels()

Returns if the labels should be visible.


Returns:
the visibility flag for the labels
setShowLabels
public void setShowLabels(boolean showLabels)

Sets if the labels should be visible.


Parameters:
showLabels - the visibility flag for the labels
isShowTickMarks
public boolean isShowTickMarks()

Returns if the tick marks should be visible.


Returns:
setShowTickMarks
public void setShowTickMarks(boolean mShowTickMarks)

Sets if the tick marks should be visible.


Parameters:
showTickMarks - the visibility flag for the tick marks

Method Detail

2873

Overview (Codename One API)


isShowGridX
public boolean isShowGridX()

Returns if the X axis grid should be visible.


Returns:
the visibility flag for the X axis grid
isShowGridY
public boolean isShowGridY()

Returns if the Y axis grid should be visible.


Returns:
the visibility flag for the Y axis grid
setShowGridX
public void setShowGridX(boolean showGrid)

Sets if the X axis grid should be visible.


Parameters:
showGrid - the visibility flag for the X axis grid
setShowGridY
public void setShowGridY(boolean showGrid)

Sets if the Y axis grid should be visible.


Parameters:
showGrid - the visibility flag for the Y axis grid
setShowGrid
public void setShowGrid(boolean showGrid)

Sets if the grid should be visible.


Parameters:
showGrid - the visibility flag for the grid
isShowCustomTextGridX
public boolean isShowCustomTextGridX()

Returns if the X axis custom text grid should be visible.


Returns:
the visibility flag for the X axis custom text grid
isShowCustomTextGridY
public boolean isShowCustomTextGridY()

Returns if the Y axis custom text grid should be visible.


Returns:
the visibility flag for the custom text Y axis grid
setShowCustomTextGridX
public void setShowCustomTextGridX(boolean showGrid)

Sets if the X axis custom text grid should be visible.


Parameters:
showGrid - the visibility flag for the X axis custom text grid
setShowCustomTextGridY
public void setShowCustomTextGridY(boolean showGrid)

Sets if the Y axis custom text grid should be visible.


Parameters:
showGrid - the visibility flag for the Y axis custom text grid

Method Detail

2874

Overview (Codename One API)


setShowCustomTextGrid
public void setShowCustomTextGrid(boolean showGrid)

Sets if the grid for custom X or Y labels should be visible.


Parameters:
showGrid - the visibility flag for the custom text grid
isShowLegend
public boolean isShowLegend()

Returns if the legend should be visible.


Returns:
the visibility flag for the legend
setShowLegend
public void setShowLegend(boolean showLegend)

Sets if the legend should be visible.


Parameters:
showLegend - the visibility flag for the legend
isFitLegend
public boolean isFitLegend()

Returns if the legend should size to fit.


Returns:
the fit behavior
setFitLegend
public void setFitLegend(boolean fit)

Sets if the legend should size to fit.


Parameters:
fit - the fit behavior
getTextTypefaceName
public int getTextTypefaceName()

Returns the text typeface name.


Returns:
the text typeface name
getTextTypefaceStyle
public int getTextTypefaceStyle()

Returns the text typeface style.


Returns:
the text typeface style
getTextTypeface
public Font getTextTypeface()

Returns the text typeface.


Returns:
the text typeface
getLegendTextSize
public float getLegendTextSize()

Returns the legend text size.


Returns:
the legend text size

Method Detail

2875

Overview (Codename One API)


setLegendTextSize
public void setLegendTextSize(float textSize)

Sets the legend text size. Consider using


instead to allow the font size to to be
adjusted appropriately for the display resolution.
Parameters:
textSize - the legend text size
setLegendTextFont
setLegendTextFont(com.codename1.ui.Font)

public void setLegendTextFont(Font font)

Sets the legend text font size using a Font object instead of a point size. This method
is the preferred way to set font size because it allows you to more easily have fonts
appear in an appropriate size for the target device. Alternatively check out
setLegendTextSize(float) to set the text size in pixels.
Parameters:
font setTextTypeface
public void setTextTypeface(int typefaceName,
int style)

Sets the text typeface name and style.


Parameters:
typefaceName - the text typeface name
style - the text typeface style
setTextTypeface
public void setTextTypeface(Font typeface)

Sets the text typeface.


Parameters:
typeface - the typeface
isAntialiasing
public boolean isAntialiasing()

Returns the antialiasing flag value.


Returns:
the antialiasing value
setAntialiasing
public void setAntialiasing(boolean antialiasing)

Sets the antialiasing value.


Parameters:
antialiasing - the antialiasing
getScale
public float getScale()

Returns the value to be used for scaling the chart.


Returns:
the scale value
getOriginalScale
public float getOriginalScale()

Returns the original value to be used for scaling the chart.


Returns:
the original scale value

Method Detail

2876

Overview (Codename One API)


setScale
public void setScale(float scale)

Sets the value to be used for scaling the chart. It works on some charts like pie,
doughnut, dial.
Parameters:
scale - the scale value
isZoomEnabled
public boolean isZoomEnabled()

Deprecated.
Returns the enabled state of the zoom.
Returns:
if zoom is enabled
setZoomEnabled
public void setZoomEnabled(boolean enabled)

Deprecated.
Sets the enabled state of the zoom.
Parameters:
enabled - zoom enabled
isZoomButtonsVisible
public boolean isZoomButtonsVisible()

Deprecated.
Returns the visible state of the zoom buttons.
Returns:
if zoom buttons are visible
setZoomButtonsVisible
public void setZoomButtonsVisible(boolean visible)

Deprecated.
Sets the visible state of the zoom buttons.
Parameters:
visible - if the zoom buttons are visible
isExternalZoomEnabled
public boolean isExternalZoomEnabled()

Deprecated.
Returns the enabled state of the external (application implemented) zoom.
Returns:
if external zoom is enabled
setExternalZoomEnabled
public void setExternalZoomEnabled(boolean enabled)

Deprecated.
Sets the enabled state of the external (application implemented) zoom.
Parameters:
enabled - external zoom enabled
getZoomRate
public float getZoomRate()

Deprecated.
Returns the zoom rate.
Returns:
the zoom rate

Method Detail

2877

Overview (Codename One API)


isPanEnabled
public boolean isPanEnabled()

Deprecated.
Returns the enabled state of the pan.
Returns:
if pan is enabled
setPanEnabled
public void setPanEnabled(boolean enabled)

Deprecated.
Sets the enabled state of the pan.
Parameters:
enabled - pan enabled
setZoomRate
public void setZoomRate(float rate)

Deprecated.
Sets the zoom rate.
Parameters:
rate - the zoom rate
isClickEnabled
public boolean isClickEnabled()

Deprecated.
Returns the enabled state of the click.
Returns:
if click is enabled
setClickEnabled
public void setClickEnabled(boolean enabled)

Deprecated.
Sets the enabled state of the click.
Parameters:
enabled - click enabled
getSelectableBuffer
public int getSelectableBuffer()

Returns the selectable radius value around clickable points.


Returns:
the selectable radius
setSelectableBuffer
public void setSelectableBuffer(int buffer)

Sets the selectable radius value around clickable points.


Parameters:
buffer - the selectable radius
getLegendHeight
public int getLegendHeight()

Returns the legend height.


Returns:
the legend height
setLegendHeight
public void setLegendHeight(int height)

Sets the legend height, in pixels.


Parameters:

Method Detail

2878

Overview (Codename One API)


height

- the legend height

getMargins
public int[] getMargins()

Returns the margin sizes. An array containing the margins in this order: top, left,
bottom, right
Returns:
the margin sizes
setMargins
public void setMargins(int[] margins)

Sets the margins, in pixels.


Parameters:
margins - an array containing the margin size values, in this order: top, left,
bottom, right
isInScroll
public boolean isInScroll()

Returns if the chart is inside a scroll view and doesn't need to shrink.
Returns:
if it is inside a scroll view
setInScroll
public void setInScroll(boolean inScroll)

To be set if the chart is inside a scroll view and doesn't need to shrink when not
enough space.
Parameters:
inScroll - if it is inside a scroll view
getStartAngle
public float getStartAngle()

Returns the start angle for circular charts such as pie, doughnut. An angle of 0
degrees correspond to the geometric angle of 0 degrees (3 o'clock on a watch.)
Returns:
the start angle in degrees
setStartAngle
public void setStartAngle(float startAngle)

Sets the start angle for circular charts such as pie, doughnut, etc. An angle of 0
degrees correspond to the geometric angle of 0 degrees (3 o'clock on a watch.)
Parameters:
startAngle - the start angle in degrees
isDisplayValues
public boolean isDisplayValues()

Returns if the values should be displayed as text.


Returns:
if the values should be displayed as text
setDisplayValues
public void setDisplayValues(boolean display)

Sets if the values should be displayed as text (supported by pie chart).


Parameters:
display - if the values should be displayed as text

Method Detail

2879

Overview (Codename One API)


com.codename1.charts.renderers

Class BasicStroke
java.lang.Object

com.codename1.charts.renderers.BasicStroke

public class
extends Object

A descriptor for the stroke style.

Field Summary
Modifier and Type Field and Description
static BasicStroke
static BasicStroke
static BasicStroke

DASHED

The dashed line style.


DOTTED

The dot line style.


SOLID

The solid line style.

Constructor Summary
Constructor and Description
BasicStroke(int cap, int join, float miter, float[] intervals, float phase)

Build a new basic stroke style.

Method Summary
Modifier and Type

Method and Description


getCap()

int

Returns the stroke cap.

float[]

getIntervals()

Returns the path effect intervals.


getJoin()

int

Returns the stroke join.


getMiter()

float

Returns the stroke miter.


getPhase()

float

Returns the path effect phase.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
SOLID
public static final BasicStroke SOLID

The solid line style.

Class BasicStroke

2880

Overview (Codename One API)


DASHED
public static final BasicStroke DASHED

The dashed line style.


DOTTED
public static final BasicStroke DOTTED

The dot line style.

Constructor Detail
BasicStroke
public BasicStroke(int cap,
int join,
float miter,
float[] intervals,
float phase)

Build a new basic stroke style.


Parameters:
cap - the stroke cap
join - the stroke join
miter - the stroke miter
intervals - the path effect intervals
phase - the path effect phase

Method Detail
getCap
public int getCap()

Returns the stroke cap.


Returns:
the stroke cap
getJoin
public int getJoin()

Returns the stroke join.


Returns:
the stroke join
getMiter
public float getMiter()

Returns the stroke miter.


Returns:
the stroke miter
getIntervals
public float[] getIntervals()

Returns the path effect intervals.


Returns:
the path effect intervals
getPhase
public float getPhase()

Returns the path effect phase.


Returns:

Field Detail

2881

Overview (Codename One API)


the path effect phase

Method Detail

2882

Overview (Codename One API)


com.codename1.charts.models

Class XYValueSeries
java.lang.Object

com.codename1.charts.models.XYSeries

com.codename1.charts.models.XYValueSeries

public class
extends XYSeries

An extension of the XY series which adds a third dimension. It is used for XY charts like bubble.

Constructor Summary
Constructor and Description
XYValueSeries(String title)

Builds a new XY value series.

Method Summary
Modifier and Type

Method and Description


add(double x, double y)

void

Adds a new value to the series.


add(double x, double y, double value)

void

Adds a new value to the series.


clear()

void

Removes all the values from the series.

double
double
double

getMaxValue()

Returns the maximum value.


getMinValue()

Returns the minimum value.


getValue(int index)

Returns the value at the specified index.


remove(int index)

void

Removes an existing value from the series.

Methods inherited from


class com.codename1.charts.models.XYSeries
add, addAnnotation, clearAnnotations, clearSeriesValues, getAnnotationAt,
getAnnotationCount, getAnnotationX, getAnnotationY, getIndexForKey,
getItemCount, getMaxX, getMaxY, getMinX, getMinY, getPadding, getRange,
getScaleNumber, getTitle, getX, getXYMap, getY, removeAnnotation, setTitle

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class XYValueSeries

2883

Overview (Codename One API)


XYValueSeries
public XYValueSeries(String title)

Builds a new XY value series.


Parameters:
title - the series title.

Method Detail
add
public void add(double x,
double y,
double value)

Adds a new value to the series.


Parameters:
x - the value for the X axis
y - the value for the Y axis
value - the value
add
public void add(double x,
double y)

Adds a new value to the series.


Overrides:
add in class XYSeries
Parameters:
x - the value for the X axis
y - the value for the Y axis
remove
public void remove(int index)

Removes an existing value from the series.


Overrides:
remove in class XYSeries
Parameters:
index - the index in the series of the value to remove
clear
public void clear()

Removes all the values from the series.


Overrides:
clear in class XYSeries
getValue
public double getValue(int index)

Returns the value at the specified index.


Parameters:
index - the index
Returns:
the value
getMinValue
public double getMinValue()

Returns the minimum value.


Returns:
the minimum value

Constructor Detail

2884

Overview (Codename One API)


getMaxValue
public double getMaxValue()

Returns the maximum value.


Returns:
the maximum value

Method Detail

2885

Overview (Codename One API)


com.codename1.charts.models

Class XYSeries
java.lang.Object

com.codename1.charts.models.XYSeries
Direct Known Subclasses:
TimeSeries, XYValueSeries

public class
extends Object

An XY series encapsulates values for XY charts like line, time, area, scatter... charts.

Constructor Summary
Constructor and Description
XYSeries(String title)

Builds a new XY series.


XYSeries(String title, int scaleNumber)

Builds a new XY series.

Method Summary
Modifier and Type

Method and Description


add(double x, double y)

void

void

void

Adds a new value to the


series.
add(int index, double x,
double y)

Adds a new value to the serie


at the specified index.

addAnnotation(String annot
double x, double y)

Add an String at (x,y)


coordinates
clear()

void

Removes all the existing


values and annotations from
the series.
clearAnnotations()

void

Removes all the existing


annotations from the series.
clearSeriesValues()

void

String
int

Removes all the existing


values from the series but
annotations.

getAnnotationAt(int index)

Get the String at index


getAnnotationCount()

Get the annotations count


getAnnotationX(int index)

double

Get X coordinate of the


annotation at index

double

getAnnotationY(int index)

Class XYSeries

2886

Overview (Codename One API)


Get Y coordinate of the
annotation at index
int

getIndexForKey(double key)
getItemCount()

int

Returns the series item count


getMaxX()

Returns the maximum value


on the X axis.

double

getMaxY()

Returns the maximum value


on the Y axis.

double

getMinX()

Returns the minimum value o


the X axis.

double

getMinY()
double

Returns the minimum value o


the Y axis.

protected double

getPadding(double x)

getRange(double start,
double stop,
boolean beforeAfterPoints)
SortedMap<Double,Double>

Returns submap of x and y


values according to the given
start and end

int

getScaleNumber()
getTitle()

String

Returns the series title.


getX(int index)

Returns the X axis value at th


specified index.

double

getXYMap()
com.codename1.charts.models.XYSeries.IndexXYMap<Double,Double>

Returns the current values tha


are used for drawing the
series.
getY(int index)

Returns the Y axis value at th


specified index.

double

remove(int index)

Removes an existing value


from the series.

void

removeAnnotation(int index

void

Remove an String at index


setTitle(String title)

void

Sets the series title.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XYSeries
public XYSeries(String title)

Builds a new XY series.


Parameters:
title - the series title.

Method Summary

2887

Overview (Codename One API)


XYSeries
public XYSeries(String title,
int scaleNumber)

Builds a new XY series.


Parameters:
title - the series title.
scaleNumber - the series scale number

Method Detail
getScaleNumber
public int getScaleNumber()

getTitle
public String getTitle()

Returns the series title.


Returns:
the series title
setTitle
public void setTitle(String title)

Sets the series title.


Parameters:
title - the series title
add
public void add(double x,
double y)

Adds a new value to the series.


Parameters:
x - the value for the X axis
y - the value for the Y axis
add
public void add(int index,
double x,
double y)

Adds a new value to the series at the specified index.


Parameters:
index - the index to be added the data to
x - the value for the X axis
y - the value for the Y axis
getPadding
protected double getPadding(double x)

remove
public void remove(int index)

Removes an existing value from the series.


Parameters:
index - the index in the series of the value to remove
clear
public void clear()

Removes all the existing values and annotations from the series.

Constructor Detail

2888

Overview (Codename One API)


clearSeriesValues
public void clearSeriesValues()

Removes all the existing values from the series but annotations.
clearAnnotations
public void clearAnnotations()

Removes all the existing annotations from the series.


getXYMap
public com.codename1.charts.models.XYSeries.IndexXYMap<Double,Double> getXYMap()

Returns the current values that are used for drawing the series.
Returns:
the XY map
getX
public double getX(int index)

Returns the X axis value at the specified index.


Parameters:
index - the index
Returns:
the X value
getY
public double getY(int index)

Returns the Y axis value at the specified index.


Parameters:
index - the index
Returns:
the Y value
addAnnotation
public void addAnnotation(String annotation,
double x,
double y)

Add an String at (x,y) coordinates


Parameters:
annotation - String text
xy removeAnnotation
public void removeAnnotation(int index)

Remove an String at index


Parameters:
index getAnnotationX
public double getAnnotationX(int index)

Get X coordinate of the annotation at index


Parameters:
index - the index in the annotations list
Returns:
the corresponding annotation X value
getAnnotationY
public double getAnnotationY(int index)

Get Y coordinate of the annotation at index

Method Detail

2889

Overview (Codename One API)


Parameters:
index - the index in the annotations list
Returns:
the corresponding annotation Y value
getAnnotationCount
public int getAnnotationCount()

Get the annotations count


Returns:
the annotations count
getAnnotationAt
public String getAnnotationAt(int index)

Get the String at index


Parameters:
index Returns:
String
getRange
public SortedMap<Double,Double> getRange(double start,
double stop,
boolean beforeAfterPoints)

Returns submap of x and y values according to the given start and end
Parameters:
start - start x value
stop - stop x value
beforeAfterPoints - if the points before and after the first and last visible
ones must be displayed
Returns:
a submap of x and y values
getIndexForKey
public int getIndexForKey(double key)

getItemCount
public int getItemCount()

Returns the series item count.


Returns:
the series item count
getMinX
public double getMinX()

Returns the minimum value on the X axis.


Returns:
the X axis minimum value
getMinY
public double getMinY()

Returns the minimum value on the Y axis.


Returns:
the Y axis minimum value
getMaxX
public double getMaxX()

Returns the maximum value on the X axis.


Returns:
the X axis maximum value

Method Detail

2890

Overview (Codename One API)


getMaxY
public double getMaxY()

Returns the maximum value on the Y axis.


Returns:
the Y axis maximum value

Method Detail

2891

Overview (Codename One API)


com.codename1.charts.models

Class XYMultipleSeriesDataset
java.lang.Object

com.codename1.charts.models.XYMultipleSeriesDataset

public class
extends Object

A series that includes 0 to many XYSeries.

Constructor Summary
Constructor and Description
XYMultipleSeriesDataset()

Method Summary
Modifier and Type

Method and Description


addAllSeries(List<XYSeries> series)

void

Adds all the provided XY series to the list.


addSeries(int index, XYSeries series)

void

Adds a new XY series to the list.


addSeries(XYSeries series)

void

Adds a new XY series to the list.


clear()

void

Removes all the XY series from the list.

XYSeries[]
XYSeries

getSeries()

Returns an array of the XY series.


getSeriesAt(int index)

Returns the XY series at the specified index.


getSeriesCount()

int

Returns the XY series count.


removeSeries(int index)

void

Removes the XY series from the list.


removeSeries(XYSeries series)

void

Removes the XY series from the list.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
XYMultipleSeriesDataset
public XYMultipleSeriesDataset()

Method Detail

Class XYMultipleSeriesDataset

2892

Overview (Codename One API)


addSeries
public void addSeries(XYSeries series)

Adds a new XY series to the list.


Parameters:
series - the XY series to add
addSeries
public void addSeries(int index,
XYSeries series)

Adds a new XY series to the list.


Parameters:
index - the index in the series list
series - the XY series to add
addAllSeries
public void addAllSeries(List<XYSeries> series)

Adds all the provided XY series to the list.


Parameters:
series - the XY series to add
removeSeries
public void removeSeries(int index)

Removes the XY series from the list.


Parameters:
index - the index in the series list of the series to remove
removeSeries
public void removeSeries(XYSeries series)

Removes the XY series from the list.


Parameters:
series - the XY series to be removed
clear
public void clear()

Removes all the XY series from the list.


getSeriesAt
public XYSeries getSeriesAt(int index)

Returns the XY series at the specified index.


Parameters:
index - the index
Returns:
the XY series at the index
getSeriesCount
public int getSeriesCount()

Returns the XY series count.


Returns:
the XY series count
getSeries
public XYSeries[] getSeries()

Returns an array of the XY series.


Returns:
the XY series array

Method Detail

2893

Overview (Codename One API)


com.codename1.charts.models

Class TimeSeries
java.lang.Object

com.codename1.charts.models.XYSeries

com.codename1.charts.models.TimeSeries

public class
extends XYSeries

A series for the date / time charts.

Constructor Summary
Constructor and Description
TimeSeries(String title)

Builds a new date / time series.

Method Summary
Modifier and Type

Method and Description


add(Date x, double y)

void

Adds a new value to the series.

protected double

getPadding(double x)

Methods inherited from


class com.codename1.charts.models.XYSeries
add, add, addAnnotation, clear, clearAnnotations, clearSeriesValues,
getAnnotationAt, getAnnotationCount, getAnnotationX, getAnnotationY,
getIndexForKey, getItemCount, getMaxX, getMaxY, getMinX, getMinY, getRange,
getScaleNumber, getTitle, getX, getXYMap, getY, remove, removeAnnotation,
setTitle

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
TimeSeries
public TimeSeries(String title)

Builds a new date / time series.


Parameters:
title - the series title

Method Detail

Class TimeSeries

2894

Overview (Codename One API)


add
public void add(Date x,
double y)

Adds a new value to the series.


Parameters:
x - the date / time value for the X axis
y - the value for the Y axis
getPadding
protected double getPadding(double x)

Overrides:
getPadding

Method Detail

in class XYSeries

2895

Overview (Codename One API)


com.codename1.charts.models

Class SeriesSelection
java.lang.Object

com.codename1.charts.models.SeriesSelection

public class
extends Object

Constructor Summary
Constructor and Description
SeriesSelection(int seriesIndex, int pointIndex, double xValue, double value)

Method Summary
Modifier and Type Method and Description
int

getPointIndex()

int

getSeriesIndex()

double

getValue()

double

getXValue()

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
SeriesSelection
public SeriesSelection(int seriesIndex,
int pointIndex,
double xValue,
double value)

Method Detail
getSeriesIndex
public int getSeriesIndex()

getPointIndex
public int getPointIndex()

getXValue
public double getXValue()

getValue
public double getValue()

Class SeriesSelection

2896

Overview (Codename One API)


com.codename1.charts.models

Class RangeCategorySeries
java.lang.Object

com.codename1.charts.models.CategorySeries

com.codename1.charts.models.RangeCategorySeries

public class
extends CategorySeries

A series for the range category charts like the range bar.

Constructor Summary
Constructor and Description
RangeCategorySeries(String title)

Builds a new category series.

Method Summary
Modifier and Type

Method and Description


add(double minValue, double maxValue)

void

Adds new values to the series


add(String category, double minValue, double maxValue)

void

Adds new values to the series.


clear()

void

Removes all the existing values from the series.


getMaximumValue(int index)

double

Returns the maximum value at the specified index.


getMinimumValue(int index)

double

Returns the minimum value at the specified index.


remove(int index)

void

Removes existing values from the series.

XYSeries

toXYSeries()

Transforms the range category series to an XY series.

Methods inherited from


class com.codename1.charts.models.CategorySeries
add, add, getCategory, getItemCount, getTitle, getValue, set

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
RangeCategorySeries
public RangeCategorySeries(String title)

Builds a new category series.


Parameters:
title - the series title

Method Detail

2897

Overview (Codename One API)


Method

Detail

add
public void add(double minValue,
double maxValue)

Adds new values to the series


Parameters:
minValue - the new minimum value
maxValue - the new maximum value
add
public void add(String category,
double minValue,
double maxValue)

Adds new values to the series.


Parameters:
category - the category
minValue - the new minimum value
maxValue - the new maximum value
remove
public void remove(int index)

Removes existing values from the series.


Overrides:
remove in class CategorySeries
Parameters:
index - the index in the series of the values to remove
clear
public void clear()

Removes all the existing values from the series.


Overrides:
clear in class CategorySeries
getMinimumValue
public double getMinimumValue(int index)

Returns the minimum value at the specified index.


Parameters:
index - the index
Returns:
the minimum value at the index
getMaximumValue
public double getMaximumValue(int index)

Returns the maximum value at the specified index.


Parameters:
index - the index
Returns:
the maximum value at the index
toXYSeries
public XYSeries toXYSeries()

Transforms the range category series to an XY series.


Overrides:
toXYSeries in class CategorySeries
Returns:
the XY series

Method Detail

2898

Overview (Codename One API)


com.codename1.charts.models

Class Point
java.lang.Object

com.codename1.charts.models.Point

public final class


extends Object

A class to encapsulate the definition of a point.

Constructor Summary
Constructor and Description
Point()
Point(float x, float y)

Method Summary
Modifier and Type Method and Description
float

getX()

float

getY()

void

setX(float x)

void

setY(float y)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Point
public Point()

Point
public Point(float x,
float y)

Method Detail
getX
public float getX()

getY
public float getY()

setX
public void setX(float x)

Class Point

2899

Overview (Codename One API)


setY
public void setY(float y)

Method Detail

2900

Overview (Codename One API)


com.codename1.charts.models

Class MultipleCategorySeries
java.lang.Object

com.codename1.charts.models.MultipleCategorySeries

public class
extends Object

A series for the multiple category charts like the doughnut.

Constructor Summary
Constructor and Description
MultipleCategorySeries(String title)

Builds a new category series.

Method Summary
Modifier and Type

Method and Description


add(String[] titles, double[] values)

void

Adds a new value to the series


add(String category, String[] titles, double[] values)

void

Adds a new value to the series.


clear()

void

Removes all the existing values from the series.


getCategoriesCount()

int

Returns the categories count.


getCategory(int index)

String

Returns the category name at the specified index.


getItemCount(int index)

int

Returns the series item count.

String[]
double[]

getTitles(int index)

Returns the series titles.


getValues(int index)

Returns the values at the specified index.


remove(int index)

void

Removes an existing value from the series.

XYSeries

toXYSeries()

Transforms the category series to an XY series.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
MultipleCategorySeries
public MultipleCategorySeries(String title)

Builds a new category series.


Parameters:

Class MultipleCategorySeries

2901

Overview (Codename One API)


title

- the series title

Method Detail
add
public void add(String[] titles,
double[] values)

Adds a new value to the series


Parameters:
titles - the titles to be used as labels
values - the new value
add
public void add(String category,
String[] titles,
double[] values)

Adds a new value to the series.


Parameters:
category - the category name
titles - the titles to be used as labels
values - the new value
remove
public void remove(int index)

Removes an existing value from the series.


Parameters:
index - the index in the series of the value to remove
clear
public void clear()

Removes all the existing values from the series.


getValues
public double[] getValues(int index)

Returns the values at the specified index.


Parameters:
index - the index
Returns:
the value at the index
getCategory
public String getCategory(int index)

Returns the category name at the specified index.


Parameters:
index - the index
Returns:
the category name at the index
getCategoriesCount
public int getCategoriesCount()

Returns the categories count.


Returns:
the categories count
getItemCount
public int getItemCount(int index)

Returns the series item count.

Constructor Detail

2902

Overview (Codename One API)


Parameters:
index - the index
Returns:
the series item count
getTitles
public String[] getTitles(int index)

Returns the series titles.


Parameters:
index - the index
Returns:
the series titles
toXYSeries
public XYSeries toXYSeries()

Transforms the category series to an XY series.


Returns:
the XY series

Method Detail

2903

Overview (Codename One API)


com.codename1.charts.models

Class CategorySeries
java.lang.Object

com.codename1.charts.models.CategorySeries
Direct Known Subclasses:
RangeCategorySeries

public class
extends Object

A series for the category charts like the pie ones.

Constructor Summary
Constructor and Description
CategorySeries(String title)

Builds a new category series.

Method Summary
Modifier and Type

Method and Description


add(double value)

void

Adds a new value to the series


add(String category, double value)

void

Adds a new value to the series.


clear()

void

Removes all the existing values from the series.


getCategory(int index)

String

Returns the category name at the specified index.


getItemCount()

int

Returns the series item count.


getTitle()

String

Returns the series title.


getValue(int index)

double

Returns the value at the specified index.


remove(int index)

void

Removes an existing value from the series.


set(int index, String category, double value)

void

Replaces the value at the specific index in the series.

XYSeries

toXYSeries()

Transforms the category series to an XY series.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

Class CategorySeries

2904

Overview (Codename One API)


CategorySeries
public CategorySeries(String title)

Builds a new category series.


Parameters:
title - the series title

Method Detail
getTitle
public String getTitle()

Returns the series title.


Returns:
the series title
add
public void add(double value)

Adds a new value to the series


Parameters:
value - the new value
add
public void add(String category,
double value)

Adds a new value to the series.


Parameters:
category - the category
value - the new value
set
public void set(int index,
String category,
double value)

Replaces the value at the specific index in the series.


Parameters:
index - the index in the series
category - the category
value - the new value
remove
public void remove(int index)

Removes an existing value from the series.


Parameters:
index - the index in the series of the value to remove
clear
public void clear()

Removes all the existing values from the series.


getValue
public double getValue(int index)

Returns the value at the specified index.


Parameters:
index - the index
Returns:
the value at the index

Constructor Detail

2905

Overview (Codename One API)


getCategory
public String getCategory(int index)

Returns the category name at the specified index.


Parameters:
index - the index
Returns:
the category name at the index
getItemCount
public int getItemCount()

Returns the series item count.


Returns:
the series item count
toXYSeries
public XYSeries toXYSeries()

Transforms the category series to an XY series.


Returns:
the XY series

Method Detail

2906

Overview (Codename One API)


com.codename1.charts.compat

Class PathMeasure
java.lang.Object

com.codename1.charts.compat.PathMeasure

Deprecated.
public class
extends Object

Constructor Summary
Constructor and Description
PathMeasure(GeneralPath p, boolean b)

Deprecated.

Method Summary
Modifier and Type

Method and Description


getLength()

Deprecated.

float

getPosTan(int i, float[] coords, float[] tan)

Deprecated.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
PathMeasure
public PathMeasure(GeneralPath p,
boolean b)

Deprecated.

Method Detail
getLength
public float getLength()

Deprecated.
getPosTan
public void getPosTan(int i,
float[] coords,
float[] tan)

Deprecated.

Class PathMeasure

2907

Overview (Codename One API)


com.codename1.charts.compat

Class Paint
java.lang.Object

com.codename1.charts.compat.Paint

Deprecated.
public class
extends Object

DO NOT USE. Compatibility class used internally by the Charts API.

Nested Class Summary


Modifier and Type Class and Description
Paint.Align
static class

Deprecated.
Paint.Cap

static class

Deprecated.
Paint.Join

static class

Deprecated.
Paint.Style

static class

Deprecated.

Constructor Summary
Constructor and Description
Paint()

Deprecated.

Method Summary
Modifier and
Type
int

Method and Description


breakText(String text, boolean measureForwards, float maxWidth,
float[] measuredWidth)

Deprecated.
getColor()

int

Deprecated.
getStrokeCap()

int

Deprecated.
getStrokeJoin()

int

Deprecated.

float

getStrokeMiter()

Deprecated.

Method Detail

2908

Overview (Codename One API)

getStrokeWidth()
float

Deprecated.
getStyle()

Paint.Style

Deprecated.
getTextAlign()

int

void

Deprecated.
getTextBounds(String string, int start, int count,
Rectangle2D rect)

Deprecated.
getTextSize()

float

Deprecated.
getTextWidths(String text, float[] widths)

void

Deprecated.
getTypeface()

Font

Deprecated.
measureText(char[] chars, int start, int count)

float

Deprecated.
measureText(String newText)

float

Deprecated.
setAntiAlias(boolean antialiasing)

void

Deprecated.
setColor(int color)

void

Deprecated.
setStrokeCap(int cap)

void

Deprecated.
setStrokeJoin(int join)

void

Deprecated.
setStrokeMiter(float miter)

void

Deprecated.
setStrokeWidth(float i)

void

Deprecated.
setStyle(Paint.Style style)

void

Deprecated.
setTextAlign(int align)

void

Deprecated.
setTextSize(float size)

void

Deprecated.
setTypeface(Font textTypeface)

void

Deprecated.

String

toString()

Method Summary

2909

Overview (Codename One API)


Deprecated.
Returns a string representation of the object.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail
Paint
public Paint()

Deprecated.

Method Detail
getTextWidths
public void getTextWidths(String text,
float[] widths)

Deprecated.
breakText
public int breakText(String text,
boolean measureForwards,
float maxWidth,
float[] measuredWidth)

Deprecated.
getTextBounds
public void getTextBounds(String string,
int start,
int count,
Rectangle2D rect)

Deprecated.
measureText
public float measureText(String newText)

Deprecated.
measureText
public float measureText(char[] chars,
int start,
int count)

Deprecated.
setAntiAlias
public void setAntiAlias(boolean antialiasing)

Deprecated.
getTypeface
public Font getTypeface()

Deprecated.

Methods inherited from class java.lang.Object

2910

Overview (Codename One API)


setTypeface
public void setTypeface(Font textTypeface)

Deprecated.
getStrokeCap
public int getStrokeCap()

Deprecated.
getStrokeJoin
public int getStrokeJoin()

Deprecated.
getStrokeMiter
public float getStrokeMiter()

Deprecated.
getStyle
public Paint.Style getStyle()

Deprecated.
setStrokeCap
public void setStrokeCap(int cap)

Deprecated.
setStrokeJoin
public void setStrokeJoin(int join)

Deprecated.
setStrokeMiter
public void setStrokeMiter(float miter)

Deprecated.
getStrokeWidth
public float getStrokeWidth()

Deprecated.
setStrokeWidth
public void setStrokeWidth(float i)

Deprecated.
getColor
public int getColor()

Deprecated.
setColor
public void setColor(int color)

Deprecated.
setStyle
public void setStyle(Paint.Style style)

Deprecated.

Method Detail

2911

Overview (Codename One API)


setTextAlign
public void setTextAlign(int align)

Deprecated.
getTextAlign
public int getTextAlign()

Deprecated.
setTextSize
public void setTextSize(float size)

Deprecated.
getTextSize
public float getTextSize()

Deprecated.
toString
public String toString()

Deprecated.
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns
a string that "textually represents" this object. The result should be a concise but
informative representation that is easy for a person to read. It is recommended that
all subclasses override this method. The toString method for class Object returns a
string consisting of the name of the class of which the object is an instance, the
at-sign character `@', and the unsigned hexadecimal representation of the hash code
of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Overrides:
toString in class Object

Method Detail

2912

Overview (Codename One API)


com.codename1.charts.compat

Enum Paint.Style
java.lang.Object

java.lang.Enum<Paint.Style>

com.codename1.charts.compat.Paint.Style
All Implemented Interfaces:
Comparable<Paint.Style>
Enclosing class:
Paint

public static enum


extends Enum<Paint.Style>

Enum Constant Summary


Enum Constant and Description
FILL
FILL_AND_STROKE
STROKE

Method Summary
Modifier and Type
static Paint.Style
static
Paint.Style[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the specified name.
values()

Returns an array containing the constants of this enum type, in the


order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


FILL
public static final Paint.Style FILL

FILL_AND_STROKE
public static final Paint.Style FILL_AND_STROKE

STROKE
public static final Paint.Style STROKE

Method Detail

Enum Paint.Style

2913

Overview (Codename One API)


values
public static Paint.Style[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (Paint.Style c : Paint.Style.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static Paint.Style valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Method Detail

2914

Overview (Codename One API)


com.codename1.charts.compat

Class Paint.Join
java.lang.Object

com.codename1.charts.compat.Paint.Join
Enclosing class:
Paint

public static class


extends Object

Field Summary
Modifier and Type Field and Description
static int

BEVEL

static int

MITER

static int

ROUND

Constructor Summary
Constructor and Description
Join()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
BEVEL
public static final int BEVEL

See Also:
Constant Field Values
MITER
public static final int MITER

See Also:
Constant Field Values
ROUND
public static final int ROUND

See Also:
Constant Field Values

Class Paint.Join

2915

Overview (Codename One API)


Constructor

Detail

Join
public Join()

Constructor Detail

2916

Overview (Codename One API)


com.codename1.charts.compat

Class Paint.Cap
java.lang.Object

com.codename1.charts.compat.Paint.Cap
Enclosing class:
Paint

public static class


extends Object

Field Summary
Modifier and Type Field and Description
static int

BUTT

static int

ROUND

static int

SQUARE

Constructor Summary
Constructor and Description
Cap()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
BUTT
public static final int BUTT

See Also:
Constant Field Values
ROUND
public static final int ROUND

See Also:
Constant Field Values
SQUARE
public static final int SQUARE

See Also:
Constant Field Values

Class Paint.Cap

2917

Overview (Codename One API)


Constructor

Detail

Cap
public Cap()

Constructor Detail

2918

Overview (Codename One API)


com.codename1.charts.compat

Class Paint.Align
java.lang.Object

com.codename1.charts.compat.Paint.Align
Enclosing class:
Paint

public static class


extends Object

Field Summary
Modifier and Type Field and Description
static int

CENTER

static int

LEFT

static int

RIGHT

Constructor Summary
Constructor and Description
Align()

Method Summary

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
CENTER
public static final int CENTER

See Also:
Constant Field Values
LEFT
public static final int LEFT

See Also:
Constant Field Values
RIGHT
public static final int RIGHT

See Also:
Constant Field Values

Class Paint.Align

2919

Overview (Codename One API)


Constructor

Detail

Align
public Align()

Constructor Detail

2920

Overview (Codename One API)


com.codename1.charts.compat

Class GradientDrawable
java.lang.Object

com.codename1.charts.compat.GradientDrawable

public class
extends Object

Nested Class Summary


Modifier and Type
static class

Class and Description


GradientDrawable.Orientation

Constructor Summary
Constructor and Description
GradientDrawable(GradientDrawable.Orientation orientation, int[] colors)

Method Summary
Modifier and Type

Method and Description

void

draw(Canvas canvas)

void

setBounds(int left, int top, int right, int bottom)

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
GradientDrawable
public GradientDrawable(GradientDrawable.Orientation orientation,
int[] colors)

Method Detail
setBounds
public void setBounds(int
int
int
int

left,
top,
right,
bottom)

draw
public void draw(Canvas canvas)

Class GradientDrawable

2921

Overview (Codename One API)


com.codename1.charts.compat

Enum GradientDrawable.Orientation
java.lang.Object

java.lang.Enum<GradientDrawable.Orientation>

com.codename1.charts.compat.GradientDrawable.Orientation
All Implemented Interfaces:
Comparable<GradientDrawable.Orientation>
Enclosing class:
GradientDrawable

public static enum


extends Enum<GradientDrawable.Orientation>

Enum Constant Summary


Enum Constant and Description
BL_TR
BOTTOM_TOP
BR_TL
LEFT_RIGHT
RIGHT_LEFT
TL_BR
TOP_BOTTOM
TR_BL

Method Summary
Modifier and Type
static
GradientDrawable.Orientation
static
GradientDrawable.Orientation[]

Method and Description


valueOf(String name)

Returns the enum constant of this type with the


specified name.
values()

Returns an array containing the constants of this


enum type, in the order they are declared.

Methods inherited from class java.lang.Enum


clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name,
ordinal, setEnumValues, toString, valueOf

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail


BL_TR
public static final GradientDrawable.Orientation BL_TR

Method Detail

2922

Overview (Codename One API)


BOTTOM_TOP
public static final GradientDrawable.Orientation BOTTOM_TOP

BR_TL
public static final GradientDrawable.Orientation BR_TL

LEFT_RIGHT
public static final GradientDrawable.Orientation LEFT_RIGHT

RIGHT_LEFT
public static final GradientDrawable.Orientation RIGHT_LEFT

TL_BR
public static final GradientDrawable.Orientation TL_BR

TOP_BOTTOM
public static final GradientDrawable.Orientation TOP_BOTTOM

TR_BL
public static final GradientDrawable.Orientation TR_BL

Method Detail
values
public static GradientDrawable.Orientation[] values()

Returns an array containing the constants of this enum type, in the order they are
declared. This method may be used to iterate over the constants as follows:
for (GradientDrawable.Orientation c : GradientDrawable.Orientation.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are
declared
valueOf
public static GradientDrawable.Orientation valueOf(String name)

Returns the enum constant of this type with the specified name. The string must
match exactly an identifier used to declare an enum constant in this type.
(Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the
specified name
NullPointerException - if the argument is null

Enum Constant Detail

2923

Overview (Codename One API)


com.codename1.charts.compat

Class Canvas
java.lang.Object

com.codename1.charts.compat.Canvas

Deprecated.
public class
extends Object

An internal compatibility class for use by the Charts library. Since the library was ported from an
Android library, it made use of Canvas and Paint, so rather than rewriting all of this, we added a
Canvas and Paint compatibility layer. **DO NOT USE DIRECTLY**

Field Summary
Modifier and Type Field and Description
absoluteX
int

Deprecated.
absoluteY

int

Deprecated.
bounds

Rectangle

Deprecated.
g

Graphics

Deprecated.

Constructor Summary
Constructor and Description
Canvas()

Deprecated.

Method Summary
Modifier and
Type
void

Method and Description


drawArc(Rectangle2D oval, float currentAngle, float sweepAngle,
boolean useCenter, Paint paint)

Deprecated.
drawBitmap(Image img, float left, float top, Paint paint)

void

Deprecated.
drawCircle(float cx, float cy, float r, Paint paint)

void

Deprecated.
drawLine(float x1, float y1, float x2, float y2, Paint paint)

void

Method Detail

Deprecated.

2924

Overview (Codename One API)


drawPath(Shape p, Paint paint)

Deprecated.

void

drawPoint(Float get, Float get0, Paint paint)

Deprecated.

void

drawRect(float left, float top, float right, float bottom,


Paint paint)

void

Deprecated.
drawRoundRect(Rectangle2D rect, float rx, float ry, Paint mPaint)

Deprecated.

void

drawText(String string, float x, float y, Paint paint)

Deprecated.

void

getClipBounds(Rectangle mRect)

Deprecated.

void

getHeight()

Deprecated.

int

getWidth()

Deprecated.

int

rotate(float angle, float x, float y)

Deprecated.

void

scale(float x, float y)

Deprecated.

void

translate(float x, float y)

Deprecated.

void

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail
g
public Graphics g

Deprecated.
bounds
public Rectangle bounds

Deprecated.
absoluteX
public int absoluteX

Deprecated.
absoluteY
public int absoluteY

Deprecated.

Method Summary

2925

Overview (Codename One API)


Constructor

Detail

Canvas
public Canvas()

Deprecated.

Method Detail
getClipBounds
public void getClipBounds(Rectangle mRect)

Deprecated.
drawRect
public void drawRect(float
float
float
float
Paint

left,
top,
right,
bottom,
paint)

Deprecated.
drawText
public void drawText(String string,
float x,
float y,
Paint paint)

Deprecated.
getHeight
public int getHeight()

Deprecated.
getWidth
public int getWidth()

Deprecated.
drawPath
public void drawPath(Shape p,
Paint paint)

Deprecated.
drawLine
public void drawLine(float
float
float
float
Paint

x1,
y1,
x2,
y2,
paint)

Deprecated.
rotate
public void rotate(float angle,
float x,
float y)

Deprecated.

Constructor Detail

2926

Overview (Codename One API)


scale
public void scale(float x,
float y)

Deprecated.
translate
public void translate(float x,
float y)

Deprecated.
drawCircle
public void drawCircle(float
float
float
Paint

cx,
cy,
r,
paint)

Deprecated.
drawArc
public void drawArc(Rectangle2D oval,
float currentAngle,
float sweepAngle,
boolean useCenter,
Paint paint)

Deprecated.
drawPoint
public void drawPoint(Float get,
Float get0,
Paint paint)

Deprecated.
drawRoundRect
public void drawRoundRect(Rectangle2D rect,
float rx,
float ry,
Paint mPaint)

Deprecated.
drawBitmap
public void drawBitmap(Image
float
float
Paint

img,
left,
top,
paint)

Deprecated.

Method Detail

2927

Overview (Codename One API)


com.codename1.charts

Class ChartUtil
java.lang.Object

com.codename1.charts.ChartUtil

public class
extends Object

A utility class for painting a chart onto a Graphics context. This is a low level API. You should use the
ChartComponent class instead.

Constructor Summary
Constructor and Description
ChartUtil()

Method Summary
Modifier and Type

Method and Description


paintChart(Graphics g, AbstractChart chart,
Rectangle bounds, int absX, int absY)

void

Draws the given chart onto the given graphics

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
ChartUtil
public ChartUtil()

Method Detail
paintChart
public void paintChart(Graphics g,
AbstractChart chart,
Rectangle bounds,
int absX,
int absY)

Draws the given chart onto the given graphics


Parameters:
g - the graphics object
chart - the chart object
bounds - the bounds in which the chart should be drawn within the graphics
absX absY -

Class ChartUtil

2928

Overview (Codename One API)


com.codename1.charts

Class ChartComponent
java.lang.Object

com.codename1.ui.Component

com.codename1.charts.ChartComponent
All Implemented Interfaces:
Animation, StyleListener

public class
extends Component

The top level component for displaying charts


The charts package enables Codename One developers to add charts and visualizations to their
apps without having to include external libraries or embedding web views. We also wanted to harness
the new features in the graphics pipeline to maximize performance.
Device Support
Since the charts package makes use of 2D transformations and shapes, it requires some of the
graphics features that are not yet available on all platforms. Currently the following platforms are
supported:
1. Simulator
2. Android
3. iOS
Features
1. Built-in support for many common types of charts including bar charts, line charts,
stacked charts, scatter charts, pie charts and more.
2. Pinch Zoom - The com.codename1.charts,ChartComponent class includes optional pinch
zoom support.
3. Panning Support - The com.codename1.charts,ChartComponent class includes optional
support for panning.
Chart Types
The com.codename1.charts package includes models and renderers for many different types of
charts. It is also extensible so that you can add your own chart types if required. The following screen
shots demonstrate a small sampling of the types of charts that can be created.

Method Detail

2929

Overview (Codename One API)

The above screenshots were taken from the ChartsDemo app. Y ou can start playing with this app
by checking it out from our git repository.
How to Create A Chart
Adding a chart to your app involves four steps:
1. Build the model. You can construct a model (aka data set) for the chart using one of the
existing model classes in the com.codename1.charts.models package. Essentially, this is just
where you add the data that you want to display.
2. Set up a renderer. You can create a renderer for your chart using one of the existing
renderer classes in the com.codename1.charts.renderers package. The renderer allows you
to specify how the chart should look. E.g. the colors, fonts, styles, to use.
3. Create the Chart View. Use one of the existing view classes in the
com.codename1.charts.views package.
4. Create a com.codename1.charts,ChartComponent . In order to add your chart to the UI, you
need to wrap it in a com.codename1.charts,ChartComponent object.
You can check out the ChartsDemo app for specific examples, but here is a high level view of some
code that creates a Pie Chart.
The charts package is derived work from the excellent open source aChartEngine API.

Class ChartComponent

2930

Overview (Codename One API)


Field

Summary

Fields inherited from class com.codename1.ui.Component


BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT,
BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X,
DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y,
DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X,
DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP

Constructor Summary
Constructor and Description
ChartComponent(AbstractChart chart)

Creates a new chart component to display the provided chart.

Method Summary
Modifier and
Type
protected
Dimension
Point

Method and Description


calcPreferredSize()

Calculates the preferred size based on component content.


chartToScreenCoord(int x, int y)

Returns the screen position from a chart coordinate


chartToScreenShape(Shape s)

Shape

AbstractChart
Transform
boolean
boolean
void

Converts a screen coordinate spaced shape to the same shape in the


chart coordinate space
getChart()

Gets the chart that is being displayed in this component.


getTransform()

Gets the transform for the chart.


isPanEnabled()

Checks if panning is enabled.


isZoomEnabled()
paint(Graphics g)

Paints the chart.


pointerDragged(int[] x, int[] y)

void

If this Component is focused, the pointer dragged event will call this
method
pointerPressed(int x, int y)

void

If this Component is focused, the pointer pressed event will call this
method
pointerReleased(int x, int y)

void

Point

If this Component is focused, the pointer released event will call this
method
screenToChartCoord(int x, int y)

Converts screen coordinates to chart coordinates.


screenToChartShape(Shape s)

Shape

protected void
protected void
void
void

Field Summary

Converts a chart coordinate spaced shape to the same shape in the


screen coordinate space
seriesPressed(SeriesSelection sel)

Called when a pointer is pressed on a series in the chart.


seriesReleased(SeriesSelection sel)

Called when a pointer is released from a series in the chart.


setChart(AbstractChart chart)

Sets the chart to be displayed in this component.


setPanEnabled(boolean panEnabled)

2931

Overview (Codename One API)

setTransform(Transform transform)

void

Sets the transform for the chart.

void

setZoomEnabled(boolean zoomEnabled)
zoomToShapeInChartCoords(Shape s)

void

Zooms the view port to show a specified shape.


zoomToShapeInChartCoords(Shape s, int duration)

void

Zooms the view port to show a specified shape.

Methods inherited from class com.codename1.ui.Component


addDragOverListener, addDropListener, addFocusListener,
addPointerDraggedListener, addPointerPressedListener,
addPointerReleasedListener, addPullToRefresh, addScrollListener, animate,
bindProperty, calcScrollSize, cancelRepaints, clearClientProperties,
contains, createStyleAnimation, deinitialize, deinitializeCustomStyle,
dragEnter, dragExit, dragFinished, draggingOver, dragInitiated,
drawDraggedImage, drop, fireClicked, focusGained, focusLost, getAbsoluteX,
getAbsoluteY, getAllStyles, getAnimationManager, getBaseline,
getBaselineResizeBehavior, getBindablePropertyNames,
getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue,
getBounds, getClientProperty, getCloudBoundProperty,
getCloudDestinationProperty, getComponentForm, getComponentState,
getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage,
getDragRegionStatus, getDragSpeed, getGridPosX, getGridPosY, getHeight,
getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft,
getNextFocusRight, getNextFocusUp, getParent, getPreferredH,
getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames,
getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight,
getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension,
getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY,
getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap,
getStyle, getTensileLength, getUIID, getUIManager, getUnselectedStyle,
getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus,
initComponent, initCustomStyle, initLaf, installDefaultPainter,
isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation,
isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable,
isGrabsPointerEvents, isHidden, isHideInPortrait, isInClippingRegion,
isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY,
isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid,
isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled,
isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress,
longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds,
paintBorder, paintBorderBackground, paintComponent, paintComponent,
paintLock, paintLockRelease, paintScrollbars, paintScrollbarX,
paintScrollbarY, paramString, pinch, pointerDragged, pointerHover,
pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased,
putClientProperty, refreshTheme, refreshTheme, refreshTheme,
removeDragOverListener, removeDropListener, removeFocusListener,
removePointerDraggedListener, removePointerPressedListener,
removePointerReleasedListener, removeScrollListener, repaint, repaint,
requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible,
setAlwaysTensile, setBoundPropertyValue, setCellRenderer,
setCloudBoundProperty, setCloudDestinationProperty, setComponentState,
setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled,
setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput,
setHeight, setHidden, setHidden, setHideInPortrait, setInitialized,
setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown,
setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH,
setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL,
setSameHeight, setSameWidth, setScrollAnimationSpeed,
setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX,
setScrollY, setSelectCommandText, setSelectedStyle,
setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid,
setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID,
setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe,
styleChanged, toString, unbindProperty

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Method Summary

2932

Overview (Codename One API)


Constructor

Detail

ChartComponent
public ChartComponent(AbstractChart chart)

Creates a new chart component to display the provided chart.


Parameters:
chart - The chart to be displayed in this component.

Method Detail
getChart
public AbstractChart getChart()

Gets the chart that is being displayed in this component.


Returns:
calcPreferredSize
protected Dimension calcPreferredSize()

Description copied from class: Component


Calculates the preferred size based on component content. This method is invoked
lazily by getPreferred size.
Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content
setChart
public void setChart(AbstractChart chart)

Sets the chart to be displayed in this component.


Parameters:
chart paint
public void paint(Graphics g)

Paints the chart.


Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g screenToChartCoord
public Point screenToChartCoord(int x,
int y)

Converts screen coordinates to chart coordinates.


Parameters:
x - screen x position
y - screen y position
Returns:
The chart coordinate corresponding to the given screen coordinate.
chartToScreenCoord
public Point chartToScreenCoord(int x,
int y)

Returns the screen position from a chart coordinate


Parameters:

Constructor Detail

2933

Overview (Codename One API)


x
y

- the x position within the chart


- the y position within the chart

Returns:
a position within the screen
screenToChartShape
public Shape screenToChartShape(Shape s)

Converts a chart coordinate spaced shape to the same shape in the screen
coordinate space
Parameters:
s - shape in screen coordinates
Returns:
same shape using chart space coordinates
chartToScreenShape
public Shape chartToScreenShape(Shape s)

Converts a screen coordinate spaced shape to the same shape in the chart
coordinate space
Parameters:
s - shape in chart coordinates
Returns:
same shape using screen coordinate space
zoomToShapeInChartCoords
public void zoomToShapeInChartCoords(Shape s)

Zooms the view port to show a specified shape. The shape should be expressed in
chart coordinates (not screen coordinates).
Parameters:
s - The shape that should be shown.
zoomToShapeInChartCoords
public void zoomToShapeInChartCoords(Shape s,
int duration)

Zooms the view port to show a specified shape. The shape should be expressed in
chart coordinates (not screen coordinates).
Parameters:
s - The shape that should be shown.
duration - The duration of the transition.
pointerPressed
public void pointerPressed(int x,
int y)

Description copied from class: Component


If this Component is focused, the pointer pressed event will call this method
Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
seriesPressed
protected void seriesPressed(SeriesSelection sel)

Called when a pointer is pressed on a series in the chart. This can be overridden by
subclasses to respond to this event.
Parameters:
sel pointerReleased
public void pointerReleased(int x,
int y)

Method Detail

2934

Overview (Codename One API)


Description copied from class: Component
If this Component is focused, the pointer released event will call this method
Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
seriesReleased
protected void seriesReleased(SeriesSelection sel)

Called when a pointer is released from a series in the chart. This can be overridden in
subclasses to handle these events.
Parameters:
sel getTransform
public Transform getTransform()

Gets the transform for the chart. This can be used to scale, translate, and rotate the
chart. This transform assumes its origin at the (absoluteX, absoluteY) of the
component at the time it is drawn rather than the screen's origin as is normally the
case with transforms. This allows the transform to be applied consistently with
respect to the chart's coordinates even when the component is moved around the
screen.
Returns:
The transform for the chart in component coordinates.
setTransform
public void setTransform(Transform transform)

Sets the transform for the chart. Transforms origin assumed to be at (getAbsoluteX,
getAbsoluteY).
Parameters:
transform - the transform to set
pointerDragged
public void pointerDragged(int[] x,
int[] y)

Description copied from class: Component


If this Component is focused, the pointer dragged event will call this method
Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate
isPanEnabled
public boolean isPanEnabled()

Checks if panning is enabled.


Returns:
the panEnabled
setPanEnabled
public void setPanEnabled(boolean panEnabled)

Parameters:
panEnabled

- the panEnabled to set

isZoomEnabled
public boolean isZoomEnabled()

Returns:
the zoomEnabled

Method Detail

2935

Overview (Codename One API)

setZoomEnabled
public void setZoomEnabled(boolean zoomEnabled)

Parameters:
zoomEnabled

Method Detail

- the zoomEnabled to set

2936

Overview (Codename One API)


com.codename1.capture

Class Capture
java.lang.Object

com.codename1.capture.Capture

public class
extends Object

This is the main class for capturing media files from the device. Use this class to invoke the native
camera to capture images, audio or video Notice that files returned by this class are potentially
temporary files and might be deleted by the OS in the future.

Constructor Summary
Constructor and Description
Capture()

Method Summary
Modifier and
Type
static String
static void

Method and Description


captureAudio()

Same as captureAudio only a blocking version that holds the EDT


captureAudio(ActionListener response)

This method tries to invoke the device native hardware to capture audio.
capturePhoto()

static String

static void

Invokes the camera and takes a photo synchronously while blocking the
EDT
capturePhoto(ActionListener response)

This method tries to invoke the device native camera to capture images.
capturePhoto(int width, int height)

static String

static String
static void
static boolean

Invokes the camera and takes a photo synchronously while blocking the
EDT
captureVideo()

Same as captureVideo only a blocking version that holds the EDT


captureVideo(ActionListener response)

This method tries to invoke the device native camera to capture video.
hasCamera()

Returns true if the device has camera false otherwise.

Methods inherited from class java.lang.Object


equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
Capture
public Capture()

Class Capture

2937

Overview (Codename One API)

Method Detail
hasCamera
public static boolean hasCamera()

Returns true if the device has camera false otherwise.


Returns:
true if the device has a camera
capturePhoto
public static void capturePhoto(ActionListener response)

This method tries to invoke the device native camera to capture images. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The image is saved as a jpeg to a file on the device. use this in
the actionPerformed to retrieve the file path String path = (String) evt.getSource(); if
evt returns null the image capture was cancelled by the user.
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform
capturePhoto
public static String capturePhoto()

Invokes the camera and takes a photo synchronously while blocking the EDT
Returns:
the photo file location or null if the user canceled
captureAudio
public static String captureAudio()

Same as captureAudio only a blocking version that holds the EDT


Returns:
the photo file location or null if the user canceled
captureVideo
public static String captureVideo()

Same as captureVideo only a blocking version that holds the EDT


Returns:
the photo file location or null if the user canceled
capturePhoto
public static String capturePhoto(int width,
int height)

Invokes the camera and takes a photo synchronously while blocking the EDT
Parameters:
width - the target width for the image if possible, some platforms don't
support scaling. To maintain aspect ratio set to -1
height - the target height for the image if possible, some platforms don't
support scaling. To maintain aspect ratio set to -1
Returns:
the photo file location or null if the user canceled
captureAudio
public static void captureAudio(ActionListener response)

This method tries to invoke the device native hardware to capture audio. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The audio is saved to a file on the device. use this in the
actionPerformed to retrieve the file path String path = (String) evt.getSource();
Parameters:
response - a callback Object to retrieve the file path

Method Detail

2938

Overview (Codename One API)

Throws:
RuntimeException

- if this feature failed or unsupported on the platform

captureVideo
public static void captureVideo(ActionListener response)

This method tries to invoke the device native camera to capture video. The method
returns immediately and the response will be sent asynchronously to the given
ActionListener Object The video is saved to a file on the device. use this in the
actionPerformed to retrieve the file path String path = (String) evt.getSource();
Parameters:
response - a callback Object to retrieve the file path
Throws:
RuntimeException - if this feature failed or unsupported on the platform

Method Detail

2939

Overview (Codename One API)


com.codename1.analytics

Class AnalyticsService
java.lang.Object

com.codename1.analytics.AnalyticsService

public class
extends Object

The analytics service allows an application to report its usage, it is seamlessly invoked by GUI builder
applications if analytics is enabled for your application! To enable analytics just use the init() method
of the analytics service. If you are not using the GUI builder invoke the visit method whenever you
would like to log a page view event.

Constructor Summary
Constructor and Description
AnalyticsService()

Method Summary
Modifier
and Type
static void
static void
protected
boolean
static
boolean

Method and Description


init(AnalyticsService i)

Allows installing an analytics service other than the default


init(String agent, String domain)

Initializes google analytics for this application


isAnalyticsEnabled()

Indicates if the analytics is enabled, subclasses must override this method to


process their information
isAppsMode()

Apps mode allows improved analytics using the newer google analytics API
designed for apps

static
boolean

isEnabled()

static
boolean

isFailSilently()

Indicates whether analytics is enabled for this application


Indicates whether analytics server failures should brodcast an error event
sendCrashReport(Throwable t, String message, boolean fatal)

static void

In apps mode we can send information about an exception to the analytics


server
setAppsMode(boolean aAppsMode)

static void

static void

Apps mode allows improved analytics using the newer google analytics API
designed for apps
setFailSilently(boolean aFailSilently)

Indicates whether analytics server failures should brodcast an error event


visit(String page, String referer)

static void

protected
void

Class AnalyticsService

Sends an asynchronous notice to the server regarding a page in the


application being viewed, notice that you don't need to append the URL prefix
to the page string.
visitPage(String page, String referer)

Subclasses should override this method to track page visits

2940

Overview (Codename One API)


Methods

inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
AnalyticsService
public AnalyticsService()

Method Detail
isFailSilently
public static boolean isFailSilently()

Indicates whether analytics server failures should brodcast an error event


Returns:
the failSilently
setFailSilently
public static void setFailSilently(boolean aFailSilently)

Indicates whether analytics server failures should brodcast an error event


Parameters:
aFailSilently - the failSilently to set
isAppsMode
public static boolean isAppsMode()

Apps mode allows improved analytics using the newer google analytics API designed
for apps
Returns:
the appsMode
setAppsMode
public static void setAppsMode(boolean aAppsMode)

Apps mode allows improved analytics using the newer google analytics API designed
for apps
Parameters:
aAppsMode - the appsMode to set
isEnabled
public static boolean isEnabled()

Indicates whether analytics is enabled for this application


Returns:
true if analytics is enabled
isAnalyticsEnabled
protected boolean isAnalyticsEnabled()

Indicates if the analytics is enabled, subclasses must override this method to process
their information
Returns:
true if analytics is enabled
init
public static void init(String agent,
String domain)

Initializes google analytics for this application


Parameters:

Methods inherited from class java.lang.Object

2941

Overview (Codename One API)


agent - the google analytics tracking agent
domain - a domain to represent your application,

commonly you should use


your package name as a URL (e.g. com.mycompany.myapp should become:
myapp.mycompany.com)
init
public static void init(AnalyticsService i)

Allows installing an analytics service other than the default


Parameters:
i - the analytics service implementation.
visit
public static void visit(String page,
String referer)

Sends an asynchronous notice to the server regarding a page in the application being
viewed, notice that you don't need to append the URL prefix to the page string.
Parameters:
page - the page viewed
referer - the source page
visitPage
protected void visitPage(String page,
String referer)

Subclasses should override this method to track page visits


Parameters:
page - the page visited
referer - the page from which the user came
sendCrashReport
public static void sendCrashReport(Throwable t,
String message,
boolean fatal)

In apps mode we can send information about an exception to the analytics server
Parameters:
t - the exception
message - up to 150 character message,
fatal - is the exception fatal

Method Detail

2942

Overview (Codename One API)


com.codename1.ads

Class InnerActive
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.ads.AdsService

com.codename1.ads.InnerActive
All Implemented Interfaces:
IOProgressListener

public class
extends AdsService

This is an Ad service implementation by InnerActive see:


http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Constructor and Description
InnerActive()

Empty constructor of the inner active ads service.

Method Summary
Modifier and Type

Method and Description


initService(Ads ads)

void

initialize the ads service

protected void

readResponse(InputStream input)

Callback for the server response with the input stream from the server.
setBanner(boolean banner)

void

Sets this ads type, by default this a banner type.

static void

setTestAds(boolean test)

If true and no ads exists the network will return house holds ads

Methods inherited from class com.codename1.ads.AdsService


createAdsService, getCurrentAd, handleErrorResponseCode, handleException,
handleRuntimeException, initialize, onAdDisplay, requestAd, setAdsProvider

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,

Class InnerActive

2943

Overview (Codename One API)


getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleIOException, hashCode, hasResponseListeners,
initConnection, initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,
kill, onRedirect, pause, postResponse, readErrorCodeHeaders, readHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
InnerActive
public InnerActive()

Empty constructor of the inner active ads service.

Method Detail
setBanner
public void setBanner(boolean banner)

Sets this ads type, by default this a banner type.


Parameters:
banner - sets the ads to banners or text ads
setTestAds
public static void setTestAds(boolean test)

If true and no ads exists the network will return house holds ads
Parameters:
testAds initService
public void initService(Ads ads)

initialize the ads service


Specified by:
initService in class AdsService
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class AdsService
Parameters:

Methods inherited fromclass com.codename1.io.ConnectionRequest

2944

Overview (Codename One API)


input

- the input stream containing the response

Throws:
IOException

Method Detail

- when a read input occurs

2945

Overview (Codename One API)


com.codename1.ads

Class AdsService
java.lang.Object

com.codename1.io.ConnectionRequest

com.codename1.ads.AdsService
All Implemented Interfaces:
IOProgressListener
Direct Known Subclasses:
InnerActive

public abstract class


extends ConnectionRequest

This is an abstract Ads Service. Each supported Ad network needs to extend this Service and to
implement the initService method

Field Summary

Fields inherited from


class com.codename1.io.ConnectionRequest
PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_NORMAL,
PRIORITY_REDUNDANT

Constructor Summary
Modifier Constructor and Description
protected

AdsService()

Empty constructor

Method Summary
Modifier and
Type
static
AdsService
String
protected
void
protected
void
protected
void
void
abstract void
void

Method and Description


createAdsService()

Creates a new AdsService to be used by the Ads Component


getCurrentAd()

Returns the last requested ad


handleErrorResponseCode(int code, String message)

Handles a server response code that is not 200 and not a redirect (unless
redirect handling is disabled)
handleException(Exception err)

Handles an exception thrown when performing a network operation, the


default implementation shows a retry dialog.
handleRuntimeException(RuntimeException err)

Handles an exception thrown when performing a network operation


initialize(Ads adsComponent)

Initialize the ads service.


initService(Ads adsComponent)

init the service requests.


onAdDisplay(HTMLComponent cmp)

This a callback method to inform to the service the Ad is displayed


readResponse(InputStream input)

Class AdsService

2946

Overview (Codename One API)


protected
void

Callback for the server response with the input stream from the server.
requestAd()

void

Schedule this service on the Network thread and executes the request

static void

setAdsProvider(Class provider)

Sets the provider of the ads service.

Methods inherited from


class com.codename1.io.ConnectionRequest
addArgument, addArgument, addArgument, addArgumentNoEncoding, addArguments,
addRequestHeader, addResponseCodeListener, addResponseListener,
buildRequestBody, cookieReceived, cookieSent, createRequestURL, equals,
fetchJSON, fireResponseListener, getContentLength, getContentType,
getCookieHeader, getDefaultUserAgent, getDestinationFile,
getDestinationStorage, getDisposeOnCompletion, getHeader,
getHeaderFieldNames, getHeaders, getHttpMethod, getPriority,
getResponseCode, getResponseContentType, getResponseData, getResposeCode,
getShowOnInit, getSilentRetryCount, getTimeout, getUrl, getUserAgent,
getYield, handleIOException, hashCode, hasResponseListeners,
initConnection, initCookieHeader, ioStreamUpdate, isCookiesEnabled,
isCookiesEnabledDefault, isDefaultFollowRedirects, isDuplicateSupported,
isFailSilently, isFollowRedirects, isKilled, isPausable, isPaused, isPost,
isReadRequest, isReadResponseForErrors, isRedirecting, isWriteRequest,
kill, onRedirect, pause, postResponse, readErrorCodeHeaders, readHeaders,
removeAllArguments, removeArgument, removeResponseCodeListener,
removeResponseListener, resume, retry, setChunkedStreamingMode,
setContentType, setCookieHeader, setCookiesEnabled,
setCookiesEnabledDefault, setDefaultFollowRedirects, setDefaultUserAgent,
setDestinationFile, setDestinationStorage, setDisposeOnCompletion,
setDuplicateSupported, setFailSilently, setFollowRedirects, setHttpMethod,
setKilled, setPaused, setPost, setPriority, setReadRequest,
setReadResponseForErrors, setShowOnInit, setSilentRetryCount, setTimeout,
setUrl, setUseNativeCookieStore, setUserAgent, setWriteRequest,
shouldAutoCloseResponse, shouldConvertPostToGetOnRedirect, shouldStop,
shouldWriteUTFAsGetBytes, validate

Methods inherited from class java.lang.Object


getClass, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
AdsService
protected AdsService()

Empty constructor

Method Detail
initialize
public void initialize(Ads adsComponent)

Initialize the ads service.


initService
public abstract void initService(Ads adsComponent)

init the service requests.


createAdsService
public static AdsService createAdsService()

Creates a new AdsService to be used by the Ads Component

Method Summary

2947

Overview (Codename One API)


setAdsProvider
public static void setAdsProvider(Class provider)

Sets the provider of the ads service.


Parameters:
provider - this class needs to extend the AdsService class
getCurrentAd
public String getCurrentAd()

Returns the last requested ad


requestAd
public void requestAd()

Schedule this service on the Network thread and executes the request
readResponse
protected void readResponse(InputStream input)
throws IOException

Callback for the server response with the input stream from the server. This method
is invoked on the network thread
Overrides:
readResponse in class ConnectionRequest
Parameters:
input - the input stream containing the response
Throws:
IOException - when a read input occurs
onAdDisplay
public void onAdDisplay(HTMLComponent cmp)

This a callback method to inform to the service the Ad is displayed


Parameters:
cmp handleErrorResponseCode
protected void handleErrorResponseCode(int code,
String message)

Handles a server response code that is not 200 and not a redirect (unless redirect
handling is disabled)
Overrides:
handleErrorResponseCode in class ConnectionRequest
Parameters:
code - the response code from the server
message - the response message from the server
handleRuntimeException
protected void handleRuntimeException(RuntimeException err)

Handles an exception thrown when performing a network operation


Overrides:
handleRuntimeException in class ConnectionRequest
Parameters:
err - the exception thrown
handleException
protected void handleException(Exception err)

Handles an exception thrown when performing a network operation, the default


implementation shows a retry dialog.
Overrides:
handleException in class ConnectionRequest
Parameters:

Method Detail

2948

Overview (Codename One API)


err

Method Detail

- the exception thrown

2949

Overview (Codename One API)

All Classes
AbstractChart
AbstractCollection
AbstractLayer
AbstractList
AbstractMap
AbstractMap.SimpleEntry
AbstractMap.SimpleImmutableEntry
AbstractQueue
AbstractSequentialList
AbstractSet
AbstractTest
AC
AccessToken
ActionEvent
ActionEvent.Type
ActionListener
Address
Adler32
Ads
AdsService
Album
AnalyticsService
Animation
AnimationManager
AnimationObject
Annotation
AnnotationFormatError
Appendable
ArithmeticException
ArrayDeque
ArrayIndexOutOfBoundsException
ArrayList
Arrays
ArrayStoreException
ArrowLinesLayer
AssertionError
AsyncDocumentRequestHandler
AsyncDocumentRequestHandlerImpl
AutoCloseable
AutoCompleteTextField
BackgroundPainter
BarChart
BarChart.Type
Base64
BaseSpinner
BasicStroke
BigDecimal
BigInteger
BindTarget
BitSet
Boolean
Border
BorderLayout
BoundingBox
BoundSize
BoxLayout
BrowserComponent
BrowserNavigationCallback
BubbleChart
BufferedInputStream
BufferedOutputStream
Button
ButtonGroup

All Classes

2950

Overview (Codename One API)


Byte
ByteArrayInputStream
ByteArrayOutputStream
CachedData
CachedDataService
CacheMap
Calendar
Calendar
Callback
CallSite
Capture
CaseInsensitiveOrder
CategorySeries
CC
CellRenderer
Character
CharacterArrayCharacterIterator
CharacterIterator
CharArrayReader
CharSequence
ChartComponent
ChartUtil
CheckBox
Class
ClassCastException
ClassNotFoundException
ClickableArea
Cloneable
CloneNotSupportedException
CloudException
CloudImageProperty
CloudListModel
CloudObject
CloudPersona
CloudResponse
CloudStorage
CodeScanner
Collection
Collections
ColorUtil
CombinedXYChart
CombinedXYChart.XYCombinedChartDef
ComboBox
Command
CommonTransitions
Comparable
Comparator
Component
ComponentAnimation
ComponentGroup
ComponentWrapper
ConcurrentModificationException
ConnectionRequest
Constraint
ConstraintParser
Contact
ContactsManager
ContactsModel
Container
ContainerList
ContainerWrapper
Cookie
Coord
CoordinateLayout
CrashReport
CRC32

All Classes

2951

Overview (Codename One API)


CStringBuilder
CSVParser
CubicLineChart
Cursor
CustomProperty
Database
DataChangedListener
DataInput
DataInputStream
DataOutput
DataOutputStream
Date
DateFormat
DateFormat
DateFormatPatterns
DateFormatPatterns
DateFormatSymbols
DateFormatSymbols
DateSpinner
DateTimeSpinner
DefaultCrashReporter
DefaultDocumentRequestHandler
DefaultHTMLCallback
DefaultListCellRenderer
DefaultListModel
DefaultLookAndFeel
DefaultRenderer
DefaultTableModel
Deflate
Deflater
DeflaterOutputStream
Deprecated
Deque
DeviceRunner
DialChart
Dialog
DialRenderer
DialRenderer.Type
Dictionary
DimConstraint
Dimension
Dimension2D
Display
Documented
DocumentInfo
DocumentRequestHandler
Double
DoughnutChart
Effects
Element
ElementType
EmailShare
EmbeddedContainer
EmptyStackException
EncodedImage
Enum
Enumeration
EOFException
Error
EventDispatcher
EventListener
EventListenerProxy
Exception
Externalizable
FaceBookAccess
FacebookConnect

All Classes

2952

Overview (Codename One API)


FacebookShare
FBObject
FileEncodedImage
FileEncodedImageAsync
FileSystemStorage
FileTree
FileTreeModel
FilterInputStream
FilterOutputStream
FilterProxyListModel
FlipTransition
Float
FloatingHint
FlowLayout
Flushable
FocusListener
Font
FontImage
Form
Format
Format
GeneralPath
GenericListCellRenderer
GenericSpinner
Geofence
GeofenceListener
GlassTutorial
GoogleConnect
GoogleMapsProvider
Graphics
Grid
GridBagConstraints
GridBagLayout
GridLayout
GroupConstraint
GroupLayout
GZConnectionRequest
GZIPException
GZIPHeader
GZIPInputStream
GZIPOutputStream
HashMap
HashSet
Hashtable
HTMLCallback
HTMLComponent
HTMLElement
HTMLParser
HTMLUtils
IdentityHashMap
IllegalAccessException
IllegalArgumentException
IllegalMonitorStateException
IllegalStateException
IllegalThreadStateException
Image
ImageDownloadService
ImageIO
ImageViewer
InCellGapProvider
IncompatibleClassChangeError
IncompleteAnnotationException
IndexOutOfBoundsException
InfiniteContainer
InfiniteProgress
InfiniteScrollAdapter

All Classes

2953

Overview (Codename One API)


Inflater
InflaterInputStream
Inherited
InnerActive
InputStream
InputStreamReader
Insets
InstantiationException
Integer
InteractionDialog
InterruptedException
InterruptedIOException
IOCallback
IOException
IOProgressListener
Iterable
Iterator
JavascriptContext
JSFunction
JSObject
JSONParseCallback
JSONParser
JUnitXMLReporting
JZlib
L10NManager
Label
LambdaMetafactory
Layer
LayeredLayout
Layout
LayoutCallback
LayoutStyle
LayoutUtil
LazyValue
LC
LengthConstraint
LikeButton
LineChart
LinesLayer
LinkageError
LinkedHashMap
LinkedHashSet
LinkedList
LinkHandler
List
List
ListCellRenderer
ListIterator
ListModel
LocalNotification
LocalNotificationCallback
Location
LocationListener
LocationManager
LocationRequest
Log
Login
LoginCallback
Long
LookAndFeel
Map
Map.Entry
MapComponent
MapListener
MapProvider
MasterDetail

All Classes

2954

Overview (Codename One API)


Math
MathHelper
MathUtil
Media
MediaManager
MediaPlayer
MenuBar
Mercator
Message
MethodHandle
MethodHandles
MethodHandles.Lookup
MethodType
MigLayout
MorphTransition
Motion
MultiButton
MultiList
MultipartRequest
MultipleCategorySeries
NativeInterface
NativeLookup
NavigableMap
NavigableSet
NavigationCommand
NegativeArraySizeException
NetworkEvent
NetworkManager
NoClassDefFoundError
NoSuchElementException
NoSuchFieldError
NullPointerException
NumberFormat
NumberFormatException
NumericSpinner
Oauth2
Object
Observable
Observer
Octal
OnOffSwitch
OpenStreetMapProvider
OutOfMemoryError
OutputStream
OutputStreamWriter
Override
Page
Painter
PainterChain
ParseException
ParseException
ParserCallback
PathIterator
PeerComponent
Photo
Picker
PieChart
PieMapper
PieSegment
PlatformDefaults
Point
Point
Point2D
PointLayer
PointsLayer
PointStyle

All Classes

2955

Overview (Codename One API)


Post
Preferences
PrintStream
PriorityQueue
Product
Progress
Projection
Properties
ProxyHttpTile
Purchase
PurchaseCallback
Push
PushCallback
Queue
RadioButton
Random
RandomAccess
RangeBarChart
RangeCategorySeries
RangeStackedBarChart
RE
Reader
ReaderCharacterIterator
RECharacter
RECompiler
Rectangle
Rectangle2D
REDebugCompiler
Reference
RegexConstraint
ReplaceableImage
REProgram
Resources
RestoreCallback
Result
RESyntaxException
Retention
RetentionPolicy
REUtil
RGBImage
RoundChart
Row
RSSReader
RSSService
Runnable
Runtime
RuntimeException
ScaleImageButton
ScaleImageLabel
ScanResult
ScatterChart
ScrollListener
SecurityException
SelectionListener
Serializable
SeriesSelection
SeriesTransition
Set
Shape
ShareButton
ShareService
Short
SideMenuBar
SimpleDateFormat
SimpleDateFormat
SimpleSeriesRenderer

All Classes

2956

Overview (Codename One API)


Slider
SliderBridge
SMSShare
Socket
Socket.StopListening
SocketConnection
SortedMap
SortedSet
SpanButton
SpanLabel
Stack
Storage
StorageImage
StorageImageAsync
StreamCharacterIterator
String
StringBuffer
StringBuilder
StringCharacterIterator
StringIndexOutOfBoundsException
StringReader
StringTokenizer
StringUtil
Stroke
Style
StyleListener
SuppressWarnings
SwipeableContainer
SwipeBackSupport
System
Table
TableLayout
TableLayout.Constraint
TableModel
Tabs
TarConstants
TarEntry
Target
TarHeader
TarInputStream
TarOutputStream
TarUtils
TestReporting
TestUtils
TextArea
TextField
Thread
Throwable
Tile
TiledProvider
TimeChart
Timeline
Timer
TimerTask
TimeSeries
TimeSpinner
TimeZone
ToastBar
Toolbar
Transform
Transition
Tree
TreeMap
TreeModel
TreeSet
TwitterRESTService

All Classes

2957

Overview (Codename One API)


UIBuilder
UIManager
UITimer
UnitConverter
UnitTest
UnitValue
UnsupportedEncodingException
URI
URISyntaxException
URLCallback
URLImage
URLImage.ImageAdapter
User
UTFDataFormatException
Util
Validator
Validator.HighlightMode
Vector
VirtualKeyboard
VirtualMachineError
Void
WeakHashMap
WeakReference
WebBrowser
WebServiceProxyCall
WebServiceProxyCall.WSDefinition
Writer
XMLParser
XMLWriter
XYChart
XYMultipleSeriesDataset
XYMultipleSeriesRenderer
XYMultipleSeriesRenderer.Orientation
XYMultiSeriesTransition
XYSeries
XYSeriesRenderer
XYSeriesRenderer.FillOutsideLine
XYSeriesRenderer.FillOutsideLine.Type
XYSeriesTransition
XYValueSeries
XYValueSeriesTransition
ZStream

All Classes

2958

Overview (Codename One API)

All Classes
AbstractChart
AbstractCollection
AbstractLayer
AbstractList
AbstractMap
AbstractMap.SimpleEntry
AbstractMap.SimpleImmutableEntry
AbstractQueue
AbstractSequentialList
AbstractSet
AbstractTest
AC
AccessToken
ActionEvent
ActionEvent.Type
ActionListener
Address
Adler32
Ads
AdsService
Album
AnalyticsService
Animation
AnimationManager
AnimationObject
Annotation
AnnotationFormatError
Appendable
ArithmeticException
ArrayDeque
ArrayIndexOutOfBoundsException
ArrayList
Arrays
ArrayStoreException
ArrowLinesLayer
AssertionError
AsyncDocumentRequestHandler
AsyncDocumentRequestHandlerImpl
AutoCloseable
AutoCompleteTextField
BackgroundPainter
BarChart
BarChart.Type
Base64
BaseSpinner
BasicStroke
BigDecimal
BigInteger
BindTarget
BitSet
Boolean
Border
BorderLayout
BoundingBox
BoundSize
BoxLayout
BrowserComponent
BrowserNavigationCallback
BubbleChart
BufferedInputStream
BufferedOutputStream
Button
ButtonGroup

All Classes

2959

Overview (Codename One API)


Byte
ByteArrayInputStream
ByteArrayOutputStream
CachedData
CachedDataService
CacheMap
Calendar
Calendar
Callback
CallSite
Capture
CaseInsensitiveOrder
CategorySeries
CC
CellRenderer
Character
CharacterArrayCharacterIterator
CharacterIterator
CharArrayReader
CharSequence
ChartComponent
ChartUtil
CheckBox
Class
ClassCastException
ClassNotFoundException
ClickableArea
Cloneable
CloneNotSupportedException
CloudException
CloudImageProperty
CloudListModel
CloudObject
CloudPersona
CloudResponse
CloudStorage
CodeScanner
Collection
Collections
ColorUtil
CombinedXYChart
CombinedXYChart.XYCombinedChartDef
ComboBox
Command
CommonTransitions
Comparable
Comparator
Component
ComponentAnimation
ComponentGroup
ComponentWrapper
ConcurrentModificationException
ConnectionRequest
Constraint
ConstraintParser
Contact
ContactsManager
ContactsModel
Container
ContainerList
ContainerWrapper
Cookie
Coord
CoordinateLayout
CrashReport
CRC32

All Classes

2960

Overview (Codename One API)


CStringBuilder
CSVParser
CubicLineChart
Cursor
CustomProperty
Database
DataChangedListener
DataInput
DataInputStream
DataOutput
DataOutputStream
Date
DateFormat
DateFormat
DateFormatPatterns
DateFormatPatterns
DateFormatSymbols
DateFormatSymbols
DateSpinner
DateTimeSpinner
DefaultCrashReporter
DefaultDocumentRequestHandler
DefaultHTMLCallback
DefaultListCellRenderer
DefaultListModel
DefaultLookAndFeel
DefaultRenderer
DefaultTableModel
Deflate
Deflater
DeflaterOutputStream
Deprecated
Deque
DeviceRunner
DialChart
Dialog
DialRenderer
DialRenderer.Type
Dictionary
DimConstraint
Dimension
Dimension2D
Display
Documented
DocumentInfo
DocumentRequestHandler
Double
DoughnutChart
Effects
Element
ElementType
EmailShare
EmbeddedContainer
EmptyStackException
EncodedImage
Enum
Enumeration
EOFException
Error
EventDispatcher
EventListener
EventListenerProxy
Exception
Externalizable
FaceBookAccess
FacebookConnect

All Classes

2961

Overview (Codename One API)


FacebookShare
FBObject
FileEncodedImage
FileEncodedImageAsync
FileSystemStorage
FileTree
FileTreeModel
FilterInputStream
FilterOutputStream
FilterProxyListModel
FlipTransition
Float
FloatingHint
FlowLayout
Flushable
FocusListener
Font
FontImage
Form
Format
Format
GeneralPath
GenericListCellRenderer
GenericSpinner
Geofence
GeofenceListener
GlassTutorial
GoogleConnect
GoogleMapsProvider
Graphics
Grid
GridBagConstraints
GridBagLayout
GridLayout
GroupConstraint
GroupLayout
GZConnectionRequest
GZIPException
GZIPHeader
GZIPInputStream
GZIPOutputStream
HashMap
HashSet
Hashtable
HTMLCallback
HTMLComponent
HTMLElement
HTMLParser
HTMLUtils
IdentityHashMap
IllegalAccessException
IllegalArgumentException
IllegalMonitorStateException
IllegalStateException
IllegalThreadStateException
Image
ImageDownloadService
ImageIO
ImageViewer
InCellGapProvider
IncompatibleClassChangeError
IncompleteAnnotationException
IndexOutOfBoundsException
InfiniteContainer
InfiniteProgress
InfiniteScrollAdapter

All Classes

2962

Overview (Codename One API)


Inflater
InflaterInputStream
Inherited
InnerActive
InputStream
InputStreamReader
Insets
InstantiationException
Integer
InteractionDialog
InterruptedException
InterruptedIOException
IOCallback
IOException
IOProgressListener
Iterable
Iterator
JavascriptContext
JSFunction
JSObject
JSONParseCallback
JSONParser
JUnitXMLReporting
JZlib
L10NManager
Label
LambdaMetafactory
Layer
LayeredLayout
Layout
LayoutCallback
LayoutStyle
LayoutUtil
LazyValue
LC
LengthConstraint
LikeButton
LineChart
LinesLayer
LinkageError
LinkedHashMap
LinkedHashSet
LinkedList
LinkHandler
List
List
ListCellRenderer
ListIterator
ListModel
LocalNotification
LocalNotificationCallback
Location
LocationListener
LocationManager
LocationRequest
Log
Login
LoginCallback
Long
LookAndFeel
Map
Map.Entry
MapComponent
MapListener
MapProvider
MasterDetail

All Classes

2963

Overview (Codename One API)


Math
MathHelper
MathUtil
Media
MediaManager
MediaPlayer
MenuBar
Mercator
Message
MethodHandle
MethodHandles
MethodHandles.Lookup
MethodType
MigLayout
MorphTransition
Motion
MultiButton
MultiList
MultipartRequest
MultipleCategorySeries
NativeInterface
NativeLookup
NavigableMap
NavigableSet
NavigationCommand
NegativeArraySizeException
NetworkEvent
NetworkManager
NoClassDefFoundError
NoSuchElementException
NoSuchFieldError
NullPointerException
NumberFormat
NumberFormatException
NumericSpinner
Oauth2
Object
Observable
Observer
Octal
OnOffSwitch
OpenStreetMapProvider
OutOfMemoryError
OutputStream
OutputStreamWriter
Override
Page
Painter
PainterChain
ParseException
ParseException
ParserCallback
PathIterator
PeerComponent
Photo
Picker
PieChart
PieMapper
PieSegment
PlatformDefaults
Point
Point
Point2D
PointLayer
PointsLayer
PointStyle

All Classes

2964

Overview (Codename One API)


Post
Preferences
PrintStream
PriorityQueue
Product
Progress
Projection
Properties
ProxyHttpTile
Purchase
PurchaseCallback
Push
PushCallback
Queue
RadioButton
Random
RandomAccess
RangeBarChart
RangeCategorySeries
RangeStackedBarChart
RE
Reader
ReaderCharacterIterator
RECharacter
RECompiler
Rectangle
Rectangle2D
REDebugCompiler
Reference
RegexConstraint
ReplaceableImage
REProgram
Resources
RestoreCallback
Result
RESyntaxException
Retention
RetentionPolicy
REUtil
RGBImage
RoundChart
Row
RSSReader
RSSService
Runnable
Runtime
RuntimeException
ScaleImageButton
ScaleImageLabel
ScanResult
ScatterChart
ScrollListener
SecurityException
SelectionListener
Serializable
SeriesSelection
SeriesTransition
Set
Shape
ShareButton
ShareService
Short
SideMenuBar
SimpleDateFormat
SimpleDateFormat
SimpleSeriesRenderer

All Classes

2965

Overview (Codename One API)


Slider
SliderBridge
SMSShare
Socket
Socket.StopListening
SocketConnection
SortedMap
SortedSet
SpanButton
SpanLabel
Stack
Storage
StorageImage
StorageImageAsync
StreamCharacterIterator
String
StringBuffer
StringBuilder
StringCharacterIterator
StringIndexOutOfBoundsException
StringReader
StringTokenizer
StringUtil
Stroke
Style
StyleListener
SuppressWarnings
SwipeableContainer
SwipeBackSupport
System
Table
TableLayout
TableLayout.Constraint
TableModel
Tabs
TarConstants
TarEntry
Target
TarHeader
TarInputStream
TarOutputStream
TarUtils
TestReporting
TestUtils
TextArea
TextField
Thread
Throwable
Tile
TiledProvider
TimeChart
Timeline
Timer
TimerTask
TimeSeries
TimeSpinner
TimeZone
ToastBar
Toolbar
Transform
Transition
Tree
TreeMap
TreeModel
TreeSet
TwitterRESTService

All Classes

2966

Overview (Codename One API)


UIBuilder
UIManager
UITimer
UnitConverter
UnitTest
UnitValue
UnsupportedEncodingException
URI
URISyntaxException
URLCallback
URLImage
URLImage.ImageAdapter
User
UTFDataFormatException
Util
Validator
Validator.HighlightMode
Vector
VirtualKeyboard
VirtualMachineError
Void
WeakHashMap
WeakReference
WebBrowser
WebServiceProxyCall
WebServiceProxyCall.WSDefinition
Writer
XMLParser
XMLWriter
XYChart
XYMultipleSeriesDataset
XYMultipleSeriesRenderer
XYMultipleSeriesRenderer.Orientation
XYMultiSeriesTransition
XYSeries
XYSeriesRenderer
XYSeriesRenderer.FillOutsideLine
XYSeriesRenderer.FillOutsideLine.Type
XYSeriesTransition
XYValueSeries
XYValueSeriesTransition
ZStream

All Classes

2967

Vous aimerez peut-être aussi