Andrew said:
I have difficulty seeing the HTML formatted text
in the sample code you did not supply as well ivang..
<
http://www.physci.org/codes/sscce.jsp>
It must be something going around, my
telepathy is all clogged up. :-(
I have difficulty seeing the HTML formatted text
in the sample code you did not supply as well ivang..
<
http://www.physci.org/codes/sscce.jsp>
It must be something going around, my
telepathy is all clogged up. :-(
my apologies!
the code is pretty straight forward:
public class MyDialog extends JDIalog {
private JTable tbl;
private MyTableModel tblModel;
***
tblModel = new MyTableModel();
tbl = new JTable(tblModel);
tbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
***
private class MyTableModel extends AbstractTableModel {
private List items;
public ApplicationTemplatesTableModel() {
items = new ArrayList();
// test objects
Item i1 = new Item("name1", "value1");
Item i2 = new Item("name2", "<html>value1</html>");
items.add(i1);
items.add(i2);
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount() {
return 2;
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getRowCount()
*/
public int getRowCount() {
if(items == null) {
return 0;
}
return items.size();
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
public Object getValueAt(int rowIndex, int columnIndex) {
Items item = (Item)aitems.get(rowIndex);
switch(columnIndex) {
case (0) : {
return item.getName();
}
case (1) : {
return item.getValue();
}
}
return null;
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getColumnName(int)
*/
public String getColumnName(int col) {
switch(col) {
case 0: {
return "name"; }
case 1: {
return "value";
}
}
return null;
}
}
}
so if in the test object i2 i put value not '<html>value1</html>' but
'@<html>value1</html>' then this string is displayed in the table.
otherwise the column 'value' for this row is empty.