版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zp357252539/article/details/88720277
如下示例:
JButton[] buttons = new JButton[1];
JButton openFileB = new JButton("打开文件");
buttons[0] = openFileB;
openFileB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Runtime.getRuntime().exec("cmd /c start " + doc);
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
JOptionPane.showOptionDialog(context.getParentFrame(), doc,
"影响性分析报告生成路径", JOptionPane.YES_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, buttons, buttons[0]);