You can use several strategies but the simplest one would be to use TableLayout roughly like this:
TableLayout tl = new TableLayout(NUMBER_OF_BUTTONS, 1); Container f1 = new Container(tl); f1.add(tl.cc().ha(CENTER).wp(100), play); f1.add(tl.cc().ha(CENTER), movie); Notice the other lines don't need the widthPercent value since they're in the same column. On Thursday, May 20, 2021 at 9:49:30 AM UTC+3 P5music wrote: > Maybe you should use BorderLayout so you can place the f1 container in the > center of it. > > https://www.codenameone.com/javadoc/com/codename1/ui/layouts/BorderLayout.html > > Container f1 = new Container(BoxLayout.y()); > Container blContainer = new Container(new BorderLayout()); > > Button concert=new Button("Concerts"); > > Button play=new Button("Theatres"); > Button movie=new Button("Movies"); > Button cinema=new Button("Cinemas"); > Button musicien=new Button("Musiciens"); > Button tactor=new Button("Theatre Actor"); > Button factor=new Button("Movie Actor"); > Button logout=new Button("Logout"); > f1.addAll(concert,play,movie,cinema,musicien,tactor,factor,logout); > > blContainer.add(BorderLayout.CENTER,f1); > add(blContainer); > > I do not test it but I have some similar code in my app. It should work. > > Regards > Il giorno giovedì 20 maggio 2021 alle 02:36:21 UTC [email protected] ha > scritto: > >> Having this problem. You'll find the display below, please how to center >> it? >> >> CODE: >> >> >> Container f1 = new Container(BoxLayout.y()); >> >> Button concert=new Button("Concerts"); >> >> Button play=new Button("Theatres"); >> Button movie=new Button("Movies"); >> Button cinema=new Button("Cinemas"); >> Button musicien=new Button("Musiciens"); >> Button tactor=new Button("Theatre Actor"); >> Button factor=new Button("Movie Actor"); >> Button logout=new Button("Logout"); >> f1.addAll(concert,play,movie,cinema,musicien,tactor,factor,logout); >> add(f1); >> >> >> OUTPUT >> [image: test.png] >> > -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/19dada0c-e721-4641-bf75-e8c34a2f74c3n%40googlegroups.com.
