Print without a DialogTag(s): IO

JobAttributes  theJobAttribs  = new JobAttributes();
PageAttributes thePageAttribs = new PageAttributes();

theJobAttribs.setDialog(JobAttributes.DialogType.NONE);
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);
          g.dispose();
          }
      myJob.end();
      }



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2012
[ home ]