001package jmri.jmrix.openlcb.swing.tie;
002
003import java.util.ResourceBundle;
004import javax.swing.BoxLayout;
005import javax.swing.JPanel;
006import javax.swing.JScrollPane;
007import javax.swing.JTable;
008import javax.swing.table.TableColumn;
009import javax.swing.table.TableColumnModel;
010import javax.swing.table.TableRowSorter;
011
012/**
013 * Pane for showing the tie table
014 *
015 * @author Bob Jacobsen 2008
016  * @since 2.3.7
017 */
018public class TieTablePane extends JPanel {
019
020    static ResourceBundle rb = ResourceBundle.getBundle("jmri.jmrix.openlcb.swing.tie.TieBundle");
021
022    protected JTable table = null;
023    protected TieTableModel tableModel = null;
024
025    public void initComponents() {
026
027        // set the frame's initial state
028        setSize(500, 300);
029        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
030
031        tableModel = new TieTableModel();
032        table = new JTable(tableModel);
033        table.setRowSorter(new TableRowSorter<>(tableModel));
034        table.setRowSelectionAllowed(true);
035        table.setPreferredScrollableViewportSize(new java.awt.Dimension(300, 350));
036
037        TableColumnModel columnModel = table.getColumnModel();
038        TableColumn column;
039        column = columnModel.getColumn(TieTableModel.USERNAME_COLUMN);
040        column.setMinWidth(20);
041        //column.setMaxWidth(40);
042        column.setResizable(true);
043        column = columnModel.getColumn(TieTableModel.ID_COLUMN);
044        column.setMinWidth(40);
045        //column.setMaxWidth(85);
046        column.setResizable(true);
047        JScrollPane scrollPane = new JScrollPane(table);
048        add(scrollPane);
049
050    }
051
052}