private void addListener(final JComponent component) {
   if (component instanceof JComboBox) {
     ItemListener itemListener =
         new ItemListener() {
           public void itemStateChanged(ItemEvent e) {
             JComboBox comboBox = (JComboBox) component;
             final Object selectedItem = comboBox.getSelectedItem();
             _dotDefinitionDialogFrame
                 .getScratchDisplayObjectType()
                 .setValueOfStaticProperty(_primitiveForm.getName(), _property, selectedItem);
           }
         };
     JComboBox comboBox = (JComboBox) component;
     comboBox.addItemListener(itemListener);
   } else if (component instanceof JSpinner) {
     javax.swing.event.ChangeListener changeListener =
         new javax.swing.event.ChangeListener() {
           public void stateChanged(ChangeEvent e) {
             JSpinner spinner = (JSpinner) component;
             final Object value = spinner.getValue();
             _dotDefinitionDialogFrame
                 .getScratchDisplayObjectType()
                 .setValueOfStaticProperty(_primitiveForm.getName(), _property, value);
           }
         };
     JSpinner spinner = (JSpinner) component;
     spinner.addChangeListener(changeListener);
   }
 }
  public JComponent renderSpecial(final Shield shield) {
    final JSpinner atSpinner =
        new JSpinner(new SpinnerNumberModel(shield.getAttackeMod(), -10, 10, 1));
    atSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            shield.setAttackeMod(((Number) atSpinner.getValue()).intValue());
          }
        });

    final JSpinner paSpinner =
        new JSpinner(new SpinnerNumberModel(shield.getParadeMod(), -10, 10, 1));
    paSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            shield.setParadeMod(((Number) paSpinner.getValue()).intValue());
          }
        });

    final JPanel panel = new JPanel();

    panel.add(atSpinner);
    panel.add(new JLabel("/"));
    panel.add(paSpinner);

    return panel;
  }
  private JPanel getYearAndMonthPanal() {
    Calendar c = getDateCalendar();
    int currentYear = c.get(Calendar.YEAR);
    int currentMonth = c.get(Calendar.MONTH) + 1;
    int currentHour = c.get(Calendar.HOUR_OF_DAY);
    int currentMinute = c.get(Calendar.MINUTE);
    int currentSecond = c.get(Calendar.SECOND);

    JPanel result = new JPanel();
    result.setLayout(new FlowLayout());
    result.setBackground(controlLineColor);

    yearSpin = new JSpinner(new SpinnerNumberModel(currentYear, startYear, lastYear, 1));
    yearSpin.setPreferredSize(new Dimension(48, 20));
    yearSpin.setName("Year");
    yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
    yearSpin.addChangeListener(this);
    result.add(yearSpin);
    JLabel yearLabel = new JLabel("年");
    yearLabel.setForeground(controlTextColor);
    result.add(yearLabel);

    monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 12, 1));
    monthSpin.setPreferredSize(new Dimension(35, 20));
    monthSpin.setName("Month");
    monthSpin.addChangeListener(this);
    result.add(monthSpin);
    JLabel monthLabel = new JLabel("月");
    monthLabel.setForeground(controlTextColor);
    result.add(monthLabel);

    hourSpin = new JSpinner(new SpinnerNumberModel(currentHour, 0, 23, 1));
    hourSpin.setPreferredSize(new Dimension(35, 20));
    hourSpin.setName("Hour");
    hourSpin.addChangeListener(this);
    result.add(hourSpin);
    JLabel hourLabel = new JLabel("时");
    hourLabel.setForeground(controlTextColor);
    result.add(hourLabel);

    minuteSpin = new JSpinner(new SpinnerNumberModel(currentMinute, 0, 59, 1));
    minuteSpin.setPreferredSize(new Dimension(35, 20));
    minuteSpin.setName("Minute");
    minuteSpin.addChangeListener(this);
    result.add(minuteSpin);
    JLabel minuteLabel = new JLabel("分");
    hourLabel.setForeground(controlTextColor);
    result.add(minuteLabel);

    secondSpin = new JSpinner(new SpinnerNumberModel(currentSecond, 0, 59, 1));
    secondSpin.setPreferredSize(new Dimension(35, 20));
    secondSpin.setName("Second");
    secondSpin.addChangeListener(this);
    result.add(secondSpin);
    JLabel secondLabel = new JLabel("秒");
    secondLabel.setForeground(controlTextColor);
    result.add(secondLabel);

    return result;
  }
  public SpinnerModelEditorDemo() {
    // Group labels
    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(4, 1));
    panel1.add(new JLabel("Date"));
    panel1.add(new JLabel("Day"));
    panel1.add(new JLabel("Month"));
    panel1.add(new JLabel("Year"));

    // Group spinners
    JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayout(4, 1));
    panel2.add(jspDate);
    panel2.add(jspDay);
    panel2.add(jspMonth);
    panel2.add(spinnerYear);

    // Add spinner and label to the UI
    add(panel1, BorderLayout.WEST);
    add(panel2, BorderLayout.CENTER);

    // Set editor for date
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(jspDate, "MMM dd, yyyy");
    jspDate.setEditor(dateEditor);

    // Set editor for year
    JSpinner.NumberEditor yearEditor = new JSpinner.NumberEditor(spinnerYear, "####");
    spinnerYear.setEditor(yearEditor);

    // Update date to synchronize with the day, month, and year
    updateDate();

    // Register and create a listener for jspDay
    jspDay.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });

    // Register and create a listener for jspMonth
    jspMonth.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });

    // Register and create a listener for spinnerYear
    spinnerYear.addChangeListener(
        new ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent e) {
            updateDate();
          }
        });
  }
  private MainPanel() {
    super(new BorderLayout());
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < 100; i++) {
      String s = i + LF;
      buf.append(s);
    }

    final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString()));
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    JSpinner spinner =
        new JSpinner(
            new SpinnerNumberModel(
                scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1));
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0"));
    spinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            JSpinner s = (JSpinner) e.getSource();
            scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue());
          }
        });
    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Unit Increment:"));
    box.add(Box.createHorizontalStrut(2));
    box.add(spinner);
    box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(box, BorderLayout.NORTH);
    add(scrollPane);
    setPreferredSize(new Dimension(320, 240));
  }
	/**
	 * Returns the maximum frequency spinner.
	 * If the spinner doesn't exist it is created:
	 * <ul>
	 * <li>with the specified {@link #getMaxFrequencyModel() model},</li>
	 * <li>to have specified size (80x25 pixel),</li>
	 * <li>with the listener which updates the value of the {@link
	 * #getMinFrequencySpinner() minimum frequency spinner} to be at least
	 * {@code 0.01} smaller then the value of this spinner.</li></ul>
	 * @return the maximum frequency spinner
	 */
	public JSpinner getMaxFrequencySpinner() {
		if (maxFrequencySpinner == null) {
			maxFrequencySpinner = new JSpinner(getMaxFrequencyModel());

			Dimension spinnerSize = new Dimension(80,25);
			maxFrequencySpinner.setPreferredSize(spinnerSize);
			maxFrequencySpinner.setMinimumSize(spinnerSize);
			maxFrequencySpinner.setMaximumSize(spinnerSize);

			maxFrequencySpinner.addChangeListener(new ChangeListener() {

				@Override
				public void stateChanged(ChangeEvent e) {

					double value = ((Number) maxFrequencySpinner.getValue()).doubleValue();

					double otherValue = ((Number) getMinFrequencySpinner().getValue()).doubleValue();

					if ((value-0.01) < otherValue) {
						getMinFrequencySpinner().setValue(value - 0.01);
					}

				}

			});

			maxFrequencySpinner.setEditor(new JSpinner.NumberEditor(maxFrequencySpinner, "0.00"));
			maxFrequencySpinner.setFont(maxFrequencySpinner.getFont().deriveFont(Font.PLAIN));

		}
		return maxFrequencySpinner;
	}
Exemple #7
0
 public SpinSlider() {
   this.setLayout(new FlowLayout());
   final JSpinner spinner = new JSpinner();
   final JSlider slider = new JSlider();
   slider.addChangeListener(
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           JSlider s = (JSlider) e.getSource();
           spinner.setValue(s.getValue());
         }
       });
   this.add(slider);
   spinner.setModel(new SpinnerNumberModel(50, 0, 100, 1));
   spinner.setEditor(new JSpinner.NumberEditor(spinner, "0'%'"));
   spinner.addChangeListener(
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           JSpinner s = (JSpinner) e.getSource();
           slider.setValue((Integer) s.getValue());
         }
       });
   this.add(spinner);
 }
  public TimeStampEditor() {
    super(new BorderLayout());
    add(BorderLayout.WEST, datePicker);
    add(BorderLayout.CENTER, hours);
    add(BorderLayout.EAST, minutes);
    datePicker.setOpaque(false);
    datePicker.addActionListener(this);
    datePicker.getEditor().addFocusListener(this);

    hours.setOpaque(false);
    hours.addChangeListener(this);
    ((JSpinner.DefaultEditor) hours.getEditor()).getTextField().addFocusListener(this);

    minutes.setOpaque(false);
    minutes.addChangeListener(this);
    ((JSpinner.DefaultEditor) minutes.getEditor()).getTextField().addFocusListener(this);
  }
