• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JTable scrolling

 
Dilip kumar
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
 
Paul Smiley
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic