Advanced Swong jTable cells



Hi !

I'm writing swing application that shall compare differences between
objects. I have a jTable, and its every row represents one entity. In
database i have corresponding states of that object and it is possible
to show differences between these states in table cells. I have my own
table model

public Object getValueAt(int rowNumber, int columnNumber) {
if (rowNumber < 0 || rowNumber >= getRowCount())
return "";

Object obj = objectList.get(rowNumber);

switch (columnNumber) {
....
case 2:
return obj.getSomeValue()
...
case x:
return new
ComparableValues(obj.getSomValue(), value to compare with);
}
}

I also have specific TableCellRenderer attached to column, it acts
like this

class MyCellRenderer extends DefaultTableCellRenderer {

public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);

if (value instanceof ComparableValues) {
// cast
setText("(" + value.getDifference() +
" )" + value.getOriginalValue())
}
}
}

Everything works great, but i would like to improve cell design ...

Q1) How to use more than one text color in cell ?
Q2) How to use many font sizes in one cell ?

I have one idea but i don't like it ;) (MyTableCellRendere extends
JLabel and use html as a content ... )

in advance, thx for any help

.



Relevant Pages

  • Help with difference in time macro
    ... First of all I want to say this is my first time here and I am on my ... Compare H with system date and insert the difference in "I" ... the background of the cell should be colored in RED. ... This is based on a 24/5 clock (meaning it does not include Saturday and ...
    (microsoft.public.excel.programming)
  • Re: How to sort/update large excel db
    ... in a cell, save the ss, close, reopen, and the data was in a different cell. ... first, don't sort while the ss is filtered, this will hang your ... > to try for a cleaner sheet to compare to the current one. ... > You'll see True if it appears on that other worksheet. ...
    (microsoft.public.excel.misc)
  • Re: Convert "Time Interval" in "hours : minutes : seconds" to seco
    ... > calculation on that cell. ... >>> service providers available to me. ... >>> provider and I wish to compare the cost of each call if I had used ...
    (microsoft.public.excel.newusers)
  • Re: Loopy question
    ... Dim rng3 As Range, rng4 As Range ... > store the value in cell D2 as a temporary variable, ... > separate the each set of 60 lines, so the cursor ... > there would be only four values to compare with the ...
    (microsoft.public.excel.programming)