New Thing
hell guys This tutorial im going to show you how to make a print out from your printer in java like this
first you have to create class file PrintDemo.java in your platform then you can use it as a you needed
lets go on
import java.awt.Graphics;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
/**
*
* @author Admin
*/
public class PrintDemo implements Printable{
public PrintDemo() {
PrinterJob p = PrinterJob.getPrinterJob();
p.setPrintable(this);
if(p.printDialog()){
try{
p.print();
}catch(Exception e){}
}
}
public static void main(String[] arg){
PrintDemo pd = new PrintDemo();
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Enjoy it and leave a comment see you Guys from a next tutorial Bye
No comments:
Post a Comment