blue-sky
blue-sky

Reputation: 53916

Aligning buttons on a screen

I would like to layout two buttons side by side and have multiple rows of these buttons like so -

B1 B2
B1 B2
B1 B2

For this do I need to combine VerticalFieldManager and HorizontalFieldManager somehow ?

Thanks

Upvotes: 0

Views: 330

Answers (2)

Adil Soomro
Adil Soomro

Reputation: 37729

Here is a TableLayoutManager class to support such type of layouts. TableLayoutManager.java You can download and copy it in your porject and use it. Use TableLayoutManager like this.

TableLayoutManager btnManager= new TableLayoutManager(new int[ {TableLayoutManager.USE_PREFERRED_SIZE, TableLayoutManager.USE_PREFERRED_SIZE},Manager.FIELD_HCENTER);
btnManager.add(B1);
btnManager.add(B2);
btnManager.add(B1);
btnManager.add(B2);

you can even define your number of columns and there layout styles.

Upvotes: 0

Dale Campbell
Dale Campbell

Reputation: 496

If you're using JDK 5.0 or greater, there's GridFieldManager. If you're using anything below 5.0, you'll have to use nested Vertical/Horizontal field managers.

Upvotes: 2

Related Questions