java - How do enable cut, copy in JPasswordField? -


i noticed unable cut , copy in jpasswordfield? how copy/cut selected part of password clipboard? there methods this?

simple, use method

jpasswordfield jt=new jpasswordfield(20);              // put client property             jt.putclientproperty("jpasswordfield.cutcopyallowed",true);              add(jt); 

by default, password in jpasswordfield not allowed cut/copied. need enable them.

as per comment on disabling paste didn't find property, have achieved using this, (i dont recommend way)

jt.getactionmap().put("a",null);         jt.getinputmap(jcomponent.when_focused).put(keystroke.getkeystroke("ctrl v"),"a"); 

another way, override paste() (i recommend way) while declaring

jpasswordfield jt=new jpasswordfield(20){   public void paste(){} }; 

update: misunderstood comment. above disabling paste. disable 1 of copy/cut/paste, better if required method disabled overrided no implementation in it.

if there better way, love hear.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -