Hi have a requirement where on some condition I have to black out the swing component(Text Field) preserving its string value. ie the component should not show what string value it holds.
There is JPasswordField
, which is a text field that can be toggled to show ** (or some other echo character) instead of the actual content. That is probably the easiest way.
If that isn't good enough, you could pull the content and store it externally, blank or blot or whatever the field, and setEnabled(false)
on it. When you enable the field again, put the content back. If it's necessary to use getText()
in the meantime, you'll have to override that so you can substitute the stored content when appropriate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With