Frage

super();
this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.addComponent(new TopBar());
this.addComponent(new MyList());
this.addComponent(new BottomBar()); // must be below

I tried to use BorderLayout, but it didn't help me.

enter image description here

myList is not always occupy the all screen. But it is always located under mylist.

Sorry for simple question, I'm still beginner lwuit.

War es hilfreich?

Lösung

I think you might not be setting the layout to appropriate container, try below code see if it suits your requirement.

    Button topBar = new Button("TopBar");
    List mylist = new List(new String[]{"Item 1","Item 2","Item 3"});
    Button bottomBar = new Button("BottomBar");

    Form form = new Form();
    Container contentPane = form.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.addComponent(BorderLayout.NORTH, topBar);
    contentPane.addComponent(BorderLayout.CENTER, mylist);
    contentPane.addComponent(BorderLayout.SOUTH, bottomBar);
    contentPane.revalidate();

    form.show();

The above code you can interchangeably use it with Container.

PS: In order to run the above code make sure you set the Resources and Theme correct in your code. If you need help on this check the LWUITDemo jar file / project that is included in the downloaded LWUIT library zip file.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top