Example usage for javax.swing.text MaskFormatter setOverwriteMode

List of usage examples for javax.swing.text MaskFormatter setOverwriteMode

Introduction

In this page you can find the example usage for javax.swing.text MaskFormatter setOverwriteMode.

Prototype

public void setOverwriteMode(boolean overwriteMode) 

Source Link

Document

Configures the behavior when inserting characters.

Usage

From source file:Main.java

MaskFormatter createFormatter(String format) {
    MaskFormatter formatter = null;
    try {//from w w w. j a  va2s  .  c  o m
        formatter = new MaskFormatter(format);
        formatter.setPlaceholderCharacter('.'/*or '0' etc*/);
        formatter.setAllowsInvalid(false); // if needed
        formatter.setOverwriteMode(true); // if needed
    } catch (java.text.ParseException exc) {
        System.err.println("formatter is bad: " + exc.getMessage());
    }
    return formatter;
}