001package jmri.jmrit.automat.monitor; 002 003import javax.swing.BoxLayout; 004import javax.swing.JPanel; 005import javax.swing.JScrollPane; 006import javax.swing.JTable; 007import javax.swing.table.TableRowSorter; 008 009/** 010 * Frame providing a table of Automat instances 011 * 012 * @author Bob Jacobsen Copyright (C) 2004 013 */ 014public class AutomatTableFrame extends jmri.util.JmriJFrame { 015 016 AutomatTableDataModel dataModel; 017 JTable dataTable; 018 JScrollPane dataScroll; 019 020 public AutomatTableFrame(AutomatTableDataModel model) { 021 022 super(); 023 dataModel = model; 024 025 dataTable = new JTable(dataModel); 026 dataTable.setRowSorter(new TableRowSorter<>(dataModel)); 027 dataScroll = new JScrollPane(dataTable); 028 029 // configure items for GUI 030 dataModel.configureTable(dataTable); 031 032 // general GUI config 033 getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); 034 035 // install items in GUI 036 JPanel pane1 = new JPanel(); 037 getContentPane().add(dataScroll); 038 pack(); 039 pane1.setMaximumSize(pane1.getSize()); 040 041 setTitle(Bundle.getMessage("TitleAutomatTable")); 042 043 addHelpMenu("package.jmri.jmrit.automat.monitor.AutomatTableFrame", true); 044 045 pack(); 046 } 047 048 @Override 049 public void dispose() { 050 if (dataModel != null) { 051 dataModel.dispose(); 052 } 053 dataModel = null; 054 dataTable = null; 055 dataScroll = null; 056 super.dispose(); 057 } 058}