Article View: borland.public.jbuilder.java.swing
Article #1441JTable how to go to the top
From: 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);
}
Technical Details
Message-ID:
<67d8e1e3.0311191937.6a11fe85@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,bdbe1f953768bbd7,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-11-19 19:37:00 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: kelvinq415@yahoo.com (kelvinq) Newsgroups: borland.public.jbuilder.java.swing Subject: JTable how to go to the top Date: 19 Nov 2003 19:37:00 -0800 Organization: http://groups.google.com Lines: 26 Message-ID: <67d8e1e3.0311191937.6a11fe85@posting.google.com> NNTP-Posting-Host: 203.134.5.83 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1069299420 21094 127.0.0.1 (20 Nov 2003 03:37:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 20 Nov 2003 03:37:00 +0000 (UTC)