Class PrintableArrayList

All Implemented Interfaces:
Printable, Serializable, Cloneable, Iterable, Collection, List, RandomAccess, SequencedCollection

public class PrintableArrayList extends ArrayList implements Printable
Implements the printable for the ArrayList. The item in the ArrayList will be printed line by line. The toString() for each item in the ArrayList will be called for the printing.
Author:
Dachywan Wu
See Also:
  • Constructor Details

    • PrintableArrayList

      public PrintableArrayList()
      Constructs an empty list with an initial capacity of ten.
    • PrintableArrayList

      public PrintableArrayList(Collection c)
      Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The ArrayList instance has an initial capacity of 110% the size of the specified collection.
      Parameters:
      c - the collection whose elements are to be placed into this list.
    • PrintableArrayList

      public PrintableArrayList(int initialCapacity)
      Constructs an empty list with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list.
  • Method Details

    • print

      public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException
      This method implements the Printable interface. Used exclusively for printing.
      Specified by:
      print in interface Printable
      Parameters:
      g - the graphics context.
      pf - the PageFormat for printing.
      pageIndex - the page index starting from 0.
      Returns:
      PAGE_EXISTS, or NO_SUCH_PAGE if printing failed.
      Throws:
      PrinterException
    • setPageHeader

      public void setPageHeader(String header)
      Set the printing page header for the array.
      Parameters:
      header - the header text.
    • getPageHeader

      public String getPageHeader()
      Get the page header.
      Returns:
      the page header.
    • setDesc

      public void setDesc(ArrayList al)
      Set the description for the array. Will be used in printing.
      Parameters:
      al - the description array. The toString() for each item will be called for printing the description area.
    • getDesc

      public ArrayList getDesc()
      Get the description ArrayList.
      Returns:
      the description array.
    • setFont

      public void setFont(Font font)
      Set the printing font.
      Parameters:
      font - the font for printing.
    • getFont

      public Font getFont()
      Get the printing font.
      Returns:
      the printing font.