This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Comparing JTable cells Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Comparing JTable cells" Watch "Comparing JTable cells" New topic
Author

Comparing JTable cells

Frederick Pease
Greenhorn

Joined: Aug 12, 2013
Posts: 3
Is it possible to compare two JTabel cells in the same row, then whichever number is higher in the cell, set that cell's background color green, and the other red?
This is how my table looks right now:
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

Welcome to the Ranch.

Are you using a TableModel to fetch your data? For the cell background color, a cell renderer will do the trick.

Depending on how you set up your classes/data, you may just do something like:



K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing JTable cells
 
Similar Threads
Highlight cell in JTable, even once table has lost focus
Vote on my behaviour
Apache POI
Long Walk to Freedom: The Autobiography of Nelson Mandela
JTextArea in JTable