summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view')
-rw-r--r--src/jrummikub/view/IView.java3
-rw-r--r--src/jrummikub/view/impl/View.java33
2 files changed, 27 insertions, 9 deletions
diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java
index b127377..86ab5be 100644
--- a/src/jrummikub/view/IView.java
+++ b/src/jrummikub/view/IView.java
@@ -276,4 +276,7 @@ public interface IView {
/** */
WIN_PANEL
}
+ void showError();
+
+ void enableSave(boolean enable);
}
diff --git a/src/jrummikub/view/impl/View.java b/src/jrummikub/view/impl/View.java
index 60202e4..e436419 100644
--- a/src/jrummikub/view/impl/View.java
+++ b/src/jrummikub/view/impl/View.java
@@ -17,6 +17,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
@@ -52,6 +53,7 @@ public class View extends JFrame implements IView {
private JLayeredPane layeredPane;
private JPanel mainLayer;
private JMenuBar menuBar;
+ private JMenuItem saveItem;
private TablePanel table;
private PlayerPanel playerPanel;
@@ -162,11 +164,20 @@ public class View extends JFrame implements IView {
setSelectedStones(Collections.<Stone> emptyList());
}
+ @Override
+ public void showError() {
+ JOptionPane.showMessageDialog(this, "Kein g\u00fcltiger Spielstand",
+ "Fehler", JOptionPane.ERROR_MESSAGE);
+ }
+
private void createFileChooser() {
chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"JRummikub-Spiele", "rum");
chooser.setFileFilter(filter);
+
+ String defaultFile = "spiel.rum";
+ chooser.setSelectedFile(new File(defaultFile));
}
private void createMenuBar() {
@@ -188,7 +199,8 @@ public class View extends JFrame implements IView {
}
});
gameMenu.add(loadItem);
- JMenuItem saveItem = new JMenuItem("Speichern...");
+
+ saveItem = new JMenuItem("Speichern...");
saveItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -215,6 +227,11 @@ public class View extends JFrame implements IView {
return item;
}
+ @Override
+ public void enableSave(boolean enable) {
+ saveItem.setEnabled(enable);
+ }
+
private void load() {
int returnVal = chooser.showOpenDialog(View.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
@@ -322,7 +339,7 @@ public class View extends JFrame implements IView {
winPanel = new WinPanel();
winPanel.setVisible(false);
mainLayer.add(winPanel);
-
+
sidePanel = new SidePanel();
mainLayer.add(sidePanel);
}
@@ -339,8 +356,6 @@ public class View extends JFrame implements IView {
int width = getContentPane().getWidth(), height = getContentPane()
.getHeight();
-
-
layeredPane.setBounds(0, 0, width, height);
mainLayer.setBounds(0, 0, width, height);
@@ -354,9 +369,9 @@ public class View extends JFrame implements IView {
playerPanel.setBounds(0, tableHeight, width, playerPanelHeight);
playerPanel.rescale();
-
+
int sideWidth = playerPanel.getLeftPanelWidth() + 1;
-
+
table.setBounds(sideWidth, 0, width - sideWidth, tableHeight);
table.validate();
sidePanel.setBounds(0, 0, sideWidth, tableHeight);
@@ -414,7 +429,7 @@ public class View extends JFrame implements IView {
startTurnPanel.setCurrentPlayerName(playerName);
pausePanel.setCurrentPlayerName(playerName);
}
-
+
@Override
public void setInitialMeldError(int points) {
startTurnPanel.setInitialMeldError(points);
@@ -444,7 +459,7 @@ public class View extends JFrame implements IView {
public IEvent getAcknowledgeInvalidEvent() {
return startTurnPanel.getAcknowledgeInvalidEvent();
}
-
+
@Override
public IEvent getNewRoundEvent() {
return winPanel.getNewRoundEvent();
@@ -524,7 +539,7 @@ public class View extends JFrame implements IView {
playerPanel.showButtons(type != BottomPanelType.START_GAME_PANEL);
playerPanel.enableButtons(type != BottomPanelType.COMPUTER_HAND_PANEL);
}
-
+
@Override
public void setStoneCollectionHidden(boolean enable) {
table.getStoneCollectionPanel().setHidden(enable);