1

how to put 4 button in row, as in the picture:

enter image description here

The distance between the elements should be changed at different resolutions

Tim
  • 1,606
  • 2
  • 20
  • 32
  • I am not sure if it possible or not. However I have used three button at a same time in my mobile application using .css style as Left Button, Middle Button & Right Button. – Lucifer Nov 18 '11 at 10:55

3 Answers3

1

There are allot of ways to do everything in LWUIT. Its unclear from your image what your exact constraints are, I'm guessing you want the left most button to be left aligned and the right most to be right aligned. You probably also want the two other buttons to be centered.

I would implement this using a GridLayout with nested FlowLayout elements. As such:

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);
}
Shai Almog
  • 51,749
  • 5
  • 35
  • 65
0

Play with setMargin(Component.RIGHT,x) for the first three Buttons. Set the value of x such that the Buttons are equi-partitioned in the row : you must take into account the preferredWidth of the Buttons for that. For the first Button set its margin-left to 0 ( setMargin(Component.LEFT,0) ) , and for the last Button set its right-margin to 0 ( setMargin(Component.RIGHT,0) ).

pheromix
  • 18,213
  • 29
  • 88
  • 158
0

You should use use BorderLayout and add the container (described in this answer inside south)

Community
  • 1
  • 1
OSH
  • 2,847
  • 3
  • 25
  • 46