HTML tags in JTable

I

ivang

Hi, I am having difficulty displaying html formatted text (or simple web
page source) in a JTable...a row with such a source is empty while
other rows have the appropriate values. If I add '@' at the beginning of
HTML for instance - then there is no problem seeing the value in JTable.
 
A

Andrew Thompson

Hi, I am having difficulty displaying html formatted text

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. :-(

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
I

ivang

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top