Replacing PDF Viewers notification popup with your own
The Viewer has several notifications that may be displayed to the user. When using the Viewer in your own application you may wish to handle these messages in a different manner, with a difference appearance, or even trigger additional actions.
Customizing how these notifications popups are handled can be done by implementing your own CustomMessageHandler.
The CustomMessageHandler has 3 methods that need to be implemented.
- showMessage - The method takes a single String message or Component to be displayed.
- requestInput - This method takes an Object array containing String values defining the kind of input expected.
- requestConfirm - This method takes an Object array containing String values defining the kind of confirmation expected.
These methods minim the JOptionPane methods with input following the same pattern without a parent component being required.
How to add a CustomMessageHandler to the Java PDF viewer
Below is an example demonstrating how to add a CustomMessageHandler to the Viewer.
Your implementation should be added to the viewer before Viewer.setUpViewer() is called.
PdfDecoderInt pdfDecoder = viewer.getPdfDecoder(); MyCustomMessageHandler messageHandler = new MyCustomMessageHandler(); pdfDecoder.addExternalHandler(messageHandler, Options.CustomMessageOutput); viewer.setupViewer();
Just click a button below if you have more questions or need any help