/**
   * Constructs a CurrencyWidget object with specified currency.
   *
   * @param currencyCode International currency code (ISO 4217).
   */
  public CurrencyWidget(String currencyCode) {
    currencyData = CurrencyList.get().lookup(currencyCode);
    assert (currencyData != null);
    currencySymbol = new Label(currencyData.getPortableCurrencySymbol());
    formatter = NumberFormat.getFormat(getCurrencyAmountPattern());

    initWidget(horizontalPanel);
    horizontalPanel.setSpacing(2);
    if (isLeadingSymbol()) {
      horizontalPanel.add(currencySymbol);
      horizontalPanel.add(amountBox);
      amountBox.setTextAlignment(TextBoxBase.ALIGN_LEFT);
    } else {
      horizontalPanel.add(amountBox);
      horizontalPanel.add(currencySymbol);
      amountBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);
    }
    amountBox.setText(formatter.format(0));

    amountBox.addFocusListener(
        new FocusListener() {
          public void onFocus(Widget sender) {
            if (!valueInitiated) {
              amountBox.setText("");
              valueInitiated = true;
            }
          }

          public void onLostFocus(Widget sender) {
            amountBox.setText(reformatContent());
          }
        });

    amountBox.addKeyboardListener(
        new KeyboardListenerAdapter() {
          public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            if (keyCode == (char) KEY_ENTER) {
              amountBox.setText(reformatContent());
            }
          }

          public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (acceptableCharset.indexOf(keyCode) == -1) {
              amountBox.cancelKey();
            }
            if (amountBox.getText().length() >= 16) {
              amountBox.cancelKey();
            }
          }
        });
  }
 public DistanceNumberFormat(UserSettings.DistanceUnit distanceUnit) {
   super("0.##", CurrencyList.get().getDefault(), true);
   this.distanceUnit = distanceUnit;
 }
 public SpeedNumberFormat(UserSettings.SpeedUnit speedUnit) {
   super("0.##", CurrencyList.get().getDefault(), true);
   this.speedUnit = speedUnit;
 }