Using the show Method of the PrintDialog to Print a View

You use the show method of the PrintDialog or PreviewDialog object when you want to let the bean manage the entire printing process, including the user interface. This is appropriate under the following circumstances:

How to use a print dialog

Create an appropriate view printer object, such as a TablePrinter to print a table, and pass it to the constructor for the PrintDialog. The PrintDialog is in the oracle.dss.dataView.gui package.

The system print dialog appears after the end user chooses OK in the presentation bean's print dialog. If the end user cancels the print operation instead, then the system print dialog does not appear.

After an end user chooses OK from the system print dialog, the view printer prints the view according to the options that the end user set in the print dialog for the bean.

Example: Printing a graph, using PrintDialog.show

The following example shows the simplest way to print a graph. This example allows end users to select printing options. This example assumes that you have a graph named myGraph.


//create an instance of the GraphPrinter GraphPrinter printer = new GraphPrinter(myGraph); //create a frame from which to display the print dialog Frame frame = oracle.bali.ewt.util.WindowUtils.parentFrame(myGraph); //create an instance of the print dialog PrintDialog dialog = new PrintDialog(frame, printer); //display the dialog, so that users can set options and initiate printing dialog.show(); //after the printing is completed or canceled, dispose of the dialog dialog.dispose(); dialog = null;