use of javax.swing.JSpinner in project pcgen by PCGen.
the class PostLevelUpDialog method initComponents.
private void initComponents() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JTable table = new JTable(tableModel) {
@Override
public TableCellEditor getCellEditor(int row, int column) {
if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
//TODO: the max roll should be calculated in a different manner
String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
int max = NumberUtils.toInt(hd);
return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
}
return super.getCellEditor(row, column);
}
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
return new SpinnerRenderer();
}
return super.getCellRenderer(row, column);
}
};
table.setCellSelectionEnabled(false);
table.setRowHeight(new JSpinner().getPreferredSize().height);
JTableHeader header = table.getTableHeader();
header.setReorderingAllowed(false);
JScrollPane scrollPane = new JScrollPane(table);
pane.add(scrollPane, BorderLayout.CENTER);
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
//$NON-NLS-1$
JButton button = new JButton(LanguageBundle.getString("in_close"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
//$NON-NLS-1$
button.setActionCommand("Close");
button.addActionListener(this);
box.add(button);
pane.add(box, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//Make sure to remove the listeners so that the garbage collector can
//dispose of this dialog and prevent a memory leak
levels.removeHitPointListener(tableModel);
}
});
Utility.installEscapeCloseOperation(this);
}
use of javax.swing.JSpinner in project pcgen by PCGen.
the class SkillInfoTab method initComponents.
private void initComponents() {
setOrientation(VERTICAL_SPLIT);
setResizeWeight(0.70);
JSpinner spinner = new JSpinner();
//$NON-NLS-1$
spinner.setEditor(new JSpinner.NumberEditor(spinner, "#0.#"));
skillTable.setDefaultRenderer(Float.class, new SpinnerRenderer(spinner));
skillTable.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
skillTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
skillTable.setRowHeight(26);
FilterBar<CharacterFacade, SkillFacade> filterBar = new FilterBar<>();
filterBar.addDisplayableFilter(new SearchFilterPanel());
//$NON-NLS-1$
cFilterButton.setText(LanguageBundle.getString("in_classString"));
cFilterButton.setEnabled(false);
filterBar.addDisplayableFilter(cFilterButton);
//$NON-NLS-1$
trainedFilterButton.setText(LanguageBundle.getString("in_trained"));
trainedFilterButton.setEnabled(false);
filterBar.addDisplayableFilter(trainedFilterButton);
JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(skillTable, filterBar);
availPanel.setPreferredSize(new Dimension(650, 300));
JScrollPane tableScrollPane;
JPanel tablePanel = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
constraints.fill = java.awt.GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.ipady = 0;
constraints.weighty = 1.0;
SkillPointTableModel.initializeTable(skillpointTable);
tableScrollPane = new JScrollPane(skillpointTable);
tablePanel.add(tableScrollPane, constraints);
htmlPane.setOpaque(false);
htmlPane.setEditable(false);
htmlPane.setFocusable(false);
//$NON-NLS-1$
htmlPane.setContentType("text/html");
skillFilterBox.setRenderer(new DefaultListCellRenderer());
JScrollPane selScrollPane = new JScrollPane(htmlPane);
JPanel skillPanel = new JPanel(new BorderLayout());
skillPanel.add(skillFilterBox, BorderLayout.NORTH);
skillPanel.add(selScrollPane, BorderLayout.CENTER);
selScrollPane.setPreferredSize(new Dimension(530, 300));
FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, skillPanel, "SkillTop");
setTopComponent(topPane);
FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "SkillBottom");
bottomPane.setLeftComponent(tablePanel);
tablePanel.setPreferredSize(new Dimension(650, 100));
bottomPane.setRightComponent(infoPane);
infoPane.setPreferredSize(new Dimension(530, 100));
setBottomComponent(bottomPane);
}
use of javax.swing.JSpinner in project ACS by ACS-Community.
the class BeanGrouper method getTimeWindowSpinner.
/**
* Initializes the TextField that will allow to input the desired Time Window for the Sampling Group.<br>
* By default the value is 10, which means 10 minutes.<br>
* Also checks for its correctness when the value changes.
* @return javax.swing.JTextField Reference to the Text Field containing the number.
*/
private JSpinner getTimeWindowSpinner() {
if (timeWindowSpinner == null) {
timeWindowSpinner = new JSpinner();
timeWindowSpinner.setToolTipText("How much data, expressed in seconds, will the trend present in the graph.");
timeWindowSpinner.setModel(new SpinnerNumberModel(5, 1, 900, 1));
timeWindowSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
setTimeWindow();
}
});
}
return timeWindowSpinner;
}
use of javax.swing.JSpinner in project JMRI by JMRI.
the class GuiLafConfigPane method doToolTipDismissDelay.
public void doToolTipDismissDelay(JPanel panel) {
GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
JLabel toolTipDismissDelayLabel = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelay"));
toolTipDismissDelaySpinner = new JSpinner(new SpinnerNumberModel(manager.getToolTipDismissDelay() / 1000, MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME, 1));
this.toolTipDismissDelaySpinner.addChangeListener((ChangeEvent e) -> {
// convert to milliseconds from seconds
manager.setToolTipDismissDelay((int) toolTipDismissDelaySpinner.getValue() * 1000);
});
this.toolTipDismissDelaySpinner.setToolTipText(MessageFormat.format(ConfigBundle.getMessage("GUIToolTipDismissDelayToolTip"), MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME));
toolTipDismissDelayLabel.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
JLabel toolTipDismissDelayUoM = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelayUoM"));
toolTipDismissDelayUoM.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
panel.add(toolTipDismissDelayLabel);
panel.add(toolTipDismissDelaySpinner);
panel.add(toolTipDismissDelayUoM);
}
use of javax.swing.JSpinner in project JMRI by JMRI.
the class MemoryItemPanel method makeDndIconPanel.
@Override
protected void makeDndIconPanel(java.util.HashMap<String, NamedIcon> iconMap, String displayKey) {
if (_update) {
return;
}
JPanel panel = new JPanel();
panel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints c = new java.awt.GridBagConstraints();
c.gridwidth = 1;
c.gridheight = 1;
c.gridx = 0;
c.gridy = 0;
c.anchor = java.awt.GridBagConstraints.CENTER;
c.weightx = 1.0;
panel.add(new JLabel(Bundle.getMessage("ReadWriteMemory")), c);
c.gridy = 1;
_writeMem = new MemoryInputIcon(5, _editor);
// JPanel p0 = makeDragIcon(_writeMem, Type.READWRITE);
panel.add(makeDragIcon(_writeMem, Type.READWRITE), c);
_spinner = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1));
JTextField field = ((JSpinner.DefaultEditor) _spinner.getEditor()).getTextField();
field.setColumns(2);
field.setText("5");
_spinner.setMaximumSize(_spinner.getPreferredSize());
_spinner.addChangeListener(this);
c.gridy = 2;
panel.add(_spinner, c);
c.gridy = 3;
c.anchor = java.awt.GridBagConstraints.NORTH;
panel.add(new JLabel(Bundle.getMessage("NumColsLabel")), c);
c.gridx = 1;
c.gridy = 0;
c.anchor = java.awt.GridBagConstraints.CENTER;
panel.add(new JLabel(Bundle.getMessage("ReadMemory")), c);
c.gridy = 1;
_readMem = new MemoryIcon(NamedIcon.getIconByName("resources/icons/misc/X-red.gif"), _editor);
panel.add(makeDragIcon(_readMem, Type.READONLY), c);
c.gridx = 2;
c.gridy = 0;
panel.add(new JLabel(Bundle.getMessage("SpinnerMemory")), c);
c.gridy = 1;
_spinMem = new MemorySpinnerIcon(_editor);
panel.add(makeDragIcon(_spinMem, Type.SPINNER), c);
c.gridx = 0;
c.gridy = 2;
c.gridwidth = 4;
panel.add(new JLabel(Bundle.getMessage("ComboMemory")), c);
c.gridy = 3;
_comboMem = new MemoryComboIcon(_editor, null);
panel.add(makeDragIcon(_comboMem, Type.COMBO), c);
_dragIconPanel = panel;
_dragIconPanel.invalidate();
}
Aggregations