문제

I have created a program in which I display result-filtering options on the side of my Swing window, however by default they appear horizontally next to one another, which wastes the space I have allotted in my BorderLayout's WEST side. Is there anything I can pass in my constructor or add-statement that will stack these up? Here's my relevant code in a class that extends JFrame:

box1 = new JCheckBox("Points");box2 = new JCheckBox("Bleh");
pane = new JPanel();
pane.add(box1);pane.add(box2);
add(pane, BorderLayout.WEST); 

So this is quite simple, but when displayed they show side-by-side, and that's what I am looking to change. Any help will be greatly appreciated. If I missed a good source of research info, please pass it along.

도움이 되었습니까?

해결책

Use GridLayout with n rows and one column for pane, where n is the number of checkboxes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top