diff --git a/ts3-client/swing/src/main/java/com/ts3client/ui/ChannelAdvancedPanel.java b/ts3-client/swing/src/main/java/com/ts3client/ui/ChannelAdvancedPanel.java index 11e549a..5084af6 100644 --- a/ts3-client/swing/src/main/java/com/ts3client/ui/ChannelAdvancedPanel.java +++ b/ts3-client/swing/src/main/java/com/ts3client/ui/ChannelAdvancedPanel.java @@ -14,6 +14,7 @@ import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.SpinnerNumberModel; +import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -76,6 +77,7 @@ final class ChannelAdvancedPanel extends JPanel implements ChannelDialog.Tab { JPanel other = otherSettings(); other.setAlignmentX(0f); + fixHeight(other); add(other); add(Box.createVerticalStrut(6)); @@ -86,6 +88,7 @@ final class ChannelAdvancedPanel extends JPanel implements ChannelDialog.Tab { limits.add(limitBox("Family Max Users", new JRadioButton[]{familyInherited, familyUnlimited, familyLimited}, familyMaxUsers)); limits.setAlignmentX(0f); + fixHeight(limits); add(limits); add(Box.createVerticalGlue()); } @@ -162,26 +165,36 @@ final class ChannelAdvancedPanel extends JPanel implements ChannelDialog.Tab { c.gridx = 1; c.gridy = 2; panel.add(encrypted, c); - - c.gridx = 0; - c.gridy = 3; - c.weighty = 1; - panel.add(Box.createGlue(), c); return panel; } + /** + * A limit box: its choices stacked, with the count beside the last of them — + * "Limited", the only choice it belongs to. + */ private JPanel limitBox(String title, JRadioButton[] choices, JSpinner spinner) { JPanel box = new JPanel(); box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS)); box.setBorder(BorderFactory.createTitledBorder(title)); - for (JRadioButton radio : choices) { + for (int i = 0; i < choices.length; i++) { + JRadioButton radio = choices[i]; radio.setAlignmentX(0f); - box.add(radio); + if (i < choices.length - 1) { + box.add(radio); + continue; + } + JPanel row = new JPanel(new FlowLayout(FlowLayout.LEFT, 6, 0)); + row.setAlignmentX(0f); + row.add(radio); + row.add(spinner); + box.add(row); } - spinner.setAlignmentX(0f); - box.add(Box.createVerticalStrut(4)); - box.add(spinner); box.add(Box.createVerticalGlue()); return box; } + + /** Keeps a section at its natural height, so the free space collects at the bottom. */ + private static void fixHeight(JPanel panel) { + panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, panel.getPreferredSize().height)); + } }