Example usage for javax.swing.table DefaultTableModel setNumRows

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

Introduction

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

Prototype

public void setNumRows(int rowCount) 

Source Link

Document

Obsolete as of Java 2 platform v1.3.

Usage

From source file:Interface.FramePrincipal.java

private void bt_atuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_atuActionPerformed

    ///////////////////////////////////////////// Baixa xml do bucket //////////////////////////////////////////////////////////        
    File diretorio = new File(dir_dow.getText());

    if ("".equals(dir_dow.getText())) {
        JOptionPane.showMessageDialog(null, "Campo diretrio deve ser preenchido!");
    } else if (!diretorio.exists()) {
        JOptionPane.showMessageDialog(null, "Este no  um diretrio vlido!");
    } else {//from w  w  w  .j  a v a  2 s.c  o m
        try {
            URL arquivoBucket = new URL("http://storage.googleapis.com/" + bac.getNome());

            //Passa caminho de saida do arquivo que esta sendo baixado
            ReadableByteChannel canalArquivoSaida = Channels.newChannel(arquivoBucket.openStream());
            FileOutputStream arquivoSaida = new FileOutputStream(
                    dir_dow.getText() + "/" + bac.getNome() + ".xml");

            //Calcula tempo que o processo de download levou
            long inicio = System.currentTimeMillis();
            arquivoSaida.getChannel().transferFrom(canalArquivoSaida, 0, 1 << 24);
            long fim = System.currentTimeMillis();
            System.out.println(fim - inicio);

            arquivoSaida.close(); //libera o arquivo aps ser baixado.

            /////////////////////////////// Carrega tabela com nome de arquivos ////////////////////////////////////////////////////       
            //percorret tabela
            DefaultTableModel adm = (DefaultTableModel) jTable.getModel();
            adm.setNumRows(0);
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //Importar arquivo xml         
            File file = new File(dir_dow.getText() + "/" + bac.getNome() + ".xml");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);
            doc.getDocumentElement().normalize();
            System.out.println("Root element " + doc.getDocumentElement().getNodeName());
            NodeList nodeLst = doc.getElementsByTagName("Contents");
            System.out.println("Information of all employees");

            for (int s = 0; s < nodeLst.getLength(); s++) {

                Node fstNode = nodeLst.item(s);

                if (fstNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element fstElmnt = (Element) fstNode;
                    NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("Key");
                    Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
                    NodeList fstNm = fstNmElmnt.getChildNodes();
                    System.out.println("Key : " + ((Node) fstNm.item(0)).getNodeValue());

                    String val = ((Node) fstNm.item(0)).getNodeValue();

                    adm.addRow(new Object[] { val });

                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java

public void setFileSchemeProperties(SftpSchemeProperties schemeProperties) {
    if (schemeProperties.isPasswordAuth() && schemeProperties.isKeyAuth()) {
        useBothRadio.setSelected(true);//w  ww .ja  v  a 2s .c  o m
    } else {
        if (schemeProperties.isKeyAuth()) {
            usePrivateKeyRadio.setSelected(true);
        } else {
            usePasswordRadio.setSelected(true);
        }
    }

    keyLocationField.setText(schemeProperties.getKeyFile());
    passphraseField.setText(schemeProperties.getPassPhrase());

    String hostnameVerification = schemeProperties.getHostChecking();
    if (hostnameVerification.equals("yes")) {
        useKnownHostsYesRadio.setSelected(true);
    } else if (hostnameVerification.equals("ask")) {
        useKnownHostsAskRadio.setSelected(true);
    } else {
        useKnownHostsNoRadio.setSelected(true);
    }

    knownHostsField.setText(schemeProperties.getKnownHostsFile());

    Map<String, String> configurationSettings = schemeProperties.getConfigurationSettings();
    if (configurationSettings != null && configurationSettings.size() > 0) {
        DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel();
        model.setNumRows(0);

        for (Map.Entry<String, String> entry : configurationSettings.entrySet()) {
            model.addRow(new Object[] { entry.getKey(), entry.getValue() });
        }

        deleteButton.setEnabled(true);
    } else {
        configurationsTable.setModel(new RefreshTableModel(new Object[0][1], new String[] { "Name", "Value" }));
        configurationsTable.getColumnModel()
                .getColumn(configurationsTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME))
                .setCellEditor(new ConfigTableCellEditor(true));
        configurationsTable.getColumnModel()
                .getColumn(configurationsTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME))
                .setCellEditor(new ConfigTableCellEditor(false));
    }

    authenticationRadioButtonActionPerformed();
}

From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java

public void setProperties(PollConnectorProperties properties) {
    scheduleTypeComboBox.removeActionListener(scheduleTypeActionListener);

    clearProperties();/* www .  j  a v a2 s .  c  o m*/

    if (properties.getPollingType().equals(PollingType.INTERVAL)) {
        String frequencyType = POLLING_FREQUENCY_MILLISECONDS;
        int frequency = properties.getPollingFrequency();

        if (frequency % 3600000 == 0) {
            frequency /= 3600000;
            frequencyType = POLLING_FREQUENCY_HOURS;
        } else if (frequency % 60000 == 0) {
            frequency /= 60000;
            frequencyType = POLLING_FREQUENCY_MINUTES;
        } else if (frequency % 1000 == 0) {
            frequency /= 1000;
            frequencyType = POLLING_FREQUENCY_SECONDS;
        }

        pollingFrequencyField.setText(String.valueOf(frequency));
        pollingFrequencyTypeComboBox.setSelectedItem(frequencyType);
    } else if (properties.getPollingType().equals(PollingType.TIME)) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm aa");
        Calendar timeCalendar = Calendar.getInstance();
        timeCalendar.set(Calendar.HOUR_OF_DAY, properties.getPollingHour());
        timeCalendar.set(Calendar.MINUTE, properties.getPollingMinute());
        pollingTimePicker.setDate(dateFormat.format(timeCalendar.getTime()));
    } else if (properties.getPollingType().equals(PollingType.CRON)) {
        List<CronProperty> cronJobs = properties.getCronJobs();
        if (cronJobs != null && cronJobs.size() > 0) {
            DefaultTableModel model = (DefaultTableModel) cronJobsTable.getModel();
            model.setNumRows(0);

            for (CronProperty property : cronJobs) {
                model.addRow(new Object[] { property.getExpression(), property.getDescription() });
            }

            deleteJobButton.setEnabled(true);
        }
    }

    nextFireTimeProperties = properties.clone();

    String pollingType = properties.getPollingType().getDisplayName();
    yesStartPollRadioButton.setSelected(properties.isPollOnStart());

    scheduleTypeComboBox.setSelectedItem(pollingType);

    enableComponents(pollingType);
    cachedAdvancedConnectorProperties = properties.getPollConnectorPropertiesAdvanced();
    scheduleTypeComboBox.addActionListener(scheduleTypeActionListener);
}

