/* * This is a Java sample showing how to integrate jPDFEditor * This program will create and display a simple Frame * containing a panel with the jPDFEditorBean inside it */ package jPDFEditorSamples; import java.awt.BorderLayout; import java.awt.Rectangle; import java.util.StringTokenizer; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.LookAndFeel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import com.qoppa.pdfEditor.PDFEditorBean; public class SimpleFrame extends JFrame { private static double DPI_SCALING_MULTIPLIER = 0.0; private JPanel jPanel = null; private PDFEditorBean pdfEditorBean = null; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { final SimpleFrame sf = new SimpleFrame(); sf.setVisible(true); } }); } /** * This method initializes * */ public SimpleFrame() { super(); initialize(); } /** * This method initializes this * */ private void initialize() { this.setBounds(new Rectangle(0, 0, (int)(900 * getDPIScalingMultiplier()), (int)(600 * getDPIScalingMultiplier()))); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setContentPane(getJPanel()); this.setTitle("Qoppa Software - jPDFEditor Sample"); this.setLocationRelativeTo(null); } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(getPDFEditorBean(), BorderLayout.CENTER); } return jPanel; } /** * This method initializes PDFViewerBean * * @return com.qoppa.pdfViewer.PDFViewerBean */ private PDFEditorBean getPDFEditorBean() { if (pdfEditorBean == null) { pdfEditorBean = new PDFEditorBean(); // Buttons from the toolbar can be removed and added here: // pdfNotesBean.getAnnotToolbar().getjbAttachFile().setVisible(false); } return pdfEditorBean; } /** * This method allows high DPI monitor support * */ public static double getDPIScalingMultiplier() { if (DPI_SCALING_MULTIPLIER == 0) { String version = System.getProperty("java.version"); StringTokenizer st = new StringTokenizer(version, "."); if (Integer.valueOf(st.nextToken()).intValue() > 8) { DPI_SCALING_MULTIPLIER = 1; } else { try { String osName = System.getProperty("os.name").toLowerCase(); LookAndFeel current = UIManager.getLookAndFeel(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); DPI_SCALING_MULTIPLIER = Math.max(1, osName.indexOf("mac") != -1 ? 1 : new JLabel().getFont().getSize() / (osName.indexOf("windows") != -1 ? 11.0 : 15.0)); UIManager.setLookAndFeel(current); } catch (Exception e) { DPI_SCALING_MULTIPLIER = 1; } } } return DPI_SCALING_MULTIPLIER; } }