File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Jscrollpane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jscrollpane" Watch "Jscrollpane" New topic


Vijay Ram

Joined: Feb 02, 2004
Posts: 4
I have a swing applet that contains a JTable within a JScrollpane. As the data is added at the end i need the new records to be visible. For this I set my TableModel listener move the scrollpane accordingly. But i always find that the table displays upto to last but one row. On clicking the scrollpane i find that i can see one more row at the bottom. My code is as below. Am i missing something or going wrong some where?
public void tableChanged(javax.swing.event.TableModelEvent event) {
if (event.getType() != TableModelEvent.INSERT) { return; }
final int row = event.getLastRow();
table.scrollRectToVisible(table.getCellRect(applet.table.getRowCount(), 0, true));
// i tried different variations of the last statement like
using setRowselection() before the statement.
using table.scrollRectToVisible(new Rectangle(0,table.getRowHeight()*(row),c.getWidth(),table.getRowHeight()));
Appreciate your comments.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: Jscrollpane
It's not a secret anymore!