• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Painting an entire line in jtable.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We usually discuss such tables on the GUIs forum: moving discussion.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic