• 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

Flashing a particular row in JTable

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthick, please UseOneThreadPerQuestion. We'll stick to your own thread for this question.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any chance you would post the code to show the row flashing? Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic