在我开发基于桌面的应用程序时,有一个.pdf格式的用户手册,应该在用户点击帮助菜单项时打开.
我不知道从swing应用程序打开.pdf文件的方法,所以如何在我jframe
或任何pdf文件查看器(如acrobat reader)中打开它.
小智 5
ActionListener listener = new MyListener();
butt.addActionListener(listener);
Run Code Online (Sandbox Code Playgroud)
在My Listener中添加此内容
if (Desktop.isDesktopSupported()) {
try {
File myFile = new File( "path/to/file");
Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
// no application registered for PDFs
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23658 次 |
最近记录: |