Search in sources :

Example 66 with JTable

use of javax.swing.JTable in project JMRI by JMRI.

the class EcosLocoTableAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    // create the JTable model, with changes for specific NamedBean
    createModel();
    TableRowSorter<BeanTableDataModel> sorter = new TableRowSorter<>(m);
    JTable dataTable = m.makeJTable(getClassName(), m, sorter);
    // create the frame
    f = new jmri.jmrit.beantable.BeanTableFrame(m, helpTarget(), dataTable) {
    };
    setMenuBar(f);
    setTitle();
    addToFrame(f);
    f.pack();
    f.setVisible(true);
}
Also used : JTable(javax.swing.JTable) BeanTableDataModel(jmri.jmrit.beantable.BeanTableDataModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 67 with JTable

use of javax.swing.JTable in project processdash by dtuma.

the class SizeMetricsTableModel method createJTable.

public JTable createJTable() {
    JTable table = new ItemListJTable(this);
    // adjust column widths
    table.getColumnModel().getColumn(0).setPreferredWidth(100);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(100);
    table.setRowHeight(table.getRowHeight() + 4);
    // draw read-only phases with a different appearance
    table.setDefaultRenderer(String.class, new ItemTableCellRenderer());
    // install a combo box as the editor for the "phase type" column
    TableColumn unitsColumn = table.getColumnModel().getColumn(UNITS_COL);
    JComboBox unitsEditor = new JComboBox(UNITS_TYPES);
    unitsEditor.setRenderer(new UnitsCellRenderer());
    unitsEditor.setFont(unitsEditor.getFont().deriveFont(Font.PLAIN));
    unitsColumn.setCellEditor(new DefaultCellEditor(unitsEditor));
    return table;
}
Also used : JComboBox(javax.swing.JComboBox) JTable(javax.swing.JTable) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 68 with JTable

use of javax.swing.JTable in project processdash by dtuma.

the class ManuallyEnteredPreferencesList method createList.

@Override
protected void createList(String id, String currentValue) {
    Object[][] data = getCurrentData(currentValue);
    String settingColumnName = map.getResource(id + ".Setting_Column");
    String valueColumnName = map.getResource(id + ".Value_Column");
    Object[] columns = { settingColumnName, valueColumnName };
    tableModel = new DefaultTableModel(data, columns) {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    settingTable = new JTable(tableModel);
    settingTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    settingTable.getSelectionModel().addListSelectionListener(this);
    JScrollPane listScroller = new JScrollPane(settingTable);
    listScroller.setPreferredSize(new Dimension(LIST_WIDTH, LIST_HEIGHT));
    this.add(listScroller, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) DefaultTableModel(javax.swing.table.DefaultTableModel) JTable(javax.swing.JTable) Dimension(java.awt.Dimension)

Example 69 with JTable

use of javax.swing.JTable in project processdash by dtuma.

the class UserEditor method makeTable.

private Component makeTable() {
    table = new JTable(model);
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    rowSorter = new TableRowSorter(model);
    rowSorter.setSortable(UserTableModel.ROLES_COL, false);
    table.setRowSorter(rowSorter);
    table.getColumnModel().getColumn(UserTableModel.USERNAME_COL).setCellEditor(new UsernameCellEditor());
    table.getColumnModel().getColumn(UserTableModel.ROLES_COL).setCellEditor(new RolesCellEditor());
    table.getColumnModel().getColumn(UserTableModel.ROLES_COL).setHeaderRenderer(new RolesHeaderRenderer());
    table.getTableHeader().addMouseListener(new RolesColumnClickHandler());
    int preferredWidth = TableUtils.configureTable(table, UserTableModel.COLUMN_WIDTHS, UserTableModel.COLUMN_TOOLTIPS);
    int preferredHeight = 15 * table.getRowHeight();
    table.setPreferredScrollableViewportSize(new Dimension(preferredWidth, preferredHeight));
    // active, not us; so don't display the "Active" column in the table.
    if (isLegacyPdesMode()) {
        table.getColumnModel().removeColumn(table.getColumnModel().getColumn(UserTableModel.ACTIVE_COL));
    }
    return new JScrollPane(table);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) Dimension(java.awt.Dimension) TableRowSorter(javax.swing.table.TableRowSorter)

Example 70 with JTable

use of javax.swing.JTable in project processdash by dtuma.

the class EVMetricsWidget method getWidgetComponent.

public Component getWidgetComponent(Map environment, Map parameters) {
    EVSchedule schedule = (EVSchedule) environment.get(EVSnippetEnvironment.SCHEDULE_KEY);
    EVMetrics m = schedule.getMetrics();
    JTable table = new JTable(m);
    table.removeColumn(table.getColumnModel().getColumn(3));
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setPreferredSize(new Dimension(100, 100));
    DescriptionPane descr = new DescriptionPane(m, table.getSelectionModel());
    Box result = Box.createVerticalBox();
    result.add(scrollPane);
    result.add(Box.createVerticalStrut(2));
    result.add(descr);
    return result;
}
Also used : JScrollPane(javax.swing.JScrollPane) EVSchedule(net.sourceforge.processdash.ev.EVSchedule) JTable(javax.swing.JTable) EVMetrics(net.sourceforge.processdash.ev.EVMetrics) Box(javax.swing.Box) Dimension(java.awt.Dimension)

Aggregations

JTable (javax.swing.JTable)584 JScrollPane (javax.swing.JScrollPane)282 JPanel (javax.swing.JPanel)217 Dimension (java.awt.Dimension)145 JButton (javax.swing.JButton)139 BorderLayout (java.awt.BorderLayout)133 JLabel (javax.swing.JLabel)129 ActionEvent (java.awt.event.ActionEvent)109 ActionListener (java.awt.event.ActionListener)81 TableColumn (javax.swing.table.TableColumn)79 DefaultTableModel (javax.swing.table.DefaultTableModel)75 Component (java.awt.Component)66 BoxLayout (javax.swing.BoxLayout)66 FlowLayout (java.awt.FlowLayout)58 MouseEvent (java.awt.event.MouseEvent)58 JTextField (javax.swing.JTextField)57 TableColumnModel (javax.swing.table.TableColumnModel)52 GridBagConstraints (java.awt.GridBagConstraints)46 TableCellRenderer (javax.swing.table.TableCellRenderer)43 Test (org.junit.Test)43