Scrolling with Borderlayout (NORTH & SOUTH) overlappng

5 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Feb 19, 2019, 8:49:29 AM2/19/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10 Pro
Simulator  Latest
Device PC, Android, IOS

I have a BorderLayout Dialog, 2 com.codename1.ui.table.TableLayout(rows, 1) Containers
First Container has 20 rows of Label("some text) and is set as
            dlg.add(BorderLayout.NORTH,ContainerDataBaseContainer);

And An Options Container set as
            dlg.add(BorderLayout.SOUTH,OptionsContainer);
Scrolling is set true for ContainerDataBaseContainer

When Running demo, ContainerDataBaseContainer consumes 100% of the frame and overlaps OptionsContainer Container
VS Always showing
OptionsContainer  at Bottom and the ContainerDataBaseContainer scrolls between top and OptionsContainer 
Please see attached pics BorderLayoutScrollPic1.JPG , BorderLayoutScrollPic2.JPG& BorderLayoutScrollPic3.JPG
Pic one shows when app first opened,
Pic two shoes app when Top container is scrolled.
Pic Three shows correct scrolling between Top header and bottom options container

Here is the demo code:
----------------------------------------------------------------------------------------------
            Dialog dlg = new Dialog("A3-Tech Customer Search");
            try {
                int rows = 20;
                dlg.setLayout(new BorderLayout());
                Container ContainerDataBaseContainer = new Container(new com.codename1.ui.table.TableLayout(rows, 1));
                ContainerDataBaseContainer.setScrollableY(true);
                for (int a = 0; a < rows; a++) {
                    buildConstrantsGeneric(ContainerDataBaseContainer, new Label("Label Row [" + (a + 1) + "]"), a, 0, 100);
                }
                Container OptionsContainer = new Container(new com.codename1.ui.table.TableLayout(1, 3));
                Button CmdCancel = new Button("Cancel", "Button");
                CmdCancel.addActionListener(e -> {
                    dlg.dispose();
                });
                Button ExecSearch = new Button("Execute Search", "Button");
                ExecSearch.addActionListener(e -> {
                    dlg.dispose();
                });
                Button OpenRos = new Button("Load Open Invoices", "Button");
                OpenRos.addActionListener(e -> {
                    dlg.dispose();
                });
                buildConstrantsGeneric(OptionsContainer, OpenRos, 0, 0, 33);
                buildConstrantsGeneric(OptionsContainer, ExecSearch, 0, 1, 33);
                buildConstrantsGeneric(OptionsContainer, CmdCancel, 0, 2, 34);
                dlg.add(BorderLayout.NORTH, ContainerDataBaseContainer);
                dlg.add(BorderLayout.SOUTH, OptionsContainer);
            } catch (Exception e) {
                e.printStackTrace();
            }
            dlg.show(0, 0, 0, 0);

    public static TableLayout.Constraint buildConstrantsGeneric(Container CTR, Component comp, int row, int col, int widthPercent) {
        TableLayout.Constraint ConSt = ((TableLayout) CTR.getLayout()).createConstraint(row, col);
        ConSt.setWidthPercentage(widthPercent);
        CTR.addComponent(ConSt, comp);
        return ConSt;
    }

Regards
BorderLayoutScrollPic1.JPG
BorderLayoutScrollPic2.JPG
BorderLayoutScrollPic3.JPG

Shai Almog

unread,
Feb 19, 2019, 10:02:52 PM2/19/19
to CodenameOne Discussions
North and south take up their preferred height. East and west take up their preferred width.
As such all of these need to take components that have reasonable height/width expectations e.g. buttons etc.

So you need to place the larger component in the center not in the north.

shop.servic...@gmail.com

unread,
Feb 20, 2019, 8:08:50 AM2/20/19
to CodenameOne Discussions
Thank You!
Reply all
Reply to author
Forward
0 new messages