在一个JTextField禁用“粘贴” [英] Disabling 'paste' in a jTextfield
本文介绍了在一个JTextField禁用“粘贴”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜
我有写在Swing,AWT的应用程序。
我想prevent用户粘贴值到文本框。
有没有办法做到这一点不使用动作监听器?
Hi I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners?
推荐答案
您只需调用setTransferHandler像这样一个空参数:
You can just call setTransferHandler with a null parameter like this:
textComponent.setTransferHandler(null);
这将禁用场上所有拷贝/粘贴操作。
This will disable all copy/paste actions on the field.
这篇关于在一个JTextField禁用“粘贴”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文