summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 20:19:17 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-29 20:19:17 +0200
commit794777c2fe8808444d2952d8abe287278d81f119 (patch)
tree014c8dce4acda3da13d1c6eb0e6b27a1a480f3fa /src/jrummikub/view/impl
parenteb7ccb46c5023fb8a3052f1c6d9fa5d2e384d15e (diff)
downloadJRummikub-794777c2fe8808444d2952d8abe287278d81f119.tar
JRummikub-794777c2fe8808444d2952d8abe287278d81f119.zip
Neuer Button im WinPanel mit funktion
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@309 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r--src/jrummikub/view/impl/View.java10
-rw-r--r--src/jrummikub/view/impl/WinPanel.java52
2 files changed, 45 insertions, 17 deletions
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 184155f..b2ae7fb 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -205,7 +205,13 @@ public class View extends JFrame implements IView {
}
@Override
- public IEvent getFinalScoreEvent() {
- return winPanel.getFinalScoreEvent();
+ public IEvent getNewGameEvent() {
+ return winPanel.getNewGameEvent();
}
+
+ @Override
+ public IEvent getEndProgramEvent() {
+ return winPanel.getEndProgramEvent();
+ }
+
}
diff --git a/src/jrummikub/view/impl/WinPanel.java b/src/jrummikub/view/impl/WinPanel.java
index 13a7eb4..61f6e05 100644
--- a/src/jrummikub/view/impl/WinPanel.java
+++ b/src/jrummikub/view/impl/WinPanel.java
@@ -27,9 +27,11 @@ class WinPanel extends JPanel {
private JLabel winLabel;
private JButton newRoundButton;
- private JButton finalScoreButton;
+ private JButton newGameButton;
+ private JButton endProgramButton;
- private Event finalScoreEvent = new Event();
+ private Event endProgramEvent = new Event();
+ private Event newGameEvent = new Event();
private Event newRoundEvent = new Event();
/**
@@ -56,14 +58,23 @@ class WinPanel extends JPanel {
});
add(newRoundButton);
- finalScoreButton = new JButton("Endauswertung");
- finalScoreButton.addActionListener(new ActionListener() {
+ newGameButton = new JButton("Neues Spiel");
+ newGameButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
- finalScoreEvent.emit();
+ newGameEvent.emit();
}
});
- add(finalScoreButton);
+ add(newGameButton);
+
+ endProgramButton = new JButton("Programm verlassen");
+ endProgramButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ endProgramEvent.emit();
+ }
+ });
+ add(endProgramButton);
addComponentListener(new ComponentAdapter() {
@Override
@@ -77,7 +88,7 @@ class WinPanel extends JPanel {
* Sets the name of the current player
*
* @param name
- * the player name
+ * the player name
*/
void setCurrentPlayerName(String name) {
winLabel.setText("Du hast gewonnen, " + name + "!");
@@ -92,19 +103,24 @@ class WinPanel extends JPanel {
return newRoundEvent;
}
+ IEvent getNewGameEvent() {
+ return newGameEvent;
+ }
+
/**
- * The quit event is emitted when the player wants to quit the program
+ * The end program is emitted when the player wants to quit the program
*
* @return the event
*/
- IEvent getFinalScoreEvent() {
- return finalScoreEvent;
+ IEvent getEndProgramEvent() {
+ return endProgramEvent;
}
private void rescale() {
Insets insets = getInsets();
int x = insets.left, y = insets.top, width = getWidth() - insets.left
- - insets.right, height = getHeight() - insets.top - insets.bottom;
+ - insets.right, height = getHeight() - insets.top
+ - insets.bottom;
if (width > PANEL_MAX_WIDTH) {
x += (width - PANEL_MAX_WIDTH) / 4;
@@ -112,7 +128,7 @@ class WinPanel extends JPanel {
}
int firstLineHeight = (int) ((height - PANEL_SEPARATOR) * PANEL_FIRST_LINE_HEIGHT);
- int buttonWidth = (width - PANEL_SEPARATOR) / 2;
+ int buttonWidth = (width - 2 * PANEL_SEPARATOR) / 3;
int buttonHeight = height - PANEL_SEPARATOR - firstLineHeight;
float fontSize = (float) Math.sqrt(buttonWidth * buttonHeight) / 5;
if (fontSize > MAX_BUTTON_FONT_SIZE)
@@ -123,8 +139,14 @@ class WinPanel extends JPanel {
buttonWidth, buttonHeight);
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
- finalScoreButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y + firstLineHeight
- + PANEL_SEPARATOR, buttonWidth, buttonHeight);
- finalScoreButton.setFont(finalScoreButton.getFont().deriveFont(fontSize));
+ newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y
+ + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight);
+ newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
+
+ endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y
+ + firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight);
+ endProgramButton.setFont(endProgramButton.getFont()
+ .deriveFont(fontSize));
+
}
}