Results 1 to 1 of 1
- 03-21-2011, 03:42 PM #1Member
- Join Date
- Mar 2011
- Rep Power
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?
- By ahmed80 in forum New To JavaReplies: 2Last Post: 01-07-2011, 12:29 PM
- By bhatti in forum NetworkingReplies: 0Last Post: 12-22-2010, 04:46 PM
- By chyrl in forum AWT / SwingReplies: 9Last Post: 05-05-2010, 05:33 PM
- By dejos456 in forum New To JavaReplies: 9Last Post: 11-30-2009, 08:11 AM
- By conv_bay in forum New To JavaReplies: 10Last Post: 04-28-2009, 12:34 AM