Here you can find the source of tableColumnValueAlign(JTable table, int column, int align)
Parameter | Description |
---|---|
table | a parameter |
column | a parameter |
align | RIGHT | CENTER | LEFT [0, 1, 2] |
public static void tableColumnValueAlign(JTable table, int column, int align)
//package com.java2s; //License from project: Open Source License import javax.swing.JTable; import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; public class Main { /**/*from w w w .ja va2s. c om*/ * * @param table * @param column * @param align RIGHT | CENTER | LEFT [0, 1, 2] */ public static void tableColumnValueAlign(JTable table, int column, int align) { DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer(); rightRenderer.setHorizontalAlignment( align == 0 ? SwingConstants.RIGHT : align == 1 ? SwingConstants.CENTER : SwingConstants.LEFT); table.getColumnModel().getColumn(column).setCellRenderer(rightRenderer); } }