コード例 #1
0
 public void mouseClicked(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   int currentTabIndex = -1;
   int tabCount = tabPane.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     if (rects[i].contains(x, y)) {
       currentTabIndex = i;
       break;
     } // if contains
   } // for i
   if (currentTabIndex >= 0) {
     Rectangle tabRect = rects[currentTabIndex];
     x = x - tabRect.x;
     y = y - tabRect.y;
     if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) {
       try {
         tabbedPane.remove(currentTabIndex);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     } // if
   } // if currentTabIndex >= 0
   System.gc();
 } // mouseClicked
コード例 #2
0
 // ------------------------------------------------------------------------------------------------------
 public void connectToGaggle() {
   try {
     connector.connectToGaggle();
   } catch (Exception ex0) {
     System.err.println("failed to connect to gaggle: " + ex0.getMessage());
     ex0.printStackTrace();
   }
   gaggleBoss = connector.getBoss();
 } // connectToGaggle
コード例 #3
0
  // -------------------------------------------------------------------------------------
  protected JPanel createScrolledPdfViewer(String clusterIdAs3DigitString) {
    final PdfDecoder pdfDecoder = new PdfDecoder();
    String urlString =
        baseUrl + "/" + imageFileNameBase + clusterIdAs3DigitString + imageFileNameSuffix;
    currentFile = urlString;

    System.out.println("url: " + urlString);
    try {
      pdfDecoder.openPdfFileFromURL(urlString);
      // System.out.println ("page count: " + pdfDecoder.getPageCount ());
      pdfDecoder.decodePage(1);
      pdfDecoder.setPageParameters(1.0f, 1, PAGE_ROTATION); // values scaling (1=100%). page number
      pdfDecoder.invalidate();
    } catch (Exception e) {
      e.printStackTrace();
    }

    final ViewerState viewerState = new ViewerState(pdfDecoder.getPageCount());

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    panel.add(toolbar, BorderLayout.NORTH);

    JButton backButton = new JButton("<");
    backButton.setToolTipText("Back One page");
    toolbar.add(backButton);
    backButton.addActionListener(new BackButtonListener(pdfDecoder, viewerState));

    JButton forwardButton = new JButton(">");
    forwardButton.setToolTipText("Forward One page");
    toolbar.add(forwardButton);
    forwardButton.addActionListener(new ForwardButtonListener(pdfDecoder, viewerState));

    JButton zoomOutButton = new JButton("-");
    zoomOutButton.setToolTipText("Zoom Out");
    toolbar.add(zoomOutButton);
    zoomOutButton.addActionListener(new ZoomOutButtonListener(pdfDecoder, viewerState));

    JButton zoomInButton = new JButton("+");
    zoomInButton.setToolTipText("Zoom In");
    toolbar.add(zoomInButton);
    zoomInButton.addActionListener(new ZoomInButtonListener(pdfDecoder, viewerState));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    scrollPane.setViewportView(pdfDecoder);
    panel.add(scrollPane, BorderLayout.CENTER);
    return panel;
  } // createScrolledPdfViewer
コード例 #4
0
 public void actionPerformed(ActionEvent e) {
   int currentPage = viewerState.getPage();
   if (currentPage < pdfDecoder.getPageCount()) {
     currentPage += 1;
     viewerState.setPage(currentPage);
     try {
       pdfDecoder.decodePage(currentPage);
       pdfDecoder.invalidate();
       mainFrame.repaint();
     } catch (Exception e1) {
       System.err.println("forward 1 page");
       e1.printStackTrace();
     }
   }
 }