• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Jason Richard
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 21869
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!