While working with code, requirement implemented fine, but there is an issue with this code..
When user clicks on "Check All", all the checkboxes gets selected, But if user un select any of the checkbox from table then ideally "check all" shud gets unselected. But it still remains selected.
please help me on this, Sso I get my things done asap.
You could use a TableModelListener to listen for changes in the table model. Keep in mind that this could cause an infinite loop: checking the check box will change multiple table values, all of which will trigger a check box change. Which could change multiple table values again, etc.
One way to prevent this is only to change the selected state / table model value if it should be changed:
Thats my problem is.
I am explaning the complete scenario once again.
I am using header renderer.
Say in a table i am having 5 rows. So if user selects "select all" check box then all the 5 check boxes gets selected.
and again if user de selects the header checkbox(select all) then all the 5 check boxes gets deselected.
if user selects header checkbox then all the checkboxes gets selected.
After this user deselect any one checkbox from table rows. in this case still header checkbox is shown as selected.
My requirement is, if user deselects any of the checkbox from table rows, then header checkbiox should automatically gets deselected.
Hope, this is the correct information for what you are asking for
In pseudo code
1) You need a listener which will help you figure out if the user has clicked any of the table check boxes
2) Then you need to figure out what is the state of the other check boxes in the table
3) If the click has resulted in unchecking the check box in the table, you need to uncheck the checkbox in the header too.
I used the above code for the first column of my JTable which contains checkboxes. I've set the project UI look&feel as System Look & Feel. But the select all checkbox header displays different than the other header elements after implementing this code. I'm new to Java so can you please explain how to give this custom checkbox header the same UI?