可编辑的JComboBox限制长度
我有一个可编辑的 JCombobox,需要设置用户可以设置的字符数限制。
谢谢
i have an editable JCombobox and need to set a limit to the number of characters that can be set by the user.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然您提到了字符,我假设您的
JCombobox
上的编辑器可以是JTextField
。在这种情况下,您可以通过设置自定义Document
来限制JTextField
接受的字符数,如详细说明此处Since you mentions characters, I assume the editor on your
JCombobox
can be aJTextField
. In that case, you can limit the number of characters theJTextField
accepts by setting a customDocument
, as explained in full detail here您可以修改组合框编辑器的最大字符数,如下所示(最多 4 个字符):
You can modify maximum number of characters changing the comboBox editor as you can see below (Max 4 characters):