Пример #1
0
  /**
   * Create a instance of this check entry and set the configuration entry that is used to setup
   * this class.
   *
   * @param usedEntry the entry used to setup this class, the entry needs to pass the check with the
   *     static method
   */
  @SuppressWarnings("nls")
  public NumberEntryAwt(final ConfigEntry usedEntry) {
    super(new BorderLayout(10, 0));

    if (!isUsableEntry(usedEntry)) {
      throw new IllegalArgumentException("ConfigEntry type illegal.");
    }
    entry = (NumberEntry) usedEntry;

    currentValue = entry.getValue();

    display = new Label(Integer.toString(currentValue));
    add(display, BorderLayout.EAST);

    final Scrollbar scroll = new Scrollbar();
    scroll.setOrientation(Scrollbar.HORIZONTAL);
    scroll.setValues(currentValue, 1, entry.getRange().getMin(), entry.getRange().getMax() + 1);
    scroll.addAdjustmentListener(new NumberEntryScrollListener(this));
    add(scroll, BorderLayout.CENTER);

    setMinimumSize(new Dimension(300, 10));
  }
Пример #2
0
 /**
  * Set the current value of this entry. This is a internal function that is required to update the
  * state of this instance.
  *
  * @param val the value the current value is supposed to be set to
  */
 void setCurrentValue(final int val) {
   currentValue = FastMath.clamp(val, entry.getRange());
   display.setText(Integer.toString(currentValue));
 }
Пример #3
0
 /** Save the value in this text entry to the configuration. */
 @Override
 public void save() {
   entry.setValue(FastMath.clamp(currentValue, entry.getRange()));
 }