• 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

How can I make a row of a JTable not editable and really stand out

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Here is what I'm trying to do. When I click on a row in a JTable, I want to have a row appear above it. For now I'm just making that row be a duplicate of the row I clicked on, but eventually this will be some sort of previous history of that row, so as you are editing the row you actually clicked on you can look directly above it and see what the data used to look like.

I"m not having any problem creating the row, nor am I having an issue getting it positioned correctly. What I want to do with this added row is made it so you can't edit the entire row, and also really make this row stand out. I'd like to say make this row stand out or "POP" so to speak so there is no confusing what it is. I'd almost like to make it look like the row header or even better. . Most of what I am seeing are ways to make particular cells uneditable, so I think my backup plan is that, but Is there a good way to do what I described?

Thanks in advance for any help. I did not provide any sample code, because I don't have anything not-working, I"m just looking to expand, although I could provide a snipit if somebody things it's necessary.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a couple of ways, depending on how you have set things up. If you have your own table model supporting the JTable, then just override its "isCellEditable(row, column)" method with appropriate code. If you don't, then you could override that method in JTable directly.

If you want to change how cells look, then designing a TableCellRenderer to display different cells in different ways isn't too hard.
 
Get off me! Here, read 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