Olá pessoal peguei esse exemplo e gostaria de trabalhar nele porém eu não consegui acrescentar mais uma linha !
Gostaria de adicionar uma segunda linha com uma fonte diferente.
Obrigado
import javax.swing.*;
import java.awt.print.*;
import java.awt.*;
public class PrintExample {
public static void main(String[] args)
{
JFrame frame = new JFrame();
final JPanel panel = new JPanel();
JLabel label = new JLabel("É um exemplo de impressão");
// Adicionar uma segunda linha sem o uso do "\n"
label.setFont( new Font("Arial Narrow", Font.ITALIC, 10) );
// adicionar uma segunda fonte !!!!
frame.getContentPane().add(panel);
panel.add(label);
frame.pack();
frame.setVisible(false);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new Printable() {
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException
{
if (pageIndex >= 1) {
return Printable.NO_SUCH_PAGE;
} else {
((Graphics2D)graphics).translate(pageFormat.getImageableX(), pageFormat.getImageableY());
panel.print(graphics);
return Printable.PAGE_EXISTS;
}
}
});
try
{
job.print();
}
catch (PrinterException ex)
{
ex.printStackTrace();
}
System.exit(0);
}
}