Fixed loading and saving not showing agenda. Added new Agenda button
This commit is contained in:
@@ -128,6 +128,7 @@ public class Agenda implements Serializable {
|
|||||||
{
|
{
|
||||||
clearAgenda();
|
clearAgenda();
|
||||||
fillAgenda(file);
|
fillAgenda(file);
|
||||||
|
JOptionPane.showMessageDialog(null, "Loaded succesfully");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,6 +202,7 @@ public class Agenda implements Serializable {
|
|||||||
oos.writeObject(event);
|
oos.writeObject(event);
|
||||||
}
|
}
|
||||||
oos.close();
|
oos.close();
|
||||||
|
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 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);
|
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);
|
||||||
|
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);
|
||||||
//TabbedPane tab = new TabbedPane(e1, true);
|
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);
|
||||||
//TabbedPane tab2 = new TabbedPane(e3, false);
|
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);
|
||||||
//TabbedPane tab3 = new TabbedPane(e4, true);
|
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(e1);
|
||||||
agn.addEvent(e2);
|
agn.addEvent(e2);
|
||||||
agn.addEvent(e3);
|
agn.addEvent(e3);
|
||||||
agn.addEvent(e4);
|
agn.addEvent(e4);
|
||||||
|
agn.addEvent(e5);
|
||||||
|
agn.addEvent(e6);
|
||||||
|
agn.addEvent(e7);
|
||||||
|
agn.addEvent(e8);
|
||||||
|
|
||||||
agn.fillArtists();
|
agn.fillArtists();
|
||||||
agn.fillStages();
|
agn.fillStages();
|
||||||
|
|||||||
+18
-1
@@ -5,6 +5,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.KeyStroke;
|
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");
|
JMenuItem open = new JMenuItem("Open");
|
||||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
w.getAgenda().loadAgenda();
|
w.getAgenda().loadAgenda();
|
||||||
|
Window.updatePanel("table");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,13 +68,17 @@ public class MenuBar extends JMenuBar {
|
|||||||
save.addActionListener(new ActionListener() {
|
save.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
w.getAgenda().saveAgenda();
|
w.getAgenda().saveAgenda();
|
||||||
|
Window.updatePanel("table");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
JMenuItem exit = new JMenuItem("Exit");
|
||||||
exit.addActionListener(new ActionListener() {
|
exit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
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(newArtist);
|
||||||
file.add(newStage);
|
file.add(newStage);
|
||||||
file.addSeparator();
|
file.addSeparator();
|
||||||
|
file.add(newAgenda);
|
||||||
|
file.addSeparator();
|
||||||
file.add(open);
|
file.add(open);
|
||||||
file.add(save);
|
file.add(save);
|
||||||
file.addSeparator();
|
file.addSeparator();
|
||||||
|
|||||||
@@ -210,5 +210,10 @@ public class Window extends JFrame {
|
|||||||
return agenda;
|
return agenda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAgenda(Agenda a)
|
||||||
|
{
|
||||||
|
agenda = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user