I want to build a dialog in Java with a List and a couple of buttons underneath it. The list ends up with the same height as the buttons (about one line) and the whole dialog is about two lines of height.
However, I'd like the dialog to be taller (maybe 10 lines) and the JList to take up most of the space .. I've played around with the parameters, but for the life of it can't get it to work. Any ideas?
Here's my current code:
//layout
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
int y = 0;
//List
gbc.gridx = 0;
gbc.gridy = y;
gbc.weighty = 3;
gbc.weightx = 1;
gbc.gridwidth= 3;
add(new JScrollPane(_myList), gbc);
_myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// Buttons
gbc.gridx = 1;
gbc.gridy = ++y;
gbc.gridwidth = 1;
gbc.weighty = 0;
add(_Save, gbc);
gbc.gridx = 2;
add(_Cancel, gbc);