Layout in J2ME, MIDP 2.0

Discussion in 'Java' started by Franz, Feb 5, 2007.

  1. Franz

    Franz Guest

    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---
    Franz, Feb 5, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vagif Abilov
    Replies:
    12
    Views:
    19,387
    ZMMmike
    Aug 21, 2006
  2. nishadixit
    Replies:
    5
    Views:
    1,229
    Joe Discar
    Jun 1, 2005
  3. Fahad
    Replies:
    1
    Views:
    572
    Andrew Thompson
    Aug 8, 2005
  4. Roy D
    Replies:
    1
    Views:
    845
    Darryl L. Pierce
    May 15, 2006
  5. Replies:
    1
    Views:
    553
    John Timney \(MVP\)
    Jun 19, 2006
Loading...

Share This Page