Page Index Toggle Pages: 1 [2] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Jplanner Scheduler java timetable (Read 23785 times)
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #15 - Apr 4th, 2019 at 10:36am
Print Post  
so what is wrong with this?

Code (Java)
Select All
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.
  

without_sout.PNG ( 57 KB | 214 Downloads )
without_sout.PNG
with_sout.PNG ( 14 KB | 179 Downloads )
with_sout.PNG
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Jplanner Scheduler java timetable
Reply #16 - Apr 4th, 2019 at 11:07am
Print Post  
See the difference in day names in header - that's either a different month or a different year. Leave it displaying the full date as in tutorial to verify. Our DateTime constructor type expects the natural date values and not zero-based ones, so make sure you adjust values from your DB if they are zero-based.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #17 - Apr 4th, 2019 at 11:16am
Print Post  
what do you mean by zero based?
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #18 - Apr 4th, 2019 at 11:16am
Print Post  
as in 04/04/2019?
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Jplanner Scheduler java timetable
Reply #19 - Apr 4th, 2019 at 11:22am
Print Post  
Zero based would be January = 0, or first day of month = 0, or year counting starting from 0, while DateTime constructor expects counts starting from 1. So new DateTime(2019,4,4) is today's date and equals (DateTime.today()) should give you true. So check if your recordset is actually returning today's or this week's values (judging by day names in second screenshot they aren't from this month at all), and if some of your DB columns is zero-based (maybe month), make sure you add 1 to the value before passing to DateTime.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #20 - Apr 4th, 2019 at 11:27am
Print Post  
They returned as true, they dont start from zero but it does go 01 for january for example, that should be fine right?
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #21 - Apr 4th, 2019 at 11:29am
Print Post  
Do I even need an Appointment then? it doesnt seem like it does anything.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #22 - Apr 4th, 2019 at 11:36am
Print Post  
I tried to adapt mine to tutorial 1 but it still does nothing ;/
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Jplanner Scheduler java timetable
Reply #23 - Apr 4th, 2019 at 11:37am
Print Post  
Appointment is the green box from your last screenshot, you decide if you want it or not. However the day names there show the dates you add aren't from same month or year (e.g. 4th = Monday, 3rd = Wednesday obviously aren't dates from same month). You will need to add appointments on same dates as the dates added to timetable settings if you want to see them.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #24 - Apr 4th, 2019 at 11:42am
Print Post  
I've gotten somewhere, it's now correctly showing the appointment but still showing the day twice, how do I do this please? I literally have 10 mins to work on this.
  

progress.PNG ( 28 KB | 178 Downloads )
progress.PNG
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Jplanner Scheduler java timetable
Reply #25 - Apr 4th, 2019 at 11:44am
Print Post  
try calling timetableSettings.setHeaderDateFormat("MMM dd, yyyy") to show full dates in header, while keeping your calendar.getTimetableSettings().getDates().add(dt) calls - this should show the full dates of appointments you create. If they are not in current week, it should explain why you are not seeing them when add(dt) is missing. Otherwise it's shown twice because you also add dt2 as a column, which is same date.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #26 - Apr 4th, 2019 at 11:52am
Print Post  
Hi, this is what I go when I put it in the format "dd MM yyy"
  

result.PNG ( 6 KB | 175 Downloads )
result.PNG
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #27 - Apr 4th, 2019 at 11:55am
Print Post  
I need to have d2 to declare end time dont I?
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Jplanner Scheduler java timetable
Reply #28 - Apr 4th, 2019 at 11:56am
Print Post  
So now make sure you have yesterday in the dates you add to timetable settings, remove the add(dt/dt2) lines, and you should see this appointment show correctly once. Otherwise since the dates you initially add start from today, you won't see yesterday's appointment when add(dt) is missing.
  
Back to top
 
IP Logged
 
robert_v
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Apr 2nd, 2019
Re: Jplanner Scheduler java timetable
Reply #29 - Apr 4th, 2019 at 12:00pm
Print Post  
It actually worked?!!?! I was so close to this to begin with fml. Thanks so much, with 1 min to spare as well.

Absolute legend.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint