Bläddra i källkod

Fixed missing "save" menuitem in menubar

Jeroen96 10 år sedan
förälder
incheckning
abc6944f61
2 ändrade filer med 7 tillägg och 8 borttagningar
  1. 1 1
      src/agenda/Io.java
  2. 6 7
      src/gui/menubar/MenuBar.java

+ 1 - 1
src/agenda/Io.java

@@ -11,7 +11,7 @@ import javax.swing.JFileChooser;
 
 public class Io {
 
-	public void writeIo(Agenda agenda) throws IOException
+	public static void writeIo(Agenda agenda) throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser();
 		if(fileChooser.showSaveDialog(null)

+ 6 - 7
src/gui/menubar/MenuBar.java

@@ -77,14 +77,13 @@ public class MenuBar extends JMenuBar{
 				}
 			}
 		});
-		fileMenu.add(openAction);
-		openAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
+		fileMenu.add(saveAction);
+		saveAction.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent e) {
 				try {
-					Agenda agenda = Io.readIo();
-					mainFrame.setAgenda(agenda);
-				} catch (IOException e) {
-					e.printStackTrace();
+					Io.writeIo(mainFrame.getAgenda());
+				} catch (IOException e1) {
+					e1.printStackTrace();
 				}
 			}
 		});