Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages
Started by kelvinq
Thu, 20 Nov 2003 03:37
JTable how to go to the top
Author: kelvinq
Date: Thu, 20 Nov 2003 03:37
Date: Thu, 20 Nov 2003 03:37
26 lines
1816 bytes
1816 bytes
This Byzantine mumbo-jumbo will scroll a JTable to the top
(with thanks to Java Developers Almanac)
Just proves my point that Java has been hijacked by obsessive Computer
science types.
Frankly, I would be ecstatic if I never heard anyone mumbling
"Model.... View....." ever again.
I dont want a model nor a view, I just want to manipulate some data...
anyway heres the code:
// Assumes table is contained in a JScrollPane.
public void scrollToTop(JTable table, int rowIndex, int
vColIndex) {
if (!(table.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport)table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex,
true);
Rectangle viewRect = viewport.getViewRect();
int bigfatoffset = 200;
rect.setLocation(rect.x-viewRect.x , rect.y-viewRect.y -
bigfatoffset ) ;
viewport.scrollRectToVisible(rect);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads