/* * Created on Sep 24, 2008 * */ package jPDFNotesSamples; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.BorderLayout; import java.awt.Rectangle; import java.util.StringTokenizer; import javax.swing.JPanel; import javax.swing.LookAndFeel; import javax.swing.UIManager; import com.qoppa.pdfNotes.PDFNotesBean; public class SimpleFrame extends JFrame { private static double DPI_SCALING_MULTIPLIER = 0.0; private JPanel jPanel = null; private PDFNotesBean PDFNotesBean = null; public static void main (String [] args) { 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)(800 * getDPIScalingMultiplier()), (int)(600 * getDPIScalingMultiplier()))); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setContentPane(getJPanel()); this.setTitle("Qoppa Software - jPDFNotes 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(getPDFNotesBean(), BorderLayout.CENTER); } return jPanel; } /** * This method initializes PDFViewerBean * * @return com.qoppa.pdfViewer.PDFViewerBean */ private PDFNotesBean getPDFNotesBean() { if (PDFNotesBean == null) { PDFNotesBean = new PDFNotesBean(); // Buttons from the toolbar can be removed and added here: // PDFNotesBean.getAnnotToolbar().getJbAttachFile().setVisible(false); } return PDFNotesBean; } /** * 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; } }