Example usage for javax.swing JTable getValueAt

List of usage examples for javax.swing JTable getValueAt

Introduction

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

Prototype

public Object getValueAt(int row, int column) 

Source Link

Document

Returns the cell value at row and column.

Usage

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

/**
 * reset dataTable to default (demo data), and refesh chart
 *//*  w w  w.ja  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(dataset);   
    convertor.Y2Table(raw_y, data_count);
    JTable tempDataTable = convertor.getTable();
    //int seriesCount = tempDataTable.getColumnCount()/2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    //resetTableColumns(seriesCount*2);
    resetTableColumns(1);

    //correct the column name
    //  columnModel.getColumn(0).setHeaderValue("Data");
    columnModel.getColumn(0).setHeaderValue("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();

    setMapping();

    updateStatus(url);
}

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

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

    dataset = createDataset(true);

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

    hasExample = true;
    convertor.valueList2Table(values_storage, SERIES_COUNT, CATEGORY_COUNT);
    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);
}

From source file:com.smanempat.controller.ControllerClassification.java

public void showClassificationResult(JTable tableResult, JTable tablePreview, String[] knnValue,
        int rowCountData, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan,
        JYearChooser jYearChooser1, JYearChooser jYearChooser2, int kValue) {
    DefaultTableModel tableModelResult = new DefaultTableModel();
    tableModelResult = (DefaultTableModel) tableResult.getModel();
    int jumlahSiswaIPA = 0;
    int jumlahSiswaIPS = 0;

    for (int i = 0; i < rowCountData; i++) {
        if (knnValue[i].equals("IPA")) {
            jumlahSiswaIPA = jumlahSiswaIPA + 1;
        } else if (knnValue[i].equalsIgnoreCase("IPS")) {
            jumlahSiswaIPS = jumlahSiswaIPS + 1;
        }//from  w ww  .ja v  a2  s  .  co  m

        String nis = tablePreview.getValueAt(i, 0).toString();
        String nama = tablePreview.getValueAt(i, 1).toString();
        String jenKel = tablePreview.getValueAt(i, 2).toString();
        String nilaiUN = tablePreview.getValueAt(i, 3).toString();
        String ptBindo = tablePreview.getValueAt(i, 4).toString();
        String ptMtk = tablePreview.getValueAt(i, 5).toString();
        String ptBing = tablePreview.getValueAt(i, 6).toString();
        String ptIpa = tablePreview.getValueAt(i, 7).toString();
        String minat = tablePreview.getValueAt(i, 8).toString();
        String jurusan = knnValue[i];
        Object[] resultData = { nis, nama, jenKel, nilaiUN, ptBindo, ptMtk, ptBing, ptIpa, minat, jurusan };
        tableModelResult.addRow(resultData);
    }
    tableResult.setModel(tableModelResult);
    labelSiswaIPA.setText(jumlahSiswaIPA + "");
    labelSiswaIPS.setText(jumlahSiswaIPS + "");
    labelKeterangan.setText("Hasil Klasifikasi Penjurusan Siswa Pada Tahun Ajaran " + jYearChooser1.getYear()
            + "/" + jYearChooser2.getYear() + ", dengan paramater K = " + kValue + " adalah sebagai berikut ");
}

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

protected void setTable(XYDataset ds) {

    convertor.Y2Table(raw_x, raw_y, transformed_x, transformed_y, 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));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }/*from   w  ww. j  a v  a2s. com*/

    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:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ??????//from   www.  ja v  a  2  s  .  c  o m
 * ?????????????
 * 
 * @return ???
 * @see JTable#getValueAt(int, int)
 * @see ItemSelectable#getSelectedObjects()
 */
public Object[] selectedObjects() {
    for (Component child : list) {
        if (child instanceof JTable) {
            JTable table = ((JTable) child);
            int[] rows = table.getSelectedRows();
            int col = table.getSelectedColumn();
            ArrayList<Object> sublist = new ArrayList<Object>();
            for (int index : rows) {
                sublist.add(table.getValueAt(index, col));
            }
            return sublist.toArray();
        } else if (child instanceof ItemSelectable) {
            ItemSelectable selector = (ItemSelectable) child;
            return selector.getSelectedObjects();
        } else {
            // ignore
        }
    }

    return new Object[0];
}

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