Exemple #9
0
  public TimeChooser() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    hour = new JSpinner(hourModel);
    add(hour);
    hour.addChangeListener(this);
    hour.setToolTipText("Hours 0-23, type in 24 to set the time to 23:59:59");

    minute = new JSpinner(minuteModel);
    add(minute);
    minute.addChangeListener(this);
    minute.setToolTipText("Minutes, 0-59");

    second = new JSpinner(secondModel);
    add(second);
    second.addChangeListener(this);
    second.setToolTipText("Seconds, 0-59");
  }
Exemple #10
0
  protected void attachTo(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
      extListener.startListeningTo(jc, extNotifier);
      listenedTo.add(jc);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
      return;
    }
    if (isProbablyAContainer(jc)) {
      attachToHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      listenedTo.add(jc);
      ((JList) jc).addListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).addActionListener(this);
    } else if (jc instanceof JTree) {
      listenedTo.add(jc);
      ((JTree) jc).getSelectionModel().addTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).addItemListener(this);
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.addPropertyChangeListener("value", this);
    } else if (jc instanceof JTextComponent) {
      listenedTo.add(jc);
      ((JTextComponent) jc).getDocument().addDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      listenedTo.add(jc);
      ((JColorChooser) jc).getSelectionModel().addChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).addChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).addChangeListener(this);
    } else if (jc instanceof JTable) {
      listenedTo.add(jc);
      ((JTable) jc).getSelectionModel().addListSelectionListener(this);
    } else {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "Don't know how to listen to a "
                + // NOI18N
                jc.getClass().getName());
      }
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.addPropertyChangeListener("name", this);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Begin listening to " + jc); // NOI18N
    }
  }
 private void initSpinner(SpinnerNumberModel model) {
   spinner = new JSpinner(model);
   spinner.addChangeListener(
       new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
           updateSliderState();
         }
       });
 }
  public LabelledSpinner(String label, int value, int min, int max, int step) {
    setLayout(new GridLayout(1, 2));

    add(new JLabel(label));

    spinnerNumberModel = new SpinnerNumberModel(value, min, max, step);
    JSpinner jSpinner = new JSpinner(spinnerNumberModel);
    jSpinner.addChangeListener(this);
    add(jSpinner);
  }
  private void initSpinner() {
    spinner.setBorder(BorderFactory.createEmptyBorder());
    Component textfield = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    // textfield.removeFocusListener(focusListener);
    textfield.addFocusListener(focusListener);

    // spinner.removeChangeListener(changeListener);
    spinner.addChangeListener(changeListener);

    if (spinner.getModel() instanceof SpinnerNumberModel) isNumberModel = true;
  }
    private void addSpinner(final JSpinner spinner, final UpdateStatus status) {
      spinner.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              status.setStatus(StatusFlag.Update);
            }
          });

      add(spinner);
    }
