Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



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

Painting an entire line in jtable.  RSS feed

 
Robson Martinz
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I have in my app a JTable. I would like to know how can i do to, when i click in a cell, my jtable paint the entire line of this cell.
Here is what i did.

Method call:


RowRender class:
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your table model is an AbstractTableModel or some subclass of that, then to get a row repainted you call the model's fireTableRowsUpdated method with suitable parameters.
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We usually discuss such tables on the GUIs forum: moving discussion.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you setting the renderer every time a mouse click happens? What are you trying to achieve here?
Check out http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer to understand how to correctly use renderers
 
Robson Martinz
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you setting the renderer every time a mouse click happens? What are you trying to achieve here?

Because i want paint the entire line when a mouse click happens. Why is this wrong?

If your table model is an AbstractTableModel or some subclass of that, then to get a row repainted you call the
model's fireTableRowsUpdated method with suitable parameters.


Yes is an AbstractTableModel. I tried this to see what happens but i got a compilation error.
"Cannot find symbol error.
Symbol method fireTableRowsUpdated"


Mods, please, i accidentally clicked in "Resolved" but this problem is not solved yet!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The model itself may be an AbstractTableModel, but to use its methods you'll need to use a variable which is also an AbstractTableModel. You didn't show us the relevant code but my guess is that jTable1 is a TableModel variable.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also, it would be less, um, old-fashioned if you stopped using mouse listeners and instead redisplay the row when one of its cells is selected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!