In my own Viewer which extends JRViewer I don't load the JasperPrint object before JRViewer is shown. Instead I show the Viewer with empty (null) JasperPrint object and later start to load the real JasperPrint object.
This patch provides a fix for the NullPointerException when calling the constructor with
super((JasperPrint) null);
Snippet from the patch file:
/**
*/
private void setPageIndex(int index)
{
- if(index > -1 && index < jasperPrint.getPages().size())
+ boolean pagesExist = jasperPrint != null
+ && jasperPrint.getPages() != null;
+ if(index > -1 && pagesExist && index < jasperPrint.getPages().size())
{
-
- if (
- jasperPrint != null &&
- jasperPrint.getPages() != null &&
- jasperPrint.getPages().size() > 0
- )
+ if (pagesExist && jasperPrint.getPages().size() > 0)
{
Extended visibility of the fields:
- private KeyListener keyNavigationListener =
+ protected KeyListener keyNavigationListener =
So I can use this navigation listener in my own JButtons.
- private java.util.List saveContributors = new ArrayList();
+ protected java.util.List saveContributors = new ArrayList();
Allows me to override the default saveContributors with my own implementations.
- scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+ scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- private void keyNavigate(KeyEvent evt)
+ protected void keyNavigate(KeyEvent evt)
Makes the warnings go away in Eclipse and doesn't harm either.
Please include this patch in the standard distribution.
Thanks.
Recommended Comments