JTable - Can I change the color of the text on a row by row basis?
Hi All,
I'm redoing a bit of old uni coursework (to model a stockmarket, stock ticker server & stock ticker application) to brush up my Java skills (esp Swing and Event Handling) and am programming the UI by hand using Swing (its the only way to learn something....(I've certianly nailed Layout Management!!))
In the stocktickerserver GUI I'm using a JTable to display the details about stocks.
The user can select a stock and view the details of the stock in another frame. In one panel in the JFrame I've got a JTable listing the history items for the stock (Price, Change, Date).
Is it possible to color the rows of the JTable according to the value of the change column (or at least the value I insert there)?
e.g
if (change > 0){
Blue;
else{
if (change < 0){
Red;
}
else{
Green;
}
I'm completly ignorant on how to achieve this (or even if its possible at all) so all your ideas welcome.
Any help much appreciated
Pete
P.S.
The Stock History is a class that I store in a [private] Vector in the Stock Class.
For the selected Stock I loop through this vector getting the items (using various accessor methods)
I extract the values from the return StockHistory object and build a DefaultTableModel from these
Then I call JTable.setModel(theModel) to build the table

