Skip to content

Customizing the SwingViewBuilder

Patrick Corless edited this page Jan 18, 2020 · 1 revision

The org.icepdf.ri.common.SwingViewBuilder class constructs a set of GUI components which are pre-configured to work with the org.icepdf.ri.common.SwingController class to manipulate and reflect the status of view of a rendered PDF document.

The SwingViewBuilder methods, buildViewerFrame and buildViewerPanel, provide the high-level entry points for the GUI construction process, with each constructing complete PDF Viewer user interfaces. In addition, numerous other build... methods are available that construct specific components and subcomponents.

See the JavaDoc for the SwingViewBuilder class for an overview of the various build... methods.

For example, the buildCompleteMenubar() method will construct and return a complete application menu bar, including File, View, Document, Window, and Help menus. The buildFileMenu() method will construct and return the File menu, including menu items for Open, Close, Save As, Export, Print, etc. You may use the SwingViewBuilder methods at any level that is appropriate for your application to construct the various user interface components that you require.

If you prefer to customize the GUI components that the SwingViewBuilder creates, you will need to adopt one of the following strategies:

  1. Directly modify the SwingViewBuilder source code, or copy the SwingViewBuilder class into a new class of your own and make required changes to the new class. Using this approach will ensure that any changes or enhancements made to the default Viewer user interface in future versions of ICEpdf will not impact your application. You will need to integrate any changes you wish to adopt manually.

  2. Subclass the SwingViewBuilder class and override the build... methods that you need to modify. The advantage of this approach is that your application will automatically incorporate any changes or additions to the Viewer user interface provided in subsequent releases of ICEpdf for those methods that you haven't overridden. For example, if you are satisfied with the default Viewer Component user interface, but need to modify the Help->About menu-item to display a custom About dialog for your application, you would extend the SwingViewBuilder class and override the buildAboutMenuItem() method to return a menu item that displays your custom About dialog. If a future version of ICEpdf includes additional Tools, such as a Text Selection Tool, your user interface will automatically adopt the new toolbar and menu changes to add support for the new Tool without requiring any manual integration of the new code.

Clone this wiki locally