Rotating a Dialog (Portrait to Landscape) shown with max screen problem (dlg.show(0, 0, 0, 0);)

4 views
Skip to first unread message

Mark Bolduc

unread,
Dec 14, 2019, 11:21:16 AM12/14/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA Netbeans 11
Desktop OS Windows 10 Pro
Simulator Latest
Device PC (Simulator),  IOS 13+, Android 7+

Have a Dialog set to occupy 100% of screen.
When rotating orientation, Dialog does not fill full screen.
See Pic RotateDialog_1.JPG (Initially opened Dialog. Full Screen)
See Pic RotateDialog_2.JPG (Rotate Landscape, Dialog using 20% of screen)
See Pic RotateDialog_3.JPG (Rotate Portrait, Dialog using 20% of screen)

Code:
            Dialog dlg = new Dialog("A3-Tech Customer Search");
            try {
                int rows = 3;
                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();
                    System.exit(0);
                });
                Button ExecSearch = new Button("Execute Search", "Button");
                ExecSearch.addActionListener(e -> {
                    dlg.dispose();
                    System.exit(0);
                });
                Button OpenRos = new Button("Load Open Invoices", "Button");
                OpenRos.addActionListener(e -> {
                    dlg.dispose();
                    System.exit(0);
                });
                buildConstrantsGeneric(OptionsContainer, OpenRos, 0, 0, 33);
                buildConstrantsGeneric(OptionsContainer, ExecSearch, 0, 1, 33);
                buildConstrantsGeneric(OptionsContainer, CmdCancel, 0, 2, 34);
                dlg.add(BorderLayout.CENTER, 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;
    }

Thoughts?

Regards

RotateDialog_1.JPG
RotateDialog_2.JPG
RotateDialog_3.JPG

Shai Almog

unread,
Dec 14, 2019, 9:04:56 PM12/14/19
to CodenameOne Discussions
We automatically adjust the size of the dialogs on rotation to fit the new proportions otherwise they might look distorted. You can disable it for this dialog by overriding this Dialog method as a blank method:

@Override

protected void autoAdjust(int w, int h) {
}



Alternatively you can disable this globally (and re-enable later if desired) using:

 Dialog.setAutoAdjustDialogSize(false).


Mark Bolduc

unread,
Dec 15, 2019, 8:45:32 AM12/15/19
to CodenameOne Discussions
Thanks.

Regards
Reply all
Reply to author
Forward
0 new messages