multiple instances display the last text
Brought to you by:
marcel-boehme,
oliverhe
JEditTextArea jta1 = new JEditTextArea();
jta1.setText("xxxxxx");
JEdittextArea jta2 = new JEditTextArea();
jta2.setText("yyyyyy");
This causes even jta1 to display "yyyyyy"
Looks like there is a static reference in
JEditTextArea that I am not able to figure out
Please help
Logged In: YES
user_id=323100
Try
jta2.setDocument(new SyntaxDocument());
just after creating jta2.
The default's for JEditText area are to share the same
document amongst all instances.
Logged In: YES
user_id=570959
Yeah, that bummed me out for a while too, but setting a new
instance of a document seemed to do the trick (plus I
removed the word final from everywhere, but I think that was
not needed)
i.e.
setDocument(new org.syntax.jedit.SyntaxDocument());
Logged In: NO
I think this is a serious bug. Should be fixed soon!
Logged In: YES
user_id=597335
To use multiple instances with differents settings, you must
use your own implementation of TextAreaDefaults, not
DEFAULT.
Logged In: NO
To avoid this issue, you have to assign a new TokenMarker to the second instance.
jta2.setTokenMarker(new syntax.tokenmarker.TSQLTokenMarker());
Logged In: NO
The instance of the TextAreaDefaults.document is shared between all JEditTextArea's - hence the document content is shared. The document must be newly instantiated for each instance of the editor.