-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduleList.java
More file actions
52 lines (43 loc) · 1.07 KB
/
ScheduleList.java
File metadata and controls
52 lines (43 loc) · 1.07 KB
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
/***************************************************\
| |
| Copyright ©2005, 2006 |
| Michael Cook |
| |
\***************************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ScheduleList extends JList {
String[] noSchedules = {"No schedules"};
public ScheduleList() {
super();
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
clearList();
}
public void setScheduleList(int scheduleCount) {
if (scheduleCount < 1) {
clearList();
} else {
String[] temp = new String[scheduleCount];
for (int i = 0; i < scheduleCount; i++)
temp[i] = "Schedule " + i;
setListData(temp);
}
}
public boolean scheduleSelected() {
if ((String) getSelectedValue() == noSchedules[0])
return false;
else if (getSelectedValue() == null)
return false;
return true;
}
public int getSelectedSchedule() {
if (scheduleSelected())
return getSelectedIndex();
return -1;
}
public void clearList() {
setListData(noSchedules);
clearSelection();
}
}