-
Notifications
You must be signed in to change notification settings - Fork 0
/
todoListView.java
80 lines (55 loc) · 2.19 KB
/
todoListView.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
77
78
79
80
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import java.util.Date;
public class TodoListView extends JPanel{
public TodoListView(TodoList list){
this(Calendar.getInstance(), list);
}
public TodoListView(Calendar date, TodoList list){
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
setFont(getFont().deriveFont(18.0f));
Calendar min = Calendar.getInstance();
min.setTime(new Date(Long.MIN_VALUE));
Calendar today = (Calendar)date.clone();
today.set(Calendar.HOUR, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
Calendar tomorrow = (Calendar)today.clone();
tomorrow.add(Calendar.DATE, 1);
Calendar afterTomorrow = (Calendar)tomorrow.clone();
afterTomorrow.add(Calendar.DATE, 1);
Calendar nextWeek = (Calendar)today.clone();
nextWeek.add(Calendar.DATE, 7);
Calendar max = Calendar.getInstance();
max.setTime(new Date(Long.MAX_VALUE));
ListView allView = new ListView(list);
ListView pastView = new ListView(list.filterByDate(min,today));
ListView todayView = new ListView(list.filterByDate(today,tomorrow));
ListView tomorrowView = new ListView(list.filterByDate(tomorrow,afterTomorrow));
ListView weekView = new ListView(list.filterByDate(today,nextWeek));
ListView futureView = new ListView(list.filterByDate(today,max));
add(new Label("All"));
add(allView);
add(new Label("Past"));
add(pastView);
add(new Label("Today"));
add(todayView);
add(new Label("Tomorrow"));
add(tomorrowView);
add(new Label("This Week"));
add(weekView);
add(new Label("Future"));
add(futureView);
Button addNewItem = new Button("Add New Item");
addNewItem.setBackground(new Color(127,255,127));
addNewItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame window = new NewItemMenu();
}
});
add(addNewItem);
}
}