Reputation: 1011
I configured a layout with the following result:
The Layout
of the Form
's contentpane is TableLayout
which consists of one cell. The contentpane has only one container as child for which I set the layoutConstraint with the following modified values: width = 100%, height = 100%, Align = CENTER, Vertical Align = CENTER
.
In other words, I'm centering the components of the form.
In the preview it looks as expected but not when the app runs in the simulator! Note:
I'm not modifiying any style or layout properties in my code! Thus I have no idea why it's not as intended in the simulator.
The approach from How to show two or more label at centre of the container in codenameone didn't work for me!
this is my code concerning that form:
@Override
protected void postIntroLangSelect(Form f) {
f.getTitleArea().setHidden(true);
f.revalidate();
// button configuration
Button btnDE = findButtonDE(f);
Button btnTR = findButtonTR(f);
btnDE.addActionListener((e) -> {
settings.setLocale(Lang.GERMAN);
showNextForm();
});
btnTR.addActionListener((e) -> {
settings.setLocale(Lang.TURKISH);
showNextForm();
});
}
Upvotes: 2
Views: 38
Reputation: 7483
Set your form's layout to BorderLayout
and check the Absolute Center
, then add a container on the form with its layout constraint set to Center
. Give this container a BoxLayout Y
layout and add all your other components in it.
If this approach didn't work for you, then you will have to hand-code your form and set it's Layout to new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER)
.
Upvotes: 2