use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class NodeTablePane method initComponents.
/**
* Initialize the window
*/
public void initComponents() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
nodesModel = new NodesModel();
JTable nodesTable = new JTable(nodesModel);
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
nodesTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
nodesTable.setDefaultEditor(JButton.class, buttonEditor);
TableRowSorter<NodesModel> sorter = new TableRowSorter<>(nodesModel);
RowSorterUtil.setSortOrder(sorter, NodesModel.STATUSCOL, SortOrder.DESCENDING);
nodesTable.setRowSorter(sorter);
nodesTable.setRowSelectionAllowed(false);
nodesTable.setPreferredScrollableViewportSize(new java.awt.Dimension(580, 80));
JScrollPane scrollPane = new JScrollPane(nodesTable);
add(scrollPane);
// status info on bottom
JPanel p = new JPanel() {
@Override
public Dimension getMaximumSize() {
int height = getPreferredSize().height;
int width = super.getMaximumSize().width;
return new Dimension(width, height);
}
};
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
JButton b = new JButton(rb.getString("ButtonCheck"));
b.setToolTipText(rb.getString("TipCheck"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
startPoll();
}
});
p.add(b);
status = new JLabel("");
p.add(status);
p.add(Box.createHorizontalGlue());
// renumber button
b = new JButton(rb.getString("ButtonRenumber"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
renumber();
}
});
p.add(b);
add(p);
// start the search for nodes
startPoll();
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class StackMonDataModel method initTable.
void initTable(JTable stackTable, StackMonFrame stackFrame) {
// Install the button handlers for the Delete Buttons
TableColumnModel tcm = stackTable.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(DELCOLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(DELCOLUMN).setCellEditor(buttonEditor);
_stackFrame = stackFrame;
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class SlotMonDataModel method setColumnToHoldButton.
void setColumnToHoldButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class AlignTablePane method initComponents.
/**
* Initialize the window
*/
public void initComponents() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
alignModel = new AlignModel();
JTable alignTable = new JTable(alignModel);
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
alignTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
alignTable.setDefaultEditor(JButton.class, buttonEditor);
TableRowSorter<AlignModel> sorter = new TableRowSorter<>(alignModel);
RowSorterUtil.setSortOrder(sorter, AlignModel.NUMCOL, SortOrder.ASCENDING);
alignTable.setRowSelectionAllowed(false);
alignTable.setPreferredScrollableViewportSize(new java.awt.Dimension(580, 80));
JScrollPane scrollPane = new JScrollPane(alignTable);
add(scrollPane);
// status info on bottom
JPanel p = new JPanel() {
@Override
public Dimension getMaximumSize() {
int height = getPreferredSize().height;
int width = super.getMaximumSize().width;
return new Dimension(width, height);
}
};
p.setLayout(new FlowLayout());
p.add(new JLabel(rb.getString("LabelNumCol")));
num.setText("" + Engine.instance().getMaxReceiverNumber());
p.add(num);
JButton b = new JButton(rb.getString("ButtonSet"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
// set number of columns
Engine.instance().setMaxReceiverNumber(Integer.parseInt(num.getText()));
// mark modification
flag.setModifiedFlag(true);
// resize table
alignModel.fireTableStructureChanged();
}
});
p.add(b);
add(p);
p = new JPanel() {
@Override
public Dimension getMaximumSize() {
int height = getPreferredSize().height;
int width = super.getMaximumSize().width;
return new Dimension(width, height);
}
};
p.setLayout(new FlowLayout());
p.add(new JLabel(rb.getString("LabelVSound")));
vsound.setText("" + Engine.instance().getVSound());
p.add(vsound);
p.add(new JLabel(rb.getString("LabelOffset")));
offset.setText("" + Engine.instance().getOffset());
p.add(offset);
p.add(new JLabel(rb.getString("LabelAlgorithm")));
p.add(algorithmBox);
b = new JButton(rb.getString("ButtonSet"));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
// set number of vsound, offset
Engine.instance().setOffset(Integer.parseInt(offset.getText()));
Engine.instance().setVSound(Double.parseDouble(vsound.getText()));
Engine.instance().setAlgorithm((String) algorithmBox.getSelectedItem());
// mark modification
flag.setModifiedFlag(true);
}
});
p.add(b);
add(p);
//
add(loadStore = new jmri.jmrix.rps.swing.LoadStorePanel() {
// make sure we redisplay if changed
@Override
public void load() {
super.load();
alignModel.fireTableStructureChanged();
// modified (to force store of default after load new values)
flag.setModifiedFlag(true);
}
@Override
public void storeDefault() {
super.storeDefault();
// no longer modified after storeDefault
flag.setModifiedFlag(false);
}
});
// add sound listener
Engine.instance().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
if (e.getPropertyName().equals("vSound")) {
// update sound display
vsound.setText("" + e.getNewValue());
}
}
});
}
use of jmri.util.table.ButtonRenderer in project JMRI by JMRI.
the class AddEntryExitPairPanel method setColumnToHoldButton.
/**
* Service method to set up a column so that it will hold a button for it's
* values.
*
* @param table the table
* @param column the column
* @param sample Typical button, used for size
*/
protected void setColumnToHoldButton(JTable table, int column, JButton sample) {
//TableColumnModel tcm = table.getColumnModel();
// install a button renderer & editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
table.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
table.setDefaultEditor(JButton.class, buttonEditor);
// ensure the table rows, columns have enough room for buttons
table.setRowHeight(sample.getPreferredSize().height);
table.getColumnModel().getColumn(column).setPreferredWidth((sample.getPreferredSize().width) + 4);
}
Aggregations