Shikhar13 / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

This layout wont scroll vertically #295

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
One cannot scroll a screen with the following layout:

A Form with a Button and a FlowLayout consisting of a just Labels. The Label 
count is such that a screen scroll is required.

Just run this sample code and you'll see.

public class ScrollTestForTextOnly {

    public ScrollTestForTextOnly() {

        Form form = new Form();
        Container contentPane = form.getContentPane();

        Container toolbar = new Container(new BoxLayout(BoxLayout.X_AXIS));
        toolbar.addComponent(new Button("Test"));

        Container flowContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        Container flowControl = new Container(new FlowLayout());        
        Random random = new  Random(10);

        for (int i = 0; i < 200; i++) {         
            flowControl.addComponent(new Label(pad(random.nextInt(10))));
        }
        flowContainer.addComponent(flowControl);

        contentPane.addComponent(toolbar);
        contentPane.addComponent(flowContainer);
        form.show();

    }

    private String pad(int len) {
        if (len == 0) {
            len = 1;
        }
        String s = "";
        for (int i = 0; i < len; i++) {
            s += "A";
        }
        return s;
    }

}

Original issue reported on code.google.com by jkoo...@gmail.com on 15 Aug 2012 at 2:27

GoogleCodeExporter commented 9 years ago
This Scrolls:

public ScrollTestForTextOnly() {
        Form form = new Form();
        Container contentPane = form.getContentPane();
        contentPane.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        contentPane.addComponent(new Button("Test"));
        for (int i = 0; i < 200; i++) {                             
            contentPane.addComponent(new Label("testing one two three"));
        }
        form.show();
    }

This does not scroll:

public ScrollTestForTextOnly() {
        Form form = new Form();
        Container contentPane = form.getContentPane();
        contentPane.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        // contentPane.addComponent(new Button("Test"));
        for (int i = 0; i < 200; i++) {                             
            contentPane.addComponent(new Label("testing one two three"));
        }
        form.show();
    }

Original comment by jkoo...@gmail.com on 15 Aug 2012 at 5:15

GoogleCodeExporter commented 9 years ago
I think this issue was resolved a long time ago. 

Original comment by shai.almog on 22 Nov 2013 at 9:06