Search in sources :

Example 96 with TableColumnModel

use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.

the class MarketTableModel method removeCols.

public static void removeCols(JTable marketTable) {
    TableColumnModel tcm = marketTable.getColumnModel();
    System.out.println("getColumnCount:" + tcm.getColumnCount());
    if (tcm.getColumnCount() == 2) {
        marketTable.removeColumn(tcm.getColumn(1));
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Example 97 with TableColumnModel

use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.

the class NYMOutboxTableModel method setValue.

public void setValue(List values, JTable nymOutBox) {
    data = new Object[values.size()][];
    for (int i = 0; i < values.size(); i++) {
        String[] row = (String[]) values.get(i);
        data[i] = row;
    }
    TableColumnModel tcm = nymOutBox.getColumnModel();
    System.out.println("nymbox.getColumn(2)" + tcm.getColumnCount());
    if (tcm.getColumnCount() == 4) {
        nymOutBox.removeColumn(tcm.getColumn(3));
    }
    fireTableDataChanged();
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Example 98 with TableColumnModel

use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.

the class NYMTableModel method setValue.

@Override
public void setValue(Map values, JTable nymTable) {
    clearValue();
    Set set = values.keySet();
    Iterator iterator = set.iterator();
    int i = 0;
    data = new Object[values.size()][];
    while (iterator.hasNext()) {
        Integer key = (Integer) iterator.next();
        String[] rowData = new String[2];
        rowData = (String[]) values.get(key);
        /*rowData[0] = (String)values.get(key);
            rowData[1] = String.valueOf(key);*/
        data[i] = rowData;
        i++;
    }
    /*RowSorter<TableModel> sorter =
        new TableRowSorter<TableModel>(this);
        nymTable.setRowSorter(sorter);*/
    TableColumnModel tcm = nymTable.getColumnModel();
    System.out.println("getColumnCount:" + tcm.getColumnCount());
    if (tcm.getColumnCount() == 2) {
        nymTable.removeColumn(tcm.getColumn(1));
    }
    fireTableDataChanged();
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator) TableColumnModel(javax.swing.table.TableColumnModel)

Example 99 with TableColumnModel

use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.

the class CheckBoxEditor method setValue.

/* public void setValueAt(Object aValue, int row, int column) {
    System.out.println("setValueAt:"+aValue+"row:"+row+" col:"+column);
    
    }*/
@Override
public void setValue(Map values, final JTable inbox) {
    if (null == values) {
        System.out.println("OTInboxTableModel.setValue: Failure: Map 'values' is null.");
        return;
    }
    clearValue();
    Set set = values.keySet();
    if (null == set) {
        System.out.println("OTInboxTableModel.setValue: Failure: values.keySet() returned null.");
        return;
    }
    Iterator iterator = set.iterator();
    int i = 0;
    data = new Object[values.size()][];
    while (iterator.hasNext()) {
        try {
            String key = (String) iterator.next();
            String[] row = (String[]) values.get(key);
            Object[] tableData = new Object[12];
            for (int j = 0; j < tableData.length - 1; j++) {
                tableData[j] = row[j];
            }
            tableData[7] = Boolean.FALSE;
            tableData[8] = Boolean.FALSE;
            tableData[9] = key;
            tableData[10] = row[8];
            tableData[11] = row[9];
            data[i] = tableData;
            i++;
        } catch (Exception e) {
            System.out.println("IIIIIII:" + e);
            e.printStackTrace();
        }
    }
    /*RowSorter<TableModel> sorter =
        new TableRowSorter<TableModel>(this);
        inbox.setRowSorter(sorter);*/
    TableColumnModel tcm = inbox.getColumnModel();
    System.out.println("inbox:" + tcm.getColumnCount());
    if (tcm.getColumnCount() == 12) {
        inbox.removeColumn(tcm.getColumn(11));
    }
    if (tcm.getColumnCount() == 11) {
        inbox.removeColumn(tcm.getColumn(10));
    }
    if (tcm.getColumnCount() == 10) {
        inbox.removeColumn(tcm.getColumn(9));
    }
    tcm.getColumn(7).setCellEditor(editorAccept);
    // tcm.getColumn(7).setMaxWidth(20);
    checkBoxAccept.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.out.println("In acion");
            if (checkBoxAccept.isSelected()) {
                setValueAt(false, inbox.getSelectedRow(), 8);
                fireTableCellUpdated(inbox.getSelectedRow(), 8);
                // finalReceipt
                if ("finalReceipt".equalsIgnoreCase((String) getValueAt(inbox.getSelectedRow(), 3))) {
                    String finalReceiptRefNo = (String) getValueAt(inbox.getSelectedRow(), 1);
                    for (int i = 0; i < data.length; i++) {
                        Object[] row = (Object[]) data[i];
                        if (finalReceiptRefNo.equals(row[1].toString())) {
                            setValueAt(true, i, 7);
                            fireTableCellUpdated(i, 7);
                        }
                    }
                }
            } else {
                if ("finalReceipt".equalsIgnoreCase((String) getValueAt(inbox.getSelectedRow(), 3))) {
                    String finalReceiptRefNo = (String) getValueAt(inbox.getSelectedRow(), 1);
                    for (int i = 0; i < data.length; i++) {
                        Object[] row = (Object[]) data[i];
                        if (finalReceiptRefNo.equals(row[1].toString())) {
                            setValueAt(false, i, 7);
                            fireTableCellUpdated(i, 7);
                        }
                    }
                }
            }
        }
    });
    tcm.getColumn(8).setCellEditor(editorReject);
    //tcm.getColumn(8).setMaxWidth(20);
    checkBoxReject.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.out.println("In acion -- reject");
            if (checkBoxReject.isSelected()) {
                setValueAt(false, inbox.getSelectedRow(), 7);
                fireTableCellUpdated(inbox.getSelectedRow(), 7);
            }
        }
    });
    fireTableDataChanged();
// tcm.getColumn(8).setCellRenderer(renderer);
}
Also used : Set(java.util.Set) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Iterator(java.util.Iterator) TableColumnModel(javax.swing.table.TableColumnModel)

Example 100 with TableColumnModel

use of javax.swing.table.TableColumnModel in project otapij by FellowTraveler.

the class ContactTableModel method removeCols.

public static void removeCols(JTable contactTable) {
    TableColumnModel tcm = contactTable.getColumnModel();
    System.out.println("getColumnCount:" + tcm.getColumnCount());
    if (tcm.getColumnCount() == 2) {
        contactTable.removeColumn(tcm.getColumn(1));
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Aggregations

TableColumnModel (javax.swing.table.TableColumnModel)168 TableColumn (javax.swing.table.TableColumn)66 JTable (javax.swing.JTable)34 JScrollPane (javax.swing.JScrollPane)31 JButton (javax.swing.JButton)30 BoxLayout (javax.swing.BoxLayout)24 TableCellEditor (javax.swing.table.TableCellEditor)23 ButtonEditor (jmri.util.table.ButtonEditor)23 ButtonRenderer (jmri.util.table.ButtonRenderer)23 JLabel (javax.swing.JLabel)22 JPanel (javax.swing.JPanel)22 ActionEvent (java.awt.event.ActionEvent)20 ActionListener (java.awt.event.ActionListener)16 FlowLayout (java.awt.FlowLayout)15 Border (javax.swing.border.Border)13 Iterator (java.util.Iterator)12 Set (java.util.Set)12 JTableHeader (javax.swing.table.JTableHeader)12 TableCellRenderer (javax.swing.table.TableCellRenderer)12 Container (java.awt.Container)10