btnHelp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (Desktop.isDesktopSupported()) {
try {
String userDir= System.getProperty("user.dir");
String fileSeparator = System.getProperty("file.separator");
String pdfPath = userDir + fileSeparator + "usermanual.pdf";
File myFile = new File(pdfPath);
Desktop.getDesktop().open(myFile);
} catch (IOException e) {
JOptionPane.showMessage(null, "No PDF viewer installed.");
}
}
}
});
Tuesday, May 19, 2015
Open PDF file from your Java application
I have this help button in my application and I want that when the Help button is clicked, the User Manual in PDF format should be opened for the user.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment