Layout issues

35 views
Skip to first unread message

mcw

unread,
Aug 21, 2019, 10:38:42 AM8/21/19
to CodenameOne Discussions
I am having layout issues. It is a complicated form so producing a test case might take a while. I was hoping you might have some ideas.

I have a form which uses BorderLayout. I add the actual content to a second container which uses GridBagLayout and then add the container to the center of the BorderLayout. I have set vertical scrolling to true.

Variable amounts of data are displayed. As long as all the data fits on the screen, it works perfectly. The problem starts when scrolling takes place. The panel scrolls but the first component on the panel is clipped. The height of the first component is reduced and it is only partially visible. I was expecting my complete panel to be untouched and scrollable.

I have tried the various center behavior flags on the BorderLayouit but the problem persists.

This is happening everywhere, in the simulator, Android and iOS devices.

Do you have any idea why the first component would be clipped when scrolling is active?

Thanks,

Martin

mcw

unread,
Aug 21, 2019, 5:35:06 PM8/21/19
to CodenameOne Discussions
I was able to get this to work. What I ended up doing was changing the layout of my Container to BoxLayout. Most of the boxes used GridBagLayout so I was still able to get the exact format I wanted.

I am still not sure why it didn't work when the whole Container used GridBagLayout.

Thanks,

Martin

Shai Almog

unread,
Aug 21, 2019, 10:18:11 PM8/21/19
to CodenameOne Discussions
I don't understand the original problem. BorderLayout can't be scrollable so which part was scrollable and how did it look?

mcw

unread,
Aug 23, 2019, 2:25:26 PM8/23/19
to CodenameOne Discussions
I set vertical scrolling on the Container and it does scroll.

The problem is that as soon as there is enough data to scroll, the first component is clipped. I tried different components in the first position but they always got clipped.

image1.png

Image1 shows the top of the screen when there is no scrolling.

image2.png

Image2 shows the same area after more data is added and scrolling kicks in.

The first component has been reduced in height.

As I mentioned I have found a good workaround for this problem, so it is not a big deal. I used to construct the whole form with GridBagLayout, now it is a BoxLayout with GridBagLayout in the boxes.

Thanks,

Martin

Shai Almog

unread,
Aug 24, 2019, 12:33:07 AM8/24/19
to CodenameOne Discussions
I need to understand the code to understand what's going on and why something like this would happen. I'm assuming that portion isn't scrollable and is in the NORTH portion of the container?
Is it possible you have nested elements which are scrollable implicitly or explicitly?

mcw

unread,
Aug 24, 2019, 3:31:03 PM8/24/19
to CodenameOne Discussions
In this version it is one GridBagLayout that is added to the center component of the BorderLayout. Everyting is laid out with GridBagLayout. That top component is added to the GridBagLayout. too There is nothing in the north component.

No other components were scrollable although I had played around with that. I actually made that first item scrollable at one point so that at least I could see it all but that didn't help.

Shai Almog

unread,
Aug 25, 2019, 2:31:32 AM8/25/19
to CodenameOne Discussions
So the gridbag layout was made scrollable?
I'm not sure how well that will work as we never really use gridbag. It was added to help Swing developers port legacy code to Codename One.
Reply all
Reply to author
Forward
0 new messages