将文本框限制为最大值 [英] limiting the textbox to max

查看:148
本文介绍了将文本框限制为最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制jTextField,使其只能占用x(字符数)?我想创建一个名为Validate的类,其中将有一个方法,我将调用键类型事件,以便我可以管理字符的限制?



请帮帮我

解决方案

设置textField的文档。扩展PlianDocument以创建自己的自定义文档并将char限制逻辑放在那里并将其设置为文本字段。



这是一个example

i want to limit the jTextField so that it can take only x(number of characters ) ? i want to make a class named Validate in which there will be a method which will i call on key typed event so that i can manage the limitation of characters ?

Please help me

解决方案

Set document for the textField. Extends PlianDocument to create your own custom document and put the char limit logic over there and set it to the textfield.

Here is one example


这篇关于将文本框限制为最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