StringItem
is an item that can contain
static text, hyperlinks and buttons. A StringItem
is always non-editable, although both the label and the textual
content of a StringItem
may be modified by the
application. The font of the label text can not be set.
The intended behavior is defined by setting the appearance mode
to be one of the following: PLAIN
, HYPERLINK
, or BUTTON
.
If the StringItem
contains a long text, the
text forms a paragraph that wraps on the screen. Text wrapping in
a paragraph is based on word boundaries. A newline (/n) character
embedded in StringItem
creates a new line.
Figure: An example StringItem
Source code for the example:
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ExampleMIDlet extends MIDlet implements CommandListener{ private Display display; private Form form; private Command exit; public ExampleForm5() { form = new Form("Form example 5"); // StringItem(label, text); StringItem sItem = new StringItem("Text Example", "Hello World!"); form.append(sItem); exit = new Command("Exit", Command.EXIT, 1); form.addCommand(exit); form.setCommandListener(this); } public void startApp() { display = Display.getDisplay(this); display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(false); notifyDestroyed(); } } }
If the StringItem
is null, empty or just whitespace,
only the label is displayed.
A newline (/n
) character embedded in a StringItem
creates a new line.
If there are two consecutive StringItem
s
(SI 1 and SI 2), and SI 2 has an empty label, the text of SI 1 continues
in SI, on non-touch devices. Depending upon the Unicode character
properties of the last character of SI 1 and the first character of
SI 2 (hereafter C1 and C2 respectively) a separator may be required
between them. If both C1 and C2 are characters used in Chinese, Japanese,
Korean or Thai, no separator is required, because these languages
do not use word separators. If either C1 or C2 is any other character
(for example, Latin, Cyrillic), indicating a language that uses word
separators, a single space character is inserted between C1 and C2.
The exception to the concatenation behavior is when one or more
of the StringItem
s has got an appearance mode BUTTON
. In this circumstance concatenation will only occur
if the StringItem
(s) with appearance mode BUTTON
can fit entirely into a single row. If it/they
cannot fit completely into one row then a row break is forced before
the StringItem
and it is displayed on a new row.
On touch and type and full touch Series 40 and Nokia Asha software
platform devices, the text of SI 2 will be placed on a new line below
the text of SI 1.
ImageItem
s with appearance
mode PLAIN
are always displayed in the Form
in black text with no border surrounding them (these ImageItem
s can never be focused).
If a StringItem
with appearance mode BUTTON
can fit entirely on a single row then it will be displayed there,
if it doesn’t fit entirely on one row then a new line is forced before
and after it.
The way the actual visual behavior is selected is presented in the table below.
For more information about StringItem see: