Problems with Shift select in Jtable
I want to get a situation where if a user holds down shift key and elects between two boolean check boxes shown in a Jtable it will check all the in between check boxes.
At the moment I have a messy solution where the class implements the KeyListener which toggles a boolean value when the shift key is pressed or released.
Then the Jtable (which the check box is in) has the addTableModelListener, which over writes the table Changed method to look at the e.getFirstRow() function to find the row number of the table, and depending on whether or not the boolean flag for the Shift value is true or false will choose whether to select the in between rows.
As I said before this is messy and doesn't work perfectly. (i.e. if already selected it doesn't toggle or if new selections are made etc.).
As the Shift function is quite a big function I was wondering if anyone knows of an easier way. I.e. different classes to implement or where to find similar solutions. I have already had a look around but couldn't find much.
Hope I have explained it clear enough
Thanks in advance,
I suppose it may be worth mentioning that when the shift key is held and two points are selected the first and last point are check (assuming user selects the check boxes). But the others in between are just highlighted - what I need is a way for these to also to be checked when highlighted.