• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jscrollpane

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reply
    Bookmark Topic Watch Topic
  • New Topic