How to disable ctrl+v (paste) in JPasswordField?

You may have questions like how to disable paste in JPasswordField in java swing or how to avoid ctrl+v in JPasswordField?

Here is a simple solution :
You need to just override paste function as follows :

JPasswordField pwField = new JPasswordField() {
public void paste() {
UIManager.getLookAndFeel().provideErrorFeedback(this);
}
}

Share on Google Plus

About Pranav

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment