FlowLayout in Swing doesn't move to the next line

為{幸葍}努か 提交于 2019-12-11 17:54:25

问题


I'm using a flow layout inside a scroll panel. I keep adding button expecting them to add to the next line when there is no more available space, but they just keep adding.

I want the scroll bar to only scroll vertically, not horizontally.

My code:

JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 6));

for(int i = 0; i < 30; i++) panel.add(new JButton("asd"));

来源:https://stackoverflow.com/questions/50192589/flowlayout-in-swing-doesnt-move-to-the-next-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!