Example usage for javax.swing JTable getColumnCount

List of usage examples for javax.swing JTable getColumnCount

Introduction

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

Prototype

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

Source Link

Document

Returns the number of columns in the column model.

Usage

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

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

    dataset = (DefaultStatisticalCategoryDataset) createDataset(true);

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

    hasExample = true;
    convertor.dataset2TableA(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));
    }
    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.HistogramChartDemo6.java

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

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

    hasExample = true;

    //convertor.dataset2Table(dataset);   
    convertor.data2Table(raw_x, y_freq, domainLabel, rangeLabel, data_count);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);

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

    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));
    }

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    dataPanel.removeAll();
    JScrollPane tablePanel = new JScrollPane(dataTable);
    tablePanel.setRowHeaderView(headerTable);
    dataPanel.add(tablePanel);
    dataPanel.add(new JScrollPane(summaryPanel));
    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();

    setMapping();

    updateStatus(url);
}

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

public void resetExample() {
    isDemo = true;/*from ww w .j  a  va 2  s.  co  m*/
    dataset = createDataset(isDemo);

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

    hasExample = true;

    //convertor.dataset2Table(dataset);   
    convertor.data2Table(raw_x, raw_y, domainLabel, rangeLabel, xyLength);

    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount() + 1);

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

    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));
    }

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }

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

    dataPanel.removeAll();
    JScrollPane tablePanel = new JScrollPane(dataTable);
    tablePanel.setRowHeaderView(headerTable);
    dataPanel.add(tablePanel);
    dataPanel.add(new JScrollPane(summaryPanel));
    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();

    setMapping();

    updateStatus(url);
}

From source file:SampleTableModel.java

@Override
public void init() {
    tableModel = new SampleTableModel();
    // create javafx panel for charts
    chartFxPanel = new JFXPanel();
    chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT));

    //JTable/*  w  ww.j a v  a  2  s. c om*/
    JTable table = new JTable(tableModel);
    table.setAutoCreateRowSorter(true);
    table.setGridColor(Color.DARK_GRAY);
    SwingInterop.DecimalFormatRenderer renderer = new SwingInterop.DecimalFormatRenderer();
    renderer.setHorizontalAlignment(JLabel.RIGHT);
    for (int i = 0; i < table.getColumnCount(); i++) {
        table.getColumnModel().getColumn(i).setCellRenderer(renderer);
    }
    JScrollPane tablePanel = new JScrollPane(table);
    tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT));

    JPanel chartTablePanel = new JPanel();
    chartTablePanel.setLayout(new BorderLayout());

    //Split pane that holds both chart and table
    JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    jsplitPane.setTopComponent(chartTablePanel);
    jsplitPane.setBottomComponent(tablePanel);
    jsplitPane.setDividerLocation(410);
    chartTablePanel.add(chartFxPanel, BorderLayout.CENTER);

    //          add(tablePanel, BorderLayout.CENTER);
    add(jsplitPane, BorderLayout.CENTER);

    // create JavaFX scene
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            createScene();
        }
    });
}

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

/**
 * reset dataTable to default (demo data), and refesh chart
 *///  ww  w  .j a  va2s  .  c  o  m
public void resetExample() {
    isDemo = true;

    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();

    setMapping();

    updateStatus(url);
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellStatisticsController.java

/**
 * Show Summary Statistics in correspondent table
 *
 * @param analysisGroup// w  w  w  . j ava 2  s. co m
 */
private void showSummary(SingleCellAnalysisGroup singleCellAnalysisGroup) {
    singleCellAnalysisController.getAnalysisPanel().getCurrentGroupName()
            .setText(singleCellAnalysisGroup.getGroupName());
    // set model and cell renderer for statistics summary table
    SingleCellStatSummaryTableModel statisticalSummaryTableModel = new SingleCellStatSummaryTableModel(
            singleCellAnalysisGroup);
    JTable statisticalSummaryTable = singleCellAnalysisController.getAnalysisPanel().getStatTable();
    statisticalSummaryTable.setModel(statisticalSummaryTableModel);
    for (int i = 1; i < statisticalSummaryTable.getColumnCount(); i++) {
        statisticalSummaryTable.getColumnModel().getColumn(i)
                .setCellRenderer(new FormatRenderer(new DecimalFormat("#.####"), SwingConstants.CENTER));
    }
    statisticalSummaryTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.RIGHT));
}

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

protected void setTable(XYDataset ds) {

    convertor.data2Table(raw_y, transformed_x, "Data", "Transformed Data", row_count);
    //convertor.dataset2Table(dataset);            
    JTable tempDataTable = convertor.getTable();

    resetTableRows(tempDataTable.getRowCount());
    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));
    }//from  w  ww.  j  a v  a2s .co m

    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();
    JScrollPane dt = new JScrollPane(dataTable);
    dataPanel.add(dt);
    dt.setRowHeaderView(headerTable);
    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();

    // don't bring graph to the front
    if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) {
        //   tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel));
    } else {
        dataPanel2.removeAll();
        dataPanel2.add(new JLabel(" "));
        dataPanel2.add(new JLabel("Data"));
        JScrollPane dt2 = new JScrollPane(dataTable);
        dt2.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8));
        dt2.setRowHeaderView(headerTable);
        dataPanel2.add(dt2);
        JScrollPane st = new JScrollPane(summaryPanel);
        st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6));
        dataPanel2.add(st);
        st.validate();

        dataPanel2.add(new JLabel(" "));
        dataPanel2.add(new JLabel("Mapping"));
        mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2));
        dataPanel2.add(mapPanel);

        dataPanel2.validate();
    }
}

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

/**
  * reset dataTable to default (demo data), and refesh chart
  */// ww w . ja v a2 s  .  co m
public void resetExample() {
    isDemo = true;
    dataset = createDataset(isDemo);

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

    hasExample = true;
    convertor.YIntervalDataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount());
    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);

    // 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.SuperXYChart_QQ_DD.java

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

    XYDataset dataset = createDataset(true);

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

    hasExample = true;
    convertor.XY2Table(raw_x, raw_y, larger_row_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));
        columnModel.getColumn(i).setHeaderValue("Group " + (i + 1));
    }

    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.SuperCategoryChart_vertical.java

/**
  * reset dataTable to default (demo data), and refesh chart
  *//*  w  w w  .j  a  v a  2  s .c  o  m*/
public void resetExample() {

    dataset = createDataset(true);

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

    setChart();

    hasExample = true;
    convertor.dataset2Table_vertical(dataset);
    JTable tempDataTable = convertor.getTable();
    resetTableRows(tempDataTable.getRowCount());
    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);
}