FlowLayout in Swing doesn't move to the next line
问题 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