Can I have a look at your code?
For example, in this simplest example, nothing is wrapped:
public class TableTest {
public static void main(String[] args) {
JFrame frm = new JFrame();
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return 10;
}
public int getRowCount() {
return 10;
}
public Object getValueAt(int row, int col) {
return new String(
"<a href=\"127.0.0.1\">row*col*1000000000</a>");
}
};
JTable table = new JTable(dataModel);
table.getColumnModel().getColumn(2).setMaxWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setMinWidth(120);
frm.getContentPane().add(table);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setPreferredSize(new Dimension(300, 300));
frm.pack();
frm.setVisible(true);
}
}
Edited by @latata strong> You can try to create your own CellRenderer and play with it by applying it to the desired column:
table.getColumnModel().getColumn(0).setCellRenderer(new NonWrappedCellRenderer());
Renderer might look like this:
class NonWrappedCellRenderer extends JTextArea implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
this.setText((String)value);
this.setLineWrap(false);
return this;
}
}
Here the line will not be wrapped since JTextArea uses by default
setLineWrap(false)
, JTextArea html, . - . JTextPane - , , wrapping.
, .