Java JTable Data tableColumnValueAlign(JTable table, int column, int align)

Here you can find the source of tableColumnValueAlign(JTable table, int column, int align)

Description

table Column Value Align

License

Open Source License

Parameter

Parameter Description
table a parameter
column a parameter
align RIGHT | CENTER | LEFT [0, 1, 2]

Declaration

public static void tableColumnValueAlign(JTable table, int column, int align) 

Method Source Code

//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);
    }
}

Related

  1. retrieveSelectedValuesFromTable(JTable table, int column)
  2. selectRows(JTable table, String[] values, int column)
  3. selectValueInTable(JTable table, String value, int column)
  4. setModelValueAt(JTable table, Object value, int row, String columnTitle)
  5. setValueAt(JTable table, Object value, int row, String columnTitle)
  6. updateTable(Object value, int rowId, int columnId, JTable table)