List of utility methods to do JTable Row
boolean | checkRow(DefaultTableModel table, List Checks if data could be written on the table starting from row .
String[] locations = data.get(1); String[] time = data.get(2); int rows = table.getRowCount(); int cols = table.getColumnCount(); int counter = 0; for (int i = 0; i < locations.length; i++) { if (i - 1 >= 0) { counter += Integer.parseInt(time[i - 1].trim()); ... |
void | clearAllRows(JTable table) clear All Rows DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { tableModel.removeRow(rowCount - i - 1); |
boolean | contains(int row, TableModel model) contains if (model == null) { return false; if (row < 0) { return false; return row < model.getRowCount(); |
void | copyRows(JTable table) copy Rows StringBuffer sb = new StringBuffer(); for (int iSelectedRow : table.getSelectedRows()) { sb.append(getColumnData(table, iSelectedRow)); sb.append("\n"); final StringSelection stsel = new StringSelection(sb.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stsel, stsel); |
String | createDBXMLFile(JTable table, String docField, String rowField, Connection con, boolean reuseConnection, String driver, String dsn, String user, String password, String tableName, String whereString, String orderByString, String groupByString, boolean convertCharsToEntites) create DBXML File String rootElement = docField; String elementName = rowField; StringBuffer toWrite = new StringBuffer(""); toWrite.append("<?xml version=\"1.0\" encoding=\"" + "UTF-8" + "\"?>\n"); toWrite.append("<" + rootElement + ">"); Vector data = getRowsFromDatabase(con, 0, reuseConnection, driver, dsn, user, password, tableName, whereString, orderByString, groupByString); data = removeBadChars(data, convertCharsToEntites); ... |
Object | createThrowableMessage(Throwable t) create Throwable Message JPanel panel = new JPanel(new BorderLayout(12, 12)); panel.add(new JLabel(t.getLocalizedMessage()), BorderLayout.NORTH); JTextArea stackTrace = new JTextArea(); stackTrace.setForeground(Color.red); stackTrace.setColumns(50); stackTrace.setEditable(false); stackTrace.setTabSize(4); stackTrace.setText(toString(t)); ... |
void | deleteRows(final int[] sortedRows, final List> list, final AbstractTableModel model) delete Rows for (int i = sortedRows.length - 1; i >= 0; --i) { list.remove(sortedRows[i]); model.fireTableDataChanged(); |
void | ensureRowCount(int count, JTable table) Method checks if the row count is greater or equal to specified count, if not - it add a row DefaultTableModel model = (DefaultTableModel) table.getModel(); int i, j; for (i = table.getRowCount(); i < count; ++i) { model.addRow(new Object[table.getColumnCount()]); for (j = 0; j < table.getColumnCount(); ++j) table.setValueAt("", i, j); |
boolean | firstRowIsVoid(TableModel model) first Row Is Void boolean isVoid = true; for (int colIndex = 0; colIndex < model.getColumnCount(); colIndex++) { if (model.getValueAt(0, colIndex) == null) { isVoid = true; } else { isVoid = false; break; return isVoid; |
int | getModelRowAtPoint(JTable table, Point point) get Model Row At Point int row = table.rowAtPoint(point); return rowToModelIndex(table, row); |