List of utility methods to do JTable Column
void | ponerAncho(TableColumn loColumn, int plAncho) poner Ancho if (plAncho == 0) { loColumn.setMinWidth(0); loColumn.setPreferredWidth(0); loColumn.setWidth(0); loColumn.setMaxWidth(0); } else { loColumn.setPreferredWidth(plAncho); loColumn.setWidth(plAncho); ... |
void | removeColumn(int index, JTable table) Method removes column from table if (index < table.getColumnCount()) { int j; Object[][] data = new Object[table.getRowCount()][table.getColumnCount() - 1]; int[] minwidth = new int[table.getColumnCount() - 1]; int[] maxwidth = new int[table.getColumnCount() - 1]; int[] prefwidth = new int[table.getColumnCount() - 1]; for (int i = 0; i < table.getRowCount(); ++i) { for (j = 0; j < table.getColumnCount(); ++j) { ... |
void | selectByTyping(JTable table, javax.swing.JTextField textfield, int column) This method selects the first entry in the JTable table that start with the text that is entered in the filter-textfield textfield . String text = textfield.getText().toLowerCase(); for (int cnt = 0; cnt < table.getRowCount(); cnt++) { String val = table.getValueAt(cnt, column).toString(); if (val.toLowerCase().startsWith(text)) { table.getSelectionModel().setSelectionInterval(cnt, cnt); table.scrollRectToVisible(table.getCellRect(cnt, column, false)); return; |
void | setColumnOrder(final JTable table, final String positions) Sets the column order of a table given a correctly formatted String . if (positions == null) { return; String[] array = SPACE_DELIMITER_PATTERN.split(positions); int count = table.getColumnCount(); if (array.length == count) { for (int i = 0; i < count; i++) { int index = table.convertColumnIndexToView(i); ... |
void | setearPrimerRegistro(JTable pTabla, JTextField pTextoDeBusqueda, int pColumna) setear Primer Registro if (pTabla.getRowCount() > 0) { showCell(pTabla, 0, 0); if (pTextoDeBusqueda != null) setearTextoDeBusqueda(pTabla, pTextoDeBusqueda, pColumna); |
void | setearTextoDeBusqueda(JTable pTabla, JTextField pTextoDeBusqueda, int pColumna) setear Texto De Busqueda if (pTabla.getSelectedRow() >= 0) {
showCell(pTabla, pTabla.getSelectedRow(), 0);
pTextoDeBusqueda
.setText(((String) pTabla.getValueAt(pTabla.getSelectedRow(), pColumna)).trim().toUpperCase());
pTextoDeBusqueda.selectAll();
|
void | setSelectedRow(JTable table, int rowIndex, int columnIndex) set Selected Row table.setRowSelectionInterval(rowIndex, columnIndex); scrollToSelectedRow(table); |
void | setupColumns(JTable table) setup Columns for (int i = 0; i < table.getColumnCount(); i++) { DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); TableColumn column = table.getColumnModel().getColumn(i); Class columnClass = table.getColumnClass(i); String columnName = table.getColumnName(i); renderer.setToolTipText(columnName); if (columnClass.getSuperclass().equals(Number.class)) { renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT); ... |
double | sumColumTable(JTable pTable, int pColumna) Realiza la Suma de toda una Colunma de un Jtable y lo retorna como String con formato double suma = 0.00; for (int p = 0; p < pTable.getRowCount(); p++) { suma += getDecimalNumber(((String) pTable.getValueAt(p, pColumna)).trim()); suma = getDecimalNumber(formatNumber(suma)); return suma; |