A qustion about the model of JTextArea
First please look at the following test code:
import javax.swing.*;
publicclass TextAreaModel{
private JTextArea area;
public TextAreaModel(){
area =new JTextArea();
if (area.getDocument() ==null){
System.out.println("area's model is null");
}else{
System.out.println(area.getDocument());
}
}
publicstaticvoid main(String[] args){
new TextAreaModel();
}
}
The output is javax.swing.text.PlainDocument@54172f or sth. like this
except the string after '@'. I just thought that it should output "area's
model is null".
I tried to analyse the code, but I got totally confused.
area = new JTextArea() invokesJTextArea(null, null, 0,0),
which causesJTextComponent() to be called.
JTextComponent() 's java doc says that this constructor will set
the document model tonull, but I set breakpoints to trace into the
excution and find that model becomes aPlainDocument instance
after the constructorJTextComponent(), and then the test code outputs the non-null model
object 's information.
Is there anyone that can tell me why the constructor
JTextComponent()'s behavior seems confliting with its java-doc?

