Java examples for Swing:JTable Column
align JTable column Center
//package com.java2s; import javax.swing.JTable; import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; public class Main { public static void align_column_to_Center(JTable tbl, int col) { tbl = new JTable() { DefaultTableCellRenderer renderRight = new DefaultTableCellRenderer(); {//initializer block renderRight.setHorizontalAlignment(SwingConstants.RIGHT); }//from w w w. j a va 2s. co m @Override public TableCellRenderer getCellRenderer(int arg0, int arg1) { return renderRight; } }; } }