use of javax.swing.SpinnerNumberModel in project jgnash by ccavanaugh.
the class GeneralOptions method initComponents.
private void initComponents() {
animationsEnabled = new JCheckBox(rb.getString("Button.SubstanceAnimations"));
numButton = new JButton(rb.getString("Menu.EditTranNumList.Name"));
selectOnFocusCheckBox = new JCheckBox(rb.getString("Button.SelectText"));
SpinnerModel model = new SpinnerNumberModel(ThemeManager.getNimbusFontSize(), 9, 15, 1);
nimbusFontSpinner = new JSpinner(model);
}
use of javax.swing.SpinnerNumberModel in project gephi by gephi.
the class EqualNumberPanel method setup.
public void setup(EqualNumberFilter f) {
this.filter = f;
new Thread(new Runnable() {
@Override
public void run() {
setToolTipText(filter.getName() + " '" + filter.getColumn().getTitle() + "'");
Number match = filter.getMatch();
Number stepSize = null;
final Comparable min = (Comparable) filter.getRange().getMinimum();
final Comparable max = (Comparable) filter.getRange().getMaximum();
Class type = filter.getColumn().getTypeClass();
if (type.equals(Double.class)) {
match = (match != null ? match : (Double) min);
stepSize = .1;
} else if (type.equals(Float.class)) {
match = (match != null ? match : (Float) min);
stepSize = .1f;
} else if (type.equals(Long.class)) {
match = (match != null ? match : (Long) min);
stepSize = 1l;
} else if (type.equals(Integer.class)) {
match = (match != null ? match : (Integer) min);
stepSize = 1;
} else {
throw new IllegalArgumentException("Column must be number");
}
Number minNumber = (Number) min;
Number maxNumber = (Number) max;
if (match.doubleValue() < minNumber.doubleValue()) {
match = minNumber;
filter.getProperties()[1].setValue(minNumber);
} else if (match.doubleValue() > maxNumber.doubleValue()) {
match = maxNumber;
filter.getProperties()[1].setValue(maxNumber);
}
final SpinnerNumberModel model = new SpinnerNumberModel(match, min, max, stepSize);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (min.equals(Double.NEGATIVE_INFINITY) || min.equals(Integer.MIN_VALUE)) {
minLabel.setText("");
maxLabel.setText("");
} else {
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(5);
minLabel.setText(df.format(min));
maxLabel.setText(df.format(max));
}
valueSpinner.setModel(model);
model.addChangeListener(WeakListeners.change(EqualNumberPanel.this, model));
}
});
}
}).start();
}
use of javax.swing.SpinnerNumberModel in project FBReaderJ by geometer.
the class ZLSpinOptionView method createItem.
protected void createItem() {
final ZLSpinOptionEntry option = (ZLSpinOptionEntry) myOption;
mySpinner = new JSpinner(new SpinnerNumberModel(option.initialValue(), option.minValue(), option.maxValue(), option.getStep()));
if (myName == null || "".equals(myName)) {
myLabel = null;
myTab.insertWidget(mySpinner);
} else {
JPanel panel1 = new JPanel();
panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));
mySpinner.setMaximumSize(new Dimension(mySpinner.getMaximumSize().width, mySpinner.getPreferredSize().height));
panel1.add(mySpinner);
myLabel = new JLabel(myName);
JPanel panel2 = new JPanel(new BorderLayout());
panel2.add(myLabel, BorderLayout.LINE_END);
myPanel = new JPanel(new GridLayout(1, 2, 10, 0));
myPanel.add(panel2);
myPanel.add(panel1);
myTab.insertWidget(myPanel);
}
}
use of javax.swing.SpinnerNumberModel in project libgdx by libgdx.
the class NumericPanel method initializeComponents.
protected void initializeComponents() {
super.initializeComponents();
JPanel contentPanel = getContentPanel();
{
JLabel label = new JLabel("Value:");
contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
}
{
valueSpinner = new JSpinner(new SpinnerNumberModel(new Float(0), new Float(-99999), new Float(99999), new Float(0.1f)));
contentPanel.add(valueSpinner, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
valueSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
NumericPanel.this.value.setValue((Float) valueSpinner.getValue());
}
});
}
use of javax.swing.SpinnerNumberModel in project binnavi by google.
the class PointerTypePanel method createControls.
private void createControls() {
setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
add(contentPanel, BorderLayout.CENTER);
final GridBagLayout gbl_m_contentPanel = new GridBagLayout();
gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 };
gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
contentPanel.setLayout(gbl_m_contentPanel);
final JLabel lblBaseType = new JLabel("Base type:");
final GridBagConstraints gbc_lblBaseType = new GridBagConstraints();
gbc_lblBaseType.anchor = GridBagConstraints.WEST;
gbc_lblBaseType.insets = new Insets(0, 0, 5, 5);
gbc_lblBaseType.gridx = 0;
gbc_lblBaseType.gridy = 0;
contentPanel.add(lblBaseType, gbc_lblBaseType);
baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), Predicates.and(new TypeListModel.ArrayTypesFilter(), new TypeListModel.PrototypesFilter())));
baseTypes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_baseTypes = new GridBagConstraints();
gbc_baseTypes.insets = new Insets(0, 0, 5, 0);
gbc_baseTypes.fill = GridBagConstraints.HORIZONTAL;
gbc_baseTypes.gridx = 1;
gbc_baseTypes.gridy = 0;
contentPanel.add(baseTypes, gbc_baseTypes);
final JLabel lblNewLabel_1 = new JLabel("Pointer level:");
final GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
gbc_lblNewLabel_1.gridx = 0;
gbc_lblNewLabel_1.gridy = 1;
contentPanel.add(lblNewLabel_1, gbc_lblNewLabel_1);
pointerLevel = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
pointerLevel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_m_pointerLevel = new GridBagConstraints();
gbc_m_pointerLevel.anchor = GridBagConstraints.WEST;
gbc_m_pointerLevel.insets = new Insets(0, 0, 5, 0);
gbc_m_pointerLevel.gridx = 1;
gbc_m_pointerLevel.gridy = 1;
contentPanel.add(pointerLevel, gbc_m_pointerLevel);
final JLabel lblPreview = new JLabel("Preview:");
final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
gbc_lblPreview.gridx = 0;
gbc_lblPreview.gridy = 2;
contentPanel.add(lblPreview, gbc_lblPreview);
preview = new JTextArea();
preview.setEditable(false);
final GridBagConstraints gbc_preview = new GridBagConstraints();
gbc_preview.insets = new Insets(0, 0, 5, 0);
gbc_preview.fill = GridBagConstraints.BOTH;
gbc_preview.gridx = 1;
gbc_preview.gridy = 2;
contentPanel.add(preview, gbc_preview);
}
Aggregations