List of usage examples for javax.swing.table DefaultTableModel getRowCount
public int getRowCount()
From source file:HW3.java
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed // TODO add your handling code here: DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); if (model.getRowCount() > 0) { deleteAllRows(model);//from w w w . j a v a2 s. c o m } selectedBid = null; reviewPanel.setVisible(false); topPanel.setVisible(true); }
From source file:la2launcher.MainFrame.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < procs.size(); j++) { if (Boolean.TRUE.equals(dtm.getValueAt(i, 1))) { if ((procs.get(j).hashCode() + "").equals(dtm.getValueAt(i, 0).toString())) { procs.get(j).destroyForcibly(); }// ww w . j a v a 2 s . c o m } } } }
From source file:HW3.java
private void piechartValues(int[] val) { DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); int rowCount = model.getRowCount(); String temp;/*w ww . j a v a 2s . c o m*/ for (int i = 0; i < rowCount; i++) { temp = (String) model.getValueAt(i, 1); switch (temp) { case "1": val[0] += 1; break; case "2": val[1] += 1; break; case "3": val[2] += 2; break; case "4": val[3] += 1; break; case "5": val[4] += 1; break; } } }
From source file:lob.VisualisationGUI.java
public void clearTable(final JTable table) { DefaultTableModel dm = (DefaultTableModel) table.getModel(); for (int i = 0; i < dm.getRowCount(); i++) { for (int j = 0; j < dm.getColumnCount(); j++) { dm.setValueAt("", i, j); }/* www . j a va 2s . co m*/ } }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void NLComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NLComboBoxActionPerformed // TODO add your handling code here: NL = NLComboBox.getSelectedIndex() + 1; DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); int row = model.getRowCount(); for (int i = 0; i < row; i++) { model.removeRow(0);//from w w w . ja va2 s . c o m } row = 0; if (row < NL) { while (row < NL) { Object[] vec = new Object[3]; if (jRadioKeyboard.isSelected()) { vec[0] = row + 1; model.addRow(vec); row++; continue; } vec[0] = row + 1; vec[1] = Math.floor(DU[row] * 1000) / 1000; vec[2] = Math.floor(WC[row] * 1000) / 1000; model.addRow(vec); row++; } } }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void updateSoilInfoAndSoilLayerInfo(int index) { // Update the data in the table base on the index 0 SoilData soilData = utils.getSoilData(); String key = (String) soilFileListCombo.getItemAt(index); if (key == null) { return;/* www. j av a 2 s . c om*/ } soilNameCombo.removeAllItems(); ArrayList<Soil> soilList = soilData.getSoilsFromFile(key); if (soilList.size() > 0) { for (Soil soil : soilList) { soilNameCombo.addItem(soil.getName()); } DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); int row = model.getRowCount(); for (int i = 0; i < row; i++) { model.removeRow(0); } int soilIndex = soilNameCombo.getSelectedIndex(); Soil soil = soilList.get(soilIndex == -1 ? 0 : soilIndex); DU = soil.getDU(); WCL = soil.getWCL(); WCU = soil.getWCU(); WC = soil.getWC(); NL = soil.getNL(); SNAME = soil.getName(); utils.setDefaultSoil(soil); for (int i = 0; i < soil.getNL(); i++) { Object[] vec = new Object[4]; vec[0] = i + 1; vec[1] = soil.getDU()[i]; vec[2] = soil.getWC()[i]; DecimalFormat df = new DecimalFormat("####0.000"); vec[3] = df.format(WCU[i] - WCL[i]); model.addRow(vec); } } }
From source file:dataviewer.DataViewer.java
private void transpose(DefaultTableModel model) { try {/*from www . j a v a 2 s . c o m*/ if (model.getColumnCount() == 0) { return; } DefaultTableModel new_model = new DefaultTableModel(); // if not transposed if (!model.getColumnName(0).equals("_field_") && transpose == true) { new_model.addColumn("_field_"); for (int r = 1; r <= model.getRowCount(); ++r) { new_model.addColumn("_col_" + r); } long n = 1; for (int c = 0; c < model.getColumnCount(); ++c) { Object[] s = new Object[new_model.getColumnCount()]; String colname = model.getColumnName(c); int l = 0; s[l++] = colname; for (int r = 0; r < model.getRowCount(); ++r) { s[r + l] = model.getValueAt(r, c); } new_model.addRow(s); } } if (model.getColumnName(0).equals("_field_") && transpose == false) { // if transposed for (int r = 0; r < model.getRowCount(); ++r) { new_model.addColumn(model.getValueAt(r, 0)); } List<Integer> colIdx = new ArrayList(); for (int c = 0; c < model.getColumnCount(); ++c) { if (!model.getColumnName(c).equals("_field_")) { colIdx.add(c); } } for (int c = 0; c < colIdx.size(); ++c) { Object[] s = new Object[new_model.getColumnCount()]; for (int r = 0; r < model.getRowCount(); ++r) { s[r] = model.getValueAt(r, colIdx.get(c)); } new_model.addRow(s); } } renderData(new_model); } catch (Exception e) { txt_count.setText(e.getMessage()); } }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void toogleStateOfControls(java.awt.event.ActionEvent evt) { isInitializing = true;/* w w w . jav a 2s. c o m*/ boolean isFileLocationSelected = jRadioButtonSavedLocation.isSelected(); boolean isFileSelected = jRadioFile.isSelected(); boolean isKeyboardEnabled = jRadioKeyboard.isSelected(); jButtonMap.setEnabled(isFileLocationSelected); soilFileListCombo.setEnabled(isFileLocationSelected); showSoilDataButton.setEnabled(isFileSelected || isFileLocationSelected); soilListBox.setEnabled(isFileSelected); waterholdcapacityBox.setEnabled(!isKeyboardEnabled); soilNameCombo.setEnabled(isFileLocationSelected); soilNameText.setEnabled(isKeyboardEnabled); soilTextureText.setEnabled(isKeyboardEnabled); NLComboBox.setEnabled(isKeyboardEnabled); soilTable.setEnabled(isKeyboardEnabled || isFileLocationSelected); soilNameCombo.setEditable(isKeyboardEnabled); jButtonRefresh.setEnabled(isFileLocationSelected); errorLabel.setVisible(false); wcErrorLabel.setVisible(false); DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); int row = model.getRowCount(); for (int i = 0; i < row; i++) { model.removeRow(0); } // Update the list of soils in the soil name combo box. if (jRadioButtonSavedLocation.isSelected()) { if (utils.getSoilData() == null) { utils.setSoilData(new SoilData()); } if (soilFileListCombo.getItemCount() > 0) { soilFileListCombo.removeAllItems(); } soilFileListCombo.removeAllItems(); if (isFileLocationSelected) { files = null; files = getListOfDataFiles(); int i = 0; for (File f : files) { String key = f.getName(); key = key.trim(); soilFileListCombo.addItem(f.getName()); updateSoilDataBaseOnSoilFileSelection(i++); } } //updateSoilDataBaseOnSoilFileSelection (0); updateSoilInfoAndSoilLayerInfo(0); prevButtonSelectedSavedLocation = true; } int index = isFileSelected ? 0 : (isFileLocationSelected ? 1 : 2); //System.out.println ("\n\n ToogleSelection ---- " + index); waterholdcapacityBox.setSelectedIndex(waterHoldSelectedItemIndex[index]); isInitializing = false; }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void jRadioKeyboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioKeyboardActionPerformed // TODO add your handling code here: if (isPreviousSelectionSavedLocation) { DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); if (prevSoil != null) { for (int i = 0; i < model.getRowCount(); i++) { prevSoil.getDU()[i] = (Double) model.getValueAt(i, 1); prevSoil.getWC()[i] = (Double) model.getValueAt(i, 2); }/*from w w w .java 2 s .c om*/ } prevSoil = null; isPreviousSelectionSavedLocation = false; } toogleStateOfControls(evt); }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void jRadioFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioFileActionPerformed // TODO add your handling code here: if (isPreviousSelectionSavedLocation) { DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); if (prevSoil != null) { for (int i = 0; i < model.getRowCount(); i++) { prevSoil.getDU()[i] = (Double) model.getValueAt(i, 1); prevSoil.getWC()[i] = (Double) model.getValueAt(i, 2); }//from w w w .ja v a 2s. c o m } prevSoil = null; isPreviousSelectionSavedLocation = false; } toogleStateOfControls(evt); if (jRadioFile.isSelected()) { try { readFromFile(soilListBox.getSelectedIndex()); soilNameText.setText(SNAME); soilTextureText.setText(TXT[0]); NLComboBox.setSelectedIndex(NL - 1); waterholdcapacityBox.setSelectedIndex(waterHoldSelectedItemIndex[2]); } catch (Exception e) { e.printStackTrace(); } } }