-
Notifications
You must be signed in to change notification settings - Fork 0
/
MonthlyTasksFrame.java
76 lines (66 loc) · 1.79 KB
/
MonthlyTasksFrame.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.awt.*;
import java.util.*;
import javax.swing.*;
/*
* A view
* Displays all the tasks in a month in a window
*/
public class MonthlyTasksFrame {
private Data model;
private JFrame frame;
public MonthlyTasksFrame(Data m) {
model = m;
makeAFrame();
frame.setVisible(false);
}
public void makeNewFrame() {
frame.setVisible(false);
makeAFrame();
}
public void makeAFrame() {
frame = new JFrame("Monthly Tasks");
/*
* Label displaying month
*/
JLabel month = new JLabel(model.getCurrentDay().getMonth() + "'s To Do List:");
month.setFont(new Font("Times New Roman", Font.ITALIC, 18));
/*
* List displaying monthly tasks
*/
DefaultListModel listModel = new DefaultListModel();
String content = "";
Iterator<Day> iterDay = model.getDays();
Day temp = null;
while (iterDay.hasNext()) {
temp = iterDay.next();
if(temp.getYear() == model.getCurrentDay().getYear()) {
if (temp.getMonth().equals(model.getCurrentDay().getMonth())) {
Iterator<String> iterString = temp.getTasks();
while (iterString.hasNext())
listModel.addElement(iterString.next());
}
}
}
JList list = new JList(listModel);
JScrollPane scrollPane = new JScrollPane(list);
list.setFont(new Font("Times New Roman", Font.PLAIN, 18));
scrollPane.setPreferredSize(new Dimension(225, 290));
JPanel listPanel = new JPanel();
listPanel.setBackground(Color.ORANGE);
listPanel.add(scrollPane);
/*
* Add components to frame
*/
frame.setLayout(new BorderLayout());
frame.add(month, BorderLayout.NORTH);
frame.add(listPanel, BorderLayout.CENTER);
/*
* Frame settings
*/
frame.setSize(250, 350);
frame.setLocation(1200, 275);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
}