JTextComponent: print(MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintService service, PrintRequestAttributeSet attributes, boolean interactive) : JTextComponent « javax.swing « Java by API






JTextComponent: print(MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintService service, PrintRequestAttributeSet attributes, boolean interactive)

  


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 Main {
  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);

  }
}

   
    
  








Related examples in the same category

1.JTextComponent.KeyBinding
2.JTextComponent: addCaretListener(CaretListener listener)
3.JTextComponent: getActions()
4.JTextComponent: getCaretPosition()
5.JTextComponent: getDocument()
6.JTextComponent: getHighlighter()
7.JTextComponent: getSelectedText()
8.JTextComponent: getText(int offs, int len)
9.JTextComponent: moveCaretPosition(int pos)
10.JTextComponent: read(Reader in, Object desc)
11.JTextComponent: replaceSelection(String content)
12.JTextComponent: select(int selectionStart, int selectionEnd)
13.JTextComponent: setDocument(Document doc)
14.JTextComponent: setDragEnabled(boolean b)
15.JTextComponent: setFocusAccelerator(char aKey)
16.JTextComponent: setNavigationFilter(NavigationFilter filter)
17.JTextComponent: setSelectedTextColor(Color c)
18.JTextComponent: setSelectionColor(Color c)
19.JTextComponent: setSelectionEnd(int selectionEnd)
20.JTextComponent: setSelectionStart(int selectionStart)
21.JTextComponent: write(Writer out)