Sometimes, you wish to print some stuff from your Java application and don't want the print dialog to be displayed. The code below does exactly that.

Java Code:
JobAttributes  theJobAttribs  = new JobAttributes();
PageAttributes thePageAttribs = new PageAttributes();

theJobAttribs.setPrinter("HP DeskJet 610C"); // the printer to be used
PrintJob myJob = getToolkit().getPrintJob(this, "PrintJob",
  theJobAttribs, thePageAttribs);

  if (myJob != null) {
      Graphics g = myJob.getGraphics();

      if (g != null) {
          String s = myArea.getText(); // what you like to print
          printText(myJob, g, s);