use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class AudioBufferFrame method layoutFrame.
@Override
@SuppressWarnings("UnnecessaryBoxing")
public void layoutFrame() {
super.layoutFrame();
JPanel p;
JPanel p2;
p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelSample")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(urlLabel);
p2.add(url);
buttonBrowse.addActionListener(this::browsePressed);
buttonBrowse.setToolTipText(Bundle.getMessage("ToolTipButtonBrowse"));
p2.add(buttonBrowse);
p.add(p2);
p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(stream);
p.add(p2);
// p2 = new JPanel(); p2.setLayout(new FlowLayout());
// p2.add(formatLabel);
// p2.add(format);
// p.add(p2);
main.add(p);
// p = new JPanel();
// p.setBorder(BorderFactory.createCompoundBorder(
// BorderFactory.createTitledBorder("Waveforms"),
// BorderFactory.createEmptyBorder(5, 5, 5, 5)));
//
// JLabel label = new JLabel("Whole sample");
// label.setUI(new VerticalLabelUI());
// p.add(label);
//
// waveForm.setPreferredSize(new Dimension(400, 120));
// p.add(waveForm);
//
// label = new JLabel("Loop-point detail");
// label.setUI(new VerticalLabelUI());
// p.add(label);
//
// AudioWaveFormPanel waveFormLoop = new AudioWaveFormPanel();
// waveFormLoop.setPreferredSize(new Dimension(80, 120));
// p.add(waveFormLoop);
//
// main.add(p);
//
p = new JPanel();
p.setLayout(new FlowLayout());
p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelLoopPoints")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
p.add(loopStartLabel);
loopStart.setPreferredSize(new JTextField(8).getPreferredSize());
loopStart.setModel(new SpinnerNumberModel(Long.valueOf(0), Long.valueOf(0), Long.valueOf(Long.MAX_VALUE), Long.valueOf(1)));
loopStart.addChangeListener((ChangeEvent e) -> {
loopEnd.setValue(((Long) loopStart.getValue() < (Long) loopEnd.getValue()) ? loopEnd.getValue() : loopStart.getValue());
});
p.add(loopStart);
p.add(loopEndLabel);
loopEnd.setPreferredSize(new JTextField(8).getPreferredSize());
loopEnd.setModel(new SpinnerNumberModel(Long.valueOf(0), Long.valueOf(0), Long.valueOf(Long.MAX_VALUE), Long.valueOf(1)));
loopEnd.addChangeListener((ChangeEvent e) -> {
loopStart.setValue(((Long) loopEnd.getValue() < (Long) loopStart.getValue()) ? loopEnd.getValue() : loopStart.getValue());
});
p.add(loopEnd);
main.add(p);
p = new JPanel();
JButton apply;
p.add(apply = new JButton(Bundle.getMessage("ButtonApply")));
apply.addActionListener((ActionEvent e) -> {
applyPressed(e);
});
JButton ok;
p.add(ok = new JButton(Bundle.getMessage("ButtonOK")));
ok.addActionListener((ActionEvent e) -> {
applyPressed(e);
frame.dispose();
});
JButton cancel;
p.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
cancel.addActionListener((ActionEvent e) -> {
frame.dispose();
});
frame.getContentPane().add(p);
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class AudioListenerFrame method layoutFrame.
@Override
@SuppressWarnings("UnnecessaryBoxing")
public void layoutFrame() {
super.layoutFrame();
JPanel p;
main.add(position);
main.add(velocity);
p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelOrientation")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
p.add(oriAtLabel);
p.add(oriAt);
p.add(oriUpLabel);
p.add(oriUp);
main.add(p);
main.add(gain);
p = new JPanel();
p.setLayout(new FlowLayout());
p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelMetersPerUnit")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
metersPerUnit.setPreferredSize(new JTextField(8).getPreferredSize());
metersPerUnit.setModel(new SpinnerNumberModel(Float.valueOf(0f), Float.valueOf(0f), Float.valueOf(65536f), Float.valueOf(0.0001f)));
metersPerUnit.setEditor(new JSpinner.NumberEditor(metersPerUnit, "0.0000"));
p.add(metersPerUnit);
p.add(metersPerUnitLabel);
main.add(p);
p = new JPanel();
JButton apply;
p.add(apply = new JButton(Bundle.getMessage("ButtonApply")));
apply.addActionListener((ActionEvent e) -> {
applyPressed(e);
});
JButton ok;
p.add(ok = new JButton(Bundle.getMessage("ButtonOK")));
ok.addActionListener((ActionEvent e) -> {
applyPressed(e);
frame.dispose();
});
JButton cancel;
p.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
cancel.addActionListener((ActionEvent e) -> {
frame.dispose();
});
frame.getContentPane().add(p);
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class CoordinateEdit method initSetLevel.
public void initSetLevel() {
oldX = pl.getDisplayLevel();
textX = new javax.swing.JLabel();
textX.setText(Bundle.getMessage("Level") + ": " + pl.getDisplayLevel());
textX.setVisible(true);
SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 10, 1);
spinX = new javax.swing.JSpinner(model);
spinX.setValue(Integer.valueOf(pl.getDisplayLevel()));
spinX.setToolTipText(Bundle.getMessage("EnterLevel"));
spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
getContentPane().setLayout(new GridBagLayout());
addSpinItems(false);
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
int l = ((Number) spinX.getValue()).intValue();
pl.getEditor().setSelectionsDisplayLevel(l, pl);
textX.setText(Bundle.getMessage("Level") + ": " + l);
dispose();
}
});
okButton.getRootPane().setDefaultButton(okButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pl.getEditor().setSelectionsDisplayLevel(oldX, pl);
dispose();
}
});
setMinimumSize(new Dimension(250, 175));
pack();
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class CoordinateEdit method initZoom.
public void initZoom() {
oldD = pl.getScale();
textX = new javax.swing.JLabel();
textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Scale"), oldD * 100));
textX.setVisible(true);
SpinnerNumberModel model = new SpinnerNumberModel(100.0, 1.0, 5000.0, 1.0);
spinX = new javax.swing.JSpinner(model);
if (log.isDebugEnabled()) {
log.debug("scale%= " + (int) Math.round(oldD * 100));
}
spinX.setToolTipText(Bundle.getMessage("enterZoom"));
spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
getContentPane().setLayout(new GridBagLayout());
addSpinItems(false);
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
double s = ((Number) spinX.getValue()).doubleValue() / 100;
pl.setScale(s);
pl.getEditor().setPaintScale(s);
textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Scale"), pl.getScale() * 100));
dispose();
}
});
okButton.getRootPane().setDefaultButton(okButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
dispose();
}
});
pack();
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class CoordinateEdit method initScale.
public void initScale() {
//int scale = (int)Math.round(pl.getScale()*100);
oldD = pl.getScale();
textX = new javax.swing.JLabel();
textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Scale"), oldD * 100));
textX.setVisible(true);
SpinnerNumberModel model = new SpinnerNumberModel(100.0, 10.0, 5000.0, 1.0);
spinX = new javax.swing.JSpinner(model);
if (log.isDebugEnabled()) {
log.debug("scale%= " + (int) Math.round(oldD * 100));
}
spinX.setValue((int) Math.round(oldD * 100));
spinX.setToolTipText(Bundle.getMessage("enterScale"));
spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
getContentPane().setLayout(new GridBagLayout());
addSpinItems(false);
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
double s = ((Number) spinX.getValue()).doubleValue() / 100;
pl.getEditor().setSelectionsScale(s, pl);
textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Scale"), pl.getScale() * 100));
dispose();
}
});
okButton.getRootPane().setDefaultButton(okButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
dispose();
}
});
pack();
}
Aggregations