use of javax.swing.JSpinner in project knime-core by knime.
the class PMCCNodeView method getJMenu.
private JMenu getJMenu() {
JMenu menu = new JMenu("View");
JCheckBoxMenuItem useColorBox = new JCheckBoxMenuItem("Use Colors");
useColorBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (((JCheckBoxMenuItem) e.getSource()).isSelected()) {
changeRenderer(ColorRender.DESCRIPTION);
} else {
changeRenderer(DoubleValueRenderer.STANDARD_RENDERER.getDescription());
}
}
});
useColorBox.addPropertyChangeListener("ancestor", new PropertyChangeListener() {
/**
* {@inheritDoc}
*/
@Override
public void propertyChange(final PropertyChangeEvent evt) {
((JCheckBoxMenuItem) evt.getSource()).setSelected(m_currentRendererID.equals(ColorRender.DESCRIPTION));
}
});
JMenuItem colWidthItem = new JMenuItem("Cell Size...");
colWidthItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
int colWidth = m_tableView.getColumnWidth();
JSpinner s = new JSpinner(new SpinnerNumberModel(colWidth, 1, Integer.MAX_VALUE, 1));
int r = JOptionPane.showConfirmDialog(m_tableView, s, "Cell Size", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (r == JOptionPane.OK_OPTION) {
m_tableView.setColumnWidth((Integer) s.getValue());
m_tableView.setRowHeight((Integer) s.getValue());
}
}
});
menu.add(useColorBox);
menu.add(colWidthItem);
return menu;
}
Aggregations