How place the components the front of another one?
-
14-04-2021 - |
Frage
I want to place the components A and B over component with List. I need that would text of list will be to visible. I can not find which layout can do it. How this behavior is in lwuit? What solutions exist?
Lösung
The question is somewhat unclear, jmunoz answer is correct if you want component's A and B to reside at the bottom of the screen and the list to scroll above. However from the drawing it seems you want an "always on top" effect which you can achieve either via a glass pane (for non-interactive components) or via the LayeredLayout
class.
This is actually quite simple using the following:
myForm.setLayout(new LayeredLayout());
myForm.setScrollable(false);
// will occupy the entire area of the form but should be scrollable
myForm.addComponent(componentUnderneath);
Container south = new Container(new BorderLayout());
myForm.addComponent(south);
south.addComponent(BorderLayout.SOUTH, whateverYouWantToPlaceOnTopInTheSouth);
Andere Tipps
You must do the following:
The Form
must not do scroll. Use Form.setScrollable(false)
. Set the layout of the ´Form´ to BORDER_LAYOUT
, myForm.setLayout(new BorderLayout())
. Ok in BorderLayout
you can put the components in the Form
as you want.
Put the List
component in the center of the BorderLayout
with myForm.addComponent(BorderLayout.CENTER, List)
and the other two elements in the south of the layout using
Container southContainer = new Container();
southContainer.addComponent(A);
southContainer.addComponent(B);
myForm.addComponent(BorderLayout.SOUTH, southContainer)
With this you can get a scrollable List
and two elements always visible.