Reputation: 35
I am trying to create a table within a JTextArea using the contents of a LinkedList. Right now I have:
for(int i = 0; i < commands.size(); i++) {
String row = "<html><table><tr><td>"+commands.get(i)+"</td><td>"+desc.get(i)+"</td></tr></table></html>";
MainConsole.console.textArea.append(row+"\n");
}
However, when it compiles, it remains as plain text: 1
Any tips on getting the table to display?
Thanks in advance.
Upvotes: 0
Views: 61
Reputation: 1127
TextArea is for displaying simple text, use JEditorPane for HTML text
public class TestJEditorPane {
public static void main(String[] args) {
JFrame frame = new JFrame();
JEditorPane pane = new JEditorPane();
pane.setContentType("text/html");
pane.setText("<html><b>Hello World</b></html>");
frame.add(pane);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
Upvotes: 2