craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Events/Actions Post New Topic   Post A Reply
listen for row selection change printer friendly version
next newest post | next oldest post
Author Messages
rafalele
Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, August 19, 2004 @ 02:17:11  

Hello,
First of all thanks for all your answers.
I want to control the change of the selected row, by a mouse click , keyboard or controlpane buttons.

Thanks in advance.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Friday, August 20, 2004 @ 22:36:44  

I didn't understand you question. Currently you can already control the selected row using mouse click, keyborad & controlpane. If you want to manually programtically select a row call setSelectedRows(rowstart, rowEnd);
rafalele
Unregistered
Edit or delete this message Reply w/Quote
Posted Sunday, August 22, 2004 @ 09:10:46  

Hi,

What I want is to know when user changes the selected row in every manner, (mouse, keyboard or controlpane), because I have a data panel that shows aditional data depending on the grid selected row, and I want to change it automatically when user selects a row in the grid.

Thanks,

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, August 22, 2004 @ 21:05:01  

Code:

javax.swing.JTable table = dBTable1.getTable();
javax.swing.ListSelectionModel rowSM = table.getSelectionModel();
int lastSelectedRow = 0;

rowSM.addListSelectionListener(new javax.swing.event.ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
int currentSelectedRow = table.getSelectedRow();

if( currentSelectedRow == lastSelectedRow || currentSelectedRow == -1 )
return;

//the currently selected row is currentSelectedRow,
//now you can use dBTable1.getValueAt() and get the data in different columns of this row

lastSelectedRow = currentSelectedRow;
}
});


Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios