Background
I’m building a Java desktop app for booking classrooms at a school. I have a class called ClassroomReservation that stores booking info:
public class ClassroomReservation implements java.io.Serializable {
private int reservationId;
private String classroom, teacherName;
private Date reservationDate;
private int startHour; // like 9 for 09:00
private int finishHour; // like 10 for 10:00
private int classroomId;
// constructors and getters/setters here
}
I load all bookings from the database into a List sorted by date.
What I Need
I want to make a calendar view using JTable that shows a month grid (like Google Calendar). It should have 7 columns for weekdays and rows for each week. Each cell shows a day number and I want to highlight cells that have bookings and show the time range.
The tricky part is mapping my booking list to the right table cells. I need to figure out which row and column each date goes to, plus I have to handle cases where the month doesn’t start on Monday.
My Questions
-
Are there any free Java calendar components that can display monthly grids with custom text in each cell?
-
Has anyone built something similar? Any tips for creating a method that converts dates to table coordinates?