List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:cz.muni.fi.mushroomhunter.restclient.MushroomCreateSwingWorker.java
@Override protected void done() { try {//from w ww . jav a2 s. com get(); } catch (Exception e) { restClient.getlMessageMushrooms().setText("ERROR: server is unavailable."); return; } DefaultTableModel model = (DefaultTableModel) restClient.getTblMushroom().getModel(); model.addRow(new Object[] { restClient.getTfMushroomName().getText(), restClient.getComboBoxMushroomType().getSelectedItem().toString(), restClient.getComboBoxMushroomStartOfOccurence().getSelectedItem().toString(), restClient.getComboBoxMushroomEndOfOccurence().getSelectedItem().toString() }); }
From source file:com.yosanai.java.swing.config.ConfigPanel.java
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnAddActionPerformed DefaultTableModel model = (DefaultTableModel) tblConfig.getModel(); model.addRow(new Object[] { "key", "value" }); }
From source file:com.cch.aj.entryrecorder.frame.CheckJFrame.java
private void init() { this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.tblCheck.getColumnModel().getColumn(1).setMaxWidth(80); DefaultTableModel model = (DefaultTableModel) this.tblCheck.getModel(); for (Checkitem ci : AppHelper.entryProduct.getCheckitemCollection()) { model.addRow(new Object[] { ci.getDescription(), false }); }//from www. ja va 2 s.com }
From source file:temp1.JFrame1.java
static void comp(int[] k1, int[] k2, int[] k3, int[] k4, int length1, int i, int eve1, int eve2, int eve3, JFreeChart jfreechart) {/* ww w . j av a 2s .c o m*/ jfreechart1 = jfreechart; int j, l; length2 = length1; time1 = i; if (i == 5) { if (jFormattedTextField1.getValue() != null) fre = Integer.parseInt(jFormattedTextField1.getText()); if (jFormattedTextField2.getValue() != null) calo = Integer.parseInt(jFormattedTextField2.getText()); } if (((k1[i + 1] - k1[i + 2]) <= 15) && ((k1[i + 1] - k1[i + 2]) >= -15) && ((k1[i + 2] - k1[i + 3]) <= 15) && ((k1[i + 2] - k1[i + 3]) >= -15) && ((k1[i + 3] - k1[i + 4]) <= 15) && ((k1[i + 3] - k1[i + 4]) >= -15) && ((k1[i + 4] - k1[i + 5]) <= 15) && ((k1[i + 4] - k1[i + 5]) >= -15)) eve1 = ((((k1[i + 1] + k1[i + 2] + k1[i + 3] + k1[i + 4] + k1[i + 5]) / 5) - eve1) * 2 / 3) + eve1; if (((k2[i + 1] - k2[i + 2]) <= 15) && ((k2[i + 1] - k2[i + 2]) >= -15) && ((k2[i + 2] - k2[i + 3]) <= 15) && ((k2[i + 2] - k2[i + 3]) >= -15) && ((k2[i + 3] - k2[i + 4]) <= 15) && ((k2[i + 3] - k2[i + 4]) >= -15) && ((k2[i + 4] - k2[i + 5]) <= 15) && ((k2[i + 4] - k2[i + 5]) >= -15)) eve2 = ((((k2[i + 1] + k2[i + 2] + k2[i + 3] + k2[i + 4] + k2[i + 5]) / 5) - eve2) * 2 / 3) + eve2; if (((k3[i + 1] - k3[i + 2]) <= 15) && ((k3[i + 1] - k3[i + 2]) >= -15) && ((k3[i + 2] - k3[i + 3]) <= 15) && ((k3[i + 2] - k3[i + 3]) >= -15) && ((k3[i + 3] - k3[i + 4]) <= 15) && ((k3[i + 3] - k3[i + 4]) >= -15) && ((k3[i + 4] - k3[i + 5]) <= 15) && ((k3[i + 4] - k3[i + 5]) >= -15)) eve3 = ((((k3[i + 1] + k3[i + 2] + k3[i + 3] + k3[i + 4] + k3[i + 5]) / 5) - eve3) * 2 / 3) + eve3; if (k1[i] - eve1 > 35 && q1 == true) { t1 = k1[i]; q1 = false; q2 = true; } if (q2 == true && k1[i] >= t1) { t1 = k1[i]; } if (q2 == true && k1[i] < t1) { t1 = k1[i]; l1 = i - 1; j = l1; q2 = false; while (((k1[j + 1] - k1[j + 2]) >= 5) || ((k1[j + 1] - k1[j + 2]) <= -5) || ((k1[j + 2] - k1[j + 3]) >= 5) || ((k1[j + 2] - k1[j + 3]) <= -5) || ((k1[j + 3] - k1[j + 4]) >= 5) || ((k1[j + 3] - k1[j + 4]) <= -5) || ((k1[j + 4] - k1[j + 5]) >= 5) || ((k1[j + 4] - k1[j + 5]) <= -5)) j--; sta11 = j + 5; q3 = true; } if (q3 == true && k1[i] <= t1) { t1 = k1[i]; } if (q3 == true && k1[i] > t1) { m1 = i - 1; q4 = true; q3 = false; } if (((k1[i + 5] - k1[i + 4]) >= -5) && ((k1[i + 5] - k1[i + 4]) <= 5) && ((k1[i + 4] - k1[i + 3]) >= -5) && ((k1[i + 4] - k1[i + 3]) <= 5) && ((k1[i + 3] - k1[i + 2]) >= -5) && ((k1[i + 3] - k1[i + 2]) <= 5) && ((k1[i + 2] - k1[i + 1]) >= -5) && ((k1[i + 2] - k1[i + 1]) <= 5) && q4 == true) { end11 = i; p1 = true; q4 = false; q1 = true; } if (k3[i] - eve3 > 35 && e1 == true) { t3 = k3[i]; e1 = false; e2 = true; } if (e2 == true && k3[i] >= t3) { t3 = k3[i]; } if (e2 == true && k3[i] < t3) { t3 = k1[i]; l3 = i - 1; j = l3; e2 = false; while (((k2[j + 1] - k2[j + 2]) >= 5) || ((k2[j + 1] - k2[j + 2]) <= -5) || ((k2[j + 2] - k2[j + 3]) >= 5) || ((k2[j + 2] - k2[j + 3]) <= -5) || ((k2[j + 3] - k2[j + 4]) >= 5) || ((k2[j + 3] - k2[j + 4]) <= -5) || ((k2[j + 4] - k2[j + 5]) >= 5) || ((k2[j + 4] - k2[j + 5]) <= -5)) j--; sta33 = j + 5; e3 = true; } if (e3 == true && k3[i] <= t3) { t3 = k3[i]; } if (e3 == true && k3[i] > t3) { t3 = k3[i]; e4 = true; e3 = false; } if (e4 == true && k3[i] >= t3) t3 = k3[i]; if (e4 == true && k3[i] < t3) { m3 = i - 1; e4 = false; e5 = true; } if (((k3[i + 5] - k3[i + 4]) >= -5) && ((k3[i + 5] - k3[i + 4]) <= 5) && ((k3[i + 4] - k3[i + 3]) >= -5) && ((k3[i + 4] - k3[i + 3]) <= 5) && ((k3[i + 3] - k3[i + 2]) >= -5) && ((k3[i + 3] - k3[i + 2]) <= 5) && ((k3[i + 2] - k3[i + 1]) >= -5) && ((k3[i + 2] - k3[i + 1]) <= 5) && e5 == true) { end33 = i; p2 = true; e5 = false; e1 = true; } if (k2[i] - eve2 > 35 && w1 == true) { t2 = k1[i]; w1 = false; w2 = true; } if (w2 == true && k2[i] >= t2) { t2 = k2[i]; } if (w2 == true && k2[i] < t2) { t2 = k1[i]; l2 = i - 1; j = l2; w2 = false; while (((k2[j + 1] - k2[j + 2]) >= 5) || ((k2[j + 1] - k2[j + 2]) <= -5) || ((k2[j + 2] - k2[j + 3]) >= 5) || ((k2[j + 2] - k2[j + 3]) <= -5) || ((k2[j + 3] - k2[j + 4]) >= 5) || ((k2[j + 3] - k2[j + 4]) <= -5) || ((k2[j + 4] - k2[j + 5]) >= 5) || ((k2[j + 4] - k2[j + 5]) <= -5)) j--; sta22 = j + 5; w3 = true; } if (w3 == true && k2[i] <= t2) { t2 = k2[i]; } if (w3 == true && k2[i] > t2) { m2 = i - 1; w4 = true; w3 = false; } if (((k2[i + 5] - k2[i + 4]) >= -5) && ((k2[i + 5] - k2[i + 4]) <= 5) && ((k2[i + 4] - k2[i + 3]) >= -5) && ((k2[i + 4] - k2[i + 3]) <= 5) && ((k2[i + 3] - k2[i + 2]) >= -5) && ((k2[i + 3] - k2[i + 2]) <= 5) && ((k2[i + 2] - k2[i + 1]) >= -5) && ((k2[i + 2] - k2[i + 1]) <= 5) && w4 == true) { end22 = i; p3 = true; w4 = false; w1 = true; } if (p1 && p2 && p3) { p1 = false; p2 = false; p3 = false; if (fre == -1 && calo == -1) { System.out.println(k); DefaultTableModel tableMode2 = (DefaultTableModel) jTable1.getModel(); tableMode2.addRow(new Object[] { k, ":" + sta11 + "-" + ":" + end11, ":" + sta22 + "-" + ":" + end22, ":" + sta33 + "-" + ":" + end33, "", " " }); jTextPane3.setText(String.valueOf(k)); k++; } if (fre != -1 && calo == -1) { DefaultTableModel tableMode2 = (DefaultTableModel) jTable1.getModel(); double t = (double) ((m1 - l1 + m2 - l2 + m3 - l3) / 3 * fre); tableMode2.addRow(new Object[] { k, ":" + sta11 + "-" + ":" + end11, ":" + sta22 + "-" + ":" + end22, ":" + sta33 + "-" + ":" + end33, df.format(t), " " }); jTextPane3.setText(String.valueOf(k)); jTextField1.setText( String.valueOf(df.format((double) k / (((double) i * (double) fre / 3600) / 1000)))); k++; } if (fre != -1 && calo != -1) { DefaultTableModel tableMode2 = (DefaultTableModel) jTable1.getModel(); double t = (double) ((m1 - l1 + m2 - l2 + m3 - l3) / 3 * fre); double d = ((calo / t) * 1000) * 3.6; tableMode2.addRow(new Object[] { k, "" + sta11 + "-" + "" + end11, "" + sta22 + "-" + "" + end22, "" + sta33 + "-" + "" + end33, df.format(t), df.format(d) }); jTextPane3.setText(String.valueOf(k)); jTextField1.setText( String.valueOf(df.format((double) k / (((double) i * (double) fre / 3600) / 1000)))); k++; } } jProgressBar1.setBackground(Color.LIGHT_GRAY); jProgressBar1.setForeground(Color.blue); jProgressBar1.setValue((int) (i * 100 / (length2 - 5))); }
From source file:Main.java
public Main() { DefaultTableModel model = new DefaultTableModel(0, 5) { @Override/*from w ww . j av a2 s .c o m*/ public boolean isCellEditable(int row, int column) { return false; } }; JTable table = new JTable(model); for (int i = 0; i < 20; i++) { model.addRow(new String[] { i + ".1", i + ".2", i + ".3", i + ".4", i + ".5", }); } add(table, BorderLayout.CENTER); table.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { System.out.println("pressed"); char key = e.getKeyChar(); int selectedColumn = table.getSelectedColumn(); for (int i = 0; i < model.getRowCount(); i++) { String value = (String) model.getValueAt(i, selectedColumn); model.setValueAt(value + key, i, selectedColumn); } } }); }
From source file:com.willwinder.universalgcodesender.uielements.panels.ControllerProcessorSettingsPanel.java
private void addNewPatternRemover() { DefaultTableModel model = (DefaultTableModel) this.customRemoverTable.getModel(); model.addRow(new Object[] { true, "" }); }
From source file:Controlador.ControladorLecturas.java
public DefaultTableModel tablaTemperatura() { DefaultTableModel tabla = new DefaultTableModel(new Object[][] {}, new String[] { "Hora", "Temperatura" }); for (Lecturas lectura : lista) { tabla.addRow(new Object[] { lectura.getHora(), lectura.getTemperatura() }); }/*from www .java 2s . co m*/ return tabla; }
From source file:cz.muni.fi.mushroomhunter.restclient.AllLocationSwingWorker.java
@Override protected void done() { try {/* ww w .j av a 2s . c o m*/ get(); } catch (Exception e) { restClient.getlMessageLocations().setText("ERROR: server is unavailable."); return; } try { List<LocationDto> list = get(); DefaultTableModel model = (DefaultTableModel) restClient.getTblLocation().getModel(); model.setRowCount(0); for (LocationDto list1 : list) { RestClient.getLocationIDs().add(list1.getId()); model.addRow(new Object[] { list1.getName(), list1.getDescription(), list1.getNearCity() }); } } catch (ExecutionException ex) { } catch (InterruptedException ex) { throw new RuntimeException("Operation interrupted", ex); } }
From source file:Controlador.ControladorLecturas.java
public DefaultTableModel tablaHumedadSuelo() { DefaultTableModel tabla = new DefaultTableModel(new Object[][] {}, new String[] { "Hora", "Humedad de Suelo" }); for (Lecturas lectura : lista) { tabla.addRow(new Object[] { lectura.getHora(), lectura.getHumedadsuelo() }); }/* www . j a va 2s .co m*/ return tabla; }
From source file:Controlador.ControladorLecturas.java
public DefaultTableModel tablaHumedadAmbiental() { DefaultTableModel tabla = new DefaultTableModel(new Object[][] {}, new String[] { "Hora", "Humedad Ambiental" }); for (Lecturas lectura : lista) { tabla.addRow(new Object[] { lectura.getHora(), lectura.getHumedadambiente() }); }//from w w w. j a v a 2 s . c o m return tabla; }