Original Post
I have been looking for about 3 hours, it will come up with the print dialog but never prints, here is the code any help appreciated P.S. this is printing to a SLP240
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.print.*;
import java.awt.print.PageFormat;
import java.lang.String;
import java.io.*;
import java.util.*;
import java.applet.Applet;
import java.awt.GridLayout;
import java.awt.TextArea;
public class label extends JApplet implements Printable
{
String one = "";
String two = "";
public void init()
{
one=getParameter("one");
two=getParameter("two");
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(this);
boolean ok = job.printDialog();
if (ok) {
try {
job.print();
} catch (PrinterException ex) {
System.out.println("ERR");/* The job did not successfully complete */
}
}
}
public int print(Graphics g, PageFormat pf, int page) throws
PrinterException {
if (page > 0) { /* We have only one page, and 'page' is zero-based */
return NO_SUCH_PAGE;
}
/* User (0,0) is typically outside the imageable area, so we must
* translate by the X and Y values in the PageFormat to avoid clipping
*/
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
g.setColor(Color.decode("0x000000"));
/* Now we perform our rendering */
g.drawString(one, 2, 10);
g.drawString(two, 2, 50);
/* tell the caller that this page is part of the printed document */
return PAGE_EXISTS;
}
}