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:Compare.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // 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);//  w  w  w  . j a  v  a 2 s .co  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);
    }

    listofFiles(myfolder);
    sortByName();

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

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

}

From source file:UserInterface.DoctorRole.ViewDonorReport.java

public void PopulateTable() {
    DefaultTableModel model = (DefaultTableModel) DonorsummaryTable.getModel();

    model.setRowCount(0);/*from   w w w . j a  va  2  s.co  m*/
    for (VitalSign vs : vitalSigndir.getVitalSignDir()) {
        Object row[] = new Object[4];
        row[0] = vs;
        row[1] = vs.getBloodPressure();
        row[2] = vs.getBloodPlatlets();
        row[3] = vs.getHemoglobinLevel();
        model.addRow(row);

    }
}

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

public RegexAttachmentDialog(AttachmentHandlerProperties properties) {
    super(PlatformUI.MIRTH_FRAME, true);
    this.parent = PlatformUI.MIRTH_FRAME;

    setTitle("Set Attachment Properties");
    getContentPane().setBackground(UIConstants.BACKGROUND_COLOR);
    setLayout(new MigLayout("novisualpadding, hidemode 3, insets 12", "[fill, grow]"));
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setPreferredSize(new Dimension(650, 550));

    initComponents();/*w  w w.  j a  v  a 2  s.com*/
    initLayout();
    initInboundReplacementTable();
    initOutboundReplacementTable();

    attachmentHandlerProperties = properties;

    regexTextField.setText(
            StringUtils.defaultIfEmpty(attachmentHandlerProperties.getProperties().get("regex.pattern"), ""));
    regexTextField.requestFocus();
    regexTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            if (initialFocus) {
                regexTextField.setCaretPosition(0);
                initialFocus = false;
            }
        }

    });
    mimeTypeField.setText(
            StringUtils.defaultIfEmpty(attachmentHandlerProperties.getProperties().get("regex.mimetype"), ""));

    int count = 0;
    while (attachmentHandlerProperties.getProperties().containsKey("regex.replaceKey" + count)) {
        DefaultTableModel tableModel = (DefaultTableModel) inboundReplacementTable.getModel();
        tableModel.addRow(
                new Object[] { attachmentHandlerProperties.getProperties().get("regex.replaceKey" + count),
                        attachmentHandlerProperties.getProperties().get("regex.replaceValue" + count) });
        count++;
    }

    count = 0;
    while (attachmentHandlerProperties.getProperties().containsKey("outbound.regex.replaceKey" + count)) {
        DefaultTableModel tableModel = (DefaultTableModel) outboundReplacementTable.getModel();
        tableModel.addRow(new Object[] {
                attachmentHandlerProperties.getProperties().get("outbound.regex.replaceKey" + count),
                attachmentHandlerProperties.getProperties().get("outbound.regex.replaceValue" + count) });
        count++;
    }

    setLocationRelativeTo(parent);
    setVisible(true);
}

From source file:boundary.ReportProduce.java

private void setMusicianTbl(String session) {
    DefaultTableModel model = new DefaultTableModel();
    jTable3.setModel(model);/*from www .  java 2 s  .  c o  m*/
    model.addColumn("ID");
    model.addColumn("Instrument");
    for (Musician entry : ReportProduceControl.getMusicians(Integer.valueOf(session))) {
        model.addRow(new Object[] { entry.getFreelancerID(), entry.getType() });
    }
}

From source file:UserInterface.CDC.VaccineStateDistributionJPanel.java

private void populateTable() {
    DefaultTableModel model = (DefaultTableModel) summaryjTable.getModel();
    model.setRowCount(0);/*from  w  ww  .j  a  va 2 s  . c  om*/
    if (business.getStateList() != null) {
        for (StateNetwork state : business.getStateList()) {
            Object[] row = new Object[2];
            row[0] = state;
            row[1] = state.getTotalVaccinesDistributedInState();

            model.addRow(row);
        }

    }

}

