The list of methods to do JTable Data are organized into topic(s).
int
addMissingRows(DefaultTableModel model, String[] values, int column) For each value in the input array that does not appear in the specified column of at least one of the table model's rows, a new row is added with that value in the specified column and the empty string in the remaining columns.
int numInserted = 0;
if ((values != null) && (model != null)) {
int columnCount = model.getColumnCount();
if ((column >= 0) && (column < columnCount)) {
Set existingValues = new HashSet();
int rowCount = model.getRowCount();
for (int row = 0; row < rowCount; row++) {
existingValues.add(model.getValueAt(row, column));
...
boolean
columnContains(TableModel table, int colIdx, T... values) column Contains
HashSet<T> set = new HashSet<T>();
set.addAll(Arrays.asList(values));
for (int i = 0; i < table.getRowCount(); i++) {
set.remove(table.getValueAt(i, colIdx));
if (set.isEmpty()) {
return true;
return false;
int
findFirstRow(TableModel model, int col, String value) Finds the first row of a TableModel that contains a specific String value in a given column.
String trimmedValue = value.trim();
for (int i = 0; i < model.getRowCount(); i++) {
if (((String) model.getValueAt(i, col)).trim().equals(trimmedValue)) {
return i;
return -1;
String[]
getSelectedValues(JTable table, int column) Returns the value of the specified column for each row currently selected in the table.
String[] selectedValues = new String[0];
if (table != null) {
int columnCount = table.getColumnCount();
if ((column >= 0) && (column < columnCount)) {
int[] selectedRows = table.getSelectedRows();
selectedValues = new String[selectedRows.length];
for (int i = 0; i < selectedRows.length; i++) {
selectedValues[i] = (String) table.getValueAt(selectedRows[i], column);
...
String
getSelectValue(JTable table, String columnName) get Select Value
int row = table.getSelectedRow();
if (row >= table.getModel().getRowCount())
return null;
if (row == -1)
return null;
int column = table.getColumn(columnName).getModelIndex();
String id = (String) table.getValueAt(row, column);
return id;
...