diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ActionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ActionPanel.java index 0f3c5e8b233..985aca26330 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/ActionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/ActionPanel.java @@ -58,6 +58,15 @@ public static JLabel createIndentedLabel() { return new JLabelBuilder().border(BorderFactory.createEmptyBorder(0, 5, 0, 0)).build(); } + protected static JPanel createButtonsPanel(JButton... buttons) { + JPanel buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); + for (JButton button : buttons) { + buttonsPanel.add(button); + } + return buttonsPanel; + } + /** * Wait for another thread to call release. If the thread is interrupted, we will return silently. * diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsPanel.java index 9f932a7ea6e..0258cb93555 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PoliticsPanel.java @@ -176,7 +176,6 @@ public void display(final GamePlayer gamePlayer) { () -> { removeAll(); actionLabel.setText(gamePlayer.getName() + " Politics"); - add(actionLabel); add(SwingComponents.leftBox(actionLabel)); selectPoliticalActionButton = new JButton(selectPoliticalActionAction); @@ -184,10 +183,7 @@ public void display(final GamePlayer gamePlayer) { doneButton = createDoneButton(); doneButton.setEnabled(false); - final JPanel buttonsPanel = new JPanel(); - buttonsPanel.add(selectPoliticalActionButton); - buttonsPanel.add(doneButton); - add(buttonsPanel); + add(createButtonsPanel(selectPoliticalActionButton, doneButton)); SwingUtilities.invokeLater(() -> doneButton.requestFocusInWindow()); }); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PurchasePanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PurchasePanel.java index 8c828c5db74..e084876787c 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/PurchasePanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/PurchasePanel.java @@ -23,7 +23,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.SwingUtilities; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; @@ -92,24 +91,20 @@ public void display(final GamePlayer gamePlayer) { () -> { removeAll(); actionLabel.setText(gamePlayer.getName() + " production"); - add(actionLabel); add(SwingComponents.leftBox(actionLabel)); buyButton.setText(BUY); - final JPanel buttonsPanel = new JPanel(); - buttonsPanel.add(buyButton); - buttonsPanel.add(createDoneButton()); - add(buttonsPanel); + add(createButtonsPanel(buyButton, createDoneButton())); add(Box.createVerticalStrut(9)); purchasedLabel.setText(""); - add(purchasedLabel); + add(SwingComponents.leftBox(purchasedLabel)); add(Box.createVerticalStrut(4)); purchasedUnits.setUnitsFromProductionRuleMap(new IntegerMap<>(), gamePlayer); - add(purchasedUnits); + add(SwingComponents.leftBox(purchasedUnits)); getData().acquireReadLock(); try { @@ -117,9 +112,9 @@ public void display(final GamePlayer gamePlayer) { UnitSeparator.categorize(gamePlayer.getUnits())); add(Box.createVerticalStrut(4)); if (!gamePlayer.getUnitCollection().isEmpty()) { - add(purchasedPreviousRoundsLabel); + add(SwingComponents.leftBox(purchasedPreviousRoundsLabel)); } - add(purchasedPreviousRoundsUnits); + add(SwingComponents.leftBox(purchasedPreviousRoundsUnits)); } finally { getData().releaseReadLock(); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/RepairPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/RepairPanel.java index 0dbbd0831a2..38ba582eef5 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/RepairPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/RepairPanel.java @@ -16,7 +16,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.SwingUtilities; import org.triplea.java.collections.IntegerMap; import org.triplea.swing.SwingComponents; @@ -75,14 +74,10 @@ public void display(final GamePlayer gamePlayer) { () -> { removeAll(); actionLabel.setText(gamePlayer.getName() + " repair"); - add(actionLabel); add(SwingComponents.leftBox(actionLabel)); buyButton.setText(BUY); - final JPanel buttonsPanel = new JPanel(); - buttonsPanel.add(buyButton); - buttonsPanel.add(createDoneButton()); - add(buttonsPanel); + add(createButtonsPanel(buyButton, createDoneButton())); repairedSoFar.setText(""); add(Box.createVerticalStrut(9)); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TechPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TechPanel.java index 5c603e8fff8..9eb3b298a17 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TechPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TechPanel.java @@ -224,18 +224,13 @@ public void display(final GamePlayer gamePlayer) { () -> { removeAll(); actionLabel.setText(gamePlayer.getName() + " Tech Roll"); - add(actionLabel); add(SwingComponents.leftBox(actionLabel)); - final JPanel buttonsPanel = new JPanel(); if (Properties.getWW2V3TechModel(getData().getProperties())) { - buttonsPanel.add(new JButton(getTechTokenAction)); - buttonsPanel.add(new JButton(justRollTech)); + add(createButtonsPanel(new JButton(getTechTokenAction), new JButton(justRollTech))); } else { - buttonsPanel.add(new JButton(getTechRollsAction)); - buttonsPanel.add(createDoneButton()); + add(createButtonsPanel(new JButton(getTechRollsAction), createDoneButton())); } - add(buttonsPanel); }); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionPanel.java index 143d0d1651b..774875ca6e5 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/UserActionPanel.java @@ -121,7 +121,6 @@ public void display(final GamePlayer gamePlayer) { () -> { removeAll(); actionLabel.setText(gamePlayer.getName() + " Actions and Operations"); - add(actionLabel); add(SwingComponents.leftBox(actionLabel)); selectUserActionButton = new JButton(selectUserActionAction); @@ -129,10 +128,7 @@ public void display(final GamePlayer gamePlayer) { doneButton = createDoneButton(); doneButton.setEnabled(false); - final JPanel buttonsPanel = new JPanel(); - buttonsPanel.add(selectUserActionButton); - buttonsPanel.add(doneButton); - add(buttonsPanel); + add(createButtonsPanel(selectUserActionButton, doneButton)); SwingUtilities.invokeLater(() -> doneButton.requestFocusInWindow()); });