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
+2
View File
@@ -128,6 +128,7 @@ public class Agenda implements Serializable {
{
clearAgenda();
fillAgenda(file);
JOptionPane.showMessageDialog(null, "Loaded succesfully");
}
}
}
@@ -201,6 +202,7 @@ public class Agenda implements Serializable {
oos.writeObject(event);
}
oos.close();
JOptionPane.showMessageDialog(null, "Saved succesfully");
} catch (IOException e) {
e.printStackTrace();
}
+8 -4
View File
@@ -19,15 +19,19 @@ public class Main {
Event e2 = new Event("Coldplay Live", 2015, 2, 25, 20, 00, 2015, 2, 25, 22, 00, a1, s1, "A concert from a very famous band", 1);
Event e3 = new Event("Nirvana in memory", 2015, 2, 24, 16, 30, 2015, 2, 24, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
Event e4 = new Event("Epic Rap Battles of History", 2015, 3, 3, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
//TabbedPane tab = new TabbedPane(e1, true);
//TabbedPane tab2 = new TabbedPane(e3, false);
//TabbedPane tab3 = new TabbedPane(e4, true);
Event e5 = new Event("Coldplay Live", 2015, 2, 26, 21, 00, 2015, 2, 24, 23, 00, a1, s1, "A concert from a very famous band", 2);
Event e6 = new Event("Coldplay Live", 2015, 2, 27, 20, 00, 2015, 2, 25, 22, 00, a1, s1, "A concert from a very famous band", 1);
Event e7 = new Event("Nirvana in memory", 2015, 2, 28, 16, 30, 2015, 2, 24, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
Event e8 = new Event("Epic Rap Battles of History", 2015, 3, 2, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
agn.addEvent(e1);
agn.addEvent(e2);
agn.addEvent(e3);
agn.addEvent(e4);
agn.addEvent(e5);
agn.addEvent(e6);
agn.addEvent(e7);
agn.addEvent(e8);
agn.fillArtists();
agn.fillStages();
+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();
+5
View File
@@ -210,5 +210,10 @@ public class Window extends JFrame {
return agenda;
}
public void setAgenda(Agenda a)
{
agenda = a;
}
}