Example usage for javax.swing JTable getRowCount

List of usage examples for javax.swing JTable getRowCount

Introduction

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

Prototype

@BeanProperty(bound = false)
public int getRowCount() 

Source Link

Document

Returns the number of rows that can be shown in the JTable, given unlimited space.

Usage

From source file:edu.ucla.stat.SOCR.chart.demo.MultiIndexChart.java

public void resetExample() {
    //  System.out.println("resetExample get called");
    XYDataset dataset = createDataset1(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();//from  w w w  .j a  v  a  2 s .  com

    hasExample = true;

    //System.out.println("independentVarLength="+independentVarLength);
    //  System.out.println("raw+x="+raw_x[0]);
    int colCount = dataset.getSeriesCount();
    String[] columnName = new String[colCount];
    for (int i = 0; i < colCount; i++)
        columnName[i] = dataset.getSeriesKey(i).toString();

    convertor.multiY2Table(raw_x2, row_count, colCount, columnName);
    //convertor.dataset2Table(dataset);            
    JTable tempDataTable = convertor.getTable();

    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount());

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
            //System.out.println("setTabledata "+tempDataTable.getValueAt(i,j));
        }

    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < colCount; i++)
        addButtonIndependent();//Y

    rangeLabel = "";
    for (int j = 0; j < colCount; j++)
        rangeLabel += columnName[j] + "/";
    rangeLabel = rangeLabel.substring(0, rangeLabel.length() - 1);

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.demo.EventFrequencyDemo1.java

public void resetExample() {

    dataset = createDataset(true);//from   w  ww  . j av a 2 s.c  o  m

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);

    //      setSummary(dataset);
    setChart();

    hasExample = true;
    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount() + 1);

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    DecimalFormat f = new DecimalFormat("#.#E0");
    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            if (j != 0) {
                try {
                    long time = f.parse((String) tempDataTable.getValueAt(i, j)).longValue();
                    Date date = new Date(time);
                    dataTable.setValueAt(new Day(date).toString(), i, j);
                } catch (ParseException e) {
                    dataTable.setValueAt("NaN", i, j);
                }
            } else
                dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    addButtonDependent();
    int columnCount = dataset.getColumnCount();
    for (int i = 0; i < columnCount; i++)
        addButtonIndependent();

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo3.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///w  w  w  .  j a  v a2  s  . c o  m
public void resetExample() {
    isDemo = true;
    IntervalXYDataset dataset = createDataset(isDemo);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;

    convertor.dataset2Table((TimeSeriesCollection) dataset);
    JTable tempDataTable = convertor.getTable();
    int seriesCount = tempDataTable.getColumnCount() / 2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(seriesCount * 2);

    for (int i = 0; i < seriesCount * 2; i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
    }

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYAreaChartDemo2.java

public void resetExample() {
    isDemo = true;/*w ww . ja  v  a 2  s  .  co  m*/
    XYDataset dataset = createDataset(isDemo);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;

    convertor.dataset2Table((TimeSeriesCollection) dataset);
    JTable tempDataTable = convertor.getTable();
    int seriesCount = tempDataTable.getColumnCount() / 2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(seriesCount * 2 + 2);

    for (int i = 0; i < seriesCount * 2; i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
    }

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo4.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///from w w w .ja va 2s .c  o  m
public void resetExample() {
    isDemo = true;

    IntervalXYDataset dataset = createDataset(isDemo);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;

    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    int seriesCount = tempDataTable.getColumnCount() / 2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(seriesCount * 2);

    //correct the column name
    columnModel.getColumn(0).setHeaderValue("Data");
    columnModel.getColumn(1).setHeaderValue("Frequency");
    domainLabel = "Data";
    rangeLabel = "Frequency";

    /*   for(int i=0;i<seriesCount*2;i++) {
    columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }*/

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
    }

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.SuperValueChart.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///from w  ww .  j  av a 2 s. co m
public void resetExample() {

    ValueDataset dataset = createDataset(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;
    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount());

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping

    setMapping();

    updateStatus(url);
}

From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo2.java

public void resetExample() {

    BoxAndWhiskerCategoryDataset dataset = createDataset(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();//from  w  ww  . j a v  a2 s.c  o  m

    hasExample = true;

    convertor.Y2Table(raw_y, data_count);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount());

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    addButtonIndependent();//Y
    updateStatus(url);
}

From source file:Main.java

public Main() {
    JTable table = new JTable(3, 3);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    for (int i = 0; i < table.getColumnCount(); i++) {
        DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
        TableColumn col = colModel.getColumn(i);
        int width = 0;

        TableCellRenderer renderer = col.getHeaderRenderer();
        for (int r = 0; r < table.getRowCount(); r++) {
            renderer = table.getCellRenderer(r, i);
            Component comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, i), false, false,
                    r, i);/*from w  ww .  j a  v  a  2 s .c o  m*/
            width = Math.max(width, comp.getPreferredSize().width);
        }
        col.setPreferredWidth(width + 2);
    }
    JFrame f = new JFrame();
    f.add(new JScrollPane(table));
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:medsavant.enrichment.app.RegionListAggregatePanel.java

private void resetCounts() {
    variantCounts.clear();/*from  w w w.  java  2 s.  com*/
    patientCounts.clear();
    for (GenomicRegion r : currentRegions) {
        variantCounts.put(r, null);
        patientCounts.put(r, null);
    }
    JTable t = tablePanel.getTable();
    for (int i = 0; i < t.getRowCount(); i++) {
        t.setValueAt("", i, VARIANT_COLUMN);
        t.setValueAt("", i, VARIANTPERKB_COLUMN);
        t.setValueAt("", i, PATIENT_COLUMN);
    }
}

From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Stat.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *///w  w  w .ja va2 s.  c om
public void resetExample() {

    dataset = (DefaultStatisticalCategoryDataset) createDataset(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    //      setSummary(dataset);
    setChart();

    hasExample = true;
    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount() + 1);

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
    }
    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    setMapping();
    updateStatus(url);
}