JScrollPane and GridBagLayout combination
I'm developing a planner-like application, and on the road to make it comply with the requirements given, I've been stuck on a problem for a while.
I need to make a UI that has the weekdays on top, the hours to the left and columns under each day in the middle. I need to be able to insert events into these columns that can stretch several hours and also be able to show events that happen at the same hour.
I was thinking I could use GridBagLayout with the hours to the left downwards, with gridx=0 and y incrementing from 1, column headers along the top with y=0 and x incrementing from 1 with each column with events stretching underneath to the bottom (see screenshot).
I would like the weekdays to stay stationary when I scroll. Is it possible?
I've tried JTable to mimic this behaviour, but straight off the bat with JTable, I can't add several events next to each other on the same hour and day. I've also tried JTable with a JPanel as a custom TableCellRenderer, so that I can add items to this and thus have several events, but that solution won't be able to stretch across cells, which I need if an event is longer than 1 hour.
When I tried to have the column headers as a separate JPanel and have it as a ColumnHeaderView in a JScrollPane, I was unable to align the columns below the headers with the headers, and also the hours were not aligned correctly to the left.
So, do you have any ideas on how to solve this in another way or any tips on how to either a): set the headers stationary when I scroll or b): align the headers with the columns, so that I can use them as a ColumnHeaderView?