Exemple #15
0
    private void createYearAndMonthPanal() {
      Calendar c = getNowCalendar();
      int currentYear = c.get(Calendar.YEAR);
      int currentMonth = c.get(Calendar.MONTH) + 1;
      int currentHour = c.get(Calendar.HOUR_OF_DAY);
      yearSpin =
          new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1));
      monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1));
      hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1));

      yearPanel.setLayout(new java.awt.FlowLayout());
      yearPanel.setBackground(controlLineColor);

      yearSpin.setPreferredSize(new Dimension(48, 20));
      yearSpin.setName("Year");
      yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
      yearSpin.addChangeListener(this);
      yearPanel.add(yearSpin);

      JLabel yearLabel = new JLabel("年");
      yearLabel.setForeground(controlTextColor);
      yearPanel.add(yearLabel);

      monthSpin.setPreferredSize(new Dimension(35, 20));
      monthSpin.setName("Month");
      monthSpin.addChangeListener(this);
      yearPanel.add(monthSpin);

      JLabel monthLabel = new JLabel("月");
      monthLabel.setForeground(controlTextColor);
      yearPanel.add(monthLabel);

      hourSpin.setPreferredSize(new Dimension(35, 20));
      hourSpin.setName("Hour");
      hourSpin.addChangeListener(this);
      yearPanel.add(hourSpin);

      JLabel hourLabel = new JLabel("日");
      hourLabel.setForeground(controlTextColor);
      yearPanel.add(hourLabel);
    }
 private void configureSpinnerFloat(JSpinner spinner) {
   JSpinner.NumberEditor editor = (JSpinner.NumberEditor) spinner.getEditor();
   DecimalFormat format = editor.getFormat();
   format.setMinimumFractionDigits(3);
   format.setMinimumIntegerDigits(1);
   editor.getTextField().setHorizontalAlignment(SwingConstants.CENTER);
   Dimension d = spinner.getPreferredSize();
   d.width = 60;
   spinner.setPreferredSize(d);
   spinner.addChangeListener(this);
   spinner.setMaximumSize(d);
 }
 private void addListeners() {
   addSection.addActionListener(this);
   addGlue.addActionListener(this);
   addTextField0.addActionListener(this);
   addTextField1.addActionListener(this);
   removeLast.addActionListener(this);
   changeBackground.addActionListener(this);
   columnStrategy.addActionListener(this);
   rowStrategy.addActionListener(this);
   spaceSpinner.addChangeListener(this);
   alignmentCombo.addActionListener(this);
 }
  private void updateRefineSettings() {

    spinnerLineSamples.removeChangeListener(this);
    spinnerCornerOffset.removeChangeListener(this);
    spinnerSampleRadius.removeChangeListener(this);
    spinnerRefineMaxIterations.removeChangeListener(this);
    spinnerConvergeTol.removeChangeListener(this);
    spinnerMaxCornerChange.removeChangeListener(this);

    if (refineType == PolygonRefineType.LINE) {
      spinnerLineSamples.setValue(configLine.lineSamples);
      spinnerCornerOffset.setValue(configLine.cornerOffset);
      spinnerSampleRadius.setValue(configLine.sampleRadius);
      spinnerRefineMaxIterations.setValue(configLine.maxIterations);
      spinnerConvergeTol.setValue(configLine.convergeTolPixels);
      spinnerMaxCornerChange.setValue(configLine.maxCornerChangePixel);
    } else if (refineType == PolygonRefineType.CORNER) {
      spinnerLineSamples.setValue(configCorner.lineSamples);
      spinnerCornerOffset.setValue(configCorner.cornerOffset);
      spinnerSampleRadius.setValue(configCorner.sampleRadius);
      spinnerRefineMaxIterations.setValue(configCorner.maxIterations);
      spinnerConvergeTol.setValue(configCorner.convergeTolPixels);
      spinnerMaxCornerChange.setValue(configCorner.maxCornerChangePixel);
    }

    spinnerLineSamples.addChangeListener(this);
    spinnerCornerOffset.addChangeListener(this);
    spinnerSampleRadius.addChangeListener(this);
    spinnerRefineMaxIterations.addChangeListener(this);
    spinnerConvergeTol.addChangeListener(this);
    spinnerMaxCornerChange.addChangeListener(this);
  }
  public ObstacleSettings(final Scene scene, final SceneRenderer renderer) {
    PropertyLayout layout = new PropertyLayout();

    // color
    ColorPanel colorPanel = new ColorPanel("Obstacle Color", scene.view.obstacle.color);
    colorPanel.addListener(
        new ColorPanel.Listener() {
          public void colorChanged(ColorPanel panel, Vec3f newColor) {
            scene.view.obstacle.color.set(newColor);
          }
        });
    layout.add("Color", colorPanel);

    // edge width
    final SpinnerNumberModel widthModel =
        new SpinnerNumberModel(scene.view.obstacle.edgeWidth, 0, 100, 0.01);
    JSpinner widthSpinner = new JSpinner(widthModel);
    widthSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            scene.view.obstacle.edgeWidth = widthModel.getNumber().floatValue();
            renderer.get2D().getObstacleRenderer().markDirty();
          }
        });
    layout.add("Edge Width", widthSpinner);

    // visibility
    VisibilityWidget visibility =
        new VisibilityWidget(scene.view.obstacle.visible2d, scene.view.obstacle.visible3d);
    visibility.visible3d.setEnabled(false);
    visibility.addListener(
        new VisibilityWidget.Listener() {
          public void visibilityChanged(boolean visible2d, boolean visible3d) {
            scene.view.obstacle.visible2d = visible2d;
          }
        });
    layout.add(visibility);

    // draw origin
    final JCheckBox originCheckBox = new JCheckBox("Draw Origin");
    originCheckBox.setSelected(scene.view.obstacle.originVisible);
    originCheckBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            scene.view.obstacle.originVisible = originCheckBox.isSelected();
            renderer.get2D().getObstacleRenderer().markDirty();
          }
        });
    layout.add(originCheckBox);

    layout.apply(this);
  }
 /**
  * This method initializes spnCapacity
  *
  * @return javax.swing.JSpinner
  * @uml.property name="spnCapacity"
  */
 private JSpinner getSpnCapacity() {
   if (spnCapacity == null) {
     spnCapacity = new JSpinner();
     spnCapacity.setPreferredSize(new Dimension(50, 20));
     spnCapacity.setModel(new SpinnerNumberModel(1, 1, 10000, 1));
     spnCapacity.addChangeListener(
         new javax.swing.event.ChangeListener() {
           public void stateChanged(javax.swing.event.ChangeEvent e) {
             currentSchool.setCapacity((Integer) spnCapacity.getValue());
           }
         });
   }
   return spnCapacity;
 }
