Search in sources :

Example 16 with SpinnerNumberModel

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);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField)

Example 17 with SpinnerNumberModel

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);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JSpinner(javax.swing.JSpinner) JTextField(javax.swing.JTextField)

Example 18 with SpinnerNumberModel

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();
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent)

Example 19 with SpinnerNumberModel

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();
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent)

Example 20 with SpinnerNumberModel

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();
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent)

Aggregations

SpinnerNumberModel (javax.swing.SpinnerNumberModel)58 JSpinner (javax.swing.JSpinner)40 JLabel (javax.swing.JLabel)28 JPanel (javax.swing.JPanel)27 ActionEvent (java.awt.event.ActionEvent)18 ChangeEvent (javax.swing.event.ChangeEvent)16 Dimension (java.awt.Dimension)14 GridBagLayout (java.awt.GridBagLayout)14 JButton (javax.swing.JButton)9 JCheckBox (javax.swing.JCheckBox)9 JRadioButton (javax.swing.JRadioButton)9 ChangeListener (javax.swing.event.ChangeListener)9 BorderLayout (java.awt.BorderLayout)7 FormLayout (com.jgoodies.forms.layout.FormLayout)6 Insets (java.awt.Insets)6 BoxLayout (javax.swing.BoxLayout)6 JScrollPane (javax.swing.JScrollPane)6 JTextField (javax.swing.JTextField)6 GridBagConstraints (java.awt.GridBagConstraints)5 ActionListener (java.awt.event.ActionListener)5