Search in sources :

Example 1 with EnablingCheckboxRenderer

use of jmri.jmrit.beantable.EnablingCheckboxRenderer in project JMRI by JMRI.

the class TrainsScheduleTableModel method initTable.

void initTable() {
    if (_table == null) {
        return;
    }
    // Save table column order
    XTableColumnModel tcm = new XTableColumnModel();
    _table.setColumnModel(tcm);
    _table.createDefaultColumnsFromModel();
    // Install the button handlers
    _table.setDefaultRenderer(Boolean.class, new EnablingCheckboxRenderer());
    // set column preferred widths
    for (int i = 0; i < tableScheduleColumnWidths.length; i++) {
        tcm.getColumn(i).setPreferredWidth(tableScheduleColumnWidths[i]);
    }
    _frame.loadTableDetails(_table);
}
Also used : EnablingCheckboxRenderer(jmri.jmrit.beantable.EnablingCheckboxRenderer) XTableColumnModel(jmri.util.swing.XTableColumnModel)

Example 2 with EnablingCheckboxRenderer

use of jmri.jmrit.beantable.EnablingCheckboxRenderer in project JMRI by JMRI.

the class TrainsTableModel method initTable.

void initTable() {
    // Use XTableColumnModel so we can control which columns are visible
    XTableColumnModel tcm = new XTableColumnModel();
    _table.setColumnModel(tcm);
    _table.createDefaultColumnsFromModel();
    // Install the button handlers
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
    tcm.getColumn(EDITCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(EDITCOLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(ACTIONCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(ACTIONCOLUMN).setCellEditor(buttonEditor);
    tcm.getColumn(BUILDCOLUMN).setCellRenderer(buttonRenderer);
    tcm.getColumn(BUILDCOLUMN).setCellEditor(buttonEditor);
    _table.setDefaultRenderer(Boolean.class, new EnablingCheckboxRenderer());
    // set column preferred widths
    for (int i = 0; i < tcm.getColumnCount(); i++) {
        tcm.getColumn(i).setPreferredWidth(_tableColumnWidths[i]);
    }
    _frame.loadTableDetails(_table);
    // turn off column
    tcm.setColumnVisible(tcm.getColumnByModelIndex(IDCOLUMN), _sort == SORTBYID);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) EnablingCheckboxRenderer(jmri.jmrit.beantable.EnablingCheckboxRenderer) TableCellEditor(javax.swing.table.TableCellEditor) XTableColumnModel(jmri.util.swing.XTableColumnModel) ButtonRenderer(jmri.util.table.ButtonRenderer)

Aggregations

EnablingCheckboxRenderer (jmri.jmrit.beantable.EnablingCheckboxRenderer)2 XTableColumnModel (jmri.util.swing.XTableColumnModel)2 JButton (javax.swing.JButton)1 TableCellEditor (javax.swing.table.TableCellEditor)1 ButtonEditor (jmri.util.table.ButtonEditor)1 ButtonRenderer (jmri.util.table.ButtonRenderer)1