my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Flashing a particular row in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Flashing a particular row in JTable" Watch "Flashing a particular row in JTable" New topic
Author

Flashing a particular row in JTable

Karthick Dharani Vidhya
Ranch Hand

Joined: Feb 23, 2008
Posts: 89
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.


Karthick D V
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

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?


luck, db
There are no new questions, but there may be new answers.
Karthick Dharani Vidhya
Ranch Hand

Joined: Feb 23, 2008
Posts: 89
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

Joined: Mar 25, 2004
Posts: 82
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

Joined: May 03, 2008
Posts: 4664
    
    5

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

Joined: Mar 25, 2004
Posts: 82
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

Joined: Feb 23, 2008
Posts: 89
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

Joined: Oct 27, 2005
Posts: 19783
    
  20

Karthick, please UseOneThreadPerQuestion. We'll stick to your own thread for this question.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Erich Roth
Greenhorn

Joined: Jul 20, 2009
Posts: 1
Any chance you would post the code to show the row flashing? Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Flashing a particular row in JTable