From source file:NewApplication.java

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

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

    model.setNumRows(0);

    jTable1.setModel(model);//from  www  .  jav a  2  s. c om

    int index = listEntities.getSelectedIndex();

    if (index < 0)
        return;

    clazz = null;

    if (ens != null)
        clazz = (Class) ens.get(index);

    try {

        List<Object> acc = JavaApplication.GetEntities(clazz);

        int r = 0;

        int c = 0;

        for (Object a : acc) {

            Field[] fields = a.getClass().getDeclaredFields();

            Object[] obs = new Object[fields.length];

            model = (DefaultTableModel) jTable1.getModel();

            model.addRow(obs);

            jTable1.setModel(model);

            c = 0;

            for (Field field : fields) {

                field.setAccessible(true);

                Object v = field.get(a);

                if (v == null)
                    v = "";

                jTable1.getModel().setValueAt(v.toString(), r, c++);

            }

            r++;
        }

        jTable1.repaint();

        EditTable();

    } catch (Exception ex) {
    }
    ;
}

From source file:NewApplication.java

private void EditTable(Class clazz) {
    // TODO add your handling code here:

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

    model.setColumnCount(3);//from w w w . java  2 s .c  o  m

    model.setNumRows(0);

    jTable2.setModel(model);

    TableColumn tc = jTable2.getColumnModel().getColumn(0);
    tc.setHeaderValue("Field Name");
    tc = jTable2.getColumnModel().getColumn(1);
    tc.setHeaderValue("Value");
    tc = jTable2.getColumnModel().getColumn(2);
    tc.setHeaderValue("Type");

    try {

        Field[] fields = clazz.getDeclaredFields();

        for (Field f : fields) {

            Object[] obs = new Object[3];

            model = (DefaultTableModel) jTable2.getModel();

            f.setAccessible(true);

            obs[0] = f.getName();
            obs[2] = f.getType().getName();

            if (f.getName() == "" || f.getName() == null)
                continue;

            model.addRow(obs);

            jTable2.setModel(model);

        }

        jTable2.repaint();

    } catch (Exception ex) {
    }
    ;
}

From source file:NewApplication.java

private void EditTable(Class clazz, Object object) {
    // TODO add your handling code here:

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

    model.setColumnCount(3);/* w ww.  ja v  a  2  s. c  om*/

    model.setNumRows(0);

    jTable2.setModel(model);

    TableColumn tc = jTable2.getColumnModel().getColumn(0);
    tc.setHeaderValue("Field Name");
    tc = jTable2.getColumnModel().getColumn(1);
    tc.setHeaderValue("Value");
    tc = jTable2.getColumnModel().getColumn(2);
    tc.setHeaderValue("Type");

    try {

        Field[] fields = clazz.getDeclaredFields();

        for (Field f : fields) {

            Object[] obs = new Object[3];

            model = (DefaultTableModel) jTable2.getModel();

            f.setAccessible(true);

            obs[0] = f.getName();
            obs[1] = f.get(object);
            obs[2] = f.getType().getName();

            if (f.getName() == "" || f.getName() == null)
                continue;

            model.addRow(obs);

            jTable2.setModel(model);

        }

        jTable2.repaint();

    } catch (Exception ex) {
    }
    ;
}

From source file:NewApplication.java

private void EditTable() {
    // TODO add your handling code here:

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

    model.setColumnCount(3);/*from   w  ww. j  av a2s.  co  m*/

    model.setNumRows(0);

    jTable2.setModel(model);

    TableColumn tc = jTable2.getColumnModel().getColumn(0);
    tc.setHeaderValue("Field Name");
    tc = jTable2.getColumnModel().getColumn(1);
    tc.setHeaderValue("Value");
    tc = jTable2.getColumnModel().getColumn(2);
    tc.setHeaderValue("Type");

    int index = listEntities.getSelectedIndex();

    if (index < 0)
        return;
    Class clazz = null;
    if (ens != null)
        clazz = (Class) ens.get(index);

    try {

        Field[] fields = clazz.getDeclaredFields();

        for (Field f : fields) {

            Object[] obs = new Object[3];

            model = (DefaultTableModel) jTable2.getModel();

            f.setAccessible(true);

            obs[0] = f.getName();
            obs[2] = f.getType().getName();

            if (f.getName() == "" || f.getName() == null)
                continue;

            model.addRow(obs);

            jTable2.setModel(model);

        }

        jTable2.repaint();

    } catch (Exception ex) {
    }
    ;
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void preencherTabela() {
    JTableRenderer render = new JTableRenderer();
    render.setHorizontalAlignment(SwingConstants.CENTER);
    DefaultTableCellRenderer centralizar = new DefaultTableCellRenderer();
    centralizar.setHorizontalAlignment(SwingConstants.CENTER);

    ((DefaultTableCellRenderer) tabelaEnvios.getTableHeader().getDefaultRenderer())
            .setHorizontalAlignment(SwingConstants.CENTER);
    tabelaEnvios.getColumnModel().getColumn(0).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(1).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(2).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(3).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(4).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(5).setCellRenderer(centralizar);
    tabelaEnvios.getColumnModel().getColumn(6).setCellRenderer(render);
    //        tabelaEnvios.getColumnModel().getColumn(7).setCellRenderer(render);

    DefaultTableModel modelo = (DefaultTableModel) tabelaEnvios.getModel();
    modelo.setNumRows(0);

    try {/* www . j  a  va  2s.c  o m*/
        Icon log = new ImageIcon(getClass().getResource("/imagens/notas_20x20.png"));
        //Icon criticas = new ImageIcon(getClass().getResource("/imagens/alerta_20x20.png"));
        SimpleDateFormat formatComHora = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        SimpleDateFormat formatSemHora = new SimpleDateFormat("dd-MM-yyyy");
        //modelo.addRow(new Object[]{1,formatSemHora.format(DateTime.now().toDate()),formatComHora.format(DateTime.now().toDate()), "JONATHAN",
        //formatComHora.format(DateTime.now().toDate()), "JONATHAN", log, criticas });
        for (PosGpxConsignacaoPopulisControle cp : svc.buscarHistoricoProcessamento()) {
            ;
            modelo.addRow(new Object[] { cp.getSqControle(), formatSemHora.format(cp.getDtReferencia()),
                    cp.getDtExportacao() == null ? "" : formatComHora.format(cp.getDtExportacao()),
                    cp.getCdUserExportacao(),
                    cp.getDtImportacao() == null ? "" : formatComHora.format(cp.getDtImportacao()),
                    cp.getCdUserImportacao(), log });
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao carregar a tabela de envios!!!", "Mensagem de erro",
                JOptionPane.OK_OPTION);
    }

}

From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java

private void buscaAtendimento(String campo, String parametro, Integer idusuario, Boolean supervisor) {
    DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel();
    tabelaatendimento.setNumRows(0);
    //String status=verificaStatus();
    lab = new AtendimentoDao().getAtendimento(verificaStatus(), campo, parametro, idusuario, supervisor,
            jDinicial.getDate(), jDfinal.getDate(), getTipoData());
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    TableCellRenderer renderer = new PintarLinhasTabelaAtend(false);
    jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer);
    for (AtendimentoBeans ab : lab) {
        tabelaatendimento/* w  w w  . ja v  a 2 s  .  c o  m*/
                .addRow(new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()),
                        ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() });
    }
    jDconsulta.setVisible(false);
}

From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java

public void buscaAtendimento(String tipo, final String status, final Integer idtecnico, final Date ini,
        final Date fin, String campo) {
    new Thread(new Runnable() {
        @Override/*from  ww  w .j a va  2  s .c  o  m*/
        public void run() {
            showAguarde();
        }
    }).start();
    DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel();
    tabelaatendimento.setNumRows(0);
    try {
        lab = new AtendimentoDao().getAtendimento(tipo, status, idtecnico,
                new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData());
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Erro ao consultar Atendimento\n" + ex, "Atendimento",
                JOptionPane.ERROR_MESSAGE);
        jDaguarde.setVisible(false);
    }
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    TableCellRenderer renderer = new PintarLinhasTabelaAtend(false);
    jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer);
    for (AtendimentoBeans ab : lab) {
        tabelaatendimento
                .addRow(new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()),
                        ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() });
    }
    jDaguarde.setVisible(false);
}