Example usage for javax.swing.table TableModel getRowCount

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

Introduction

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

Prototype

public int getRowCount();

Source Link

Document

Returns the number of rows in the model.

Usage

From source file:semaforo.Semaforo.java

private int getFilaTickerFrontEnd(TableModel temp, String name) {

    int i = 0;/*from w ww. ja v a  2s .c  om*/

    String tickerName = "";
    Object objTicker = null;

    while (i < temp.getRowCount()) {
        objTicker = temp.getValueAt(i, 0);
        if (objTicker != null) {
            tickerName = objTicker.toString();
            if (tickerName.compareTo(name) == 0) {
                break;
            }

        }
        i++;

    }

    return (i == temp.getRowCount()) ? -1 : i;
}

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

private void waitForPreviousCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_waitForPreviousCheckboxActionPerformed
    currentChannel.getDestinationConnectors().get(destinationTable.getSelectedModelIndex())
            .setWaitForPrevious(waitForPreviousCheckbox.isSelected());

    TableModel model = destinationTable.getModel();
    int rowCount = model.getRowCount();
    int colNum = destinationTable.getColumnModelIndex(DESTINATION_CHAIN_COLUMN_NAME);
    boolean waitForPrevious = waitForPreviousCheckbox.isSelected();

    for (int i = destinationTable.getSelectedModelIndex(); i < rowCount; i++) {
        Integer chain = (Integer) model.getValueAt(i, colNum);
        chain += (waitForPrevious) ? -1 : 1;
        model.setValueAt(chain, i, colNum);
    }/*w  w w.  ja  va  2 s  .  co m*/
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * @param model//from   w  ww  .j  a  v a  2s .c  om
 * @return
 * @throws Exception
 */
public DynamicReport buildReport(final TableModel model, final PageSetupDlg pageSetupDlg) throws Exception {
    // Find a Sans Serif Font on the System
    String fontName = null;

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    for (java.awt.Font font : ge.getAllFonts()) {
        String fName = font.getFamily().toLowerCase();
        if (StringUtils.contains(fName, "sansserif") || StringUtils.contains(fName, "arial")
                || StringUtils.contains(fName, "verdana")) {
            fontName = font.getFamily();
        }
    }

    if (fontName == null) {
        fontName = Font._FONT_TIMES_NEW_ROMAN;
    }

    /**
     * Creates the DynamicReportBuilder and sets the basic options for the report
     */
    FastReportBuilder drb = new FastReportBuilder();

    Style columDetail = new Style();
    //columDetail.setBorder(Border.THIN);

    Style columDetailWhite = new Style();
    //columDetailWhite.setBorder(Border.THIN);
    columDetailWhite.setBackgroundColor(Color.WHITE);
    columDetailWhite.setFont(new Font(10, fontName, true));
    columDetailWhite.setHorizontalAlign(HorizontalAlign.CENTER);
    columDetailWhite.setBlankWhenNull(true);

    Style columDetailWhiteBold = new Style();
    //columDetailWhiteBold.setBorder(Border.THIN);
    columDetailWhiteBold.setBackgroundColor(Color.WHITE);

    Style titleStyle = new Style();
    titleStyle.setFont(new Font(14, fontName, true));

    /*Style numberStyle = new Style();
    numberStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
            
    Style amountStyle = new Style();
    amountStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
    amountStyle.setBackgroundColor(Color.cyan);
    amountStyle.setTransparency(Transparency.OPAQUE);*/

    //Font dataRowFont = new Font(10, Font._FONT_VERDANA, true);

    // Odd Row Style
    Style oddRowStyle = new Style();
    //oddRowStyle.setBorder(Border.NO_BORDER);
    //oddRowStyle.setFont(dataRowFont);
    oddRowStyle.setHorizontalAlign(HorizontalAlign.CENTER);

    Color veryLightGrey = new Color(240, 240, 240);
    oddRowStyle.setBackgroundColor(veryLightGrey);
    oddRowStyle.setTransparency(Transparency.OPAQUE);

    // Event Row Style
    //Style evenRowStyle = new Style();
    //evenRowStyle.setBorder(Border.NO_BORDER);
    //evenRowStyle.setFont(dataRowFont);

    // Create Column Headers for the Report
    for (int i = 0; i < model.getColumnCount(); i++) {
        String colName = model.getColumnName(i);

        Class<?> dataClass = model.getColumnClass(i);
        if (dataClass == Object.class) {
            if (model.getRowCount() > 0) {
                Object data = model.getValueAt(0, i);
                if (data != null) {
                    dataClass = data.getClass();
                } else {
                    // Column in first row was null so search down the rows
                    // for a non-empty cell
                    for (int j = 1; j < model.getRowCount(); j++) {
                        data = model.getValueAt(j, i);
                        if (dataClass != null) {
                            dataClass = data.getClass();
                            break;
                        }
                    }

                    if (dataClass == null) {
                        dataClass = String.class;
                    }
                }
            }
        }

        ColumnBuilder colBldr = ColumnBuilder.getInstance().setColumnProperty(colName, dataClass.getName());
        int bracketInx = colName.indexOf('[');
        if (bracketInx > -1) {
            colName = colName.substring(0, bracketInx - 1);
        }
        colBldr.setTitle(colName);
        //colBldr.setWidth(new Integer(100));

        colBldr.setStyle(columDetailWhite);
        //colBldr.setHeaderStyle(columDetailWhite);

        AbstractColumn column = colBldr.build();
        drb.addColumn(column);

        Style headerStyle = new Style();
        headerStyle.setFont(new Font(12, fontName, true));
        //headerStyle.setBorder(Border.THIN);
        headerStyle.setHorizontalAlign(HorizontalAlign.CENTER);
        headerStyle.setVerticalAlign(VerticalAlign.MIDDLE);
        headerStyle.setBackgroundColor(new Color(80, 80, 80));
        headerStyle.setTransparency(Transparency.OPAQUE);
        headerStyle.setTextColor(new Color(255, 255, 255));
        column.setHeaderStyle(headerStyle);
    }

    drb.setTitle(pageSetupDlg.getPageTitle());
    drb.setTitleStyle(titleStyle);
    //drb.setTitleHeight(new Integer(30));
    //drb.setSubtitleHeight(new Integer(20));
    //drb.setDetailHeight(new Integer(15));
    //drb.setDefaultStyles(null, null, null, evenRowStyle);

    drb.setLeftMargin(20);
    drb.setRightMargin(20);
    drb.setTopMargin(10);
    drb.setBottomMargin(10);

    drb.setPrintBackgroundOnOddRows(true);
    drb.setOddRowBackgroundStyle(oddRowStyle);
    drb.setColumnsPerPage(new Integer(1));
    drb.setUseFullPageWidth(true);
    drb.setColumnSpace(new Integer(5));

    // This next line causes an exception
    // Event with DynamicReport 3.0.12 and JasperReposrts 3.7.3
    //drb.addAutoText(AutoText.AUTOTEXT_PAGE_X_OF_Y, AutoText.POSITION_FOOTER, AutoText.ALIGMENT_CENTER);

    Page[] pageSizes = new Page[] { Page.Page_Letter_Portrait(), Page.Page_Legal_Portrait(),
            Page.Page_A4_Portrait(), Page.Page_Letter_Landscape(), Page.Page_Legal_Landscape(),
            Page.Page_A4_Landscape() };
    int pageSizeInx = pageSetupDlg.getPageSize() + (pageSetupDlg.isPortrait() ? 0 : 3);
    drb.setPageSizeAndOrientation(pageSizes[pageSizeInx]);

    DynamicReport dr = drb.build();

    return dr;
}

