Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import javax.swing.JFormattedTextField;
import javax.swing.text.DefaultFormatterFactory;

import javax.swing.text.MaskFormatter;

public class Main {
    public static void setValueMask(JFormattedTextField textField) {
        try {
            MaskFormatter mask = new MaskFormatter("R$ ###.##");
            mask.setValidCharacters("0123456789");
            mask.setPlaceholderCharacter('0');
            textField.setFormatterFactory(new DefaultFormatterFactory(mask));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}