Layout in J2ME, MIDP 2.0

F

Franz

Hi,
I wrote a little Midlet and want to have a StringItem and a TextField
next to each other, i.e. they should be in the same row. After
considering MID Profile I coded my Midlet as listed below.

So in my understanding they should be in the same row. The only
condition, which I cannot be sure of is "this Item has a LAYOUT_LEFT,
LAYOUT_CENTER, or LAYOUT_RIGHT directive that differs from the Form's
current alignment." (MIDP, class Form).

But how can I set the directive of a Form? Or did I misunderstand sth?
Why are the two items not in ONE row?

Thanks in advance!
Best regards, Franz


---BEGIN CODE---
public class Layout extends MIDlet implements CommandListener {
private Display display;
private Form form;
private Command EXIT;

public Layout() {
display = Display.getDisplay(this);
}

public void startApp() {
form = new Form("LayoutTest");
EXIT = new Command("Exit", Command.SCREEN, 1);

StringItem s1 = new StringItem("", "Eingabe:");
TextField tf1 = new TextField("", "", 20, TextField.ANY);
tf1.setLayout(TextField.LAYOUT_2);

form.append(s1);
form.append(tf1);
form.addCommand(EXIT);
form.setCommandListener(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();
}
}
}
---END CODE---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top