Esempio n. 1
0
  public MeioMaskField(
      String id,
      MaskType mask,
      String options,
      IModel<T> model,
      boolean valueContainsLiteralCharacters,
      Class<T> type) {
    super(id, model, type);
    this.maskType = mask;
    LOGGER.debug("Initializing maskfield with id {} ...", id);
    LOGGER.debug("  Mask name: {}, mask: {}", mask.getMaskName(), mask.getMask());
    LOGGER.debug("  Options: {}", options);
    LOGGER.debug("  Type: {}", type);
    LOGGER.debug("  ValueContainsLiteralCharacters: {}", valueContainsLiteralCharacters);
    try {
      maskFormatter.setMask(mask.getMask());
      maskFormatter.setValueClass(String.class);
      maskFormatter.setAllowsInvalid(true);
      maskFormatter.setValueContainsLiteralCharacters(valueContainsLiteralCharacters);
    } catch (ParseException parseException) {
      throw new WicketRuntimeException(parseException);
    }

    add(new MeioMaskBehavior(mask, options));
    setOutputMarkupId(true);

    LOGGER.debug("Maskfield {} initialized.", id);
  }
Esempio n. 2
0
  public final void setOptions() {
    try {
      MaskFormatter msf = new MaskFormatter("##:##:##");
      msf.setPlaceholderCharacter('_');
      msf.setAllowsInvalid(false);
      msf.setValueContainsLiteralCharacters(false);
      inputDatejFormattedTextField.setFormatterFactory(new DefaultFormatterFactory(msf));

    } catch (ParseException ex) {
      Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
    df.applyPattern("HH:mm:ss");
    clockjLabel.setText(df.format(cal.getTime()));
  }