• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Problem with JTable scrolling

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perfect Guess. I fixed it. Thanks for the hint.
Dilip
 
reply
    Bookmark Topic Watch Topic
  • New Topic