Atom Feed SITE FEED   ADD TO GOOGLE READER

An obvious extension to JScrollPane

The JTable is a large abuser of the JScrollPane. Out-of-the-box, JTable doesn't have a header. Only when you add it to a JScrollPane does it get its header, which gets stuffed into the JScrollPane's top track so that it is not scrolled. This is a hack. But it works. When you scroll down in your JTable, the header doesn't scroll off the screen. It's clever, but it bites many a programmer in the ass when they try to customize the JTable. For example, when you have an overly wide JTable and you scroll it horizontally, the header isn't in a scroll track so it doesn't scroll quite right.

And now, for another similar hack. The fine hackers at JDNC have decided to support column-locking. This allows you to lock the leftmost column in place, and horizontally scroll through the rest of the columns. The idea is exactly the same as for headers, but it uses a locked column as a row-header. In their bizarre implementatio, they use 2 JTables! One table is outside of the JScrollPane and the other is inside. Then when you scroll, you only scroll half the table. This is again very clever and will bring many a programmer to their knees when it comes time to debug how it all works.

So my obvious question is this: why hasn't anyone at Sun come up with the idea of building a better JScrollPane that just allows for a locked section? All you'd need to do is explicitly specify how much of the left or top to lock, and the rest would be automatic. For JTable, the locked amount would be the header's height. For JDNC, it would be the locked column's width.

I think it's time to write another email to JDNC to tell them how to do their jobs better!
Well according to the guys from sun (in there chat session today) mentioned just this. However, for Java 1.6 (aka Java 6), the idea of column locking sits below some other features that have been requested first.

So, I would expect to see table sorting, filtering, and highlighting in 1.6 and perhaps column locking by 1.7