コード例 #1
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
コード例 #2
0
  // ------------------------------------------------------------------------------------------------------
  protected void createGui() {
    mainFrame = new JFrame(myGaggleName);
    MiscUtil.setApplicationIcon(mainFrame);

    mainFrame.setJMenuBar(createMenuBar());
    mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    JPanel outerPanel = new JPanel();
    mainFrame.getContentPane().add(outerPanel);
    outerPanel.setLayout(new BorderLayout());

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    JButton bossButton = new JButton("Boss");
    bossButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              gaggleBoss.show("boss");
            } catch (RemoteException rex) {
              rex.printStackTrace();
            }
          }
        });

    toolbar.add(bossButton);
    outerPanel.add(toolbar, BorderLayout.NORTH);

    tabbedPane = new JTabbedPane();
    tabbedPane.setUI(new MyTabbedPaneUI());

    outerPanel.add(tabbedPane, BorderLayout.CENTER);

    mainFrame.pack();
    mainFrame.setSize(800, 800);
    mainFrame.setVisible(true);
    MiscUtil.placeInCenter(mainFrame);
  } // createGui