From source file:app.RunApp.java

/**
 * Action for Clear button from principal tab
 * /*w w  w.  j av  a2 s. com*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonClearActionPerformedPrincipal(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        tmodel.setValueAt(Boolean.FALSE, i, 2);
    }

    clearTableMetricsPrincipal();
}

From source file:app.RunApp.java

/**
 * Action for None button from principal tab
 * /*  ww  w.  j a va 2  s .co  m*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonNoneActionPerformedPrincipal(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        tmodel.setValueAt(Boolean.FALSE, i, 2);
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Action for None button from multiple datasets tab
 * //w w  w  .ja va  2 s.c o m
 * @param evt Event
 * @param jtable Table
 */
private void buttonNoneActionPerformedMulti(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        tmodel.setValueAt(Boolean.FALSE, i, 1);
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Action for All button from principal tab
 * /*from   w w  w . j a v  a  2s.c o  m*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonAllActionPerformedPrincipal(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        tmodel.setValueAt(Boolean.TRUE, i, 2);
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Action for All button from multiple datasets tab
 * /*  ww w.  j ava  2  s. c o  m*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonAllActionPerformedMulti(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        tmodel.setValueAt(Boolean.TRUE, i, 1);
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Get selected metrics in table from principal tab
 * //from  w  w  w .  j a v  a2  s  .  co  m
 * @param jtable Table
 * @return List with the selected metrics
 */
private ArrayList<String> getMetricsSelectedPrincipal(JTable jtable) {
    ArrayList<String> result = new ArrayList();
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        if ((Boolean) tmodel.getValueAt(i, 2)) {
            String selected = (String) tmodel.getValueAt(i, 0);
            result.add(selected);
        }
    }
    return result;
}

From source file:app.RunApp.java

/**
 * Get selected metrics in table from multiple datasets tab
 * //from   ww w  . jav  a  2s  .  c  o m
 * @param jtable Table
 * @return List with the selected metrics
 */
private ArrayList<String> getSelectedMetricsMulti(JTable jtable) {
    ArrayList<String> result = new ArrayList();
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        if ((Boolean) tmodel.getValueAt(i, 1)) {
            String selected = (String) tmodel.getValueAt(i, 0);
            result.add(selected);
        }
    }
    return result;
}