[java]代码库
import java.awt.BorderLayout;
import java.text.MessageFormat;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class JDK6TextComponentDemo {
public static void main (String[] args) throws Exception {
final JTextArea textArea = new JTextArea();
textArea.setText ("text");
JScrollPane jScrollPane = new JScrollPane (textArea);
final MessageFormat header = new MessageFormat ("My Header");
final MessageFormat footer = new MessageFormat ("My Footer");
JPanel contentPane = new JPanel();
contentPane.setLayout (new BorderLayout() );
contentPane.add (jScrollPane, BorderLayout.CENTER);
JFrame frame = new JFrame();
frame.setTitle ("Text-component Printing Demo");
frame.setSize (400, 200);
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.setContentPane (contentPane);
frame.setVisible (true);
textArea.print (header, footer, true, null, null, true);
}
}