gt: 		else if (index < cmbZoom.getModel().getSize() - 1)
context: /*
   * JasperReports - Free Java Reporting Library.
   * Copyright (C) 2001 - 2016 TIBCO Software Inc. All rights reserved.
   * http://www.jaspersoft.com
   *
   * Unless you have purchased a commercial license agreement from Jaspersoft,
   * the following license terms apply:
   *
   * This program is part of JasperReports.
   *
   * JasperReports is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * JasperReports is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
   */
  
  /*
   * Contributors:
   * Ryan Johnson - delscovich@users.sourceforge.net
   * Carlton Moore - cmoore79@users.sourceforge.net
   *  Petr Michalek - pmichalek@users.sourceforge.net
   */
  package net.sf.jasperreports.view;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Component;
  import java.awt.Container;
  import java.awt.Cursor;
  import java.awt.Dimension;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.Image;
  import java.awt.Point;
  import java.awt.Rectangle;
  import java.awt.Toolkit;
  import java.awt.event.KeyEvent;
  import java.awt.event.KeyListener;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseListener;
  import java.awt.event.MouseMotionListener;
  import java.awt.geom.AffineTransform;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.InputStream;
  import java.text.DecimalFormat;
  import java.text.DecimalFormatSymbols;
  import java.text.MessageFormat;
  import java.text.ParseException;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ListIterator;
  import java.util.Locale;
  import java.util.Map;
  import java.util.ResourceBundle;
  
  import javax.swing.DefaultComboBoxModel;
  import javax.swing.ImageIcon;
  import javax.swing.JFileChooser;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JViewport;
  import javax.swing.SwingUtilities;
  import javax.swing.filechooser.FileFilter;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import net.sf.jasperreports.engine.DefaultJasperReportsContext;
  import net.sf.jasperreports.engine.JRConstants;
  import net.sf.jasperreports.engine.JRException;
  import net.sf.jasperreports.engine.JRPrintAnchorIndex;
  import net.sf.jasperreports.engine.JRPrintElement;
  import net.sf.jasperreports.engine.JRPrintFrame;
  import net.sf.jasperreports.engine.JRPrintHyperlink;
  import net.sf.jasperreports.engine.JRPrintImage;
  import net.sf.jasperreports.engine.JRPrintImageAreaHyperlink;
  import net.sf.jasperreports.engine.JRPrintPage;
  import net.sf.jasperreports.engine.JRPropertiesUtil;
  import net.sf.jasperreports.engine.JRRuntimeException;
  import net.sf.jasperreports.engine.JasperPrint;
  import net.sf.jasperreports.engine.JasperPrintManager;
  import net.sf.jasperreports.engine.JasperReportsContext;
  import net.sf.jasperreports.engine.PrintPageFormat;
  import net.sf.jasperreports.engine.PrintPart;
  import net.sf.jasperreports.engine.PrintParts;
  import net.sf.jasperreports.engine.export.JRGraphics2DExporter;
  import net.sf.jasperreports.engine.type.HyperlinkTypeEnum;
  import net.sf.jasperreports.engine.util.JRLoader;
  import net.sf.jasperreports.engine.util.LocalJasperReportsContext;
  import net.sf.jasperreports.engine.util.SimpleFileResolver;
  import net.sf.jasperreports.engine.xml.JRPrintXmlLoader;
  import net.sf.jasperreports.export.SimpleExporterInput;
  import net.sf.jasperreports.export.SimpleGraphics2DExporterOutput;
  import net.sf.jasperreports.export.SimpleGraphics2DReportConfiguration;
  import net.sf.jasperreports.renderers.AreaHyperlinksRenderable;
  import net.sf.jasperreports.renderers.Renderable;
  import net.sf.jasperreports.renderers.RenderersCache;
  import net.sf.jasperreports.view.save.JRPrintSaveContributor;
  
  
  /**
   * Represents the built-in visual component for JasperReports.
   * <p>
   * This class is different from the rest of the classes listed previously in that it is more like a 
   * pluggable component than a utility class. It can be used in Swing-based
   * applications to view the reports generated by the JasperReports library.
   * </p><p>
   * This visual component was included like a demo
   * component to show how the core printing functionality can be used to display the reports
   * in Swing-based applications.
   * </p><p>
   * The preferred way to adapt this component to a particular application is by subclassing it.
   * 
   * @author Teodor Danciu (teodord@users.sourceforge.net)
   * @deprecated Replaced by {@link net.sf.jasperreports.swing.JRViewer}.
   */
  public class JRViewer extends javax.swing.JPanel implements JRHyperlinkListener
  {
  	private static final Log log = LogFactory.getLog(JRViewer.class);
  
  	private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
  
  	/**
  	 * Maximum size (in pixels) of a buffered image that would be used by {@link JRViewer JRViewer} to render a report page.
  	 * <p>
  	 * If rendering a report page would require an image larger than this threshold
  	 * (i.e. image width x image height > maximum size), the report page will be rendered directly on the viewer component.
  	 * </p>
  	 * <p>
  	 * If this property is zero or negative, buffered images will never be user to render a report page.
  	 * By default, this property is set to 0.
  	 * </p>
  	 */
  	public static final String VIEWER_RENDER_BUFFER_MAX_SIZE = JRPropertiesUtil.PROPERTY_PREFIX + "viewer.render.buffer.max.size";
  
  	/**
  	 *
  	 */
  	protected static final int TYPE_FILE_NAME = 1;
  	protected static final int TYPE_INPUT_STREAM = 2;
  	protected static final int TYPE_OBJECT = 3;
  
  	/**
  	 * The DPI of the generated report.
  	 */
  	public static final int REPORT_RESOLUTION = 72;
  
  	protected final float MIN_ZOOM = 0.5f;
  	protected final float MAX_ZOOM = 10f;
  	protected int zooms[] = {50, 75, 100, 125, 150, 175, 200, 250, 400, 800};
  	protected int defaultZoomIndex = 2;
  
  	protected int type = TYPE_FILE_NAME;
  	protected boolean isXML;
  	protected String reportFileName;
  	JasperPrint jasperPrint;
  	private int pageIndex;
  	private boolean pageError;
  	protected float zoom;
  
  	private JRGraphics2DExporter exporter;
  	protected RenderersCache renderersCache;
  
  	/**
  	 * the screen resolution.
  	 */
  	private int screenResolution = REPORT_RESOLUTION;
  
  	/**
  	 * the zoom ration adjusted to the screen resolution.
  	 */
  	protected float realZoom;
  
  	private DecimalFormat zoomDecimalFormat;
  	protected JasperReportsContext jasperReportsContext;
  	protected LocalJasperReportsContext localJasperReportsContext;
  	private ResourceBundle resourceBundle;
  
  	private int downX;
  	private int downY;
  	
  	private boolean pnlTabsChangeListenerEnabled = true;
  
  	private List<JRHyperlinkListener> hyperlinkListeners = new ArrayList<JRHyperlinkListener>();
  	private Map<JPanel,JRPrintHyperlink> linksMap = new HashMap<JPanel,JRPrintHyperlink>();
  	private MouseListener mouseListener =
  		new java.awt.event.MouseAdapter()
  		{
  			@Override
  			public void mouseClicked(java.awt.event.MouseEvent evt)
  			{
  				hyperlinkClicked(evt);
  			}
  		};
  
  	protected KeyListener keyNavigationListener =
  		new KeyListener() {
  			@Override
  			public void keyTyped(KeyEvent evt)
  			{
  			}
  			@Override
  			public void keyPressed(KeyEvent evt)
  			{
  				keyNavigate(evt);
  			}
  			@Override
  			public void keyReleased(KeyEvent evt)
  			{
  			}
  		};
  
  	protected List<JRSaveContributor> saveContributors = new ArrayList<JRSaveContributor>();
  	protected File lastFolder;
  	protected JRSaveContributor lastSaveContributor;
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(String fileName, boolean isXML) throws JRException
  	{
  		this(fileName, isXML, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(InputStream is, boolean isXML) throws JRException
  	{
  		this(is, isXML, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle)
  	 */
  	public JRViewer(JasperPrint jrPrint)
  	{
  		this(jrPrint, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(String fileName, boolean isXML, Locale locale) throws JRException
  	{
  		this(fileName, isXML, locale, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(InputStream is, boolean isXML, Locale locale) throws JRException
  	{
  		this(is, isXML, locale, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle)
  	 */
  	public JRViewer(JasperPrint jrPrint, Locale locale)
  	{
  		this(jrPrint, locale, null);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(String fileName, boolean isXML, Locale locale, ResourceBundle resBundle) throws JRException
  	{
  		this(
  			DefaultJasperReportsContext.getInstance(), 
  			fileName,
  			isXML,
  			locale, 
  			resBundle
  			);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle)
  	 */
  	public JRViewer(InputStream is, boolean isXML, Locale locale, ResourceBundle resBundle) throws JRException
  	{
  		this(
  			DefaultJasperReportsContext.getInstance(), 
  			is, 
  			isXML, 
  			locale, 
  			resBundle
  			);
  	}
  
  
  	/**
  	 * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle)
  	 */
  	public JRViewer(JasperPrint jrPrint, Locale locale, ResourceBundle resBundle)
  	{
  		this(
  			DefaultJasperReportsContext.getInstance(), 
  			jrPrint, 
  			locale, 
  			resBundle
  			);
  	}
  
  
  	/**
  	 * 
  	 */
  	public JRViewer(
  		JasperReportsContext jasperReportsContext, 
  		String fileName, 
  		boolean isXML, 
  		Locale locale, 
  		ResourceBundle resBundle
  		) throws JRException
  	{
  		this.jasperReportsContext = jasperReportsContext;
  		
  		initResources(locale, resBundle);
  
  		setScreenDetails();
  
  		setZooms();
  
  		initComponents();
  
  		loadReport(fileName, isXML);
  
  		cmbZoom.setSelectedIndex(defaultZoomIndex);
  
  		initSaveContributors();
  
  		addHyperlinkListener(this);
  	}
  
  
  	/**
  	 *
  	 */
  	public JRViewer(
  		JasperReportsContext jasperReportsContext, 
  		InputStream is, 
  		boolean isXML, 
  		Locale locale, 
  		ResourceBundle resBundle
  		) throws JRException
  	{
  		this.jasperReportsContext = jasperReportsContext;
  		
  		initResources(locale, resBundle);
  
  		setScreenDetails();
  
  		setZooms();
  
  		initComponents();
  
  		loadReport(is, isXML);
  
  		cmbZoom.setSelectedIndex(defaultZoomIndex);
  
  		initSaveContributors();
  
  		addHyperlinkListener(this);
  	}
  
  
  	/**
  	 *
  	 */
  	public JRViewer(
  		JasperReportsContext jasperReportsContext, 
  		JasperPrint jrPrint, 
  		Locale locale, 
  		ResourceBundle resBundle
  		)
  	{
  		this.jasperReportsContext = jasperReportsContext;
  		
  		initResources(locale, resBundle);
  
  		setScreenDetails();
  
  		setZooms();
  
  		initComponents();
  
  		loadReport(jrPrint);
  
  		cmbZoom.setSelectedIndex(defaultZoomIndex);
  
  		initSaveContributors();
  
  		addHyperlinkListener(this);
  	}
  
  
  	private void setScreenDetails()
  	{
  		screenResolution = Toolkit.getDefaultToolkit().getScreenResolution();
  	}
  
  
  	/**
  	 *
  	 */
  	public void clear()
  	{
  		emptyContainer(this);
  		jasperPrint = null;
  		renderersCache = null;
  	}
  
  
  	/**
  	 *
  	 */
  	protected void setZooms()
  	{
  	}
  
  
  	/**
  	 *
  	 */
  	public void addSaveContributor(JRSaveContributor contributor)
  	{
  		saveContributors.add(contributor);
  	}
  
  
  	/**
  	 *
  	 */
  	public void removeSaveContributor(JRSaveContributor contributor)
  	{
  		saveContributors.remove(contributor);
  	}
  
  
  	/**
  	 *
  	 */
  	public JRSaveContributor[] getSaveContributors()
  	{
  		return saveContributors.toArray(new JRSaveContributor[saveContributors.size()]);
  	}
  
  
  	/**
  	 * Replaces the save contributors with the ones provided as parameter. 
  	 */
  	public void setSaveContributors(JRSaveContributor[] saveContribs)
  	{
  		this.saveContributors = new ArrayList<JRSaveContributor>();
  		if (saveContribs != null)
  		{
  			this.saveContributors.addAll(Arrays.asList(saveContribs));
  		}
  	}
  
  
  	/**
  	 *
  	 */
  	public void addHyperlinkListener(JRHyperlinkListener listener)
  	{
  		hyperlinkListeners.add(listener);
  	}
  
  
  	/**
  	 *
  	 */
  	public void removeHyperlinkListener(JRHyperlinkListener listener)
  	{
  		hyperlinkListeners.remove(listener);
  	}
  
  
  	/**
  	 *
  	 */
  	public JRHyperlinkListener[] getHyperlinkListeners()
  	{
  		return hyperlinkListeners.toArray(new JRHyperlinkListener[hyperlinkListeners.size()]);
  	}
  
  
  	/**
  	 *
  	 */
  	protected void initResources(Locale locale, ResourceBundle resBundle)
  	{
  		//FIXME in theory, the setLocale method could be called after current Component was created, in which case all below should be reloaded
  		if (locale != null)
  		{
  			setLocale(locale);
  		}
  		else
  		{
  			setLocale(Locale.getDefault());
  		}
  		if (resBundle == null)
  		{
  			this.resourceBundle = ResourceBundle.getBundle("net/sf/jasperreports/view/viewer", getLocale());
  		}
  		else
  		{
  			this.resourceBundle = resBundle;
  		}
  
  		zoomDecimalFormat = new DecimalFormat("#.##", DecimalFormatSymbols.getInstance(getLocale()));
  	}
  
  
  	/**
  	 *
  	 */
  	protected JasperReportsContext getJasperReportsContext()
  	{
  		return jasperReportsContext;
  	}
  
  
  	/**
  	 *
  	 */
  	protected String getBundleString(String key)
  	{
  		return resourceBundle.getString(key);
  	}
  
  
  	/**
  	 *
  	 */
  	protected void initSaveContributors()
  	{
  		List<JRSaveContributor> builtinContributors = SaveContributorUtils.createBuiltinContributors(
  				jasperReportsContext, getLocale(), resourceBundle);
  		saveContributors.addAll(builtinContributors);
  	}
  
  
  	@Override
  	public void gotoHyperlink(JRPrintHyperlink hyperlink)
  	{
  		switch(hyperlink.getHyperlinkTypeValue())
  		{
  			case REFERENCE :
  			{
  				if (isOnlyHyperlinkListener())
  				{
  					System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
  					System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
  				}
  				break;
  			}
  			case LOCAL_ANCHOR :
  			{
  				if (hyperlink.getHyperlinkAnchor() != null)
  				{
  					Map<String,JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes();
  					JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor());
  					if (anchorIndex.getPageIndex() != pageIndex)
  					{
  						setPageIndex(anchorIndex.getPageIndex());
  						refreshPage();
  					}
  					Container container = pnlInScroll.getParent();
  					if (container instanceof JViewport)
  					{
  						JViewport viewport = (JViewport) container;
  
  						int newX = (int)(anchorIndex.getElementAbsoluteX() * realZoom);
  						int newY = (int)(anchorIndex.getElementAbsoluteY() * realZoom);
  
  						int maxX = pnlInScroll.getWidth() - viewport.getWidth();
  						int maxY = pnlInScroll.getHeight() - viewport.getHeight();
  
  						if (newX < 0)
  						{
  							newX = 0;
  						}
  						if (newX > maxX)
  						{
  							newX = maxX;
  						}
  						if (newY < 0)
  						{
  							newY = 0;
  						}
  						if (newY > maxY)
  						{
  							newY = maxY;
  						}
  
  						viewport.setViewPosition(new Point(newX, newY));
  					}
  				}
  
  				break;
  			}
  			case LOCAL_PAGE :
  			{
  				int page = pageIndex + 1;
  				if (hyperlink.getHyperlinkPage() != null)
  				{
  					page = hyperlink.getHyperlinkPage().intValue();
  				}
  
  				if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1)
  				{
  					setPageIndex(page - 1);
  					refreshPage();
  					Container container = pnlInScroll.getParent();
  					if (container instanceof JViewport)
  					{
  						JViewport viewport = (JViewport) container;
  						viewport.setViewPosition(new Point(0, 0));
  					}
  				}
  
  				break;
  			}
  			case REMOTE_ANCHOR :
  			{
  				if (isOnlyHyperlinkListener())
  				{
  					System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
  					System.out.println("Hyperlink anchor    : " + hyperlink.getHyperlinkAnchor());
  					System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
  				}
  				break;
  			}
  			case REMOTE_PAGE :
  			{
  				if (isOnlyHyperlinkListener())
  				{
  					System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference());
  					System.out.println("Hyperlink page      : " + hyperlink.getHyperlinkPage());
  					System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
  				}
  				break;
  			}
  			case CUSTOM:
  			{
  				if (isOnlyHyperlinkListener())
  				{
  					System.out.println("Hyperlink of type " + hyperlink.getLinkType());
  					System.out.println("Implement your own JRHyperlinkListener to manage this type of event.");
  				}
  				break;
  			}
  			case NONE :
  			default :
  			{
  				break;
  			}
  		}
  	}
  
  
  	protected boolean isOnlyHyperlinkListener()
  	{
  		int listenerCount;
  		if (hyperlinkListeners == null)
  		{
  			listenerCount = 0;
  		}
  		else
  		{
  			listenerCount = hyperlinkListeners.size();
  			if (hyperlinkListeners.contains(this))
  			{
  				--listenerCount;
  			}
  		}
  		return listenerCount == 0;
  	}
  
  
  	/** This method is called from within the constructor to
  	 * initialize the form.
  	 * WARNING: Do NOT modify this code. The content of this method is
  	 * always regenerated by the Form Editor.
  	 */
  	// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  	private void initComponents() {
  		java.awt.GridBagConstraints gridBagConstraints;
  
  		tlbToolBar = new javax.swing.JPanel();
  		btnSave = new javax.swing.JButton();
  		btnPrint = new javax.swing.JButton();
  		btnReload = new javax.swing.JButton();
  		pnlSep01 = new javax.swing.JPanel();
  		btnFirst = new javax.swing.JButton();
  		btnPrevious = new javax.swing.JButton();
  		btnNext = new javax.swing.JButton();
  		btnLast = new javax.swing.JButton();
  		txtGoTo = new javax.swing.JTextField();
  		pnlSep02 = new javax.swing.JPanel();
  		btnActualSize = new javax.swing.JToggleButton();
  		btnFitPage = new javax.swing.JToggleButton();
  		btnFitWidth = new javax.swing.JToggleButton();
  		pnlSep03 = new javax.swing.JPanel();
  		btnZoomIn = new javax.swing.JButton();
  		btnZoomOut = new javax.swing.JButton();
  		cmbZoom = new javax.swing.JComboBox();
  		DefaultComboBoxModel model = new DefaultComboBoxModel();
  		for(int i = 0; i < zooms.length; i++)
  		{
  			model.addElement("" + zooms[i] + "%");
  		}
  		cmbZoom.setModel(model);
  		pnlMain = new javax.swing.JPanel();
  		pnlTabs = new javax.swing.JTabbedPane();
  		scrollPane = new javax.swing.JScrollPane();
  		scrollPane.getHorizontalScrollBar().setUnitIncrement(5);
  		scrollPane.getVerticalScrollBar().setUnitIncrement(5);
  		pnlInScroll = new javax.swing.JPanel();
  		pnlPage = new javax.swing.JPanel();
  		jPanel4 = new javax.swing.JPanel();
  		pnlLinks = new javax.swing.JPanel();
  		jPanel5 = new javax.swing.JPanel();
  		jPanel6 = new javax.swing.JPanel();
  		jPanel7 = new javax.swing.JPanel();
  		jPanel8 = new javax.swing.JPanel();
  		jLabel1 = new javax.swing.JLabel();
  		jPanel9 = new javax.swing.JPanel();
  		lblPage = new PageRenderer(this);
  		pnlStatus = new javax.swing.JPanel();
  		lblStatus = new javax.swing.JLabel();
  
  		setMinimumSize(new java.awt.Dimension(450, 150));
  		setPreferredSize(new java.awt.Dimension(450, 150));
  		setLayout(new java.awt.BorderLayout());
  
  		tlbToolBar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 2));
  
  		btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/save.GIF"))); // NOI18N
  		btnSave.setToolTipText(getBundleString("save"));
  		btnSave.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnSave.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnSave.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnSave.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnSave.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnSaveActionPerformed(evt);
  			}
  		});
  		btnSave.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnSave);
  
  		btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/print.GIF"))); // NOI18N
  		btnPrint.setToolTipText(getBundleString("print"));
  		btnPrint.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnPrint.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnPrint.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnPrint.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnPrint.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnPrintActionPerformed(evt);
  			}
  		});
  		btnPrint.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnPrint);
  
  		btnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/reload.GIF"))); // NOI18N
  		btnReload.setToolTipText(getBundleString("reload"));
  		btnReload.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnReload.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnReload.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnReload.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnReload.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnReloadActionPerformed(evt);
  			}
  		});
  		btnReload.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnReload);
  
  		pnlSep01.setMaximumSize(new java.awt.Dimension(10, 10));
  		tlbToolBar.add(pnlSep01);
  
  		btnFirst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/first.GIF"))); // NOI18N
  		btnFirst.setToolTipText(getBundleString("first.page"));
  		btnFirst.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnFirst.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnFirst.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnFirst.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnFirst.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnFirstActionPerformed(evt);
  			}
  		});
  		btnFirst.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnFirst);
  
  		btnPrevious.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/previous.GIF"))); // NOI18N
  		btnPrevious.setToolTipText(getBundleString("previous.page"));
  		btnPrevious.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnPrevious.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnPrevious.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnPrevious.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnPrevious.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnPreviousActionPerformed(evt);
  			}
  		});
  		btnPrevious.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnPrevious);
  
  		btnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/next.GIF"))); // NOI18N
  		btnNext.setToolTipText(getBundleString("next.page"));
  		btnNext.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnNext.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnNext.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnNext.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnNext.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnNextActionPerformed(evt);
  			}
  		});
  		btnNext.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnNext);
  
  		btnLast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/last.GIF"))); // NOI18N
  		btnLast.setToolTipText(getBundleString("last.page"));
  		btnLast.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnLast.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnLast.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnLast.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnLast.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnLastActionPerformed(evt);
  			}
  		});
  		btnLast.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnLast);
  
  		txtGoTo.setToolTipText(getBundleString("go.to.page"));
  		txtGoTo.setMaximumSize(new java.awt.Dimension(40, 23));
  		txtGoTo.setMinimumSize(new java.awt.Dimension(40, 23));
  		txtGoTo.setPreferredSize(new java.awt.Dimension(40, 23));
  		txtGoTo.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				txtGoToActionPerformed(evt);
  			}
  		});
  		txtGoTo.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(txtGoTo);
  
  		pnlSep02.setMaximumSize(new java.awt.Dimension(10, 10));
  		tlbToolBar.add(pnlSep02);
  
  		btnActualSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF"))); // NOI18N
  		btnActualSize.setToolTipText(getBundleString("actual.size"));
  		btnActualSize.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnActualSize.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnActualSize.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnActualSize.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnActualSize.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnActualSizeActionPerformed(evt);
  			}
  		});
  		btnActualSize.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnActualSize);
  
  		btnFitPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF"))); // NOI18N
  		btnFitPage.setToolTipText(getBundleString("fit.page"));
  		btnFitPage.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnFitPage.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnFitPage.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnFitPage.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnFitPage.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnFitPageActionPerformed(evt);
  			}
  		});
  		btnFitPage.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnFitPage);
  
  		btnFitWidth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF"))); // NOI18N
  		btnFitWidth.setToolTipText(getBundleString("fit.width"));
  		btnFitWidth.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnFitWidth.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnFitWidth.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnFitWidth.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnFitWidth.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnFitWidthActionPerformed(evt);
  			}
  		});
  		btnFitWidth.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnFitWidth);
  
  		pnlSep03.setMaximumSize(new java.awt.Dimension(10, 10));
  		tlbToolBar.add(pnlSep03);
  
  		btnZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/zoomin.GIF"))); // NOI18N
  		btnZoomIn.setToolTipText(getBundleString("zoom.in"));
  		btnZoomIn.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnZoomIn.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnZoomIn.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnZoomIn.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnZoomIn.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnZoomInActionPerformed(evt);
  			}
  		});
  		btnZoomIn.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnZoomIn);
  
  		btnZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/zoomout.GIF"))); // NOI18N
  		btnZoomOut.setToolTipText(getBundleString("zoom.out"));
  		btnZoomOut.setMargin(new java.awt.Insets(2, 2, 2, 2));
  		btnZoomOut.setMaximumSize(new java.awt.Dimension(23, 23));
  		btnZoomOut.setMinimumSize(new java.awt.Dimension(23, 23));
  		btnZoomOut.setPreferredSize(new java.awt.Dimension(23, 23));
  		btnZoomOut.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				btnZoomOutActionPerformed(evt);
  			}
  		});
  		btnZoomOut.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(btnZoomOut);
  
  		cmbZoom.setEditable(true);
  		cmbZoom.setToolTipText(getBundleString("zoom.ratio"));
  		cmbZoom.setMaximumSize(new java.awt.Dimension(80, 23));
  		cmbZoom.setMinimumSize(new java.awt.Dimension(80, 23));
  		cmbZoom.setPreferredSize(new java.awt.Dimension(80, 23));
  		cmbZoom.addActionListener(new java.awt.event.ActionListener() {
  			@Override
  			public void actionPerformed(java.awt.event.ActionEvent evt) {
  				cmbZoomActionPerformed(evt);
  			}
  		});
  		cmbZoom.addItemListener(new java.awt.event.ItemListener() {
  			@Override
  			public void itemStateChanged(java.awt.event.ItemEvent evt) {
  				cmbZoomItemStateChanged(evt);
  			}
  		});
  		cmbZoom.addKeyListener(keyNavigationListener);
  		tlbToolBar.add(cmbZoom);
  
  		add(tlbToolBar, java.awt.BorderLayout.NORTH);
  
  		pnlMain.addComponentListener(new java.awt.event.ComponentAdapter() {
  			@Override
  			public void componentResized(java.awt.event.ComponentEvent evt) {
  				pnlMainComponentResized(evt);
  			}
  		});
  		pnlMain.setLayout(new java.awt.BorderLayout());
  
  		pnlTabs.addChangeListener(new javax.swing.event.ChangeListener() {
  			@Override
  			public void stateChanged(javax.swing.event.ChangeEvent evt) {
  				pnlTabsStateChanged(evt);
  			}
  		});
  		pnlMain.add(pnlTabs, java.awt.BorderLayout.CENTER);
  
  		scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  		scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  
  		pnlInScroll.setLayout(new java.awt.GridBagLayout());
  
  		pnlPage.setMinimumSize(new java.awt.Dimension(100, 100));
  		pnlPage.setPreferredSize(new java.awt.Dimension(100, 100));
  		pnlPage.setLayout(new java.awt.BorderLayout());
  
  		jPanel4.setMinimumSize(new java.awt.Dimension(100, 120));
  		jPanel4.setPreferredSize(new java.awt.Dimension(100, 120));
  		jPanel4.setLayout(new java.awt.GridBagLayout());
  
  		pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5));
  		pnlLinks.setOpaque(false);
  		pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5));
  		pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() {
  			@Override
  			public void mousePressed(java.awt.event.MouseEvent evt) {
  				pnlLinksMousePressed(evt);
  			}
  			@Override
  			public void mouseReleased(java.awt.event.MouseEvent evt) {
  				pnlLinksMouseReleased(evt);
  			}
  		});
  		pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
  			@Override
  			public void mouseDragged(java.awt.event.MouseEvent evt) {
  				pnlLinksMouseDragged(evt);
  			}
  		});
  		pnlLinks.setLayout(null);
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 0;
  		gridBagConstraints.gridy = 0;
  		gridBagConstraints.gridwidth = 2;
  		gridBagConstraints.gridheight = 2;
  		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
  		jPanel4.add(pnlLinks, gridBagConstraints);
  
  		jPanel5.setBackground(java.awt.Color.gray);
  		jPanel5.setMinimumSize(new java.awt.Dimension(5, 5));
  		jPanel5.setPreferredSize(new java.awt.Dimension(5, 5));
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 2;
  		gridBagConstraints.gridy = 1;
  		gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
  		jPanel4.add(jPanel5, gridBagConstraints);
  
  		jPanel6.setMinimumSize(new java.awt.Dimension(5, 5));
  		jPanel6.setPreferredSize(new java.awt.Dimension(5, 5));
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 0;
  		gridBagConstraints.gridy = 2;
  		jPanel4.add(jPanel6, gridBagConstraints);
  
  		jPanel7.setBackground(java.awt.Color.gray);
  		jPanel7.setMinimumSize(new java.awt.Dimension(5, 5));
  		jPanel7.setPreferredSize(new java.awt.Dimension(5, 5));
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 1;
  		gridBagConstraints.gridy = 2;
  		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
  		jPanel4.add(jPanel7, gridBagConstraints);
  
  		jPanel8.setBackground(java.awt.Color.gray);
  		jPanel8.setMinimumSize(new java.awt.Dimension(5, 5));
  		jPanel8.setPreferredSize(new java.awt.Dimension(5, 5));
  
  		jLabel1.setText("jLabel1");
  		jPanel8.add(jLabel1);
  
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 2;
  		gridBagConstraints.gridy = 2;
  		jPanel4.add(jPanel8, gridBagConstraints);
  
  		jPanel9.setMinimumSize(new java.awt.Dimension(5, 5));
  		jPanel9.setPreferredSize(new java.awt.Dimension(5, 5));
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 2;
  		gridBagConstraints.gridy = 0;
  		jPanel4.add(jPanel9, gridBagConstraints);
  
  		lblPage.setBackground(java.awt.Color.white);
  		lblPage.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
  		lblPage.setOpaque(true);
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.gridx = 0;
  		gridBagConstraints.gridy = 0;
  		gridBagConstraints.gridwidth = 2;
  		gridBagConstraints.gridheight = 2;
  		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
  		gridBagConstraints.weightx = 1.0;
  		gridBagConstraints.weighty = 1.0;
  		jPanel4.add(lblPage, gridBagConstraints);
  
  		pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER);
  
  		gridBagConstraints = new java.awt.GridBagConstraints();
  		gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
  		pnlInScroll.add(pnlPage, gridBagConstraints);
  
  		scrollPane.setViewportView(pnlInScroll);
  
  		pnlMain.add(scrollPane, java.awt.BorderLayout.CENTER);
  
  		add(pnlMain, java.awt.BorderLayout.CENTER);
  
  		pnlStatus.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));
  
  		lblStatus.setFont(new java.awt.Font("Dialog", 1, 10)); // NOI18N
  		lblStatus.setText("Page i of n");
  		pnlStatus.add(lblStatus);
  
  		add(pnlStatus, java.awt.BorderLayout.SOUTH);
  		addKeyListener(keyNavigationListener);
  	}// </editor-fold>//GEN-END:initComponents
  
  	void txtGoToActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtGoToActionPerformed
  		try
  		{
  			int pageNumber = Integer.parseInt(txtGoTo.getText());
  			if (
  				pageNumber != pageIndex + 1
  				&& pageNumber > 0
  				&& pageNumber <= jasperPrint.getPages().size()
  				)
  			{
  				setPageIndex(pageNumber - 1);
  				refreshPage();
  			}
  		}
  		catch(NumberFormatException e)
  		{
  		}
  	}//GEN-LAST:event_txtGoToActionPerformed
  
  	void cmbZoomItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbZoomItemStateChanged
  		// Add your handling code here:
  		btnActualSize.setSelected(false);
  		btnFitPage.setSelected(false);
  		btnFitWidth.setSelected(false);
  	}//GEN-LAST:event_cmbZoomItemStateChanged
  
  	void pnlMainComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pnlMainComponentResized
  		// Add your handling code here:
  		if (btnFitPage.isSelected())
  		{
  			fitPage();
  			btnFitPage.setSelected(true);
  		}
  		else if (btnFitWidth.isSelected())
  		{
  			setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / getPageFormat().getPageWidth());
  			btnFitWidth.setSelected(true);
  		}
  
  	}//GEN-LAST:event_pnlMainComponentResized
  
  	void btnActualSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualSizeActionPerformed
  		// Add your handling code here:
  		if (btnActualSize.isSelected())
  		{
  			btnFitPage.setSelected(false);
  			btnFitWidth.setSelected(false);
  			cmbZoom.setSelectedIndex(-1);
  			setZoomRatio(1);
  			btnActualSize.setSelected(true);
  		}
  	}//GEN-LAST:event_btnActualSizeActionPerformed
  
  	void btnFitWidthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFitWidthActionPerformed
  		// Add your handling code here:
  		if (btnFitWidth.isSelected())
  		{
  			btnActualSize.setSelected(false);
  			btnFitPage.setSelected(false);
  			cmbZoom.setSelectedIndex(-1);
  			setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / getPageFormat().getPageWidth());
  			btnFitWidth.setSelected(true);
  		}
  	}//GEN-LAST:event_btnFitWidthActionPerformed
  
  	void btnFitPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFitPageActionPerformed
  		// Add your handling code here:
  		if (btnFitPage.isSelected())
  		{
  			btnActualSize.setSelected(false);
  			btnFitWidth.setSelected(false);
  			cmbZoom.setSelectedIndex(-1);
  			fitPage();
  			btnFitPage.setSelected(true);
  		}
  	}//GEN-LAST:event_btnFitPageActionPerformed
  
  	void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
  		// Add your handling code here:
  
  		JFileChooser fileChooser = new JFileChooser();
  		fileChooser.setLocale(this.getLocale());
  		fileChooser.updateUI();
  		for(int i = 0; i < saveContributors.size(); i++)
  		{
  			fileChooser.addChoosableFileFilter(saveContributors.get(i));
  		}
  
  		if (saveContributors.contains(lastSaveContributor))
  		{
  			fileChooser.setFileFilter(lastSaveContributor);
  		}
  		else if (saveContributors.size() > 0)
  		{
  			fileChooser.setFileFilter(saveContributors.get(0));
  		}
  		
  		if (lastFolder != null)
  		{
  			fileChooser.setCurrentDirectory(lastFolder);
  		}
  		
  		int retValue = fileChooser.showSaveDialog(this);
  		if (retValue == JFileChooser.APPROVE_OPTION)
  		{
  			FileFilter fileFilter = fileChooser.getFileFilter();
  			File file = fileChooser.getSelectedFile();
  			
  			lastFolder = file.getParentFile();
  
  			JRSaveContributor contributor = null;
  
  			if (fileFilter instanceof JRSaveContributor)
  			{
  				contributor = (JRSaveContributor)fileFilter;
  			}
  			else
  			{
  				int i = 0;
  				while(contributor == null && i < saveContributors.size())
  				{
  					contributor = saveContributors.get(i++);
  					if (!contributor.accept(file))
  					{
  						contributor = null;
  					}
  				}
  
  				if (contributor == null)
  				{
  					contributor = new JRPrintSaveContributor(this.jasperReportsContext, getLocale(), this.resourceBundle);
  				}
  			}
  
  			lastSaveContributor = contributor;
  			
  			try
  			{
  				contributor.save(jasperPrint, file);
  			}
  			catch (JRException e)
  			{
  				if (log.isErrorEnabled())
  				{
  					log.error("Save error.", e);
  				}
  				JOptionPane.showMessageDialog(this, getBundleString("error.saving"));
  			}
  		}
  	}//GEN-LAST:event_btnSaveActionPerformed
  
  	void pnlLinksMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged
  		// Add your handling code here:
  
  		Container container = pnlInScroll.getParent();
  		if (container instanceof JViewport)
  		{
  			JViewport viewport = (JViewport) container;
  			Point point = viewport.getViewPosition();
  			int newX = point.x - (evt.getX() - downX);
  			int newY = point.y - (evt.getY() - downY);
  
  			int maxX = pnlInScroll.getWidth() - viewport.getWidth();
  			int maxY = pnlInScroll.getHeight() - viewport.getHeight();
  
  			if (newX < 0)
  			{
  				newX = 0;
  			}
  			if (newX > maxX)
  			{
  				newX = maxX;
  			}
  			if (newY < 0)
  			{
  				newY = 0;
  			}
  			if (newY > maxY)
  			{
  				newY = maxY;
  			}
  
  			viewport.setViewPosition(new Point(newX, newY));
  		}
  	}//GEN-LAST:event_pnlLinksMouseDragged
  
  	void pnlLinksMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseReleased
  		// Add your handling code here:
  		pnlLinks.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
  	}//GEN-LAST:event_pnlLinksMouseReleased
  
  	void pnlLinksMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMousePressed
  		// Add your handling code here:
  		pnlLinks.setCursor(new Cursor(Cursor.MOVE_CURSOR));
  
  		downX = evt.getX();
  		downY = evt.getY();
  	}//GEN-LAST:event_pnlLinksMousePressed
  
  	void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed
  	{//GEN-HEADEREND:event_btnPrintActionPerformed
  		// Add your handling code here:
  
  		Thread thread =
  			new Thread(
  				new Runnable()
  				{
  					@Override
  					public void run()
  					{
  						try
  						{
  							
  							btnPrint.setEnabled(false);
  							JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  							JasperPrintManager.getInstance(jasperReportsContext).print(jasperPrint, true);
  						}
  						catch (Exception ex)
  						{
  							if (log.isErrorEnabled())
  							{
  								log.error("Print error.", ex);
  							}
  							JOptionPane.showMessageDialog(JRViewer.this, getBundleString("error.printing"));
  						}
  						finally
  						{
  							JRViewer.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  							btnPrint.setEnabled(true);
  						}
  					}
  				}
  			);
  
  		thread.start();
  
  	}//GEN-LAST:event_btnPrintActionPerformed
  
  	void btnLastActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnLastActionPerformed
  	{//GEN-HEADEREND:event_btnLastActionPerformed
  		// Add your handling code here:
  		setPageIndex(jasperPrint.getPages().size() - 1);
  		refreshPage();
  	}//GEN-LAST:event_btnLastActionPerformed
  
  	void btnNextActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnNextActionPerformed
  	{//GEN-HEADEREND:event_btnNextActionPerformed
  		// Add your handling code here:
  		setPageIndex(pageIndex + 1);
  		refreshPage();
  	}//GEN-LAST:event_btnNextActionPerformed
  
  	void btnPreviousActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPreviousActionPerformed
  	{//GEN-HEADEREND:event_btnPreviousActionPerformed
  		// Add your handling code here:
  		setPageIndex(pageIndex - 1);
  		refreshPage();
  	}//GEN-LAST:event_btnPreviousActionPerformed
  
  	void btnFirstActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnFirstActionPerformed
  	{//GEN-HEADEREND:event_btnFirstActionPerformed
  		// Add your handling code here:
  		setPageIndex(0);
  		refreshPage();
  	}//GEN-LAST:event_btnFirstActionPerformed
  
  	void btnReloadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnReloadActionPerformed
  	{//GEN-HEADEREND:event_btnReloadActionPerformed
  		// Add your handling code here:
  		if (type == TYPE_FILE_NAME)
  		{
  			try
  			{
  				loadReport(reportFileName, isXML);
  			}
  			catch (JRException e)
  			{
  				if (log.isErrorEnabled())
  				{
  					log.error("Reload error.", e);
  				}
  				jasperPrint = null;
  				renderersCache = null;
  				refreshTabs();
  				setPageIndex(0);
  				refreshPage();
  
  				JOptionPane.showMessageDialog(this, getBundleString("error.loading"));
  			}
  
  			forceRefresh();
  		}
  	}//GEN-LAST:event_btnReloadActionPerformed
  
  	protected void forceRefresh()
  	{
  		zoom = 0;//force pageRefresh()
  		realZoom = 0f;
  		setZoomRatio(1);
  	}
  
  	void btnZoomInActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnZoomInActionPerformed
  	{//GEN-HEADEREND:event_btnZoomInActionPerformed
  		// Add your handling code here:
  		btnActualSize.setSelected(false);
  		btnFitPage.setSelected(false);
  		btnFitWidth.setSelected(false);
  
  		int newZoomInt = (int)(100 * getZoomRatio());
  		int index = Arrays.binarySearch(zooms, newZoomInt);
  		if (index < 0)
  		{
  			setZoomRatio(zooms[- index - 1] / 100f);
  		}
  