I have a JTable, with editable fields. The following code works:
protected JTable m_table;
protected MyTable m_data;
m_data = new VIPTable(this, title);
m_table = new JTable();
for (int k = 0; k < MyTable.m_columns.length; k++) {
DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
textRenderer.setHorizontalAlignment(MyTable.m_columns[k].m_alignment);
TableCellRenderer renderer = textRenderer;
TableCellEditor editor;
if (k==MyTable.COL_CATEGORY)
editor = new DefaultCellEditor(new JComboBox(MyTable.CATEGORIES));
else
editor = new DefaultCellEditor(new JTextField()); // error with JTextArea
TableColumn column = new TableColumn(k, MyTable.m_columns[k].m_width,
renderer, editor);
m_table.addColumn(column);
}
I now want to make the text fields multi-line, so I tried to replace JTextField with JTextArea. But there is no constructor for DefaultCellEditor(JTextArea).
So: how to code a editable multi-line field in a JTable?
Note: I also looked at the solution in PopupEditor, but that has the same problem when I replace JTextField with JTextArea.