From source file:com.dvd.ui.UpdateBooking.java

private void populateTable() {

    getData();/*  w w  w .ja  va2  s . c  o m*/

    DefaultTableModel model = new DefaultTableModel();
    model.setColumnIdentifiers(new String[] { "Booking ID", "User ID", "DVD Copy Number", "Added Date " });
    bookingTable.setModel(new DefaultTableModel());

    for (Booking booking_item : bookingList) {
        model.addRow(new String[] { String.valueOf(booking_item.getId()),
                String.valueOf(booking_item.getUserID()), String.valueOf(booking_item.getCopyNumber()),
                String.valueOf(booking_item.getBookingAddedDate()) });

    }
    bookingTable.setModel(model);
}

From source file:UserInterface.VaccineManufacturer.TrackVaccineWastage.java

public void populateVaccineTable() {
    DefaultTableModel model = (DefaultTableModel) vaccineJTable.getModel();
    model.setRowCount(0);/*from  ww  w  .j a  v  a 2s .co  m*/

    for (Vaccine vaccine : enterprise.getVaccineCatalog().getVaccineList()) {
        Object row[] = new Object[2];
        row[0] = vaccine;
        row[1] = vaccine.getDisease();
        model.addRow(row);
    }
}

From source file:ExtendedDnDDemo.java

private JPanel createTable() {
    DefaultTableModel model = new DefaultTableModel();

    model.addColumn("Column 0");
    model.addColumn("Column 1");
    model.addColumn("Column 2");
    model.addColumn("Column 3");

    model.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" });
    model.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" });
    model.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" });
    model.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" });

    JTable table = new JTable(model);
    table.getTableHeader().setReorderingAllowed(false);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setPreferredSize(new Dimension(400, 100));

    table.setDragEnabled(true);/*from  ww w .  j a  v  a  2s  .  c om*/
    table.setTransferHandler(new TableTransferHandler());

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createTitledBorder("Table"));
    return panel;
}

From source file:UserInterface.CentreForDiseaseControl.AddDiseaseJPanel.java

public void populateDiseaseTable() {
    DefaultTableModel model = (DefaultTableModel) diseaseJTable.getModel();
    model.setRowCount(0);//from  ww w  . j a  va 2 s . c  o m

    for (Disease disease : enterprise.getDiseaseCatalog().getDiseaseList()) {
        Object row[] = new Object[1];
        row[0] = disease;
        model.addRow(row);
    }
}

From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java

public DBSeerLiveMonitorPanel() {
    this.setLayout(new MigLayout("fill"));

    numTransactionType = 0;/*from   ww  w.j  a v a  2  s  . c  o m*/
    transactionNames = new ArrayList<String>();
    monitorTable = new JTable(new DefaultTableModel(null, new String[] { "Name", "Value" }) {
        @Override
        public boolean isCellEditable(int i, int i1) {
            return false;
        }
    });

    monitorTable.setFillsViewportHeight(true);
    monitorTable.getColumnModel().getColumn(0).setMaxWidth(1200);
    monitorTable.getColumnModel().getColumn(0).setPreferredWidth(1200);
    monitorTable.getColumnModel().getColumn(1).setMaxWidth(200);
    monitorTable.getColumnModel().getColumn(1).setPreferredWidth(200);
    monitorTable.setRowHeight(20);

    for (String header : tableHeaders) {
        DefaultTableModel model = (DefaultTableModel) monitorTable.getModel();
        model.addRow(new Object[] { header, "0.0" });
    }

    transactionLabels = new ArrayList<JLabel>();
    transactionDeleteButtons = new ArrayList<JButton>();
    transactionRenameButtons = new ArrayList<JButton>();
    transactionViewSampleButtons = new ArrayList<JButton>();
    transactionEnableDisableButtons = new ArrayList<JButton>();

    initialize();
}