1

I want to make component like JPasswordField that masks only part of an input, for example, for input 123456789, 12345**** will be rendered. I think that only correct way to do this is to override drawSelectedText() and drawUnselectedText() in component's View, but the problem with this approach is that I have to use TextUI from concrete look and feel (BasicPasswordFieldUI from AlexR's example) which might not work correctly when using some other lnf.

My problem is similar like one specified here

Any ideas on this? Is there some alternative to JTextField/JPasswordField that is more suitable for this job?

Thanks!

Community
  • 1
  • 1
Simpson
  • 11
  • 1
  • Have you considered having the JPasswordField and then having a TextField underneath with the partially masked input? You could render the mask as part of an action listener, say a button that says (verify input) which then masks the input and displays it in the text field. – Kyte Jun 02 '14 at 14:05
  • 1
    Get the [JPasswordField source code](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/javax/swing/JPasswordField.java) and modify it to display as you wish. – Gilbert Le Blanc Jun 02 '14 at 14:43

0 Answers0