diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 16:11:20 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 16:11:20 +0200 |
commit | 92fe29000b3a8da2adc498154521e7969b6f9c5f (patch) | |
tree | 03017bc91e5903ac011ae1a833bca82136871159 /src/jrummikub/view/impl | |
parent | 0506b7f154a816d591f580466a294e1b6820774b (diff) | |
download | JRummikub-92fe29000b3a8da2adc498154521e7969b6f9c5f.tar JRummikub-92fe29000b3a8da2adc498154521e7969b6f9c5f.zip |
Load error, save default file, save disable
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@483 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl')
-rw-r--r-- | src/jrummikub/view/impl/View.java | 33 |
1 files changed, 24 insertions, 9 deletions
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); |