Package javax.swing.text

Examples of javax.swing.text.NumberFormatter


        DefaultFormatter formatter;
        if (value instanceof Date) {
            formatter = new DateFormatter();
        }
        else if (value instanceof Number) {
            formatter = new NumberFormatter();
        }
        else {
            formatter = new DefaultFormatter();
        }
        if (logger.isDebugEnabled()) {
View Full Code Here


        minimum = new Integer(min);
        maximum = new Integer(max);

        //Set up the editor for the integer cells.
        integerFormat = NumberFormat.getIntegerInstance();
        NumberFormatter intFormatter = new NumberFormatter(integerFormat);
        intFormatter.setFormat(integerFormat);
        intFormatter.setMinimum(minimum);
        intFormatter.setMaximum(maximum);

        ftf.setFormatterFactory(
                new DefaultFormatterFactory(intFormatter));
        ftf.setValue(minimum);
        ftf.setHorizontalAlignment(JTextField.TRAILING);
View Full Code Here

    // Set up the editor for the integer cells.
    percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMinimumIntegerDigits(1);
    percentFormat.setMinimumFractionDigits(2);
    percentFormat.setMaximumFractionDigits(2);
    NumberFormatter percentFormatter = new NumberFormatter(percentFormat);
    percentFormatter.setFormat(percentFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(percentFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

    // Set up the editor for the integer cells.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMinimumFractionDigits(2);
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumIntegerDigits(1);
    NumberFormatter numberFormatter = new NumberFormatter(numberFormat);
    numberFormatter.setFormat(numberFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(numberFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

     * @param boleto
     *
     */
    public InputStream transform(Boleto boleto) {

        NumberFormatter formatter = new NumberFormatter(new DecimalFormat(
                "#,##0.00"));

        // gera template com o fundo do boleto
        URL imagemTitulo = BoletoTransformer.class
                .getResource("/br/com/caelum/stella/boleto/img/template.png");

        try {
            this.writer.writeImage(0, 55, imageFor(imagemTitulo), 514.22f,
                    385.109f);
            this.writer.writeImage(0, 805 - 486, imageFor(boleto.getBanco()
                    .getImage()), 100, 23);
        } catch (IOException e) {
            throw new GeracaoBoletoException(
                    "Erro na leitura das imagens do boleto", e);
        }

        for (int i = 0; i < boleto.getDescricoes().size(); i++)
            this.writer.writeBold(5, 805 - 70 - i * 15, boleto.getDescricoes()
                    .get(i));

        this.writer.write(50, LINHA1, boleto.getEmissor().getCedente());

        this.writer.write(5, LINHA2, boleto.getSacado().getNome());

        this.writer.write(230, LINHA2, formatDate(boleto.getDatas()
                .getVencimento()));

        try {
            this.writer.write(400, LINHA2, formatter.valueToString(boleto
                    .getValorBoleto().doubleValue()));
        } catch (NumberFormatException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        } catch (ParseException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        }

        this.writer.write(5, LINHA3, boleto.getEmissor().getAgencia() + "-"
                + boleto.getEmissor().getDvAgencia() + " / "
                + boleto.getEmissor().getContaCorrente() + "-"
                + boleto.getEmissor().getDvContaCorrente());

        this.writer.write(146, LINHA3, boleto.getEmissor()
                .getNossoNumeroFormatado());

        this.writer.writeBold(125, LINHA4, boleto.getBanco()
                .getNumeroFormatado());

        this.writer.writeBold(175, LINHA4, boleto.getBanco()
                .geraLinhaDigitavelPara(boleto));

        for (int i = 0; i < boleto.getLocaisDePagamento().size(); i++)
            this.writer.write(5, LINHA5 - (i - 1) * 10, boleto
                    .getLocaisDePagamento().get(i));

        this.writer.write(425, LINHA5, formatDate(boleto.getDatas()
                .getVencimento()));

        this.writer.write(5, LINHA6, boleto.getEmissor().getCedente());

        this.writer.write(420, LINHA6, boleto.getEmissor().getAgencia() + " - "
                + boleto.getEmissor().getDvAgencia() + " / "
                + boleto.getEmissor().getContaCorrente() + "-"
                + boleto.getEmissor().getDvContaCorrente());

        this.writer.write(5, LINHA7, formatDate(boleto.getDatas()
                .getDocumento()));

        this.writer.write(70, LINHA7,
                !boleto.getNoDocumento().equals("") ? boleto
                        .getNoDocumentoFormatado() : boleto.getEmissor()
                        .getNossoNumeroFormatado());

        this.writer.write(180, LINHA7, boleto.getEspecieDocumento());

        this.writer.write(250, LINHA7, boleto.getAceite() ? "S" : "N");

        this.writer.write(300, LINHA7, formatDate(boleto.getDatas()
                .getProcessamento()));

        this.writer.write(410, LINHA7, boleto.getEmissor().getCarteira()
                + " / " + boleto.getEmissor().getNossoNumeroFormatado());

        this.writer.write(122, LINHA8, boleto.getEmissor().getCarteira());

        this.writer.write(190, LINHA8, boleto.getEspecieMoeda());

        try {
            this.writer.write(430, LINHA8, formatter.valueToString(boleto
                    .getValorBoleto().doubleValue()));
        } catch (NumberFormatException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        } catch (ParseException e) {
View Full Code Here

    super(new JFormattedTextField());
    ftf = (JFormattedTextField)getComponent();

    //Set up the editor for the integer cells.
    integerFormat = NumberFormat.getIntegerInstance();
    NumberFormatter intFormatter = new NumberFormatter(integerFormat);
    intFormatter.setFormat(integerFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

        StringBuffer numberFormatString = new StringBuffer();
        numberFormatString.append("0").append((decimalPlaces > 0? "." : ""));
        for (int i = 0; i < decimalPlaces; i++) {
            numberFormatString.append("0");
        }
        nf = new NumberFormatter(new DecimalFormat(numberFormatString.toString()));
    }
View Full Code Here

        StringBuffer numberFormatString = new StringBuffer();
        numberFormatString.append("0").append((decimalPlaces > 0? "." : ""));
        for (int i = 0; i < decimalPlaces; i++) {
            numberFormatString.append("0");
        }
        nf = new NumberFormatter(new DecimalFormat(numberFormatString.toString()));
    }
View Full Code Here

     * @param boleto
     *
     */
    public InputStream transform(Boleto... boletos) {

  NumberFormatter formatter = new NumberFormatter(new DecimalFormat(
    "#,##0.00"));

  // gera template com o fundo do boleto
  URL imagemTitulo = BoletoTransformer.class
    .getResource("/br/com/caelum/stella/boleto/img/template.png");

  boolean firstPage = true;
  for (Boleto boleto : boletos) {
      if (!firstPage) {
    writer.newPage();
      }
      try {
    writer.writeImage(0, 55, imageFor(imagemTitulo), 514.22f,
      385.109f);
    writer.writeImage(0, 805 - 486, imageFor(boleto.getBanco()
      .getImage()), 100, 23);
      } catch (IOException e) {
    throw new GeracaoBoletoException(
      "Erro na leitura das imagens do boleto", e);
      }

      for (int i = 0; i < boleto.getDescricoes().size(); i++) {
    writer.writeBold(5, 805 - 70 - i * 15, boleto.getDescricoes()
      .get(i));
      }

      writer.write(50, LINHA1, boleto.getEmissor().getCedente());

      writer.write(5, LINHA2, boleto.getSacado().getNome());

      writer.write(230, LINHA2, formatDate(boleto.getDatas()
        .getVencimento()));

      try {
    writer.write(400, LINHA2, formatter.valueToString(boleto
      .getValorBoleto().doubleValue()));
      } catch (NumberFormatException e) {
    throw new CriacaoBoletoException(
      "Erro na formatação do valor do boleto", e);
      } catch (ParseException e) {
    throw new CriacaoBoletoException(
      "Erro na formatação do valor do boleto", e);
      }

      writer.write(5, LINHA3, boleto.getEmissor().getAgenciaFormatado()
        + "-"
        + boleto.getEmissor().getDvAgencia()
        + " / "
        + boleto.getBanco().getContaCorrenteDoEmissorFormatado(
          boleto.getEmissor()) + "-"
        + boleto.getEmissor().getDvContaCorrente());

      writer.write(146, LINHA3, boleto.getBanco()
        .getNossoNumeroDoEmissorFormatado(boleto.getEmissor()));

      writer.writeBold(125, LINHA4, boleto.getBanco()
        .getNumeroFormatado());

      writer.writeBold(175, LINHA4, boleto.getBanco()
        .geraLinhaDigitavelPara(boleto));

      for (int i = 0; i < boleto.getLocaisDePagamento().size(); i++) {
    writer.write(5, LINHA5 - (i - 1) * 10, boleto
      .getLocaisDePagamento().get(i));
      }

      writer.write(425, LINHA5, formatDate(boleto.getDatas()
        .getVencimento()));

      writer.write(5, LINHA6, boleto.getEmissor().getCedente());

      writer.write(420, LINHA6, boleto.getEmissor().getAgenciaFormatado()
        + " - "
        + boleto.getEmissor().getDvAgencia()
        + " / "
        + boleto.getBanco().getContaCorrenteDoEmissorFormatado(
          boleto.getEmissor()) + "-"
        + boleto.getEmissor().getDvContaCorrente());

      writer.write(5, LINHA7,
        formatDate(boleto.getDatas().getDocumento()));

      writer.write(70, LINHA7,
        !boleto.getNoDocumento().equals("") ? boleto
          .getNoDocumentoFormatado() : boleto.getBanco()
          .getNossoNumeroDoEmissorFormatado(
            boleto.getEmissor()));

      writer.write(180, LINHA7, boleto.getEspecieDocumento());

      writer.write(250, LINHA7, boleto.getAceite() ? "S" : "N");

      writer.write(300, LINHA7, formatDate(boleto.getDatas()
        .getProcessamento()));

      writer.write(410, LINHA7, boleto.getEmissor().getCarteira()
        + " / "
        + boleto.getBanco().getNossoNumeroDoEmissorFormatado(
          boleto.getEmissor()));

      writer.write(122, LINHA8, boleto.getBanco()
        .getCarteiraDoEmissorFormatado(boleto.getEmissor()));

      writer.write(190, LINHA8, boleto.getEspecieMoeda());

      try {
    writer.write(430, LINHA8, formatter.valueToString(boleto
      .getValorBoleto().doubleValue()));
      } catch (NumberFormatException e) {
    throw new CriacaoBoletoException(
      "Erro na formatação do valor do boleto", e);
      } catch (ParseException e) {
View Full Code Here

        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 2;
        inputPanel2.add(queryButton, c);

        maxHitsField = new JFormattedTextField(new NumberFormatter());
        maxHitsField.setValue(Integer.valueOf(100));
        maxHitsField.setColumns(5);

        JLabel maxHitsLabel = new JLabel("Max hits:");
        maxHitsLabel.setLabelFor(maxHitsField);
View Full Code Here

TOP

Related Classes of javax.swing.text.NumberFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.