Example usage for javax.swing.table DefaultTableModel addRow

List of usage examples for javax.swing.table DefaultTableModel addRow

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel addRow.

Prototype

public void addRow(Object[] rowData) 

Source Link

Document

Adds a row to the end of the model.

Usage

From source file:UserInterface.CDC.VaccineCityDistributionJPanel.java

private void populateTable() {
    DefaultTableModel model = (DefaultTableModel) summaryjTable.getModel();
    model.setRowCount(0);//from w  w w. j a v a 2s.c  o  m
    if (business.getStateList() != null) {
        for (CityNetwork city : state.getCityList()) {
            Object[] row = new Object[2];
            row[0] = city;
            row[1] = city.getTotalVaccinesDistributedInCity();

            model.addRow(row);
        }

    }

}

From source file:Compare.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:

    String userDir = System.getProperty("user.home");
    JFileChooser folder = new JFileChooser(userDir + "/Desktop");
    folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    folder.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Excel Files  (*.xls)", "xls");
    folder.setFileFilter(xmlfilter);/*from w ww  .j av  a 2s  .  c o m*/
    int returnvalue = folder.showSaveDialog(this);

    File myfolder = null;
    if (returnvalue == JFileChooser.APPROVE_OPTION) {
        myfolder = folder.getSelectedFile();
        //            System.out.println(myfolder);         
    }

    if (myfolder != null) {
        JOptionPane.showMessageDialog(null, "The current choosen file directory is : " + myfolder);

        listofFiles1(myfolder);
        sortByName1();
    }

    DefaultTableModel model = (DefaultTableModel) FileDetails1.getModel();

    int count = 1;

    System.out.println(filenames2.size());
    for (Files filename : filenames2) {
        String size = Long.toString(filename.Filesize) + "Bytes";
        model.addRow(new Object[] { count++, filename.Filename, size, filename.FileLocation });
    }

}

From source file:UserInterface.AdminWorkArea.InventoryUsageJPanel.java

public void populateTable() {
    Collections.sort(typeOfDevicesInInventory, IDeviceType.numberReservedComparator);

    DefaultTableModel dtm = (DefaultTableModel) deviceUsageJTable.getModel();
    dtm.setRowCount(0);//ww w .j  a va 2 s .com
    Object[] row = new Object[2];

    for (IDeviceType idt : typeOfDevicesInInventory) {
        row[0] = idt;
        row[1] = idt.getNumberOfTimesReserved();

        dtm.addRow(row);
    }

}

From source file:userInterface.cdcRole.OverviewJPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from  w  w w .  j  a  v  a  2 s  .c  om
 */
public void populate(PhdEnterprise p) {
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    dtm.setRowCount(0);
    for (Organization o : p.getOrganizationDirectory().getOrganizationList()) {
        if (o instanceof HospitalOrganization) {
            Object row[] = new Object[1];
            row[0] = o;
            dtm.addRow(row);
        }
    }
}

From source file:com.intuit.tank.tools.debugger.VariableDialog.java

public VariableDialog(AgentDebuggerFrame f, Map<String, String> variables) {
    super(f, true);
    this.f = f;// ww  w .ja v  a2 s .  com
    setLayout(new BorderLayout());
    setTitle("View Edit Project Variables");
    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Variable Name");
    model.addColumn("Variable Value");
    List<String> keys = new ArrayList<String>(variables.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        Object[] data = new Object[2];
        data[0] = key;
        data[1] = variables.get(key);
        model.addRow(data);
    }
    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(this);
    table.setGridColor(Color.GRAY);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    table.setShowGrid(true);
    table.getTableHeader().setReorderingAllowed(false);

    JScrollPane sp = new JScrollPane(table);
    JPanel panel = new JPanel(new BorderLayout());

    panel.add(table.getTableHeader(), BorderLayout.NORTH);
    panel.add(sp, BorderLayout.CENTER);

    add(panel, BorderLayout.CENTER);
    add(createButtonPanel(), BorderLayout.SOUTH);
    setSize(new Dimension(800, 600));
    setBounds(new Rectangle(getSize()));
    setPreferredSize(getSize());
    WindowUtil.centerOnParent(this);
}

From source file:dylemator.UserResultList.java

private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
    int row = this.codeTable.getSelectedRow();
    if (row == -1)
        return;/*from  w w w  .  j  a v  a  2s . c  o  m*/
    String[] values = exportData.get(row + 1);
    int dialogResult = JOptionPane.showConfirmDialog(null, "Usun wyniki uytkownika " + values[0] + "?",
            "Warning", JOptionPane.YES_NO_OPTION);
    if (dialogResult == JOptionPane.YES_OPTION) {
        exportData.remove(row + 1);
        DefaultTableModel m = (DefaultTableModel) codeTable.getModel();
        m.setRowCount(0);
        for (int i = 1; i < exportData.size(); i++) {
            m.addRow(new String[] { exportData.get(i)[0] });
        }
        DefaultTableModel n = (DefaultTableModel) infoTable.getModel();
        DefaultTableModel o = (DefaultTableModel) resultsTable.getModel();
        n.setRowCount(0);
        o.setRowCount(0);
        try {
            OutputStreamWriter output = new FileWriter(this.selectedFilename);
            BufferedWriter bufferWriter = new BufferedWriter(output);
            for (String[] v : exportData) {
                String s = StringUtils.join(v, ";");
                bufferWriter.write(s + "\n");
            }
            bufferWriter.flush();
            bufferWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}

From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java

private void inboundNewButtonActionPerformed(ActionEvent evt) {
    DefaultTableModel model = ((DefaultTableModel) inboundReplacementTable.getModel());
    int row = model.getRowCount();

    model.addRow(new Object[] { "", "" });

    inboundReplacementTable.setRowSelectionInterval(row, row);
}

From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java

private void outboundNewButtonActionPerformed(ActionEvent evt) {
    DefaultTableModel model = ((DefaultTableModel) outboundReplacementTable.getModel());
    int row = model.getRowCount();

    model.addRow(new Object[] { "", "" });

    outboundReplacementTable.setRowSelectionInterval(row, row);
}

From source file:Vista.VentasCiudad.java

private void jTable_ConsultaGeneralMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable_ConsultaGeneralMouseClicked

    this.jTable_ConsultaSucursal.repaint();

    String[] nombres = { "Id", "Sucursal", "Total Ventas" };

    String[] filasT = client.consultarSucursal("1;" + jTable_ConsultaGeneral.getModel()
            .getValueAt(jTable_ConsultaGeneral.getSelectionModel().getAnchorSelectionIndex(), 0).toString(), "")
            .split("\\n");

    DefaultTableModel dtm = new DefaultTableModel(nombres, filasT.length);
    dtm = (DefaultTableModel) this.jTable_ConsultaSucursal.getModel();

    for (String s : filasT) {
        String[] columnasT = s.split("\\t");
        dtm.addRow(new Object[] { columnasT[0], columnasT[1], columnasT[2] });
    }/*  w w w .ja  va2  s.c o m*/
}

From source file:UserInterface.PublisherRole.ViewUserHabitsJPanel.java

public void populateUserAccountsTable() {
    int rowCount = userAccountsJTable.getRowCount();
    DefaultTableModel model = (DefaultTableModel) userAccountsJTable.getModel();
    model.setRowCount(0);//  w  w w .  j a v a 2  s .c o  m

    for (UserPotential userPotential : organization.getUserPotentialDirectory().getUserPotentialList()) {

        Object row[] = new Object[1];
        row[0] = userPotential;
        model.addRow(row);
    }

}