|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.lcdui.Displayable javax.microedition.lcdui.Screen javax.microedition.lcdui.Form ch.aplu.gidlet.MForm
public class MForm
Form display with simple input and output items.
A soft button 'Exit' is shown. Hitting the corresponding key will
call the Gidlet's doExit(). If you do not need this button,
invoke removeExitButton().
If you implement your own CommandListener and call setCommandListener(), the internal
CommandListener is disabled.
main() serves as entry point for the user programm. It is called in the run-method
of a separate thread and should terminate to avoid non-terminated threads.
Creation may take place within main() or while declaring instance variable of
the application program.
If you register your own ItemStateListener, you will loose the internal one,
which is used to verify integer and double values entered with addInputField().
If you want to maintain this feature you must call the
MForm.itemStateListener() in your own itemStateListener.
Example:
import ch.aplu.gidlet.*;
import javax.microedition.lcdui.*;
public class SimpleFormGidlet extends Gidlet
{
private TextField tf1;
private TextField tf2;
private StringItem it;
private MForm form = new MForm("MForm example");
public void main()
{
tf1 = form.addInputField("Your first name:", "");
tf2 = form.addInputField("Your family name:", "");
it = form.addOutputField();
form.addOkButton();
form.show();
}
public void doOk()
{
String val1 = form.getText(tf1);
String val2 = form.getText(tf2);
it.setText("Hello,\n" + val1 + " " + val2);
}
}
Constructor Summary | |
---|---|
MForm()
Constructs a MForm with no title. |
|
MForm(java.lang.String title)
Constructs a MForm with given title. |
Method Summary | |
---|---|
javax.microedition.lcdui.TextField |
addInputField(java.lang.String prompt,
java.lang.String init)
Adds a input text field to the MForm with given prompt, given initial value with no validation. |
javax.microedition.lcdui.TextField |
addInputField(java.lang.String prompt,
java.lang.String init,
int validation)
Adds a input text field to the MForm with given prompt, given initial value and given validation type. |
void |
addOkButton()
Adds an OK soft button with label "OK". |
void |
addOkButton(java.lang.String label)
Adds an OK soft button with given label. |
javax.microedition.lcdui.StringItem |
addOutputField()
Adds a empty output text field to the MForm. |
java.lang.String |
getText(javax.microedition.lcdui.Item item)
Returns current text from the given TextField or StringItem, null if not one of these. |
void |
itemStateChanged(javax.microedition.lcdui.Item item)
Calls the internal ItemStateListener which is used to verify integer and double values entered with addInputField(). |
void |
removeExitButton()
Removes Exit soft button. |
void |
removeOkButton()
Removes Ok soft button. |
void |
setText(javax.microedition.lcdui.Item item,
java.lang.String text)
Writes given text to the given Item (must be a StringItem). |
void |
setText(javax.microedition.lcdui.StringItem item,
java.lang.String text)
Writes given text to the given StringItem (subclass of Item). |
void |
show()
Shows the form display if it is not yet visible or it was previously hidden by another display. |
void |
show(boolean wait)
Shows the form display if it is not yet visible or it was previously hidden by another display. |
Methods inherited from class javax.microedition.lcdui.Form |
---|
append, append, append, delete, deleteAll, get, getHeight, getWidth, insert, set, setItemStateListener, size |
Methods inherited from class javax.microedition.lcdui.Displayable |
---|
addCommand, getTicker, getTitle, isShown, removeCommand, setCommandListener, setTicker, setTitle, sizeChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MForm(java.lang.String title)
public MForm()
Method Detail |
---|
public void show()
public void show(boolean wait)
public javax.microedition.lcdui.TextField addInputField(java.lang.String prompt, java.lang.String init, int validation)
Gidlet
public javax.microedition.lcdui.TextField addInputField(java.lang.String prompt, java.lang.String init)
public javax.microedition.lcdui.StringItem addOutputField()
public java.lang.String getText(javax.microedition.lcdui.Item item)
public void setText(javax.microedition.lcdui.StringItem item, java.lang.String text)
public void setText(javax.microedition.lcdui.Item item, java.lang.String text)
public void itemStateChanged(javax.microedition.lcdui.Item item)
public void addOkButton()
public void addOkButton(java.lang.String label)
public void removeExitButton()
public void removeOkButton()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |