2011-11-18 61 views

回答

1

有配发的方式LWUIT做的一切。它从你的图像中不清楚你的确切约束是什么,我猜你想让最左边的按钮左对齐,最右边的对齐。您可能还希望其他两个按钮居中。

我会实现这个使用嵌套FlowLayout元素的GridLayout。因此:

Container c = new Container(new GridLayout(1, 4)); 
addButton(c, new Button("b1"), Component.LEFT); 
addButton(c, new Button("b2"), Component.CENTER); 
addButton(c, new Button("b3"), Component.CENTER); 
addButton(c, new Button("b4"), Component.RIGHT); 


private void addButton(Container c, Button b, int align) { 
    Container flow = new Container(new FlowLayout(align)); 
    flow.addComponent(b); 
    c.addComponent(flow); 
} 
0

播放前三纽扣。设置值x,使按钮在行中被等分:you must take into account the preferredWidth of the Buttons for that。对于第一个按钮,将其空白左边设置为0(setMargin(Component.LEFT,0)),对于最后一个按钮将其右边距设置为0(setMargin(Component.RIGHT,0))。

0

你应该使用使用BorderLayout并添加容器(描述in this answer南里)

相关问题