summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 23:49:39 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-25 23:49:39 +0200
commit3fb3b387c8aa8e43d746341ee6039998c05cd6a9 (patch)
treec24f173b8845827a1e8f89a678ed23e882d45c7c /src/jrummikub/view/impl
parentd69fdbacb90427d47400bd2ebe929e77f47e75b7 (diff)
downloadJRummikub-3fb3b387c8aa8e43d746341ee6039998c05cd6a9.tar
JRummikub-3fb3b387c8aa8e43d746341ee6039998c05cd6a9.zip
Cleaned up player panel code
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@279 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl')
-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();