Example usage for javax.swing JTable getModel

List of usage examples for javax.swing JTable getModel

Introduction

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

Prototype

public TableModel getModel() 

Source Link

Document

Returns the TableModel that provides the data displayed by this JTable .

Usage

From source file:app.RunApp.java

/**
 * Action for All button from principal tab
 * //from w w  w .  j  a  v  a2 s.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 a  va 2 s .  c  om
 * @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

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

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

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

From source file:app.RunApp.java

/**
 * Action for Invert button from multiple datasets tab
 * /* w  ww .  j av  a  2 s .  c om*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonInvertActionPerformedMulti(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

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

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

From source file:app.RunApp.java

/**
 * Set help for metrics table/*from w  w  w  . j ava 2 s. c o m*/
 * 
 * @param jtable Table
 * @return Table with help
 */
public JTable setMetricsHelp(JTable jtable) {
    jtable = new JTable(jtable.getModel()) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;
                jc.setToolTipText(MetricUtils.getMetricTooltip(getValueAt(row, 0).toString()));
            }
            return c;
        }
    };

    return jtable;
}

From source file:app.RunApp.java

/**
 * Set help for Chi and Phi /*from   w ww  .  j  av  a  2s  . co  m*/
 * 
 * @param jtable Table
 * @return Table with help
 */
public JTable setChiPhiTableHelp(JTable jtable) {
    jtable = new JTable(jtable.getModel()) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;
                if (row > column) {
                    jc.setToolTipText("Chi(" + getColumnName(row) + ", " + getColumnName(column) + ")");
                } else if (column > row) {
                    jc.setToolTipText("Phi(" + getColumnName(row) + ", " + getColumnName(column) + ")");
                }
            }
            return c;
        }
    };

    return jtable;
}

From source file:app.RunApp.java

/**
 * Set help for Co-ocurrence table/* www .j  a  v a2s.com*/
 * 
 * @param jtable Table
 * @return Table with help
 */
public JTable setCoocurrenceTableHelp(JTable jtable) {
    jtable = new JTable(jtable.getModel()) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;
                if (row > column) {
                    jc.setToolTipText("Coocurrence(" + getColumnName(row) + ", " + getColumnName(column) + ")");
                } else {
                    jc.setToolTipText(null);
                }
            }
            return c;
        }
    };

    return jtable;
}

From source file:app.RunApp.java

/**
 * Set help for heatmap table/* ww w  .ja v a  2 s . c  om*/
 * 
 * @param jtable Table
 * @return Table with help
 */
public JTable setHeatmapTableHelp(JTable jtable) {
    jtable = new JTable(jtable.getModel()) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;

                if (column == row) {
                    jc.setToolTipText("P(" + getColumnName(row) + ")");
                } else {
                    jc.setToolTipText("P(" + getColumnName(row) + " | " + getColumnName(column) + ")");
                }
            }
            return c;
        }
    };

    return jtable;
}

From source file:app.RunApp.java

/**
 * Set help for MVML table//from ww w . jav  a  2 s . com
 * 
 * @param jtable Table
 * @return Table with help
 */
public JTable setMVTableHelp(JTable jtable) {
    jtable = new JTable(jtable.getModel()) {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
                JComponent jc = (JComponent) c;

                switch (column) {
                case 0:
                    jc.setToolTipText("View name");
                    break;
                case 1:
                    jc.setToolTipText("Number of the attributes of the view");
                    break;
                case 2:
                    jc.setToolTipText("Labels x Instances x Features");
                    break;
                case 3:
                    jc.setToolTipText("Ratio of number of instances to the number of attributes");
                    break;
                case 4:
                    jc.setToolTipText("Average gain ratio");
                    break;
                default:
                    break;
                }
            }
            return c;
        }
    };

    return jtable;
}

From source file:app.RunApp.java

/**
 * Get selected metrics in table from principal tab
 * //from   w  ww  . j a v  a 2s . c o  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;
}