Exemple #21
0
  public GridTool() {
    try {
      setIcon(new ImageIcon(ImageUtil.getImage("net/rptools/maptool/client/image/grid.gif")));
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
    // Create the control panel
    controlPanel = new FormPanel("net/rptools/maptool/client/ui/forms/adjustGridControlPanel.xml");
    controlPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    gridSizeSpinner = controlPanel.getSpinner("gridSize");
    gridSizeSpinner.setModel(new SpinnerNumberModel());
    gridSizeSpinner.addChangeListener(new UpdateGridListener());

    gridOffsetXTextField = controlPanel.getTextField("offsetX");
    gridOffsetXTextField.addKeyListener(new UpdateGridListener());

    gridOffsetYTextField = controlPanel.getTextField("offsetY");
    gridOffsetYTextField.addKeyListener(new UpdateGridListener());

    gridSecondDimensionLabel = (JETALabel) controlPanel.getLabel("gridSecondDimensionLabel");
    gridSecondDimension = controlPanel.getTextField("gridSecondDimension");
    gridSecondDimension.addFocusListener(new UpdateGridListener());

    colorWell = (JETAColorWell) controlPanel.getComponentByName("colorWell");
    colorWell.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            copyControlPanelToGrid();
          }
        });

    JButton closeButton = (JButton) controlPanel.getComponentByName("closeButton");
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetTool();
            //				Lee: just to make the light sources snap to their owners after the tool is closed
            Zone z = MapTool.getFrame().getCurrentZoneRenderer().getZone();
            z.putTokens(z.getTokens());
          }
        });
    zoomSlider = (JSlider) controlPanel.getComponentByName("zoomSlider");
    zoomSlider.setMinimum(0);
    zoomSlider.setMaximum(zoomSliderStopCount);
    ZoomChangeListener zoomListener = new ZoomChangeListener();
    zoomSlider.addChangeListener(zoomListener);
    zoomSlider.addMouseListener(zoomListener);
  }
  /** @param model */
  public DoubleWidget(PropertyModel model, AbstractController controller) {
    super(model, controller);

    double min, max, inc;
    if (model.hasValueForParameter(MIN_VALUE_PARAM)) {
      min = model.getDoubleValueForParameter(MIN_VALUE_PARAM);
    } else {
      min = DEFAULT_MIN_VALUE;
    }
    if (model.hasValueForParameter(MAX_VALUE_PARAM)) {
      max = model.getDoubleValueForParameter(MAX_VALUE_PARAM);
    } else {
      max = DEFAULT_MAX_VALUE;
    }
    if (model.hasValueForParameter(INCREMENT_VALUE_PARAM)) {
      inc = model.getDoubleValueForParameter(INCREMENT_VALUE_PARAM);
    } else {
      inc = DEFAULT_INC_VALUE;
    }

    SpinnerNumberModel valueModel = new SpinnerNumberModel(min, min, max, inc);
    valueChooser = new JSpinner(valueModel);
    valueChooser.setEditor(new JSpinner.NumberEditor(valueChooser /*, "#.##"*/));
    valueChooser.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (e.getSource() == valueChooser) {
              updateModelFromWidget();
            }
          }
        });
    valueChooser.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    JComponent editor = valueChooser.getEditor();
    if (editor instanceof DefaultEditor) {
      ((DefaultEditor) editor).getTextField().setHorizontalAlignment(SwingConstants.LEFT);
      if (ToolBox.getPLATFORM() != ToolBox.MACOS) {
        ((DefaultEditor) editor)
            .getTextField()
            .setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
      }
    }
    if (model.hasValueForParameter(READONLY_TEXTFIELD)
        && model.getBooleanValueForParameter(READONLY_TEXTFIELD)) {
      valueChooser.setEnabled(false);
    }

    getDynamicComponent().addFocusListener(new WidgetFocusListener(this));
  }
  ConvMatrix3x3Editor(final float[] _convMatrix3x3) {
    default3x3 = Arrays.copyOf(_convMatrix3x3, _convMatrix3x3.length);
    JPanel leftPanel = new JPanel();
    JPanel controlPanel = new JPanel();
    BoxLayout layout = new BoxLayout(controlPanel, BoxLayout.Y_AXIS);
    controlPanel.setLayout(layout);
    component = leftPanel;
    JPanel grid3x3Panel = new JPanel();
    controlPanel.add(grid3x3Panel);
    grid3x3Panel.setLayout(new GridLayout(3, 3));
    for (int i = 0; i < 9; i++) {
      final int index = i;
      SpinnerModel model = new SpinnerNumberModel(_convMatrix3x3[index], -50f, 50f, 1f);
      JSpinner spinner = new JSpinner(model);
      spinners[i] = spinner;
      spinner.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent ce) {
              JSpinner source = (JSpinner) ce.getSource();
              double value = ((Double) source.getValue());
              _convMatrix3x3[index] = (float) value;
              updated(_convMatrix3x3);
            }
          });
      grid3x3Panel.add(spinner);
    }
    String[] options = new String[] {"DEFAULT", "NONE", "BLUR"};
    JComboBox combo = new JComboBox(options);
    combo.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            String value = (String) cb.getSelectedItem();
            if (value.equals("DEFAULT")) {
              set(_convMatrix3x3, default3x3);
            } else if (value.equals("NONE")) {
              set(_convMatrix3x3, none3x3);
            } else if (value.equals("BLUR")) {
              set(_convMatrix3x3, blur3x3);
            }
          }
        });
    controlPanel.add(combo);

    leftPanel.add(controlPanel, BorderLayout.NORTH);
  }
  /**
   * Configures the given date picker and associated time spinner
   *
   * @param picker the date picker
   * @param spinner the time spinner
   */
  private void initDatePicker(JXDatePicker picker, JSpinner spinner) {
    picker.setFormats(new SimpleDateFormat("E dd/MM/yyyy"));
    picker.addPropertyChangeListener("date", this);

    DateEditor editor = new JSpinner.DateEditor(spinner, "HH:mm");
    DateFormatter formatter = (DateFormatter) editor.getTextField().getFormatter();
    formatter.setAllowsInvalid(false);
    formatter.setOverwriteMode(true);
    formatter.setCommitsOnValidEdit(true);
    spinner.setEditor(editor);
    spinner.addChangeListener(new SpinnerChangeListener());

    // Set the enabled state
    picker.setEnabled(!readOnlyRoute);
    spinner.setEnabled(!readOnlyRoute);
  }
  /** @return spinner_fine_tune */
  protected JSpinner getSpinner_fine_tune() {
    if (spinner_fine_tune == null) {
      spinner_fine_tune = new JSpinner();
      spinner_fine_tune.setModel(new SpinnerNumberModel(100.0, 0, 100.0, 0.1));
      spinner_fine_tune.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              double value = (Double) getSpinner_fine_tune().getValue();
              appEngine.setRobotRatioPercentage((float) value);

              getSlider_animationControl().setValue((int) value);
            }
          });
    }
    return spinner_fine_tune;
  }
  private void addChangeListeners() {
    ChangeListener translationChangeListener =
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            _dotDefinitionDialogFrame.setSomethingChanged(true);
          }
        };
    _translationFactorSpinner.addChangeListener(translationChangeListener);

    ChangeListener joinByLineChangeListener =
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            _dotDefinitionDialogFrame.setSomethingChanged(true);
          }
        };
    _joinByLineCheckBox.addChangeListener(joinByLineChangeListener);
  }
    public ScaleEditor() {
      super(new BorderLayout());
      setOpaque(false);
      ScaleEditor.this.add(BorderLayout.CENTER, field);

      field.addChangeListener(
          new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent ce) {
              ActionEvent event = new ActionEvent(ScaleEditor.this, 0, "");

              for (ActionListener lst : listeners.getListeners(ActionListener.class)) {
                lst.actionPerformed(event);
              }
            }
          });
    }
  public OperatorPropertyPanel(final MainFrame mainFrame) {
    super();
    this.mainFrame = mainFrame;
    breakpointButton = new BreakpointButton();
    headerLabel.setHorizontalAlignment(SwingConstants.CENTER);
    expertModeHintLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    expertModeHintLabel.setIcon(WARNING_ICON);
    expertModeHintLabel.addMouseListener(
        new MouseListener() {
          public void mouseReleased(MouseEvent e) {
            mainFrame.TOGGLE_EXPERT_MODE_ACTION.actionPerformed(null);
          }

          public void mouseClicked(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}
        });
    expertModeHintLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    expertModeHintLabel.setHorizontalAlignment(SwingConstants.LEFT);
    setupComponents();

    compatibilityLevelSpinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            // compatibility level
            OperatorVersion[] versionChanges = operator.getIncompatibleVersionChanges();
            if (versionChanges.length != 0) {
              OperatorVersion latestChange = versionChanges[versionChanges.length - 1];
              if (latestChange.isAtLeast(operator.getCompatibilityLevel())) {
                compatibilityLabel.setIcon(WARNING_ICON);
              } else {
                compatibilityLabel.setIcon(SwingTools.createIcon("16/ok.png"));
              }
            }
          }
        });
  }
  /**
   * Creates a new IntegerInputComponent.
   *
   * @param param The IntegerParameter to be controlled.
   * @param parameterPanel The ParameterPanel to which this component is to be placed.
   */
  public IntegerInputComponent(IntegerParameter param, ParameterPanel parameterPanel) {
    super(parameterPanel);
    this.param = param;
    this.state = ParameterInputComponent.INPUT_IS_INITIALIZED;
    SpinnerModel model = new NullableSpinnerModel();
    model.setValue(param.getValue());
    this.spinner = new JSpinner(model);
    spinner.addFocusListener(this);
    spinner.setPreferredSize(ParameterInputComponent.PREFERRED_SIZE);

    // The second parameter of NumberEditor constructor is number format
    // The string "0" means that it is a digit without any thousand separators
    // or decimals
    spinner.setEditor(new NullableSpinnerEditor(spinner, "0"));

    spinner.addChangeListener(this);
    field = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    field.addCaretListener(this);
    field.setBackground(BG_VALID);
    this.add(spinner, BorderLayout.CENTER);
  }
  private void setUpA1(List<DataSet> dataSets, Box a1) {
    int[] shifts = params.getShifts();

    if (shifts.length != dataSets.get(0).getNumColumns()) {
      shifts = new int[dataSets.get(0).getNumColumns()];
      params.setShifts(shifts);
    }

    final int[] _shifts = shifts;

    for (int i = 0; i < dataSets.get(0).getNumColumns(); i++) {
      Node node = dataSets.get(0).getVariable(i);
      Box a5 = Box.createHorizontalBox();

      SpinnerModel shiftModel = new SpinnerNumberModel(_shifts[i], -50, 50, 1);
      JSpinner shiftSpinner = new JSpinner(shiftModel);
      shiftSpinner.setMaximumSize(shiftSpinner.getPreferredSize());
      final int nodeIndex = i;

      shiftSpinner.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              JSpinner spinner = (JSpinner) e.getSource();
              SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel();
              int value = (Integer) model.getValue();
              _shifts[nodeIndex] = value;
              params.setShifts(_shifts);
            }
          });

      a5.add(new JLabel("    Shift for "));
      a5.add(new JLabel(node.getName()));
      a5.add(new JLabel(" is "));
      a5.add(shiftSpinner);
      a5.add(Box.createHorizontalGlue());
      a1.add(a5);
    }
  }