Limiting and formatting a JTextfield

岁酱吖の 提交于 2019-12-02 11:52:30

You might want to use : JFormattedTextField

See this for more help : How to Use Formatted Text Fields

Also this might help : MaskFormatter

Here is a sample snippet :

MaskFormatter formatter = new MaskFormatter("####-###-####");

EDIT :

After some research I found out that a DocumentFilter would do things better,

See this for more details : Implementing a Document Filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!