diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java index c121fe9ef..a6601539c 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/PdfImageScrollingPanel.java @@ -776,11 +776,11 @@ public PdfImageScrollingPanel(String fileName, byte[] content, DocumentPreviewSa int extent = scrollBar.getModel().getExtent(); int value = scrollBar.getValue(); if (value + extent >= max) { - this.renderContent(labelIndex, renderedPages, renderedPages + MAX_RENDER_PAGES, zoomFactor); + this.renderContent(labelIndex, renderedPages, renderedPages + MAX_RENDER_PAGES, zoomFactor, false); } currentPage = labelIndex; - this.setCurrentPage(labelIndex); + this.setCurrentPage(labelIndex, false); } }); @@ -802,14 +802,14 @@ public PdfImageScrollingPanel(String fileName, byte[] content, DocumentPreviewSa } - private void setCurrentPage(int pageIndex) { + private void setCurrentPage(int pageIndex, boolean requestFocus) { lblCurrentPage.setText("" + (pageIndex + 1) + "/" + renderedPages); cmdFirstPage.setEnabled(currentPage > 0); cmdPageBackward.setEnabled(currentPage > 0); cmdLastPage.setEnabled((currentPage + 1) < renderedPages); cmdPageForward.setEnabled((currentPage + 1) < renderedPages); - if (!this.cmdPageForward.isEnabled()) { + if (!this.cmdPageForward.isEnabled() && requestFocus) { this.cmdPageBackward.requestFocus(); } } @@ -1014,7 +1014,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { ); }// //GEN-END:initComponents - private void scrollToPage(int page) { + private void scrollToPage(int page, boolean requestFocus) { int totalHeight = 0; Component[] components = pnlPages.getComponents(); @@ -1025,7 +1025,7 @@ private void scrollToPage(int page) { if (i == page) { this.currentPage = page; this.jScrollPane1.getViewport().setViewPosition(new Point(0, totalHeight)); - this.setCurrentPage(page); + this.setCurrentPage(page, requestFocus); break; } totalHeight += components[i].getHeight(); @@ -1034,19 +1034,19 @@ private void scrollToPage(int page) { } private void cmdPageBackwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdPageBackwardActionPerformed - this.scrollToPage(this.currentPage - 1); + this.scrollToPage(this.currentPage - 1, true); }//GEN-LAST:event_cmdPageBackwardActionPerformed private void cmdPageForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdPageForwardActionPerformed - this.scrollToPage(this.currentPage + 1); + this.scrollToPage(this.currentPage + 1, true); }//GEN-LAST:event_cmdPageForwardActionPerformed private void cmdFirstPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdFirstPageActionPerformed - this.scrollToPage(0); + this.scrollToPage(0, true); }//GEN-LAST:event_cmdFirstPageActionPerformed private void cmdLastPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLastPageActionPerformed - this.scrollToPage(this.renderedPages - 1); + this.scrollToPage(this.renderedPages - 1, true); }//GEN-LAST:event_cmdLastPageActionPerformed private void sliderZoomStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderZoomStateChanged @@ -1183,7 +1183,7 @@ public void showStatus(String text) { ThreadUtils.updateLabel(this.lblContent, text); } - private synchronized void renderContent(int currentIndex, int fromPageIndex, int toPageIndex, int zoomFactor) { + private synchronized void renderContent(int currentIndex, int fromPageIndex, int toPageIndex, int zoomFactor, boolean requestFocus) { if (rendering) { log.info("PDFs are currently being rendered - skipping concurrent rendering"); return; @@ -1279,7 +1279,7 @@ private synchronized void renderContent(int currentIndex, int fromPageIndex, int try { this.sliderZoom.setEnabled(true); this.cmdFitToScreen.setEnabled(true); - this.setCurrentPage(currentIndex); + this.setCurrentPage(currentIndex, requestFocus); inputPDF.close(); } catch (Throwable t) { @@ -1354,7 +1354,7 @@ public void showContent(String documentId, byte[] content) { this.content = content; this.currentPage = 0; this.pnlPages.removeAll(); - this.renderContent(0, 0, 9, this.zoomFactor); + this.renderContent(0, 0, 9, this.zoomFactor, false); this.tabs.setEnabledAt(1, false); this.tabs.setEnabledAt(2, false); @@ -1570,7 +1570,7 @@ public void removePages(int[] pageIndexes) { this.renderedPages = 0; this.totalPages = 0; this.currentPage = 0; - this.renderContent(0, 0, MAX_RENDER_PAGES - 1, this.zoomFactor); + this.renderContent(0, 0, MAX_RENDER_PAGES - 1, this.zoomFactor, true); }