A
ashwinijain
I have following class which i am using to set the multiline text in
jtable's cell.
And I want to set the horizonal alignment of cell.
How can i do it?
class MyCellRenderer extends JTextArea implements TableCellRenderer {
public MyCellRenderer() {
setLineWrap(true);
setWrapStyleWord(true);
setPreferredSize(new Dimension(465,340));
setAlignmentY(RIGHT_ALIGNMENT );
}
public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int
column) {
setText((String)value);
setSize(table.getColumnModel().getColumn(column).getWidth(),
getPreferredSize().height);
if (table.getRowHeight(row) != getPreferredSize().height) {
table.setRowHeight(row, getPreferredSize().height);
}
return this;
}
}
jtable's cell.
And I want to set the horizonal alignment of cell.
How can i do it?
class MyCellRenderer extends JTextArea implements TableCellRenderer {
public MyCellRenderer() {
setLineWrap(true);
setWrapStyleWord(true);
setPreferredSize(new Dimension(465,340));
setAlignmentY(RIGHT_ALIGNMENT );
}
public Component getTableCellRendererComponent(JTable table, Object
value, boolean isSelected, boolean hasFocus, int row, int
column) {
setText((String)value);
setSize(table.getColumnModel().getColumn(column).getWidth(),
getPreferredSize().height);
if (table.getRowHeight(row) != getPreferredSize().height) {
table.setRowHeight(row, getPreferredSize().height);
}
return this;
}
}