我正在尝试在容器中添加布局。它将占用我的表单的总宽度,要求是在特定坐标中显示容器,
FlowLayout flowContainer = new FlowLayout(TextArea.CENTER);
workersListForm = new Form("test", flowContainer);
Container container = new Container(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
CommonComponentsForm commonComponentsForm = new CommonComponentsForm();
Container headerContainer = commonComponentsForm.getHeader();
Container bodyContainer = new Container(new FlowLayout());
Container tableBodyContainer = this.getWorkerTableBody();
Container filterContainer = this.getFilterBody();
bodyContainer.add(filterContainer);
bodyContainer.add(tableBodyContainer);
Container footerContainer = commonComponentsForm.getFooterData();
container.add(BorderLayout.NORTH, headerContainer);
container.add(BorderLayout.CENTER, bodyContainer);
container.add(BorderLayout.SOUTH, footerContainer);
workersListForm.setUIID("workersListForm");
workersListForm.addComponent(container);
workersListForm.show();
我的要求是在中心显示总布局,而不使用填充布局,因为我想在横向模式下显示布局中心并在纵向模式下显示总屏幕,如下图所示:
答案 0 :(得分:1)
您好看看本节
http://www.codenameone.com/how-do-i---positioning-components-using-layout-managers.html
并显示某些特定的坐标
http://codenameone.blogspot.co.nz/2009/10/coordinating-that-layout.html
通常将组件设置在中心我执行如下操作:
Layout1 (LayoutType: border_layout)
|
|-- Layout2 (LayoutType: box_layout_Y and set it in center of Layout1)
|
|--Layout3 (LayoutType: box_ly_X or FlowLayout with setAlign CENTER)
| (this is first row of components)
|
|--Layout4 (LayoutType: box_ly_X or FlowLayout with setAlign CENTER)
| (this is second row of components)
干杯。