public class test extends JFrame
{
private JEditorPane rtfPane;
public test()
{
JPanel topPanel = new JPanel();
topPanel.setBackground(Color.lightGray);rtfPane = new JEditorPane("text/rtf","hello");
rtfPane.setEditable(true);
rtfPane.setText("hello");//《------------------这样不对吗?
JScrollPane scrollPane = new JScrollPane(rtfPane);
getContentPane().add(scrollPane, BorderLayout.CENTER);
Dimension screenSize = getToolkit().getScreenSize();
int width = screenSize.width * 8 / 10;
int height = screenSize.height * 8 / 10;
setBounds(width/8, height/8, width, height);
setVisible(true);
System.out.print(rtfPane.getText());
}public static void main(String args[])
{
new test();
}
}为什么最后什么都没有显示 rtfPane.getText() 为 null?????