Browse Source

Ensure correct layout after relocation.

pull/222/head
weisj 4 years ago
parent
commit
eeea3b142c
  1. 20
      core/src/main/java/com/github/weisj/darklaf/layout/LayoutHelper.java
  2. 8
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

20
core/src/main/java/com/github/weisj/darklaf/layout/LayoutHelper.java

@ -101,17 +101,19 @@ public class LayoutHelper {
layout.setVerticalGroup(verticalGroup);
int p = GroupLayout.PREFERRED_SIZE;
// add the components to the groups
for (JComponent label : left) {
verticalLabelGroup.addComponent(label, p, p, p);
}
for (JComponent field : right) {
verticalComponentGroup.addComponent(field, p, p, p);
}
for (int i = 0; i < left.size(); i++) {
JComponent lComp = left.get(i);
JComponent rComp = right.get(i);
panel.add(lComp);
panel.add(rComp);
verticalLabelGroup.addComponent(lComp, p, p, p);
verticalComponentGroup.addComponent(rComp, p, p, p);
verticalGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(left.get(i), p, p, p)
.addComponent(right.get(i), p, p, p));
.addComponent(lComp, p, p, p)
.addComponent(rComp, p, p, p));
}
return panel;
}

8
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

@ -270,11 +270,13 @@ public class ThemeSettingsPanel extends JPanel {
public void setLabelAlignment(final GroupLayout.Alignment alignment) {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createTitledBorder(UIManager.getString("title_general", getLocale())));
panel.setBorder(BorderFactory.createTitledBorder("Test"));
panel.add(LayoutHelper.createTwoColumnPanel(
new JLabel[] {themeLabel, accentColorLabel, selectionColorLabel, fontSizeLabel},
new JComponent[] {themeComboBox, accentBox, selectionBox, fontSlider},
alignment, GroupLayout.Alignment.LEADING));
new JLabel[] {themeLabel, accentColorLabel, selectionColorLabel, fontSizeLabel},
new JComponent[] {themeComboBox, accentBox, selectionBox, fontSlider},
alignment, GroupLayout.Alignment.LEADING));
add(panel, BorderLayout.CENTER);
panel.getPreferredSize(); // Forces constraints to be recalculated.
}
protected ColoredRadioButton addCustomButton(final ButtonGroup bg, final JComponent parent,

Loading…
Cancel
Save