-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUserManualActionListener.java
More file actions
49 lines (41 loc) · 1.67 KB
/
Copy pathUserManualActionListener.java
File metadata and controls
49 lines (41 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/** Author: Shikhar K Gupta, Foram Joshi
* Project: DNA Pen
* Mentor: Prof. Manish K Gupta
*/
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JOptionPane;
public class UserManualActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Desktop desktop = Desktop.getDesktop();
try {
File tempFile = new File("TempFile");
FileWriter fileWriter = new FileWriter(tempFile);
fileWriter.write("TempFile");
fileWriter.close();
String filePath = tempFile.getAbsolutePath();
filePath = filePath.substring(0, filePath.indexOf("TempFile"));
if (MainFrame.osName.toLowerCase().contains("mac")) {
filePath = filePath.concat("DNA Pen.app/Contents/Resources/DNA Pen/docs/3DNA_usermanual.pdf");
} else {
filePath = filePath.concat("/docs/3DNA_usermanual.pdf");
}
desktop.open(new File(filePath));
tempFile.delete();
} catch (IllegalArgumentException e1) {
e1.printStackTrace(System.out);
JOptionPane.showMessageDialog(null, "Exception occurred.",
"Error!", JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e2) {
e2.printStackTrace(System.out);
JOptionPane.showMessageDialog(null, "Exception occurred.",
"Error!", JOptionPane.INFORMATION_MESSAGE);
}
}
}