Search in sources :

Example 21 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class CoordinateEdit method initBorder.

public void initBorder() {
    PositionablePopupUtil util = pl.getPopupUtility();
    oldX = util.getBorderSize();
    textX = new javax.swing.JLabel();
    textX.setText(Bundle.getMessage("Border") + ": " + util.getBorderSize());
    textX.setVisible(true);
    SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 1000, 1);
    spinX = new javax.swing.JSpinner(model);
    spinX.setValue(Integer.valueOf(util.getBorderSize()));
    spinX.setToolTipText("Enter border size");
    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();
            PositionablePopupUtil util = pl.getPopupUtility();
            util.setBorderSize(l);
            pl.getEditor().setAttributes(util, pl);
            textX.setText(Bundle.getMessage("Border") + ": " + l);
            dispose();
        }
    });
    okButton.getRootPane().setDefaultButton(okButton);
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            pl.getPopupUtility().setBorderSize(oldX);
            dispose();
        }
    });
    pack();
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent)

Example 22 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class CoordinateEdit method initRotate.

public void initRotate() {
    oldX = pl.getDegrees();
    textX = new javax.swing.JLabel();
    int deg = oldX;
    textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Angle"), deg));
    textX.setVisible(true);
    SpinnerNumberModel model = new SpinnerNumberModel(0, -360, 360, 1);
    spinX = new javax.swing.JSpinner(model);
    //        spinX.setValue(Integer.valueOf(((NamedIcon)pLabel.getIcon()).getDegrees()));
    spinX.setValue(deg);
    spinX.setToolTipText(Bundle.getMessage("enterDegrees"));
    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 k = ((Number) spinX.getValue()).intValue();
            pl.getEditor().setSelectionsRotation(k, pl);
            textX.setText(java.text.MessageFormat.format(Bundle.getMessage("Angle"), k));
            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 23 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class MemoryIconCoordinateEdit method initSetXY.

@Override
public void initSetXY() {
    oldX = pl.getOriginalX();
    oldY = pl.getOriginalY();
    textX = new javax.swing.JLabel();
    textX.setText("X: " + pl.getOriginalX());
    textX.setVisible(true);
    textY = new javax.swing.JLabel();
    textY.setText("Y: " + pl.getOriginalY());
    textY.setVisible(true);
    SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 10000, 1);
    ChangeListener listener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText(" X: " + pl.getOriginalX());
            textY.setText(" Y: " + pl.getOriginalY());
        }
    };
    spinX = new javax.swing.JSpinner(model);
    spinX.setValue(Integer.valueOf(pl.getOriginalX()));
    spinX.setToolTipText(Bundle.getMessage("EnterXcoord"));
    spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
    spinX.addChangeListener(listener);
    model = new javax.swing.SpinnerNumberModel(0, 0, 10000, 1);
    spinY = new javax.swing.JSpinner(model);
    spinY.setValue(Integer.valueOf(pl.getOriginalY()));
    spinY.setToolTipText(Bundle.getMessage("EnterYcoord"));
    spinY.setMaximumSize(new Dimension(spinY.getMaximumSize().width, spinY.getPreferredSize().height));
    spinY.addChangeListener(listener);
    getContentPane().setLayout(new GridBagLayout());
    addSpinItems(true);
    okButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText(" X: " + pl.getOriginalX());
            textY.setText(" Y: " + pl.getOriginalY());
            dispose();
        }
    });
    okButton.getRootPane().setDefaultButton(okButton);
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            pl.setLocation(oldX, oldY);
            dispose();
        }
    });
    // make large enough to easily move
    setMinimumSize(new Dimension(250, 175));
    pack();
}
Also used : GridBagLayout(java.awt.GridBagLayout) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 24 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class PhysicalLocationPanel method initComponents.

protected void initComponents(String title) {
    tb = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), title);
    tb.setTitlePosition(TitledBorder.DEFAULT_POSITION);
    this.setBorder(tb);
    this.setLayout(new GridBagLayout());
    xs = new JSpinner(new SpinnerNumberModel(spin_value, min_spin, max_spin, spin_inc));
    ys = new JSpinner(new SpinnerNumberModel(spin_value, min_spin, max_spin, spin_inc));
    zs = new JSpinner(new SpinnerNumberModel(spin_value, min_spin, max_spin, spin_inc));
    JLabel xl = new JLabel("X");
    JLabel yl = new JLabel("Y");
    JLabel zl = new JLabel("Z");
    this.add(xl, setConstraints(0, 0, false));
    this.add(xs, setConstraints(GridBagConstraints.RELATIVE, 0, true));
    this.add(yl, setConstraints(GridBagConstraints.RELATIVE, 0, false));
    this.add(ys, setConstraints(GridBagConstraints.RELATIVE, 0, true));
    this.add(zl, setConstraints(GridBagConstraints.RELATIVE, 0, false));
    this.add(zs, setConstraints(GridBagConstraints.RELATIVE, 0, true));
    this.setVisible(true);
    log.debug("initComponents() complete");
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridBagLayout(java.awt.GridBagLayout) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel)

Example 25 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.

the class FrameServletPreferencesPanel method initComponents.

/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    bindingGroup = new BindingGroup();
    framesEnabled = new ButtonGroup();
    preferences = InstanceManager.getDefault(WebServerPreferences.class);
    enableFramesPnl = new JPanel();
    enableFrames = new JRadioButton();
    clickDelay = new JSpinner();
    refreshDelay = new JSpinner();
    useAjax = new JCheckBox();
    refreshDelayLbl = new JLabel();
    clickDelayLbl = new JLabel();
    disallowedFramesLbl = new JLabel();
    jScrollPane1 = new JScrollPane();
    disallowedFrames = new EditableList<String>();
    disableFramesPnl = new JPanel();
    disableFrames = new JRadioButton();
    redirectToPanels = new JCheckBox();
    framesEnabled.add(enableFrames);
    framesEnabled.add(disableFrames);
    preferences.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            preferencesPropertyChange(evt);
        }
    });
    // NOI18N
    enableFrames.setText(Bundle.getMessage("LabelEnableFrames"));
    Binding binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, preferences, ELProperty.create("${!disableFrames}"), enableFrames, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    clickDelay.setModel(new SpinnerNumberModel(1, 0, 999, 1));
    // NOI18N
    clickDelay.setToolTipText(Bundle.getMessage("ToolTipClickDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${clickDelay}"), clickDelay, BeanProperty.create("value"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), clickDelay, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    refreshDelay.setModel(new SpinnerNumberModel(5, 0, 999, 1));
    // NOI18N
    refreshDelay.setToolTipText(Bundle.getMessage("ToolTipRefreshDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${refreshDelay}"), refreshDelay, BeanProperty.create("value"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), refreshDelay, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    useAjax.setText(Bundle.getMessage("LabelUseAjax"));
    // NOI18N
    useAjax.setToolTipText(Bundle.getMessage("ToolTipUseAjax"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${useAjax}"), useAjax, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), useAjax, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    refreshDelayLbl.setText(Bundle.getMessage("LabelRefreshDelay"));
    // NOI18N
    refreshDelayLbl.setToolTipText(Bundle.getMessage("ToolTipRefreshDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), refreshDelayLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    clickDelayLbl.setText(Bundle.getMessage("LabelClickDelay"));
    // NOI18N
    clickDelayLbl.setToolTipText(Bundle.getMessage("ToolTipClickDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), clickDelayLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    disallowedFramesLbl.setText(Bundle.getMessage("LabelDisallowedFrames"));
    // NOI18N
    disallowedFramesLbl.setToolTipText(Bundle.getMessage("ToolTipDisallowedFrames"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), disallowedFramesLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    disallowedFrames.setModel(new DefaultEditableListModel<String>());
    disallowedFrames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // NOI18N
    disallowedFrames.setToolTipText(Bundle.getMessage("ToolTipDisallowedFrames"));
    disallowedFrames.setListCellEditor(new DefaultListCellEditor<>(new JTextField()));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), disallowedFrames, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    DefaultEditableListModel<String> model = (DefaultEditableListModel<String>) this.disallowedFrames.getModel();
    model.addListDataListener(this);
    for (String frame : this.preferences.getDisallowedFrames()) {
        model.addElement(frame);
    }
    model.addElement(" ");
    jScrollPane1.setViewportView(disallowedFrames);
    GroupLayout enableFramesPnlLayout = new GroupLayout(enableFramesPnl);
    enableFramesPnl.setLayout(enableFramesPnlLayout);
    enableFramesPnlLayout.setHorizontalGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addContainerGap().addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addGap(29, 29, 29).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addComponent(clickDelay, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(clickDelayLbl, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)).addGroup(enableFramesPnlLayout.createSequentialGroup().addComponent(refreshDelay, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(refreshDelayLbl, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)).addComponent(useAjax, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE).addComponent(disallowedFramesLbl, GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))).addComponent(enableFrames, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
    enableFramesPnlLayout.setVerticalGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(enableFrames).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(clickDelay, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(clickDelayLbl).addComponent(disallowedFramesLbl)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(refreshDelay, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(refreshDelayLbl)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(useAjax).addContainerGap(108, Short.MAX_VALUE)).addComponent(jScrollPane1))));
    // NOI18N
    disableFrames.setText(Bundle.getMessage("LabelDisableFrames"));
    // NOI18N
    disableFrames.setToolTipText(Bundle.getMessage("ToolTipDisableFrames"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${disableFrames}"), disableFrames, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    // NOI18N
    redirectToPanels.setText(Bundle.getMessage("LabelRedirectFramesToPanels"));
    // NOI18N
    redirectToPanels.setToolTipText(Bundle.getMessage("ToolTipRedirectFramesToPanels"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${redirectFramesToPanels}"), redirectToPanels, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, disableFrames, ELProperty.create("${selected}"), redirectToPanels, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    GroupLayout disableFramesPnlLayout = new GroupLayout(disableFramesPnl);
    disableFramesPnl.setLayout(disableFramesPnlLayout);
    disableFramesPnlLayout.setHorizontalGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(disableFrames, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(disableFramesPnlLayout.createSequentialGroup().addGap(35, 35, 35).addComponent(redirectToPanels, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))).addContainerGap()));
    disableFramesPnlLayout.setVerticalGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(disableFrames, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(redirectToPanels).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(enableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(disableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(enableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(disableFramesPnl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)));
    bindingGroup.bind();
}
Also used : JScrollPane(javax.swing.JScrollPane) AutoBinding(org.jdesktop.beansbinding.AutoBinding) Binding(org.jdesktop.beansbinding.Binding) JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) DefaultEditableListModel(jmri.swing.DefaultEditableListModel) JRadioButton(javax.swing.JRadioButton) PropertyChangeListener(java.beans.PropertyChangeListener) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ButtonGroup(javax.swing.ButtonGroup) BindingGroup(org.jdesktop.beansbinding.BindingGroup) GroupLayout(javax.swing.GroupLayout) JSpinner(javax.swing.JSpinner)

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