summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/view/impl/PlayerPanel.java54
1 files changed, 17 insertions, 37 deletions
diff --git a/src/jrummikub/view/impl/PlayerPanel.java b/src/jrummikub/view/impl/PlayerPanel.java
index 171e46b..db2721a 100644
--- a/src/jrummikub/view/impl/PlayerPanel.java
+++ b/src/jrummikub/view/impl/PlayerPanel.java
@@ -113,27 +113,19 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
currentPlayerNameLabel.setVerticalTextPosition(JLabel.CENTER);
leftPanel.add(currentPlayerNameLabel);
- sortByGroupsButton = new JButton("<html><center>Nach Sammlungen sortieren");
- sortByGroupsButton.setFont(sortByGroupsButton.getFont().deriveFont(0));
- sortByGroupsButton.setMargin(new Insets(0, 0, 0, 0));
- sortByGroupsButton.addActionListener(new ActionListener() {
+ sortByGroupsButton = createButton(leftPanel, "<html><center>Nach Sammlungen sortieren", new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
sortByGroupsEvent.emit();
}
});
- leftPanel.add(sortByGroupsButton);
- sortByRunsButton = new JButton("<html><center>Nach Reihen sortieren");
- sortByRunsButton.setFont(sortByRunsButton.getFont().deriveFont(0));
- sortByRunsButton.setMargin(new Insets(0, 0, 0, 0));
- sortByRunsButton.addActionListener(new ActionListener() {
+ sortByRunsButton = createButton(leftPanel, "<html><center>Nach Reihen sortieren", new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
sortByRunsEvent.emit();
}
});
- leftPanel.add(sortByRunsButton);
leftPanel.addComponentListener(new LeftPanelResizeListener());
}
@@ -144,68 +136,56 @@ class PlayerPanel extends JPanel implements IPlayerPanel {
rightPanel.setBorder(new EmptyBorder(SIDE_PANEL_INSET, SIDE_PANEL_INSET,
SIDE_PANEL_INSET, SIDE_PANEL_INSET));
- handRowUpButton = new JButton("<html><center>\u25B2");
- handRowUpButton.setMargin(new Insets(0, 0, 0, 0));
- handRowUpButton.addActionListener(new ActionListener() {
+ handRowUpButton = createButton(rightPanel, "<html><center>\u25B2", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hand.rowUp();
}
});
- rightPanel.add(handRowUpButton);
- handRowDownButton = new JButton("<html><center>\u25BC");
- handRowDownButton.setMargin(new Insets(0, 0, 0, 0));
- handRowDownButton.addActionListener(new ActionListener() {
+ handRowDownButton = createButton(rightPanel, "<html><center>\u25BC", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hand.rowDown();
}
});
- rightPanel.add(handRowDownButton);
timeBar = new JProgressBar(0, 60);
timeBar.setStringPainted(true);
rightPanel.add(timeBar);
- endTurnButton = new JButton("---");
- endTurnButton.setFont(endTurnButton.getFont().deriveFont(0));
- endTurnButton.setMargin(new Insets(0, 0, 0, 0));
- endTurnButton.addActionListener(new ActionListener() {
+ endTurnButton = createButton(rightPanel, "---", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
endTurnEvent.emit();
}
});
-
- rightPanel.add(endTurnButton);
- keepStonesButton = new JButton("<html><center>Steine<br>behalten");
- keepStonesButton.setFont(keepStonesButton.getFont().deriveFont(0));
- keepStonesButton.setMargin(new Insets(0, 0, 0, 0));
- keepStonesButton.addActionListener(new ActionListener() {
+ keepStonesButton = createButton(rightPanel, "<html><center>Steine<br>behalten", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
endTurnEvent.emit();
}
});
-
- rightPanel.add(keepStonesButton);
-
- redealButton= new JButton("<html><center>Neu<br>geben");
- redealButton.setFont(redealButton.getFont().deriveFont(0));
- redealButton.setMargin(new Insets(0, 0, 0, 0));
- redealButton.addActionListener(new ActionListener() {
+
+ redealButton = createButton(rightPanel, "<html><center>Neu<br>geben", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
redealEvent.emit();
}
});
- rightPanel.add(redealButton);
-
rightPanel.addComponentListener(new RightPanelResizeListener());
}
+
+ private JButton createButton(JPanel panel, String caption, ActionListener listener) {
+ JButton button = new JButton(caption);
+ button.setFont(button.getFont().deriveFont(0));
+ button.setMargin(new Insets(0, 0, 0, 0));
+ button.addActionListener(listener);
+ panel.add(button);
+ return button;
+ }
private void rescale() {
Insets insets = getInsets();