tags:

views:

74

answers:

2

Hi. Does anyone know if there is a JTextArea method that I can override to change what is displayed on screen?

I want to keep the contents of the field the same. Ie. If I set the text to "hello" and I call getText(), I wan't it to return "hello".

However, I wan't to be able to override what is displayed on screen (Eg. to replace with '*')

Yes I know JPasswordField does this, but I need to use a JTextArea, and also would like fine control over what is displayed.

Any ideas? Is there a display method that I can override? Many many thanks if you have!!!

+1  A: 

can-i-modify-a-java-swing-jtextarea-so-that-it-looks-like-a-jpasswordfield

You already got answers?

codedevour
Nah not really got a solution yet. There are a couple of pieces of advice such as following the way that JPasswordField overrides JTextField. This would involve creating an equivallent of SynthPasswordFieldUI and PasswordView to say the least, and doesn't look like a good solution.
Dave
A: 

Manipulating User Data at the Model Layer in Swing

SUMMARY: Most of the graphical user interfaces (GUIs) developed with the Java Swing toolkit accept user input and validate it. Swing is built on the principle of the separable model architecture, a version of Model-View-Controller design where all of the graphical components have corresponding data model objects.

Part 1: Model-View-Controller and Swing

Document doc  = new DefaultStyledDocument();    // MODEL object
JTextArea ta1 = new JTextArea(doc);             // VIEW object 1
JTextArea ta2 = new JTextArea(doc);             // VIEW object 1
adatapost
Thanks for this. But how does this actually help me change the text that is actually displayed on the screen for the JTextArea?
Dave