Advanced Swong jTable cells
- From: vachacz <vachacz@xxxxxxxxx>
- Date: Sat, 21 Jul 2007 18:47:30 -0000
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
.
- Follow-Ups:
- Re: Advanced Swong jTable cells
- From: Roedy Green
- Re: Advanced Swong jTable cells
- From: vachacz
- Re: Advanced Swong jTable cells
- Prev by Date: JP Morgan Investment Bank is urgently recruiting all level of Java Developers, Database and Solaris administrators
- Next by Date: Re: Advanced Swong jTable cells
- Previous by thread: JP Morgan Investment Bank is urgently recruiting all level of Java Developers, Database and Solaris administrators
- Next by thread: Re: Advanced Swong jTable cells
- Index(es):
Relevant Pages
|
|