Fixed loading and saving not showing agenda. Added new Agenda button

This commit is contained in:
2015-02-26 10:27:24 +01:00
parent 056a8b36d1
commit e0b9c991c8
4 changed files with 33 additions and 5 deletions
+18 -1
View File
@@ -5,6 +5,7 @@ import java.awt.event.KeyEvent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
@@ -44,11 +45,21 @@ public class MenuBar extends JMenuBar {
}
});
JMenuItem newAgenda = new JMenuItem("New Agenda");
newAgenda.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Agenda a = new Agenda();
w.setAgenda(a);
Window.updatePanel("table");
}
});
JMenuItem open = new JMenuItem("Open");
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
open.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
w.getAgenda().loadAgenda();
Window.updatePanel("table");
}
});
@@ -57,13 +68,17 @@ public class MenuBar extends JMenuBar {
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
w.getAgenda().saveAgenda();
Window.updatePanel("table");
}
});
JMenuItem exit = new JMenuItem("Exit");
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
{
System.exit(0);
}
}
});
@@ -71,6 +86,8 @@ public class MenuBar extends JMenuBar {
file.add(newArtist);
file.add(newStage);
file.addSeparator();
file.add(newAgenda);
file.addSeparator();
file.add(open);
file.add(save);
file.addSeparator();