This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Problem with JTable scrolling

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Jtable scrolls fine (using mouse ) until it reaches end. Afterwards it dumps several error messages on command prompt. Am I missing something ?
public class client implements ListSelectionListener, ActionListener {

public client() {
:
:
model = new FlightTableModel();
FlightTable = new JTable(model);
FlightTable.setBackground(new Color(152,215,225));
FlightTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = FlightTable.getSelectionModel();
rowSM.addListSelectionListener(this);
:
JScrollPane pane = new JScrollPane(FlightTable);
pane.setPreferredSize(new Dimension(600,200));
frame.getContentPane().add (pane, "North");

}

public void valueChanged(ListSelectionEvent e) {
if(e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
int selectedRow = lsm.getMinSelectionIndex();
rowSelected = selectedRow;

}
}
Thanks
Dilip
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the error messages, dude? My guess is that your indices are a bit off and you are attempting to scroll where there are no more data.
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect Guess. I fixed it. Thanks for the hint.
Dilip
 
Space pants. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic