Example usage for javax.swing.table DefaultTableModel getRowCount

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

Introduction

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

Prototype

public int getRowCount() 

Source Link

Document

Returns the number of rows in this data table.

Usage

From source file:MainWindowLogic.java

static void readPointsFile(File fil_hndl, JTable tabela) throws IOException, InvalidFormatInFileException {
    ReadPointsFromFile pointsReader = new ReadPointsFromFile(fil_hndl.getPath());
    System.out.println("cieka wcztytywanego pliku: " + fil_hndl.getPath());
    Point2D[] readed = pointsReader.readPoints();

    DefaultTableModel defaultModelTabeli = (DefaultTableModel) tabela.getModel();

    for (Point2D point : readed) {
        defaultModelTabeli.addRow(/*from  w  ww .  j  a  v a  2  s .c  om*/
                new Object[] { defaultModelTabeli.getRowCount() + 1 + ".", point.getX(), point.getY(), false });
    }

}

From source file:com.db2eshop.gui.component.table.BookingTable.java

/**
 * <p>destroy.</p>//  w  w w  .j  a  v a  2  s  . c om
 */
public void destroy() {
    this.ready = false;
    DefaultTableModel tableModel = ((DefaultTableModel) this.getModel());
    for (int i = tableModel.getRowCount() - 1; i >= 0; i--) {
        try {
            tableModel.removeRow(i);
        } catch (Exception e) {
            // fuck it
        }
    }
    //      ((DefaultTableModel)this.getModel()).setRowCount(0);
}

From source file:de.main.sessioncreator.ReportingHelper.java

public String getAllSessionCount(DefaultTableModel model) {
    int rows = model.getRowCount();
    int counter = 0;
    int i = 0;//ww w  .j  a va2 s . c  om
    while (i < rows) {
        counter += Integer.valueOf(model.getValueAt(i, 1).toString());
        i++;
    }
    return String.valueOf(counter);
}

From source file:com.yosanai.java.swing.config.ConfigPanel.java

public void loadConfig(Map<String, String> config) {
    DefaultTableModel model = (DefaultTableModel) tblConfig.getModel();
    while (0 < model.getRowCount()) {
        model.removeRow(0);/*from  w w w. ja  v a2  s. com*/
    }
    for (String key : config.keySet()) {
        model.addRow(new Object[] { key, (null == config.get(key) ? "" : config.get(key)) });
    }
}

From source file:com.yosanai.java.swing.config.FileBackedConfigDialog.java

protected void load(String... keys) {
    DefaultTableModel model = (DefaultTableModel) tblConfig.getModel();
    while (0 < model.getRowCount()) {
        model.removeRow(0);/*from ww  w .j a va  2s.  co m*/
    }
    for (String key : keys) {
        model.addRow(new Object[] { key, configuration.getString(key, "") });
    }
}

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

private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
    String tag = StringUtils.trim((String) tagComboBox.getSelectedItem());

    if (tag == null || tag.isEmpty()) {
        parent.alertError(parent, "Please enter a tag");
    } else {/*from ww w .  j  ava  2  s  .c  om*/
        DefaultTableModel model = (DefaultTableModel) tagTable.getModel();
        int rowCount = model.getRowCount();

        for (int i = 0; i < rowCount; i++) {
            if (model.getValueAt(i, 0).equals(tag)) {
                parent.alertError(parent, "\"" + tag + "\" is already assigned to this channel");
                return;
            }
        }

        model.addRow(new Object[] { tag });
        tagTable.setRowSelectionInterval(rowCount, rowCount);
        dispose();
    }
}

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

@Override
public void setVisible(boolean visible) {
    if (visible) {
        Dimension dlgSize = getPreferredSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            setLocationRelativeTo(null);
        } else {/*from w w w. java  2  s  .  com*/
            setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        Set<String> availableTags = new LinkedHashSet<String>(parent.getChannelTagInfo(false).getTags());
        DefaultTableModel model = (DefaultTableModel) tagTable.getModel();
        int rowCount = model.getRowCount();

        for (int i = 0; i < rowCount; i++) {
            availableTags.remove(model.getValueAt(i, 0));
        }

        tagComboBox.setModel(new DefaultComboBoxModel(availableTags.toArray()));

        if (availableTags.size() > 0) {
            tagComboBox.setSelectedIndex(0);
        }

        tagComboBox.requestFocusInWindow();
    }

    super.setVisible(visible);
}

From source file:UserInterface.Supplier.SalesOverviewJPanel.java

private void viewGraphJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewGraphJButtonActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) performanceJTable.getModel();
    int rows = dtm.getRowCount();

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

    for (int i = 0; i < rows; i++) {
        int quant = (int) performanceJTable.getValueAt(i, 1);
        dataSet.setValue(quant, "QuantitySold", (String) performanceJTable.getValueAt(i, 0));
    }//from  ww  w.  jav  a  2 s.c  o m

    JFreeChart chart = ChartFactory.createBarChart("Sales Performance Chart", "Product Name", "Quantity Sold",
            dataSet, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.BLACK);

    ChartFrame frame = new ChartFrame("Sales Overview", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);

}

From source file:UserInterface.Supplier.SalesOverviewJPanel.java

private void findTopProduct() {
    int max = 0;//  w w  w. j av a  2  s.  c om
    int current = 0;
    String currentPName = "null";
    ArrayList<String> currentPList = new ArrayList<>();
    currentPList.add("null");
    DefaultTableModel dtm = (DefaultTableModel) performanceJTable.getModel();
    for (int i = 0; i < dtm.getRowCount(); i++) {
        current = (int) dtm.getValueAt(i, 1);
        if (max < current) {
            max = current;
            currentPName = (String) dtm.getValueAt(i, 0);
            currentPList.clear();
            currentPList.add(currentPName);
        } else if (max == current) {
            currentPName = (String) dtm.getValueAt(i, 0);
            currentPList.add(currentPName);
        }
    }
    topSellingJLabel.setText(currentPList.toString());

}

From source file:Software_Jframes.chart.java

void print_excel_report(JTable jTable5) {
    Access ac = new Access();
    try {/*from   w w w. j  a v a  2s  .  c  om*/
        String filename = ac.chooseFile();

        WritableWorkbook wworkbook;
        wworkbook = Workbook.createWorkbook(new File(filename + ".xls"));
        WritableSheet wsheet = wworkbook.createSheet("First Sheet", 0);

        DefaultTableModel dtm = (DefaultTableModel) jTable5.getModel();
        Vector v = new Vector();
        int count_row = dtm.getRowCount();
        int count_col = dtm.getColumnCount();

        jxl.write.Label label1 = new jxl.write.Label(0, 0, "Good Name");
        wsheet.addCell(label1);
        jxl.write.Label label2 = new jxl.write.Label(1, 0, "Project Name");
        wsheet.addCell(label2);
        jxl.write.Label label3 = new jxl.write.Label(2, 0, "Cost");
        wsheet.addCell(label3);

        int i = 0;
        int j = 0;

        for (i = 0; i < count_row; i++) {
            for (j = 0; j < count_col; j++) {
                int temp_i = i + 2;
                jxl.write.Label label = new jxl.write.Label(j, temp_i, dtm.getValueAt(i, j) + "");
                wsheet.addCell(label);
            }
        }
        wworkbook.write();
        wworkbook.close();
        JOptionPane.showMessageDialog(null, "Successfully Create a excel file");

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