Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable selection  RSS feed

 
angela matos
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I need help with the ListSelectionModel of a Jtable. I'm trying to make a gantt chart with a jtable. The idea is simple the user will be able to select cells in a row and those cells background turn into a blue color. I did this saying that the CellRenderer changes for the selected column and it works. The problem is that when I try to select cells in a another row there are unselected cells that change their background as if they where selected in the previous selected row or in the current row. It seems as if the number of previously selected cells are saved and the previously selected row too. When the mouse is released the selection is supposed to ends and the parameters are reset up how can I do this please?
 
Brian Cole
Author
Ranch Hand
Posts: 936
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
angela matos wrote:The problem is that when I try to select cells in a another row there are unselected cells that change their background as if they where selected in the previous selected row or in the current row.


It sounds like you are using a custom cell renderer and that it's not handling cell selection correctly. Not only must it set the selected background color (blue in your case) when the cell is selected, but it must also set the unselected background color (probably white) when the cell is not selected. That is, the renderer's background color should be set on every single getTableCellRendererComponent() call.
 
angela matos
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help ! I'll try to do what you said.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!