List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:org.ops4j.pax.idea.runner.forms.OsgiConfigEditorForm.java
private void updateSystemPropertiesTable(ConfigBean data) { String[] columnNames = { "Property", "Value" }; DefaultTableModel tableModel2 = new DefaultTableModel(); tableModel2.setColumnIdentifiers(columnNames); Set<Map.Entry<String, String>> entries = data.getSystemProperties().entrySet(); for (Map.Entry<String, String> entry : entries) { String key = entry.getKey(); String value = entry.getValue(); tableModel2.addRow(new String[] { key, value }); }/* w ww . j a va 2 s . co m*/ m_systemProperties.setModel(tableModel2); m_systemProperties.setEnabled(true); }
From source file:org.pentaho.reporting.engine.classic.core.crosstab.DataRowPaddingIT.java
private static void addRow(final DefaultTableModel model, final String region, final String product, final String year) { model.addRow(new Object[] { region, product, year }); }
From source file:org.signserver.admin.gui.AddWorkerDialog.java
private void addOrEditProperty(final String key, final String value) { if (PropertiesConstants.NAME.equals(key)) { JOptionPane.showMessageDialog(this, "Use the Name text field to edit the worker name", "Set worker name", JOptionPane.ERROR_MESSAGE); } else {/*w ww .j ava2 s . co m*/ final DefaultTableModel model = (DefaultTableModel) propertiesTable.getModel(); boolean existing = false; for (int i = 0; i < model.getRowCount(); i++) { final String foundKey = (String) model.getValueAt(i, 0); if (key.equals(foundKey)) { // update existing row model.setValueAt(key, i, 0); model.setValueAt(value, i, 1); existing = true; break; } } if (!existing) { model.addRow(new Object[] { key, value }); } } }
From source file:org.smart.migrate.ui.MappingDialog.java
private void initFieldMappings() { if (StringUtils.isBlank((String) cbxSourceTables.getSelectedItem()) || StringUtils.isBlank((String) cbxTargetTables.getSelectedItem())) { return;/*from w w w .j a v a 2s .co m*/ } DefaultTableModel model = (DefaultTableModel) tblFieldMapping.getModel(); model.setRowCount(0); TableColumn srcColumn = tblFieldMapping.getColumnModel().getColumn(0); TableColumn tgtColumn = tblFieldMapping.getColumnModel().getColumn(1); JComboBox srcComboBox = new JComboBox(); srcComboBox.setMaximumRowCount(20); List<Field> srcFields = sourceMetaDao.getFieldsOfTable(sourceConnection, cbxSourceTables.getSelectedItem().toString()); List<Field> tgtFields = targetMetaDao.getFieldsOfTable(targetConnection, cbxTargetTables.getSelectedItem().toString()); srcComboBox.addItem(""); for (Field field : srcFields) { srcComboBox.addItem(field.getName()); } srcColumn.setCellEditor(new DefaultCellEditor(srcComboBox)); int k = 0; for (Field tgtField : tgtFields) { k++; model.addRow(new Object[] { null, tgtField.getName(), false, null, null, k }); } if (tableSetting != null && !CollectionUtils.isEmpty(tableSetting.getFieldSettings()) && tableSetting.getSourceTable().equals(cbxSourceTables.getSelectedItem()) && tableSetting.getTargetTable().equals(cbxTargetTables.getSelectedItem())) { for (int i = 0; i < tblFieldMapping.getRowCount(); i++) { String tgtField = (String) tblFieldMapping.getValueAt(i, 1); FieldSetting fieldSetting = tableSetting.getFieldSettingByTargetField(tgtField); if (fieldSetting != null) { tblFieldMapping.setValueAt(fieldSetting.getSourceField(), i, 0); tblFieldMapping.setValueAt(fieldSetting.isPrimaryKey(), i, 2); tblFieldMapping.setValueAt(fieldSetting.getDefaultValue(), i, 3); tblFieldMapping.setValueAt(fieldSetting.getDictText(), i, 4); } } } }
From source file:org.spottedplaid.ui.Mainframe.java
/** * addToTable - Add new row to the JTable clients object. */// w w w. j a v a 2s .co m public void addToTable() { DefaultTableModel jtabModel = (DefaultTableModel) jtabApps.getModel(); jtabModel.addRow(new Object[] { dbRec.getClientId(), dbRec.getClientName(), dbRec.getClientDesc() }); clearFields(); }
From source file:org.spottedplaid.ui.Mainframe.java
/** * addToCredsTable - Add new row to the JTable credentials object. *//*from w w w . j a v a2 s .c o m*/ public void addToCredsTable() { DefaultTableModel jtabModel = (DefaultTableModel) jtabCreds.getModel(); jtabModel.addRow(new Object[] { dbRec.getCredId(), dbRec.getChallenge(), dbRec.getResponse(), dbRec.getTrack(), dbRec.getModifyDate() }); clearCredsFields(); enableCredsButtons(); }
From source file:org.spottedplaid.ui.Mainframe.java
/** * loadTable - Loads client data.//from ww w. ja v a 2s . co m * * @param _dbRec - Parameter indicating type of data to load and any associated filters */ public void loadTable(DbRecord _dbRec) { DefaultTableModel jtabModel = null; try { ArrayList<String> arrData = l_sqliteops.getRecords(_dbRec); if (_dbRec.getType().equals(Pwdtypes.S_CLIENT_TYPE)) { jtabApps.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "ID", "URL/Application", "Description" })); jtabModel = (DefaultTableModel) jtabApps.getModel(); } else if (_dbRec.getType().equals(Pwdtypes.S_CREDS_TYPE)) { jtabCreds.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "ID", "Challenge", "Response", "Exp Days", "Expiration Date" })); jtabModel = (DefaultTableModel) jtabCreds.getModel(); } String[] sRecord = new String[6]; String sData = ""; int iElement = 0; if (arrData != null) { System.out.println("DEBUG->size [" + arrData.size() + "]"); for (int iCount = 0; iCount < arrData.size(); iCount++) { sData = arrData.get(iCount); StringTokenizer st = new StringTokenizer(sData, "|"); iElement = 0; System.out.println("DEBUG->Tokencount [" + st.countTokens() + "]"); while (st.hasMoreTokens()) { sRecord[iElement] = st.nextToken(); System.out.println("DEBUG->Element [" + sRecord[iElement] + "]"); iElement++; } jtabModel.addRow(new Object[] { sRecord[0], sRecord[1], sRecord[2], sRecord[3], sRecord[4] }); } } } catch (Exception e) { System.out.println("DEBUG->loadTable Exception [" + e.getMessage() + "]"); e.printStackTrace(); } }
From source file:org.ut.biolab.medsavant.client.patient.AddPatientsForm.java
private void createTable() throws RemoteException, SQLException { scrollPane.getViewport().setBackground(Color.white); DefaultTableModel model = new DefaultTableModel() { @Override/* www . j a v a2s . co m*/ public boolean isCellEditable(int row, int col) { return col != 0; } }; model.addColumn("Short Name"); model.addColumn("Value"); CustomField[] fields = null; try { fields = MedSavantClient.PatientManager.getPatientFields(LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID()); } catch (SessionExpiredException ex) { MedSavantExceptionHandler.handleSessionExpiredException(ex); } for (int i = 1; i < fields.length; i++) { //skip patient id model.addRow(new Object[] { fields[i], "" }); } table.setModel(model); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { setTip(); } }); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); }
From source file:phenoviewer.ReNameJFrame.java
private DefaultTableModel addVectorTable(DefaultTableModel d, Vector<TableClass> v) { // function of adding vector to table int num = v.size(); String name;/*from ww w.j ava 2 s . c o m*/ String path; for (int i = 0; i < num; i++) { name = v.elementAt(i).getFileName(); path = v.elementAt(i).getFilePath(); d.addRow(new String[] { name, path }); } return d; }
From source file:phenoviewer.ReNameJFrame.java
private boolean showConfirm() { // show the confirm message box Vector<String> columnNames = new Vector<String>(); columnNames.add(new String("Before")); columnNames.add(new String("After")); DefaultTableModel d = new DefaultTableModel(new Vector<String>(), columnNames); for (int i = 0; i < vector.size(); i++) { if (nvector.get(i).getFileName().equals("Error") == true && nvector.get(i).getFilePath().equals("File not exists") == true) { d.addRow(new String[] { vector.get(i).getFileName(), "Error: File not exist" }); } else {//from ww w . j av a 2 s . c o m d.addRow(new String[] { vector.get(i).getFileName(), nvector.get(i).getFileName() }); } } JTable table = new JTable(d); JScrollPane scrollPane = new JScrollPane(table); int select = JOptionPane.showConfirmDialog(null, scrollPane); if (select == JOptionPane.YES_OPTION) { return true; } return false; }