StringItem sample program in J2ME
By: Kamini
The StringItem class defines a two-part display component. StringItem objects contain a label and some immutable text. The sample J2ME program shows the pertinent parts of the StringItemDemo code. You can correlate the text in the constructor's two argument parameters with the text on the display. This is a very simple UI component.StringItem objects give you a convenient way to associate a label with a value. You can put a String in a Form instead of using a StringItem object, but the StringItem has the advantage that its implementation ensures that the label and value strings remain together on the display.
String items are forms.
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
/**
This class demonstrates use of the StringItem MIDP UI
class.
@see javax.microedition.lcdui.StringItem
*/
public class StringItemDemo extends Form
implements CommandListener
{
private Command back =
new Command("Back", Command.BACK, 1);
private static Displayable instance;
private StringItem si =
new StringItem("StringItem's title",
"Immutable item text");
/**
Constructor.
*/
public StringItemDemo()
{
super("StringItem Demo");
append(si);
addCommand(back);
setCommandListener(this);
instance = this;
}
...
}
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Code sample to Send SMS from a J2ME application.
Adding your own Application icon for your J2ME application (jar file)
Play a multimedia file in J2ME Program (Audio/Video) using MMAPI
Using HttpConnection in J2ME (Retrieve web content from a website to a phone)
Using HTTP vs UDP vs Socket in J2ME
RMSCookieConnector - Using Cookies in J2ME
Client Server in J2ME (Socket Programming sample)
Datagrams in J2ME (UDP Programming sample)
POST UTF-8 encoded data to the server in J2ME
Using alerts and tickers in J2ME
Using List to create a Menu and Menu items in J2ME
lists, forms, choices, gauges, text fields, text boxes in J2ME
Timer and TimerTask example in J2ME