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: Compare 2 sets of data
    ... If you want to compare column A with F, you have to be positioned in Column ... F, go to conditional formating, enter where the cell vallue is not equal to ... range is different from the second set or Disability Code is different and so ...
    (microsoft.public.excel.worksheet.functions)
  • RE: comparing componants of tables
    ... jimbo, I have to make several assumptions to provide this solution. ... Second assumption, when you do comparisons, you're wanting to compare one ... weights, and not weight for one person to belt size for someone else. ... Here is the basic formula that I placed into cell B18 of this comparison ...
    (microsoft.public.excel.newusers)
  • 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)