protected void setTable(XYDataset ds) {

    //System.out.println("setTable get Called");
    convertor.Power2Table(ds);//from   w  ww  .ja  v a 2  s  .c  om
    //convertor.dataset2Table(dataset);            
    JTable tempDataTable = convertor.getTable();

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

    //System.out.println(tempDataTable.getRowCount());

    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();
    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.SuperCategoryChart_Stat_Raw.java

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

    dataset = createDataset(true);

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

    hasExample = true;
    convertor.valueList2Table(values_storage, SERIES_COUNT, CATEGORY_COUNT);
    JTable tempDataTable = convertor.getTable();
    //      resetTable();
    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));

    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
    addButtonDependent();
    int columnCount = dataset.getColumnCount();
    for (int i = 0; i < columnCount; i++)
        addButtonIndependent();
    updateStatus(url);
}

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

/**
 * reset dataTable to default (demo data), and refesh chart
 *//*from  w w w  .ja v a 2 s .  co m*/
public void resetExample() {
    reset_Slider();
    XYZDataset dataset = createDataset(true);

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

    hasExample = true;
    convertor.dataset2Table(dataset);
    JTable tempDataTable = convertor.getTable();
    //      resetTable();
    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

    int seriesCount = dataset.getSeriesCount();
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
        addButtonDependent();
    }
    //updateStatus(url);
}

From source file:com.smanempat.controller.ControllerEvaluation.java

public void showDataSetModel(JTable tableDataSetModel, JTable tableTahunModel, JLabel totalDataModel)
        throws SQLException {
    int row;/*w  w w.java 2  s . co m*/
    int transMinat;
    tableModelDataSet1 = (DefaultTableModel) tableDataSetModel.getModel();
    row = tableModelDataSet1.getRowCount();
    for (int i = 0; i < row; i++) {
        tableModelDataSet1.removeRow(0);
    }
    row = tableTahunModel.getRowCount();
    boolean checkList;
    for (int i = 0; i < row; i++) {
        checkList = Boolean.valueOf("" + tableTahunModel.getValueAt(i, 1));
        if (checkList == true) {
            dbConnection = new DbConnection();
            connect = dbConnection.connect();
            query = "SELECT * FROM siswa WHERE tahun_ajaran = ?";
            pstmt = connect.prepareStatement(query);
            pstmt.setString(1, tableTahunModel.getValueAt(i, 0).toString());
            rs = pstmt.executeQuery();
            while (rs.next()) {
                String nis = rs.getString("nis");
                String nama = rs.getString("nama");
                String jenisKelamin = rs.getString("jenis_kelamin");
                String nilaiUN = rs.getString("nilai_un");
                double meanUN = Double.parseDouble(nilaiUN) / 4;
                String ptBindo = rs.getString("pt_bhs_indonesia");
                String ptMtk = rs.getString("pt_matematika");
                String ptBing = rs.getString("pt_bhs_inggris");
                String ptIpa = rs.getString("pt_ipa");
                double meanPt = (Double.parseDouble(ptBindo) + Double.parseDouble(ptMtk)
                        + Double.parseDouble(ptBing) + Double.parseDouble(ptIpa)) / 4;
                String minat = rs.getString("minat");
                if (minat.equals("IPA")) {
                    transMinat = 1;
                } else {
                    transMinat = 0;
                }
                String jurusan = rs.getString("jurusan");
                Object tableContent[] = { nis, nilaiUN, meanUN, ptBindo, ptMtk, ptBing, ptIpa, meanPt, minat,
                        transMinat, jurusan };
                tableModelDataSet1.addRow(tableContent);
            }
        }
        tableDataSetModel.setModel(tableModelDataSet1);
        totalDataModel.setText(tableDataSetModel.getRowCount() + " Data");
    }
}

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

/**
 * reset dataTable to default (demo data), and refesh chart
 *///from w  ww .  ja  v 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.Y2Table(raw_y, row_count);
    //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);
}