I have found a way to allocate the cell in a table, which seems to be a Component
JTable table = new JTable(...)
{
public Component prepareRenderer(
TableCellRenderer renderer, int row, int column)
{
Component c = super.prepareRenderer(renderer, row, column);
// add custom rendering here
return c;
}
};
In the code, c is the Component, but I cannot find a method in Component to modify text alignment. Anything wrong about this approach?
Use
DefaultTableCellRendererfor that purposes, it hassetHorizontalAlignment()method :COLUMNis target column,conditionis condition for switching.