• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Flashing a particular row in JTable

 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my application I have a JTable. When ever a new row is getting added to that JTable I need to flash that new row for some defined period say some 5 minutes with alternate colors and once the 5 minute expires, we need to set the color back to white.

Can some one give some idea how to proceed with this. Thanks in advance for the same.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm.. I would think in terms of using a pair of javax.swing.Timer instances, the first to flip a flag for the flashing and the second to stop the first after 5 minutes, and override prepareRenderer to do the actual color changes for "flashing".

What have you tried so far?
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the late reply!!!

Even I got the same idea yesterday. I tried it out it works!!

Thanks a lot
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karthick Dharani Vidhya:
Sorry for the late reply!!!

Even I got the same idea yesterday. I tried it out it works!!

Thanks a lot


I'm looking to something similar, although with fading in/fading out rather than flashing. I'm curious how you approached this problem. Can you provide a quick summary of what you did?

Thanks,
Dave
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave

For fading you would want to gradually change the color in each cycle of a Timer. One relatively easy way to do this is by altering the alpha component of the color.

Might take some tweaking to get it right, so why don't you read up on javax.swing.Timer, JTable#prepareRenderer, java.awt.Color then try something and post a SSCCE if the result isn't exactly what you wanted it to be.
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Darryl Burke:
Hi Dave

For fading you would want to gradually change the color in each cycle of a Timer. One relatively easy way to do this is by altering the alpha component of the color.

Might take some tweaking to get it right, so why don't you read up on javax.swing.Timer, JTable#prepareRenderer, java.awt.Color then try something and post a SSCCE if the result isn't exactly what you wanted it to be.


I've used the Java TimingFramework and the SwingX project for fading so I'm not too concerned about that, it's more the actual JTable customization part that I'm more curious in.

In particular, I first thought about using a custom TableCellRenderer, but that doesn't appear to be a clean solution given that the TableCellRenderer renders based on the column type. In this case I need to render across all the columns.

In the SwingX project the developers there have come up with a "highlighter" for JTables which is what I'm currently working with (I've already posted some questions in the Swinglabs forum). I'm just curious what approaches others have used.

Thanks,
Dave
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I too used the same thing what Darryl Burke explained above. If you still need me to tell I can. Do you want me to tell?

Can you give me any solution for the below problem?

I have a JTable in application. One cell in my table in editable. That cell will take integer as value. Say if some one has entered '10' in that cell. If someone wants to change that 10 to 30 (or something else), once that user selects that cell and start typing 30 what is happening is 30 gets appending to the previously entered 10 and becomes 1030. Once if some one selects that paricular cell and starts entering new value it should override the existing value instead of just getting appended with it.

Any clue on this?

Thanks in advance for the same.
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthick, please UseOneThreadPerQuestion. We'll stick to your own thread for this question.
 
Erich Roth
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any chance you would post the code to show the row flashing? Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic