Example usage for javax.swing JTextArea print

List of usage examples for javax.swing JTextArea print

Introduction

In this page you can find the example usage for javax.swing JTextArea print.

Prototype

public boolean print(final MessageFormat headerFormat, final MessageFormat footerFormat,
        final boolean showPrintDialog, final PrintService service, final PrintRequestAttributeSet attributes,
        final boolean interactive) throws PrinterException 

Source Link

Document

Prints the content of this JTextComponent .

Usage

From source file:JDK6TextComponentDemo.java

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);//from   ww w .ja va  2  s  .c o m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setContentPane(contentPane);
    frame.setVisible(true);
    textArea.print(header, footer, true, null, null, true);

}