Example usage for javax.swing.table TableColumnModel getColumnCount

List of usage examples for javax.swing.table TableColumnModel getColumnCount

Introduction

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

Prototype

public int getColumnCount();

Source Link

Document

Returns the number of columns in the model.

Usage

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

public void setXLabel(String xLabel) {

    domainLabel = xLabel;/*from  w  ww.j a  v a  2 s  . c o  m*/
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount() / 2; i++)
        columnModel.getColumn(2 * i).setHeaderValue(xLabel + ":" + i);
    dataTable.setTableHeader(new EditableHeader(columnModel));
}

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

public void setYLabel(String yLabel) {
    rangeLabel = yLabel;//from www .  ja  va  2s .c o  m
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount() / 2; i++)
        columnModel.getColumn(2 * i + 1).setHeaderValue(yLabel + ":" + i);
    dataTable.setTableHeader(new EditableHeader(columnModel));

}

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

public void setYLabel(String yLabel) {
    rangeLabel = yLabel;/*from   w  w  w  .j  a  v a2s.  c  o  m*/
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount() / 2; i++)
        columnModel.getColumn(2 * i + 1).setHeaderValue(rangeLabel + i);
}

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

public void setXLabel(String xLabel) {

    domainLabel = xLabel;//from w ww  . j  a  v a 2s  .c  o  m
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount() / 2; i++)
        columnModel.getColumn(2 * i).setHeaderValue(domainLabel + i);

    dataTable.setTableHeader(new EditableHeader(columnModel));
}

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

public void setYLabel(String yLabel) {
    rangeLabel = yLabel;//from ww  w . j  a v a 2 s. co m

    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 1; i < columnModel.getColumnCount(); i++)
        columnModel.getColumn(i).setHeaderValue("Case" + i);
}

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

public void setXLabel(String xLabel) {
    domainLabel = xLabel;/*from  w  ww .j a v  a 2 s .  co  m*/
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount() / 2; i++)
        columnModel.getColumn(2 * i).setHeaderValue(xLabel + ":" + i);
    dataTable.setTableHeader(new EditableHeader(columnModel));
}

From source file:SortedTableModel.java

public SimpleTableTestMultilineHeader() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    TableValues tv = new TableValues();
    SortedTableModel stm = new SortedTableModel(tv);
    stm.sortRows(TableValues.ACCOUNT_BALANCE, true);
    table = new JTable(stm);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(true);
    TableColumnModel tcm = table.getColumnModel();
    TableColumn tc = tcm.getColumn(TableValues.GENDER);
    MultiLineHeaderRenderer mlhr = new MultiLineHeaderRenderer();
    tc = tcm.getColumn(TableValues.ACCOUNT_BALANCE);
    tc.setHeaderRenderer(mlhr);/*from w  w w.j  av  a2 s. c  om*/
    renderer = new SortedColumnHeaderRenderer(stm, mlhr);
    int count = tcm.getColumnCount();
    for (int i = 0; i < count; i++) {
        tc = tcm.getColumn(i);
        tc.setHeaderRenderer(renderer);
    }
    JTableHeaderToolTips jthtt = new JTableHeaderToolTips(table.getColumnModel());
    jthtt.setToolTips(new String[] { "Customer's First Name", "Customer's Last Name",
            "Customer's Date of Birth", "Customer's Account Balance", "Customer's Gender" });
    table.setTableHeader(jthtt);
    JScrollPane jsp = new JScrollPane(table);
    pane.add(jsp, BorderLayout.CENTER);
    addHeaderListener();
}

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

public void setXLabel(String xLabel) {

    domainLabel = xLabel;//w  w w. j  a  v a2  s .co  m
    TableColumnModel columnModel = dataTable.getColumnModel();
    columnModel.getColumn(0).setHeaderValue("Series");

    for (int i = 1; i < columnModel.getColumnCount(); i++)
        columnModel.getColumn(i).setHeaderValue(domainLabel + i);

    dataTable.setTableHeader(new EditableHeader(columnModel));
}

From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java

public void resizeColumns() {
    // TODO add your handling code here:
    int tW = jTable1.getWidth();
    TableColumnModel jTableColumnModel = jTable1.getColumnModel();
    int cantCols = jTableColumnModel.getColumnCount();
    if (jTable1.getModel().getColumnCount() > 0) {
        jTableColumnModel.getColumn(0).setPreferredWidth((int) (fontSize * 3.0));
        jTableColumnModel.getColumn(1)// w w w .  j a  v a 2  s . c om
                .setPreferredWidth((int) Math.round(tW - (fontSize * 2.5) - (fontSize * 5.0)));
        jTableColumnModel.getColumn(2).setPreferredWidth((int) (fontSize * 5.0));
    }
}

From source file:net.sf.jabref.gui.maintable.MainTable.java

private void setWidths() {
    // Setting column widths:
    int ncWidth = Globals.prefs.getInt(JabRefPreferences.NUMBER_COL_WIDTH);
    List<String> widthsFromPreferences = Globals.prefs.getStringList(JabRefPreferences.COLUMN_WIDTHS);
    TableColumnModel cm = getColumnModel();
    cm.getColumn(0).setPreferredWidth(ncWidth);
    for (int i = 1; i < cm.getColumnCount(); i++) {
        MainTableColumn mainTableColumn = tableFormat.getTableColumn(cm.getColumn(i).getModelIndex());
        if (SpecialFieldsUtils.FIELDNAME_RANKING.equals(mainTableColumn.getColumnName())) {
            cm.getColumn(i).setPreferredWidth(GUIGlobals.WIDTH_ICON_COL_RANKING);
            cm.getColumn(i).setMinWidth(GUIGlobals.WIDTH_ICON_COL_RANKING);
            cm.getColumn(i).setMaxWidth(GUIGlobals.WIDTH_ICON_COL_RANKING);
        } else if (mainTableColumn.isIconColumn()) {
            cm.getColumn(i).setPreferredWidth(GUIGlobals.WIDTH_ICON_COL);
            cm.getColumn(i).setMinWidth(GUIGlobals.WIDTH_ICON_COL);
            cm.getColumn(i).setMaxWidth(GUIGlobals.WIDTH_ICON_COL);
        } else {//from  w w w. ja  v a 2s  . c o m
            List<String> allColumns = Globals.prefs.getStringList(JabRefPreferences.COLUMN_NAMES);
            // find index of current mainTableColumn in allColumns
            for (int j = 0; j < allColumns.size(); j++) {
                if (allColumns.get(j).equalsIgnoreCase(mainTableColumn.getDisplayName())) {
                    try {
                        // set preferred width by using found index j in the width array
                        cm.getColumn(i).setPreferredWidth(Integer.parseInt(widthsFromPreferences.get(j)));
                    } catch (NumberFormatException e) {
                        LOGGER.info("Exception while setting column widths. Choosing default.", e);
                        cm.getColumn(i).setPreferredWidth(BibtexSingleField.DEFAULT_FIELD_LENGTH);
                    }
                    break;
                }
            }
        }
    }
}