wood burning stoves 2.0*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1958
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing JTable cells
 
Similar Threads
Apache POI
JTextArea in JTable
Long Walk to Freedom: The Autobiography of Nelson Mandela
Vote on my behaviour
Highlight cell in JTable, even once table has lost focus