Side of Software
Print Preview Library 1.8.1

sos.preview
Class PrintPreviewSupport

java.lang.Object
  |
  +--sos.preview.PrintPreviewSupport

public class PrintPreviewSupport
extends java.lang.Object

Support for a print preview pane in an application. With this class clients can create "standard" print preview windows or create custom print preview toolbars. The methods provide different levels of granularity to accommodate applications' varying needs.

For examples of using this class, see Side of Software's online tutorial.

The class offers two "standard" toolbars: Navigation and Zoom. These toolbars are commonly found across existing applications.

The navigation toolbar includes:

  • Print Button
  • Page Setup Button
  • First Page Button
  • Previous Page Button
  • Page Field
  • Next Page Button
  • Last Page Button
  • Close Button
  • To create a panel with a print preview pane and the navigation toolbar, invoke one of the static createNavigationPanel factory methods:

     static JPanel createNavigationPanel(Pageable pageable,boolean showPrintDialog,Action closeAction,boolean largeIcons)
     static JPanel createNavigationPanel(PageableFactory pageableFactory,int printFlavor,Action closeAction,boolean largeIcons)
     
    The zoom toolbar includes:

  • Print Button
  • Page Setup Button
  • Zoom Buttons
  • Zoom Combobox
  • Close Button
  • To create a panel with a print preview pane and the zoom toolbar, invoke one of the static createZoomPanel factory methods:

      static JPanel createZoomPanel(Pageable pageable,boolean showPrintDialog,int zoomFlavor,Action closeAction,boolean largeIcons)
      static JPanel createZoomPanel(PageableFactory pageableFactory,boolean showPrintDialog,int zoomFlavor, Action closeAction,boolean largeIcons)
     
    To build a custom toolbar, create an instance of PrintPreviewSupport and use the getXxx methods to get the parts needed for the toolbar. For example,

     JToolBar toolbar = new JToolBar();
     
     JPrintPreviewPane printPreviewPane = ...
     PrintPreviewSupport support = new PrintPreviewSupport( printPreviewPane, false );
    
     JComponent printButton = support.getPrintButton();
     toolbar.add( printButton );
    
     JComponent pageField = support.getPageField();
     toolbar.add( pageField );
     
    If you take this approach, you must also create a JPrintPreviewPane, insert it into a scroll pane, and add the scroll pane to the appropriate window. (The static factory methods do these steps for you.)

    Since:
    1.0
    See Also:
    JPrintPreviewPane

    Nested Class Summary
    protected  class PrintPreviewSupport.FirstPageAction
              Action that displays the first print preview page.
    protected  class PrintPreviewSupport.LastPageAction
              Action that displays the last print preview page.
    protected  class PrintPreviewSupport.NextPageAction
              Action that displays the next print preview page.
    static interface PrintPreviewSupport.PageableFactory
              A factory that can produce a Pageable object given a page format.
    protected  class PrintPreviewSupport.PageSetupAction
              Action that changes the page format.
    protected  class PrintPreviewSupport.PreviousPageAction
              Action that displays the previous print preview page.
    protected  class PrintPreviewSupport.PrintAction
              Action that shows the print dialog and prints the print preview pages.
    protected  class PrintPreviewSupport.PrintAllAction
              Action that prints the print preview pages without showing the print dialog.
    protected  class PrintPreviewSupport.ZoomInAction
              Action that zooms in on the print preview pages.
    protected  class PrintPreviewSupport.ZoomInToggleAction
              Action that toggles the print preview pane between zoom-in mode and selection mode.
    protected  class PrintPreviewSupport.ZoomOutAction
              Action that zooms out on the print preview pages.
    protected  class PrintPreviewSupport.ZoomOutToggleAction
              Action that toggles the print preview pane between zoom-out mode and selection mode.
    protected  class PrintPreviewSupport.ZoomToggleAction
              Action that toggles the print preview pane between zoom mode and selection mode.
     
    Field Summary
    static int ZOOM
              Constant that indicates the user is always in zoom mode, which allows both zooming in and zooming out.
    static int ZOOM_IN_OUT
              Constant that indicates the user can zoom in and out by clicking the appropriate toolbar buttons.
    static int ZOOM_IN_OUT_TOGGLE
              Constant that indicates the user can toggle between zoom in mode and zoom out mode.
    static int ZOOM_TOGGLE
              Constant that indicates the user can toggle between zoom mode and selection mode, where the zoom mode allows both zooming in and zooming out.
     
    Constructor Summary
    PrintPreviewSupport(JPrintPreviewPane printPreviewPane, boolean largeIcons)
              Creates print preview support for the specified print preview pane.
     
    Method Summary
    protected  javax.swing.JButton createButton(javax.swing.Action action)
              Returns a freshly created button for the specified action.
    protected  javax.swing.Action createFirstPageAction()
              Creates and returns an action that displays the first print preview page.
    protected  javax.swing.Action createLastPageAction()
              Creates and returns an action that displays the last print preview page.
    static javax.swing.JPanel createNavigationPanel(java.awt.print.Pageable pageable, boolean showPrintDialog, javax.swing.Action closeAction, boolean largeIcons)
              Creates and returns a component with a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, and close print preview.
    static javax.swing.JPanel createNavigationPanel(PrintPreviewSupport.PageableFactory pageableFactory, boolean showPrintDialog, javax.swing.Action closeAction, boolean largeIcons)
              Creates and returns a component with a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, adjust the page setup, and close print preview.
    protected  javax.swing.Action createNextPageAction()
              Creates and returns an action that displays the next print preview page.
    protected  javax.swing.JFormattedTextField createPageField()
              Creates and returns a formatted text field that mirrors the index of the currently displayed page.
    protected  javax.swing.Action createPageSetupAction(PrintPreviewSupport.PageableFactory factory)
              Creates and returns an action that changes the page format.
    protected  javax.swing.Action createPreviousPageAction()
              Creates and returns an action that displays the previous print preview page.
    protected  javax.swing.Action createPrintAction()
              Creates and returns an action that brings up the print dialog and prints the print preview pages.
    protected  javax.swing.Action createPrintAllAction()
              Creates and returns an action that prints the print preview pages without bringing up the print dialog.
    protected  javax.swing.JToggleButton createToggleButton(javax.swing.Action action)
              Creates and returns a toggle button with the specified action.
    protected  javax.swing.JComboBox createZoomComboBox(boolean editable, boolean showSpecialLayouts)
              Creates and returns a combobox that allows the user to change the page layout.
    protected  javax.swing.Action createZoomInAction()
              Creates and returns an action that zooms in on the print preview pages.
    protected  javax.swing.Action createZoomInToggleAction()
              Creates and returns an action that switches between zoom-in mode and selection mode.
    protected  javax.swing.Action createZoomOutAction()
              Creates and returns an action that zooms out on the print preview pages.
    protected  javax.swing.Action createZoomOutToggleAction()
              Creates and returns an action that switches between zoom-out mode and selection mode.
    static javax.swing.JPanel createZoomPanel(java.awt.print.Pageable pageable, boolean showPrintDialog, int zoomFlavor, javax.swing.Action closeAction, boolean largeIcons)
              Creates and returns a component with a print preview pane and a toolbar that allows the user to zoom in and out of the pages, print the pages, and close print preview.
    static javax.swing.JPanel createZoomPanel(PrintPreviewSupport.PageableFactory pageableFactory, boolean showPrintDialog, int zoomFlavor, javax.swing.Action closeAction, boolean largeIcons)
              Creates and returns a component with a print preview pane and a toolbar that allows the user to zoom in and out of the pages, print the pages, adjust the page setup, and close print preview.
    protected  javax.swing.Action createZoomToggleAction()
              Creates and returns an action that switches between zoom mode and selection mode.
     javax.swing.JButton getCloseButton(javax.swing.Action closeAction)
              Returns the button that closes print preview.
     int getCloseMnemonic()
              Returns the mnemonic associated with the action that closes print preview.
     java.lang.String getCloseText()
              Returns the text associated with the action that closes print preview.
     java.lang.String getCloseToolTip()
              Returns the description associated with the action that closes print preview.
     javax.swing.Action getFirstPageAction()
              Returns the action that displays the first print preview page.
     javax.swing.JButton getFirstPageButton()
              Returns the button that displays the first print preview page.
     javax.swing.Icon getFirstPageIcon()
              Returns the icon associated with the action that displays the first print preview page.
     int getFirstPageMnemonic()
              Returns the mnemonic associated with the action that displays the first print preview page.
     java.lang.String getFirstPageText()
              Returns the text associated with the action that displays the first print preview page.
     java.lang.String getFirstPageToolTip()
              Returns the description associated with the action that displays the first print preview page.
     boolean getLargeIconsAreUsed()
              Returns true if this PrintPreviewSupport uses large icons in the print preview toolbar.
     javax.swing.Action getLastPageAction()
              Returns the action that displays the last print preview page.
     javax.swing.JButton getLastPageButton()
              Returns the button that displays the last print preview page.
     javax.swing.Icon getLastPageIcon()
              Returns the icon associated with the action that displays the last print preview page.
     int getLastPageMnemonic()
              Returns the mnemonic associated with the action that displays the last print preview page.
     java.lang.String getLastPageText()
              Returns the text associated with the action that displays the last print preview page.
     java.lang.String getLastPageToolTip()
              Returns the description associated with the action that displays the last print preview page.
     javax.swing.Action getNextPageAction()
              Returns the action that displays the next print preview page.
     javax.swing.JButton getNextPageButton()
              Returns the button that displays the next print preview page.
     javax.swing.Icon getNextPageIcon()
              Returns the icon associated with the action that displays the next print preview page.
     int getNextPageMnemonic()
              Returns the mnemonic associated with the action that displays the next print preview page.
     java.lang.String getNextPageText()
              Returns the text associated with the action that displays the next print preview page.
     java.lang.String getNextPageToolTip()
              Returns the description associated with the action that displays the next print preview page.
     javax.swing.JFormattedTextField getPageField()
              Returns the formatted text field that diplays and changes the current page.
     java.lang.String getPageFieldToolTip()
              Returns the description associated with the page field.
     javax.swing.Action getPageSetupAction(PrintPreviewSupport.PageableFactory factory)
              Returns the action that changes the page format using the specified factory.
     javax.swing.JButton getPageSetupButton(PrintPreviewSupport.PageableFactory factory)
              Returns the button that changes the page format given the specified factory.
     javax.swing.Icon getPageSetupIcon()
              Returns the icon associated with the action that changes the page setup.
     int getPageSetupMnemonic()
              Returns the mnemonic associated with the action that changes the page setup.
     java.lang.String getPageSetupText()
              Returns the text associated with the action that changes the page setup.
     java.lang.String getPageSetupToolTip()
              Returns the description associated with the action that changes the page setup.
     javax.swing.Action getPreviousPageAction()
              Returns the action that displays the previous print preview page.
     javax.swing.JButton getPreviousPageButton()
              Returns the button that displays the previous print preview page.
     javax.swing.Icon getPreviousPageIcon()
              Returns the icon associated with the action that displays the previous print preview page.
     int getPreviousPageMnemonic()
              Returns the mnemonic associated with the action that displays the previous print preview page.
     java.lang.String getPreviousPageText()
              Returns the text associated with the action that displays the previous print preview page.
     java.lang.String getPreviousPageToolTip()
              Returns the description associated with the action that displays the previous print preview page.
     javax.swing.Action getPrintAction()
              Returns the action that prints pages after displaying the print dialog.
     javax.swing.Action getPrintAllAction()
              Returns the action that prints all pages.
     javax.swing.JButton getPrintAllButton()
              Returns the button that prints all pages without showing the print dialog.
     javax.swing.Icon getPrintAllIcon()
              Returns the icon associated with the action that prints all print preview pages.
     int getPrintAllMnemonic()
              Returns the mnemonic associated with the action that prints all pages.
     java.lang.String getPrintAllText()
              Returns the text associated with the action that prints all pages.
     java.lang.String getPrintAllToolTip()
              Returns the description associated with the action that prints all pages.
     javax.swing.JButton getPrintButton()
              Returns the button that prints pages after displaying the print dialog.
     javax.swing.Icon getPrintIcon()
              Returns the icon associated with the action that prints print preview pages after displaying the print dialog.
     int getPrintMnemonic()
              Returns the mnemonic associated with the action that prints pages after displaying the print dialog.
     JPrintPreviewPane getPrintPreviewPane()
              Returns the print preview pane associated with this PrintPreviewSupport.
     java.lang.String getPrintText()
              Returns the text associated with the action that prints pages after displaying the print dialog.
     java.lang.String getPrintToolTip()
              Returns the description associated with the action that prints pages after displaying the print dialog.
     java.util.List getSpecialLayouts()
              Returns a list of java.awt.LayoutManagers that arrange print preview pages in a "special" way and should be included in the zoom combobox.
     javax.swing.JComboBox getZoomComboBox(boolean editable, boolean showSpecialLayouts)
              Returns the combobox that allows the user to change the page layouts.
     java.lang.String getZoomComboBoxToolTipText()
              Returns the description associated with the combobox that controls the page layout.
     javax.swing.Action getZoomInAction()
              Returns the action that zooms in.
     javax.swing.JButton getZoomInButton()
              Returns the button that zooms in when clicked.
     javax.swing.Icon getZoomInIcon()
              Returns the icon associated with the action that zooms in.
     int getZoomInMnemonic()
              Returns the mnemonic associated with the action that zooms in.
     java.lang.String getZoomInText()
              Returns the text associated with the action that zooms in.
     javax.swing.Action getZoomInToggleAction()
              Returns the action that toggles between zoom-in mode and selection mode.
     javax.swing.JToggleButton getZoomInToggleButton()
              Returns the button that toggles between zoom-in mode and selection mode.
     javax.swing.Icon getZoomInToggleIcon()
              Returns the icon associated with the action that toggles between zoom-in mode and selection mode.
     int getZoomInToggleMnemonic()
              Returns the mnemonic associated with the action that toggles between zoom-in mode and selection mode.
     java.lang.String getZoomInToggleText()
              Returns the text associated with the action that toggles between zoom-in mode and selection mode.
     java.lang.String getZoomInToggleToolTip()
              Returns the description associated with the action that toggles between zoom-in mode and selection mode.
     java.lang.String getZoomInToolTip()
              Returns the description associated with the action that zooms in.
     java.util.List getZoomLayouts()
              Returns a list of java.awt.LayoutManagers that zoom the print preview pages and should be included in the zoom combobox.
     javax.swing.Action getZoomOutAction()
              Returns the action that zooms out.
     javax.swing.JButton getZoomOutButton()
              Returns the button that zooms out when clicked.
     javax.swing.Icon getZoomOutIcon()
              Returns the icon associated with the action that zooms out.
     int getZoomOutMnemonic()
              Returns the mnemonic associated with the action that zooms out.
     java.lang.String getZoomOutText()
              Returns the text associated with the action that zooms out.
     javax.swing.Action getZoomOutToggleAction()
              Returns the action that toggles between zoom-out mode and selection mode.
     javax.swing.JToggleButton getZoomOutToggleButton()
              Returns the button that toggles between zoom-out mode and selection mode.
     javax.swing.Icon getZoomOutToggleIcon()
              Returns the icon associated with the action that toggles between zoom-out mode and selection mode.
     int getZoomOutToggleMnemonic()
              Returns the mnemonic associated with the action that toggles between zoom-out mode and selection mode.
     java.lang.String getZoomOutToggleText()
              Returns the text associated with the action that toggles between zoom-out mode and selection mode.
     java.lang.String getZoomOutToggleToolTip()
              Returns the description associated with the action that toggles between zoom-out mode and selection mode.
     java.lang.String getZoomOutToolTip()
              Returns the description associated with the action that zooms out.
     javax.swing.Action getZoomToggleAction()
              Returns the action that toggles between zoom mode and selection mode.
     javax.swing.JToggleButton getZoomToggleButton()
              Returns the button that toggles between zoom mode and selection mode.
     javax.swing.Icon getZoomToggleIcon()
              Returns the icon associated with the action that toggles between zoom mode and selection mode.
     int getZoomToggleMnemonic()
              Returns the mnemonic associated with the action that toggles between zoom mode and selection mode.
     java.lang.String getZoomToggleText()
              Returns the text associated with the action that toggles between zoom mode and selection mode.
     java.lang.String getZoomToggleToolTip()
              Returns the description associated with the action that toggles between zoom mode and selection mode.
    protected  void handlePrinterException(java.awt.print.PrinterException printerException)
              Responds to a printing error.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    ZOOM

    public static final int ZOOM
    Constant that indicates the user is always in zoom mode, which allows both zooming in and zooming out.

    See Also:
    Constant Field Values

    ZOOM_IN_OUT

    public static final int ZOOM_IN_OUT
    Constant that indicates the user can zoom in and out by clicking the appropriate toolbar buttons.

    See Also:
    Constant Field Values

    ZOOM_IN_OUT_TOGGLE

    public static final int ZOOM_IN_OUT_TOGGLE
    Constant that indicates the user can toggle between zoom in mode and zoom out mode.

    See Also:
    Constant Field Values

    ZOOM_TOGGLE

    public static final int ZOOM_TOGGLE
    Constant that indicates the user can toggle between zoom mode and selection mode, where the zoom mode allows both zooming in and zooming out.

    See Also:
    Constant Field Values
    Constructor Detail

    PrintPreviewSupport

    public PrintPreviewSupport(JPrintPreviewPane printPreviewPane,
                               boolean largeIcons)
    Creates print preview support for the specified print preview pane.

    Parameters:
    printPreviewPane - print preview pane for which support is desired
    largeIcons - true if this object should use buttons with large icons
    Method Detail

    createButton

    protected javax.swing.JButton createButton(javax.swing.Action action)
    Returns a freshly created button for the specified action. This is a hook method. Subclasses may override it to create a button other than JButton.

    Parameters:
    action - action describing the button
    Returns:
    a button component for the specified action
    See Also:
    createToggleButton(javax.swing.Action)

    createFirstPageAction

    protected javax.swing.Action createFirstPageAction()
    Creates and returns an action that displays the first print preview page. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that displays the first print preview page

    createLastPageAction

    protected javax.swing.Action createLastPageAction()
    Creates and returns an action that displays the last print preview page. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that displays the last print preview page

    createNextPageAction

    protected javax.swing.Action createNextPageAction()
    Creates and returns an action that displays the next print preview page. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that displays the next print preview page

    createPageField

    protected javax.swing.JFormattedTextField createPageField()
    Creates and returns a formatted text field that mirrors the index of the currently displayed page. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    a text field that shows and sets the index of the currently displayed page

    createPageSetupAction

    protected javax.swing.Action createPageSetupAction(PrintPreviewSupport.PageableFactory factory)
    Creates and returns an action that changes the page format. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that changes the page format

    createNavigationPanel

    public static javax.swing.JPanel createNavigationPanel(PrintPreviewSupport.PageableFactory pageableFactory,
                                                           boolean showPrintDialog,
                                                           javax.swing.Action closeAction,
                                                           boolean largeIcons)
                                                    throws java.lang.NullPointerException
    Creates and returns a component with a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, adjust the page setup, and close print preview.

    Parameters:
    pageableFactory - factory that will return the pages to be printed given the page format (cannot be null)
    showPrintDialog - true if the print button should bring up the print dialog; false if the print button should print all pages directly
    closeAction - action to take when the close button is clicked or when printing has finished
    largeIcons - true if large icons should be used in the toolbar
    Returns:
    a component that includes a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, adjust the page setup, and close print preview.

    Throws:
    java.lang.NullPointerException - if pageableFactory is null
    See Also:
    createNavigationPanel(Pageable,boolean,Action,boolean)

    createNavigationPanel

    public static javax.swing.JPanel createNavigationPanel(java.awt.print.Pageable pageable,
                                                           boolean showPrintDialog,
                                                           javax.swing.Action closeAction,
                                                           boolean largeIcons)
    Creates and returns a component with a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, and close print preview.

    Parameters:
    pageable - pages to be printed (cannot be null)
    showPrintDialog - true if the print button should bring up the print dialog; false if the print button should print all pages directly
    closeAction - action to take when the close button is clicked or when printing has finished
    largeIcons - true if large icons should be used in the toolbar
    Returns:
    a component that includes a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, and close print preview.

    Throws:
    java.lang.NullPointerException - if pageable is null
    See Also:
    createNavigationPanel(PrintPreviewSupport.PageableFactory,boolean,Action,boolean)

    createPreviousPageAction

    protected javax.swing.Action createPreviousPageAction()
    Creates and returns an action that displays the previous print preview page. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that displays the previous print preview page

    createPrintAction

    protected javax.swing.Action createPrintAction()
    Creates and returns an action that brings up the print dialog and prints the print preview pages. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that prints the print preview pages by way of the print dialog
    See Also:
    createPrintAllAction()

    createPrintAllAction

    protected javax.swing.Action createPrintAllAction()
    Creates and returns an action that prints the print preview pages without bringing up the print dialog. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that prints the print preview pages by way of the print dialog
    See Also:
    createPrintAction()

    createToggleButton

    protected javax.swing.JToggleButton createToggleButton(javax.swing.Action action)
    Creates and returns a toggle button with the specified action. This is a hook method that subclasses can create a toggle button other than JToggleButton.

    Parameters:
    action - action of the new toggle button
    Returns:
    a toggle button with the specified action
    See Also:
    createButton(javax.swing.Action)

    createZoomPanel

    public static javax.swing.JPanel createZoomPanel(PrintPreviewSupport.PageableFactory pageableFactory,
                                                     boolean showPrintDialog,
                                                     int zoomFlavor,
                                                     javax.swing.Action closeAction,
                                                     boolean largeIcons)
                                              throws java.lang.IllegalArgumentException,
                                                     java.lang.NullPointerException
    Creates and returns a component with a print preview pane and a toolbar that allows the user to zoom in and out of the pages, print the pages, adjust the page setup, and close print preview.

    Parameters:
    pageableFactory -
    showPrintDialog - true if the print button should bring up the print dialog; false if the print button should print all pages directly
    zoomFlavor - the type of zooming desired. Acceptable values are ZOOM_FLAVOR_IN_OUT_BUTTONS, ZOOM_FLAVOR_IN_OUT_MODES, and ZOOM_FLAVOR_SINGLE_MODE.
    closeAction - action to take when the close button is clicked or when printing has finished
    largeIcons - true if large icons should be used in the toolbar
    Returns:
    a component that includes a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, adjust the page setup, and close print preview.

    Throws:
    java.lang.IllegalArgumentException - if zoomFlavor is not one of ZOOM_FLAVOR_IN_OUT_BUTTONS, ZOOM_FLAVOR_IN_OUT_MODES, or ZOOM_FLAVOR_SINGLE_MODE
    java.lang.NullPointerException - if pageableFactory is null
    See Also:
    createZoomPanel(Pageable,boolean,int,Action,boolean)

    createZoomPanel

    public static javax.swing.JPanel createZoomPanel(java.awt.print.Pageable pageable,
                                                     boolean showPrintDialog,
                                                     int zoomFlavor,
                                                     javax.swing.Action closeAction,
                                                     boolean largeIcons)
                                              throws java.lang.IllegalArgumentException,
                                                     java.lang.NullPointerException
    Creates and returns a component with a print preview pane and a toolbar that allows the user to zoom in and out of the pages, print the pages, and close print preview.

    Parameters:
    pageable - pages to be printed (cannot be null)
    showPrintDialog - true if the print button should bring up the print dialog; false if the print button should print all pages directly
    zoomFlavor - the type of zooming desired. Acceptable values are ZOOM_FLAVOR_IN_OUT_BUTTONS, ZOOM_FLAVOR_IN_OUT_MODES, and ZOOM_FLAVOR_SINGLE_MODE.
    closeAction - action to take when the close button is clicked or when printing has finished
    largeIcons - true if large icons should be used in the toolbar
    Returns:
    a component that includes a print preview pane and a toolbar that allows the user to step through pages one at a time, print the pages, and close print preview.

    Throws:
    java.lang.IllegalArgumentException - if zoomFlavor is not one of ZOOM_FLAVOR_IN_OUT_BUTTONS, ZOOM_FLAVOR_IN_OUT_MODES, or ZOOM_FLAVOR_SINGLE_MODE
    java.lang.NullPointerException - if pageable is null
    See Also:
    createZoomPanel(PrintPreviewSupport.PageableFactory,boolean,int,Action,boolean)

    createZoomComboBox

    protected javax.swing.JComboBox createZoomComboBox(boolean editable,
                                                       boolean showSpecialLayouts)
    Creates and returns a combobox that allows the user to change the page layout.

    Parameters:
    editable - true if the combobox should allow the user to type in a page layout
    showSpecialLayouts - true if the combobox should include "special" page layouts such as Fit All or Fit Width
    Returns:
    a combobox that allows the user to change the page layout

    createZoomInAction

    protected javax.swing.Action createZoomInAction()
    Creates and returns an action that zooms in on the print preview pages. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that zooms in on the print preview pages
    See Also:
    createZoomOutAction()

    createZoomInToggleAction

    protected javax.swing.Action createZoomInToggleAction()
    Creates and returns an action that switches between zoom-in mode and selection mode. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that switches between zoom-in mode and selection mode
    See Also:
    createZoomOutToggleAction()

    createZoomOutAction

    protected javax.swing.Action createZoomOutAction()
    Creates and returns an action that zooms out on the print preview pages. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that zooms out on the print preview pages
    See Also:
    createZoomInAction()

    createZoomOutToggleAction

    protected javax.swing.Action createZoomOutToggleAction()
    Creates and returns an action that switches between zoom-out mode and selection mode. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that switches between zoom-out mode and selection mode
    See Also:
    createZoomInToggleAction()

    createZoomToggleAction

    protected javax.swing.Action createZoomToggleAction()
    Creates and returns an action that switches between zoom mode and selection mode. This is a hook method that subclasses can override to change the default behavior.

    Returns:
    an action that switches between zoom mode and selection mode

    getCloseButton

    public javax.swing.JButton getCloseButton(javax.swing.Action closeAction)
    Returns the button that closes print preview. The first call to this method will create a new button based on the specified action; subsequent calls will return the same button, regardless of the action.

    If the action does not contain a name, mnemonic key, or short description, this method will provide default values.

    Parameters:
    closeAction - action describing the desired close button
    Returns:
    the print preview close button
    Throws:
    java.lang.NullPointerException - if closeAction is null

    getCloseMnemonic

    public int getCloseMnemonic()
    Returns the mnemonic associated with the action that closes print preview.

    Returns:
    the mnemonic associated with the "close" action

    getCloseText

    public java.lang.String getCloseText()
    Returns the text associated with the action that closes print preview.

    Returns:
    the text associated with the "close" action

    getCloseToolTip

    public java.lang.String getCloseToolTip()
    Returns the description associated with the action that closes print preview.

    Returns:
    the description associated with the "close" action

    getFirstPageAction

    public javax.swing.Action getFirstPageAction()
    Returns the action that displays the first print preview page.

    Returns:
    the action that displays the first print preview page

    getFirstPageButton

    public javax.swing.JButton getFirstPageButton()
    Returns the button that displays the first print preview page.

    Returns:
    the print preview "first page" button

    getFirstPageIcon

    public javax.swing.Icon getFirstPageIcon()
    Returns the icon associated with the action that displays the first print preview page.

    Returns:
    the icon associated with the "first page" action

    getFirstPageMnemonic

    public int getFirstPageMnemonic()
    Returns the mnemonic associated with the action that displays the first print preview page.

    Returns:
    the mnemonic associated with the "first page" action

    getFirstPageText

    public java.lang.String getFirstPageText()
    Returns the text associated with the action that displays the first print preview page.

    Returns:
    the text associated with the "first page" action

    getFirstPageToolTip

    public java.lang.String getFirstPageToolTip()
    Returns the description associated with the action that displays the first print preview page.

    Returns:
    the description associated with the "first page" action

    getLargeIconsAreUsed

    public boolean getLargeIconsAreUsed()
    Returns true if this PrintPreviewSupport uses large icons in the print preview toolbar.

    Returns:
    true if this PrintPreviewSupport uses large icons in the print preview toolbar
    See Also:
    PrintPreviewSupport(JPrintPreviewPane,boolean)

    getLastPageAction

    public javax.swing.Action getLastPageAction()
    Returns the action that displays the last print preview page.

    Returns:
    the action that displays the last print preview page

    getLastPageButton

    public javax.swing.JButton getLastPageButton()
    Returns the button that displays the last print preview page.

    Returns:
    the print preview "last page" button

    getLastPageIcon

    public javax.swing.Icon getLastPageIcon()
    Returns the icon associated with the action that displays the last print preview page.

    Returns:
    the icon associated with the "last page" action

    getLastPageMnemonic

    public int getLastPageMnemonic()
    Returns the mnemonic associated with the action that displays the last print preview page.

    Returns:
    the mnemonic associated with the "last page" action

    getLastPageText

    public java.lang.String getLastPageText()
    Returns the text associated with the action that displays the last print preview page.

    Returns:
    the text associated with the "last page" action

    getLastPageToolTip

    public java.lang.String getLastPageToolTip()
    Returns the description associated with the action that displays the last print preview page.

    Returns:
    the description associated with the "last page" action

    getNextPageAction

    public javax.swing.Action getNextPageAction()
    Returns the action that displays the next print preview page.

    Returns:
    the action that displays the next print preview page

    getNextPageButton

    public javax.swing.JButton getNextPageButton()
    Returns the button that displays the next print preview page.

    Returns:
    the print preview "next page" button

    getNextPageIcon

    public javax.swing.Icon getNextPageIcon()
    Returns the icon associated with the action that displays the next print preview page.

    Returns:
    the icon associated with the "next page" action

    getNextPageMnemonic

    public int getNextPageMnemonic()
    Returns the mnemonic associated with the action that displays the next print preview page.

    Returns:
    the mnemonic associated with the "next page" action

    getNextPageText

    public java.lang.String getNextPageText()
    Returns the text associated with the action that displays the next print preview page.

    Returns:
    the text associated with the "next page" action

    getNextPageToolTip

    public java.lang.String getNextPageToolTip()
    Returns the description associated with the action that displays the next print preview page.

    Returns:
    the description associated with the "next page" action

    getPageField

    public javax.swing.JFormattedTextField getPageField()
    Returns the formatted text field that diplays and changes the current page.

    Returns:
    the formatted text field that displays and changes the current page

    getPageFieldToolTip

    public java.lang.String getPageFieldToolTip()
    Returns the description associated with the page field.

    Returns:
    the description associated with the page field

    getPageSetupAction

    public javax.swing.Action getPageSetupAction(PrintPreviewSupport.PageableFactory factory)
    Returns the action that changes the page format using the specified factory. Subsequent calls to this method ignore factory and return the original action.

    Parameters:
    factory - an object that geneates a Pageable object given a page format
    Returns:
    the action that changes the page format

    getPageSetupButton

    public javax.swing.JButton getPageSetupButton(PrintPreviewSupport.PageableFactory factory)
    Returns the button that changes the page format given the specified factory. Subsequent calls to this method ignore factory and return the original button.

    Returns:
    the print preview "page setup" button

    getPageSetupIcon

    public javax.swing.Icon getPageSetupIcon()
    Returns the icon associated with the action that changes the page setup.

    Returns:
    the icon associated with the "page setup" action

    getPageSetupMnemonic

    public int getPageSetupMnemonic()
    Returns the mnemonic associated with the action that changes the page setup.

    Returns:
    the mnemonic associated with the "page setup" action

    getPageSetupText

    public java.lang.String getPageSetupText()
    Returns the text associated with the action that changes the page setup.

    Returns:
    the text associated with the "page setup" action

    getPageSetupToolTip

    public java.lang.String getPageSetupToolTip()
    Returns the description associated with the action that changes the page setup.

    Returns:
    the description associated with the "page setup" action

    getPreviousPageAction

    public javax.swing.Action getPreviousPageAction()
    Returns the action that displays the previous print preview page.

    Returns:
    the action that displays the previous print preview page

    getPreviousPageButton

    public javax.swing.JButton getPreviousPageButton()
    Returns the button that displays the previous print preview page.

    Returns:
    the print preview "previous page" button

    getPreviousPageIcon

    public javax.swing.Icon getPreviousPageIcon()
    Returns the icon associated with the action that displays the previous print preview page.

    Returns:
    the icon associated with the "previous page" action

    getPreviousPageMnemonic

    public int getPreviousPageMnemonic()
    Returns the mnemonic associated with the action that displays the previous print preview page.

    Returns:
    the mnemonic associated with the "previous page" action

    getPreviousPageText

    public java.lang.String getPreviousPageText()
    Returns the text associated with the action that displays the previous print preview page.

    Returns:
    the text associated with the "previous page" action

    getPreviousPageToolTip

    public java.lang.String getPreviousPageToolTip()
    Returns the description associated with the action that displays the previous print preview page.

    Returns:
    the description associated with the "previous page" action

    getPrintPreviewPane

    public JPrintPreviewPane getPrintPreviewPane()
    Returns the print preview pane associated with this PrintPreviewSupport.

    Returns:
    the print preview pane associated with this PrintPreviewSupport

    getPrintAction

    public javax.swing.Action getPrintAction()
    Returns the action that prints pages after displaying the print dialog.

    Returns:
    the action that prints pages after displaying the print dialog

    getPrintButton

    public javax.swing.JButton getPrintButton()
    Returns the button that prints pages after displaying the print dialog.

    Returns:
    the print preview "print" button

    getPrintAllAction

    public javax.swing.Action getPrintAllAction()
    Returns the action that prints all pages.

    Returns:
    the action that prints all pages

    getPrintAllButton

    public javax.swing.JButton getPrintAllButton()
    Returns the button that prints all pages without showing the print dialog.

    Returns:
    the print preview "print all" button

    getPrintAllIcon

    public javax.swing.Icon getPrintAllIcon()
    Returns the icon associated with the action that prints all print preview pages.

    Returns:
    the icon associated with the "print all" action

    getPrintAllMnemonic

    public int getPrintAllMnemonic()
    Returns the mnemonic associated with the action that prints all pages.

    Returns:
    the mnemonic associated with the "print all" action

    getPrintAllText

    public java.lang.String getPrintAllText()
    Returns the text associated with the action that prints all pages.

    Returns:
    the text associated with the "print all" action

    getPrintAllToolTip

    public java.lang.String getPrintAllToolTip()
    Returns the description associated with the action that prints all pages.

    Returns:
    the description associated with the "print all" action

    getPrintIcon

    public javax.swing.Icon getPrintIcon()
    Returns the icon associated with the action that prints print preview pages after displaying the print dialog.

    Returns:
    the icon associated with the "print" action

    getPrintMnemonic

    public int getPrintMnemonic()
    Returns the mnemonic associated with the action that prints pages after displaying the print dialog.

    Returns:
    the mnemonic associated with the "print" action

    getPrintText

    public java.lang.String getPrintText()
    Returns the text associated with the action that prints pages after displaying the print dialog.

    Returns:
    the text associated with the "print" action

    getPrintToolTip

    public java.lang.String getPrintToolTip()
    Returns the description associated with the action that prints pages after displaying the print dialog.

    Returns:
    the description associated with the "print" action

    getSpecialLayouts

    public java.util.List getSpecialLayouts()
    Returns a list of java.awt.LayoutManagers that arrange print preview pages in a "special" way and should be included in the zoom combobox. This may include layout managers that fit all pages within the screen, show one page per screen, etc. The ordered of the returned list determines the order they appear in the zoom combobox.

    Returns:
    a list of standard "special" layout managers
    See Also:
    getZoomLayouts(), getZoomComboBox(boolean, boolean)

    getZoomComboBox

    public javax.swing.JComboBox getZoomComboBox(boolean editable,
                                                 boolean showSpecialLayouts)
    Returns the combobox that allows the user to change the page layouts.

    Parameters:
    editable - true if the combobox should allow the user to type in layouts
    showSpecialLayouts - true to include "special" layouts like "Fit All"
    Returns:
    the combobox that controls the page layout

    getZoomComboBoxToolTipText

    public java.lang.String getZoomComboBoxToolTipText()
    Returns the description associated with the combobox that controls the page layout.

    Returns:
    the description associated with the "zoom" combobox

    getZoomInAction

    public javax.swing.Action getZoomInAction()
    Returns the action that zooms in.

    Returns:
    the action that zooms in

    getZoomInButton

    public javax.swing.JButton getZoomInButton()
    Returns the button that zooms in when clicked.

    Returns:
    the print preview "zoom in" button

    getZoomInIcon

    public javax.swing.Icon getZoomInIcon()
    Returns the icon associated with the action that zooms in.

    Returns:
    the icon associated with the "zoom in" action

    getZoomInMnemonic

    public int getZoomInMnemonic()
    Returns the mnemonic associated with the action that zooms in.

    Returns:
    the mnemonic associated with the "zoom in" action

    getZoomInText

    public java.lang.String getZoomInText()
    Returns the text associated with the action that zooms in.

    Returns:
    the text associated with the "zoom in" action

    getZoomInToolTip

    public java.lang.String getZoomInToolTip()
    Returns the description associated with the action that zooms in.

    Returns:
    the description associated with the "zoom in" action

    getZoomInToggleAction

    public javax.swing.Action getZoomInToggleAction()
    Returns the action that toggles between zoom-in mode and selection mode.

    Returns:
    the action that toggles between zoom-in mode and selection mode

    getZoomInToggleButton

    public javax.swing.JToggleButton getZoomInToggleButton()
    Returns the button that toggles between zoom-in mode and selection mode.

    Returns:
    the print preview "zoom in" toggle button

    getZoomInToggleIcon

    public javax.swing.Icon getZoomInToggleIcon()
    Returns the icon associated with the action that toggles between zoom-in mode and selection mode.

    Returns:
    the icon associated with the "zoom in toggle" action

    getZoomInToggleMnemonic

    public int getZoomInToggleMnemonic()
    Returns the mnemonic associated with the action that toggles between zoom-in mode and selection mode.

    Returns:
    the mnemonic associated with the "zoom in toggle" action

    getZoomInToggleText

    public java.lang.String getZoomInToggleText()
    Returns the text associated with the action that toggles between zoom-in mode and selection mode.

    Returns:
    the text associated with the "zoom in toggle" action

    getZoomInToggleToolTip

    public java.lang.String getZoomInToggleToolTip()
    Returns the description associated with the action that toggles between zoom-in mode and selection mode.

    Returns:
    the description associated with the "zoom in toggle" action

    getZoomLayouts

    public java.util.List getZoomLayouts()
    Returns a list of java.awt.LayoutManagers that zoom the print preview pages and should be included in the zoom combobox. The ordered of the returned list determines the order they appear in the zoom combobox.

    Returns:
    a list of standard "zoom" layout managers
    See Also:
    getSpecialLayouts(), getZoomComboBox(boolean, boolean)

    getZoomOutAction

    public javax.swing.Action getZoomOutAction()
    Returns the action that zooms out.

    Returns:
    the action that zooms out

    getZoomOutButton

    public javax.swing.JButton getZoomOutButton()
    Returns the button that zooms out when clicked.

    Returns:
    the print preview "zoom out" button

    getZoomOutIcon

    public javax.swing.Icon getZoomOutIcon()
    Returns the icon associated with the action that zooms out.

    Returns:
    the icon associated with the "zoom out" action

    getZoomOutMnemonic

    public int getZoomOutMnemonic()
    Returns the mnemonic associated with the action that zooms out.

    Returns:
    the mnemonic associated with the "zoom out" action

    getZoomOutText

    public java.lang.String getZoomOutText()
    Returns the text associated with the action that zooms out.

    Returns:
    the text associated with the "zoom out" action

    getZoomOutToolTip

    public java.lang.String getZoomOutToolTip()
    Returns the description associated with the action that zooms out.

    Returns:
    the description associated with the "zoom out" action

    getZoomOutToggleAction

    public javax.swing.Action getZoomOutToggleAction()
    Returns the action that toggles between zoom-out mode and selection mode.

    Returns:
    the action that toggles between zoom-out mode and selection mode

    getZoomOutToggleButton

    public javax.swing.JToggleButton getZoomOutToggleButton()
    Returns the button that toggles between zoom-out mode and selection mode.

    Returns:
    the print preview "zoom out" toggle button

    getZoomOutToggleIcon

    public javax.swing.Icon getZoomOutToggleIcon()
    Returns the icon associated with the action that toggles between zoom-out mode and selection mode.

    Returns:
    the icon associated with the "zoom out toggle" action

    getZoomOutToggleMnemonic

    public int getZoomOutToggleMnemonic()
    Returns the mnemonic associated with the action that toggles between zoom-out mode and selection mode.

    Returns:
    the mnemonic associated with the "zoom out toggle" action

    getZoomOutToggleText

    public java.lang.String getZoomOutToggleText()
    Returns the text associated with the action that toggles between zoom-out mode and selection mode.

    Returns:
    the text associated with the "zoom out toggle" action

    getZoomOutToggleToolTip

    public java.lang.String getZoomOutToggleToolTip()
    Returns the description associated with the action that toggles between zoom-out mode and selection mode.

    Returns:
    the description associated with the "zoom out toggle" action

    getZoomToggleAction

    public javax.swing.Action getZoomToggleAction()
    Returns the action that toggles between zoom mode and selection mode.

    Returns:
    the action that toggles between zoom mode and selection mode

    getZoomToggleButton

    public javax.swing.JToggleButton getZoomToggleButton()
    Returns the button that toggles between zoom mode and selection mode.

    Returns:
    the print preview "zoom" toggle button

    getZoomToggleIcon

    public javax.swing.Icon getZoomToggleIcon()
    Returns the icon associated with the action that toggles between zoom mode and selection mode.

    Returns:
    the icon associated with the "zoom toggle" action

    getZoomToggleMnemonic

    public int getZoomToggleMnemonic()
    Returns the mnemonic associated with the action that toggles between zoom mode and selection mode.

    Returns:
    the mnemonic associated with the "zoom toggle" action

    getZoomToggleText

    public java.lang.String getZoomToggleText()
    Returns the text associated with the action that toggles between zoom mode and selection mode.

    Returns:
    the text associated with the "zoom toggle" action

    getZoomToggleToolTip

    public java.lang.String getZoomToggleToolTip()
    Returns the description associated with the action that toggles between zoom mode and selection mode.

    Returns:
    the description associated with the "zoom toggle" action

    handlePrinterException

    protected void handlePrinterException(java.awt.print.PrinterException printerException)
    Responds to a printing error. This is a hook method that allows subclasses to respond differently to exceptions that occur while trying to print pages.

    Parameters:
    printerException - the exception generated while trying to print pages

    Side of Software
    Print Preview Library 1.8.1

    Copyright 2003-07 Side of Software (SOS). All rights reserved.