Use a custom TableCellRenderer
, and specify setHorizontalAlignment(JLabel.RIGHT)
. There's a related example here that illustrates JLabel.CENTER
.
Addendum: My problem is padding and not alignment.
If you want the padding inside the cell, rather than between cells, you can use a border in the renderer, as @Guillaume Polet suggests. Note that the border can be asymmetric; the example below pads only on the right.
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));