Class PrintResult

java.lang.Object
com.codename1.printing.PrintResult

public final class PrintResult extends Object

Outcome of a print request initiated through Printer or Display.print(String, String, PrintResultListener).

Status semantics:

  • COMPLETED: the print flow finished and the job was handed to the printing system. Platforms generally can't observe the physical printer, so this means "queued/sent", not "paper came out".
  • CANCELLED: the user dismissed the print dialog without printing.
  • FAILED: the job could not be started or the printing system reported an error. getError() may carry a short, platform-supplied description.

Some platforms cannot distinguish cancellation from completion once the native dialog takes over; those report COMPLETED on a best-effort basis.

Instances are immutable. Construct through the static factories.

  • Field Details

    • STATUS_COMPLETED

      public static final int STATUS_COMPLETED
      The print job was handed to the platform printing system.
      See Also:
    • STATUS_CANCELLED

      public static final int STATUS_CANCELLED
      User dismissed/cancelled the print dialog.
      See Also:
    • STATUS_FAILED

      public static final int STATUS_FAILED
      The print job could not be completed.
      See Also:
  • Method Details

    • completed

      public static PrintResult completed()
      Build a COMPLETED result.
    • cancelled

      public static PrintResult cancelled()
      Build a CANCELLED result.
    • failed

      public static PrintResult failed(String message)
      Build a FAILED result with an optional platform message.
    • getStatus

      public int getStatus()
    • isCompleted

      public boolean isCompleted()
      True iff status == STATUS_COMPLETED.
    • isCancelled

      public boolean isCancelled()
      True iff status == STATUS_CANCELLED.
    • isFailed

      public boolean isFailed()
      True iff status == STATUS_FAILED.
    • getError

      public String getError()
      Platform-supplied message when isFailed() is true, otherwise null.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object