/** * Called to process events. Mouse events will be rewritten to indicate the position in the * document clicked, instead of the position of the panel. * * @param event to process. */ protected void processEvent(AWTEvent event) { try { if (event instanceof MouseEvent) { final Point scrollPosition = getScrollPosition(); if (scrollPosition != null) { final MouseEvent mouseEvent = (MouseEvent) event; event = new MouseEvent( (Component) mouseEvent.getSource(), mouseEvent.getID(), mouseEvent.getWhen(), mouseEvent.getModifiers(), mouseEvent.getX() + scrollPosition.x, mouseEvent.getY() + scrollPosition.y, mouseEvent.getClickCount(), mouseEvent.isPopupTrigger()); } } } catch (final Throwable exp) { exp.printStackTrace(DjVuOptions.err); System.gc(); } super.processEvent(event); }
/** * Called to draw the panel. * * @param g Graphics device to draw the panel to. */ public void paintComponent(Graphics g) { final Point scrollPosition = getScrollPosition(); g.translate(-scrollPosition.x, -scrollPosition.y); try { super.paintComponent(g); } finally { g.translate(scrollPosition.x, scrollPosition.y); } }
/** * Called to set the URL to browse, and reset the scrollbars. * * @param url indicates document to view. * @throws IOException if an error occures */ public void setURL(final URL url) throws IOException { final URL old = getURL(); super.setURL(url); if (old == null) { // bcr getImageWait().setBufferMode(DjVuImage.COMPLETE_BUFFER); setScrollbar(Scrollbar.HORIZONTAL, new Scrollbar(Scrollbar.HORIZONTAL)); setScrollbar(Scrollbar.VERTICAL, new Scrollbar(Scrollbar.VERTICAL)); hScroll.setUnitIncrement(16); vScroll.setUnitIncrement(16); } }
public void run() { super.run(); updateScrollbars(); }
/** * Called to redraw the panel. * * @param g Graphics device to draw the panel to. */ public void paint(Graphics g) { super.paint(g); updateScrollbars(); }