1JScrollPane listScroller = new JScrollPane(list);
2listScroller.setPreferredSize(new Dimension(250, 80));
3listScroller.setAlignmentX(LEFT_ALIGNMENT);
4...
5//Lay out the label and scroll pane from top to bottom.
6JPanel listPane = new JPanel();
7listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
8JLabel label = new JLabel(labelText);
9...
10listPane.add(label);
11listPane.add(Box.createRigidArea(new Dimension(0,5)));
12listPane.add(listScroller);
13listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
14
15//Lay out the buttons from left to right.
16JPanel buttonPane = new JPanel();
17buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
18buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
19buttonPane.add(Box.createHorizontalGlue());
20buttonPane.add(cancelButton);
21buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
22buttonPane.add(setButton);
23
24//Put everything together, using the content pane's BorderLayout.
25Container contentPane = getContentPane();
26contentPane.add(listPane, BorderLayout.CENTER);
27contentPane.add(buttonPane, BorderLayout.PAGE_END);
28
1JScrollPane listScroller = new JScrollPane(list);
2listScroller.setPreferredSize(new Dimension(250, 80));
3listScroller.setAlignmentX(LEFT_ALIGNMENT);
4...
5//Lay out the label and scroll pane from top to bottom.
6JPanel listPane = new JPanel();
7listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
8JLabel label = new JLabel(labelText);
9...
10listPane.add(label);
11listPane.add(Box.createRigidArea(new Dimension(0,5)));
12listPane.add(listScroller);
13listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
14
15//Lay out the buttons from left to right.
16JPanel buttonPane = new JPanel();
17buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
18buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
19buttonPane.add(Box.createHorizontalGlue());
20buttonPane.add(cancelButton);
21buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
22buttonPane.add(setButton);
23
24//Put everything together, using the content pane's BorderLayout.
25Container contentPane = getContentPane();
26contentPane.add(listPane, BorderLayout.CENTER);
27contentPane.add(buttonPane, BorderLayout.PAGE_END);