Example usage for javax.swing.table TableColumn TableColumn

List of usage examples for javax.swing.table TableColumn TableColumn

Introduction

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

Prototype

public TableColumn() 

Source Link

Document

Cover method, using a default model index of 0, default width of 75, a null renderer and a null editor.

Usage

From source file:hermes.browser.dialog.GeneralRendererConfigPanel.java

public void setHermesConfig(HermesConfig hermesConfig) {
    this.hermesConfig = hermesConfig;

    initState();//w  w  w  . ja  v a  2  s .  c  o  m

    configModel = new ListConfigTableModel();

    for (MessageRenderer rConfig : HermesBrowser.getRendererManager().getRenderers()) {

        configModel.addItem(rConfig.getDisplayName());

    }

    classTable.setModel(configModel);

    DefaultTableColumnModel cm = new DefaultTableColumnModel();
    cm.addColumn(new TableColumn());

    classTable.setColumnModel(cm);
}

From source file:DefaultsDisplay.java

protected JTable createDefaultsTable() {
    JTable table = new JTable(new UIDefaultsTableModel());
    table.setRowHeight(rowHeight);/*from w  w w .  ja  va2s  . co m*/
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    initFilters(table);

    DefaultTableColumnModel columnModel = new DefaultTableColumnModel();

    Color rowColors[] = new Color[2];
    rowColors[0] = UIManager.getColor("Table.background");
    rowColors[1] = new Color((int) (rowColors[0].getRed() * .90), (int) (rowColors[0].getGreen() * .95),
            (int) (rowColors[0].getBlue() * .95));

    int width = 0;

    TableColumn column = new TableColumn();
    column.setCellRenderer(new KeyRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.KEY_COLUMN);
    column.setHeaderValue("Key");
    column.setPreferredWidth(250);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    column = new TableColumn();
    column.setCellRenderer(new RowRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.TYPE_COLUMN);
    column.setHeaderValue("Type");
    column.setPreferredWidth(250);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    column = new TableColumn();
    column.setCellRenderer(new ValueRenderer(rowColors));
    column.setModelIndex(UIDefaultsTableModel.VALUE_COLUMN);
    column.setHeaderValue("Value");
    column.setPreferredWidth(300);
    columnModel.addColumn(column);
    width += column.getPreferredWidth();

    table.setColumnModel(columnModel);

    table.setPreferredScrollableViewportSize(new Dimension(width, 12 * rowHeight));

    return table;

}

From source file:com.aw.swing.mvp.binding.component.BndSJTable.java

public void resetHeader() {
    TableColumnModel colModel = jTable.getColumnModel();
    int colsNumber = getColumnsInfo().length;
    int colsModel = colModel.getColumnCount() + fixedColumns;
    if (colsNumber == colsModel) {
        if (getSelectorColumn() != null) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    JTable fixedJTable = (JTable) jTable.getClientProperty(CP_FIXED_TABLE);
                    if (fixedJTable != null) {
                        fixedJTable.getTableHeader().repaint();
                    } else {
                        jTable.getTableHeader().repaint();
                    }//from  w  ww .  j  a v a2  s .co m
                }
            });
        }
        return;
    }
    if (colsNumber > colsModel) {
        int delta = colsNumber - colModel.getColumnCount();
        for (int i = 0; i < delta; i++) {
            colModel.addColumn(new TableColumn());
        }
    }
    for (int i = 0; i < colsNumber; i++) {
        TableColumn column = colModel.getColumn(i);
        column.setHeaderValue(getColumnsInfo()[i].getColumnHeader());
    }
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JTable fixedJTable = (JTable) jTable.getClientProperty(CP_FIXED_TABLE);
            if (fixedJTable != null) {
                fixedJTable.getTableHeader().repaint();
            }
            jTable.getTableHeader().repaint();
        }
    });
}