package jPDFNotesSamples; import java.net.MalformedURLException; import java.net.URL; import javax.swing.JApplet; import javax.swing.JOptionPane; import javax.swing.JPanel; import com.qoppa.pdf.PDFException; import com.qoppa.pdfNotes.PDFNotesBean; import java.awt.CardLayout; public class PDFNotesApplet extends JApplet { public final static String STRING_FALSE = "False"; public final static String NUMBER_FALSE = "0"; public final static String STRING_TRUE = "True"; public final static String NUMBER_TRUE = "1"; private JPanel jPanel = null; private PDFNotesBean pdfEditor = null; /** * This method initializes this * * @return void */ public void init() { this.setContentPane(getJPanel()); } public void start() { // Set open button visibility according to the BrowseAllowed flag. getPDFEditor().getToolbar().getjbOpen().setVisible (toBoolean (getParameter("BrowseAllowed"))); // Set print button visibility according to the PrintAllowed flag. getPDFEditor().getToolbar().getjbPrint().setVisible (toBoolean (getParameter ("PrintAllowed"))); final String url = getParameter("url"); if (url != null && url.trim ().length() > 0) { try { getPDFEditor().loadPDF(new URL (url)); } catch (MalformedURLException mue) { JOptionPane.showMessageDialog(PDFNotesApplet.this, mue.getMessage()); } catch (PDFException pdfE) { JOptionPane.showMessageDialog(PDFNotesApplet.this, pdfE.getMessage()); } } } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jPanel = new JPanel(); jPanel.setLayout(new CardLayout()); jPanel.add(getPDFEditor(), getPDFEditor().getName()); } return jPanel; } /** * This method initializes PDFViewer * * @return com.qoppa.pdfViewer.PDFViewer */ private PDFNotesBean getPDFEditor() { if (pdfEditor == null) { pdfEditor = new PDFNotesBean(); pdfEditor.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); pdfEditor.setName("pdfEditor"); } return pdfEditor; } private boolean toBoolean (String str) { if (str == null || str.equalsIgnoreCase(STRING_TRUE) || str.equalsIgnoreCase(NUMBER_TRUE)) { return true; } return false; } }