so what is wrong with this?
public class revisionPlannerUI extends JFrame {//extends JFrame creates new window, extends inherits from the parent class
public static Calendar calendar = new Calendar();//declare new calendar
public revisionPlannerUI() throws ParseException, ClassNotFoundException {
initComponents();//initialise NetBeans drawn components
calendar.setTheme(ThemeType.Light);//set calendar theme
calendar.setCurrentView(CalendarView.Timetable);//set calendar type
Container cp = jPanel2;//set container to the Jpanel I drew in NetBeans design
cp.setLayout(new BorderLayout());
cp.add(calendar, BorderLayout.CENTER);
for (int i = 0; i < 7; i++) {
calendar.getTimetableSettings().getDates().add(DateTime.today().addDays(i - 1));//display 7 columns to show 1 week
}
calendar.getTimetableSettings().setStartTime(8 * 60); //start timetable from 8am
calendar.getTimetableSettings().setItemOffset(30);//30 mins between each interval
calendar.getTimetableSettings().setShowItemSpans(true);
calendar.getTimetableSettings().setSnapInterval(Duration.fromMinutes(1));//interval at which
calendar.getTimetableSettings().setVisibleColumns(7);
calendar.getTimetableSettings().setShowNavigationButtons(true);
calendar.getTimetableSettings().setScrollStep(7);
getAppointments();
Style style = new Style();
style.setBrush(new SolidBrush(new Color(102, 255, 102)));
DateStyle dStyle = new DateStyle();
calendar.getDayStyles().add(dStyle);
}
public static ArrayList<Item> items = new ArrayList<Item>();
private void getAppointments() throws ParseException,ClassNotFoundException {
try {
String SQL = "SELECT TASKNAME, TASKDATE, STARTTIME, LENGTH, SUBJECTID FROM TIMETABLE WHERE USERID = '" + globals.dbUserID + "'";
Connection con = DriverManager.getConnection(globals.host);
Statement statement = con.createStatement();
ResultSet resSet = statement.executeQuery(SQL);
Style style = new Style();
style.setBrush(new SolidBrush(new Color(102, 255, 102)));
while (resSet.next()) {
Date date = resSet.getDate("TASKDATE");
Time time = resSet.getTime("STARTTIME");
int length = resSet.getInt("LENGTH");
DateTime dt = new DateTime(date.getYear(), date.getMonth()+1, date.getDay()-1, time.getHours(), time.getMinutes(), 0);
DateTime dt2 = new DateTime(date.getYear(), date.getMonth()+1, date.getDay()-1, time.getHours(), time.getMinutes() + length, 0);
System.out.println(date);
System.out.println(dt);
System.out.println(dt2);
System.out.println(calendar.getTimetableSettings().getDates().add(dt));
System.out.println(calendar.getTimetableSettings().getDates().add(dt2));
String taskname = resSet.getString("TASKNAME");
Appointment app = new Appointment();
app.setStartTime(dt);
app.setEndTime(dt2);
app.setHeaderText(taskname);
calendar.getSchedule().getItems().add(app);
}
} catch (SQLException err) {
System.out.println(err);
}
I am pretty sure thats exactly what you have.
Unless I do the
System.out.println(calendar.getTimetableSettings().getDates().add(dt));
System.out.println(calendar.getTimetableSettings().getDates().add(dt2));
then I get nothing in my timetable
even with the above I get one task repeated over 7 days
I added attachments, one with sout and one without
I am approaching near to the final final deadline now so if we cant get it to work I suppose I have to hand this in with it faulty.