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:com.sec.ose.osi.ui.frm.main.identification.stringmatch.table.JTableInfoForSMFile.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);/*w w w .  j  a  va 2  s.co m*/
    if (value != null) {
        if (table.getColumnName(column).equals("Version") || table.getColumnName(column).equals("Pending Hits")
                || table.getColumnName(column).equals("Status")
                || table.getColumnName(column).equals("Identified Hits")
                || table.getColumnName(column).equals("Files")) {
            setHorizontalAlignment(SwingConstants.CENTER);
        } else {
            setHorizontalAlignment(SwingConstants.LEFT);
        }

        comp.setToolTipText(String.valueOf(value));
        if (table.getValueAt(row, TableModelForSMFile.COL_STATUS) != null
                && table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Identified")) {

            comp.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 12));
            comp.setForeground(new Color(20, 20, 20));
        } else if (table.getValueAt(row, TableModelForSMFile.COL_STATUS).toString().equals("Declared")) {
            comp.setForeground(new Color(150, 150, 150));
        } else {
            comp.setForeground(new Color(20, 20, 20));
        }
    } else {
        comp.setToolTipText(null);
    }
    return comp;
}

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

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

    dataset = createDataset(true);

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

    hasExample = true;
    convertor.dataset2Table((TimeSeriesCollection) dataset);
    JTable tempDataTable = convertor.getTable();
    //resetTable();
    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:edu.ucla.stat.SOCR.chart.SuperCategoryChart_StatA.java

/**
 * reset dataTable to default (demo data), and refesh chart
 */// w ww. j  ava2  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
 *//*  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.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   w  ww .  ja  v  a  2s  .  c  o  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: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();/*www  .jav  a2  s.  c  o  m*/

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

public void resetExample() {
    isDemo = true;/*from  w w w  . j a v a  2 s.com*/
    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.SuperValueChart.java

/**
 * reset dataTable to default (demo data), and refesh chart
 *//*from w w w .j  a v a  2 s. c om*/
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 w w . j  a v a  2  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:com.vgi.mafscaling.OpenLoop.java

private boolean sortRunData(TreeMap<Integer, ArrayList<Double>> result) {
    int closestVoltIdx;
    double rpm;/*from w w  w .  j  ava2  s . co m*/
    double voltage;
    double error;
    ArrayList<Double> closestVolatageArray;
    for (int i = 0; i < runTables.length; ++i) {
        JTable table = runTables[i];
        String tableName = RunTableName + (i + 1);
        String rpmValue;
        String mafvValue;
        String afrValue;
        for (int j = 0; j < table.getRowCount(); ++j) {
            rpmValue = table.getValueAt(j, 0).toString();
            mafvValue = table.getValueAt(j, 1).toString();
            afrValue = table.getValueAt(j, 2).toString();
            if (rpmValue.isEmpty() || mafvValue.isEmpty() || afrValue.isEmpty())
                continue;
            if (!Utils.validateDouble(rpmValue, j, 0, tableName)
                    || !Utils.validateDouble(mafvValue, j, 1, tableName)
                    || !Utils.validateDouble(afrValue, j, 2, tableName))
                return false;
            rpm = Double.parseDouble(rpmValue);
            voltage = Double.parseDouble(mafvValue);
            error = Double.parseDouble(afrValue);
            rpmArray.add(rpm);
            mafvArray.add(voltage);
            afrArray.add(error);
            closestVoltIdx = Utils.closestValueIndex(voltage, voltArray);
            closestVolatageArray = result.get(closestVoltIdx);
            if (closestVolatageArray == null) {
                closestVolatageArray = new ArrayList<Double>();
                result.put(closestVoltIdx, closestVolatageArray);
            }
            closestVolatageArray.add(error);
        }
    }
    return true;
}