List of utility methods to do JTable Column
StringBuffer | getColumnData(final JTable table, final int iSelectedRow) get Column Data final int iColumnCount = table.getColumnCount(); final StringBuffer sb = new StringBuffer(); for (int iColumn = 0; iColumn < iColumnCount; iColumn++) { sb.append(table.getValueAt(iSelectedRow, iColumn)); sb.append("\t"); return sb; |
int | getColumnIndex(JTable table, String columnTitle) get Column Index int columnCount = table.getColumnCount(); for (int column = 0; column < columnCount; column++) { if (table.getColumnName(column).equalsIgnoreCase(columnTitle)) { return column; return COLUMN_NOT_FOUND; |
int | getColumnIndexFromName(TableModel tableModel, String columnToRemove) get Column Index From Name for (int columnIndex = 0; columnIndex < tableModel.getColumnCount(); columnIndex++) { if (tableModel.getColumnName(columnIndex).equals(columnToRemove)) { return columnIndex; return -1; |
String[] | getColumnNames(TableModel tableModel) get Column Names int size = tableModel.getColumnCount(); String[] columnNames = new String[size]; for (int i = 0; i < size; i++) { columnNames[i] = tableModel.getColumnName(i); return columnNames; |
String | getColumnOrder(final JTable table) Returns the column order of a table in a formatted String . StringBuilder buffer = new StringBuilder(); int count = table.getColumnCount(); for (int i = 0; i < count; i++) { if (i > 0) { buffer.append(' '); buffer.append(table.convertColumnIndexToModel(i)); return buffer.toString(); |
List | getColumns(TableColumnModel columnModel) get Columns List<TableColumn> tablecolumns = new ArrayList<TableColumn>(columnModel.getColumnCount()); for (int columnIndex = 0; columnIndex < columnModel.getColumnCount(); columnIndex++) { tablecolumns.add(columnModel.getColumn(columnIndex)); return tablecolumns; |
void | getMultiLineColumnNames(String[] ret) get Multi Line Column Names int maxNbLines = 1; for (int i = 0; i < ret.length; i++) { String s = ret[i]; s = s.trim(); s = s.replaceAll(" ", " "); ret[i] = s; maxNbLines = Math.max(ret[i].split(" ").length, maxNbLines); for (int i = 0; i < ret.length; i++) { String[] split = ret[i].split(" "); StringBuilder builder = new StringBuilder(); builder.append("<html>"); for (int line = 0; line < maxNbLines; line++) { if (line > 0) { builder.append("<br>"); if (line < split.length) { builder.append(split[line]); ret[i] = builder.toString(); |
int | getRealColumnPos(int colPos, JTable table) get Real Column Pos return table.convertColumnIndexToModel(colPos);
|
Component | getRenderedComponentAt(JTable table, int row, int column) get Rendered Component At return table.getCellRenderer(row, column).getTableCellRendererComponent(table,
table.getValueAt(row, column), table.isCellSelected(row, column), false, row, column);
|
TableColumn | getTableColumn(JTable table, int columnIndex) get Table Column if (table == null) { throw new NullPointerException(); String columnName = table.getColumnName(columnIndex); if (columnName == null) { return null; TableColumn column = table.getColumn(columnName); ... |