在Mac上用Java写程序 , 如何调用本地播放器并且播放本地视频文件??
代码如下packagech6;importjava.awt.*;importjavax.swing.*;publicclassTestBoom{publicstaticv...
代码如下
package ch6;
import java.awt.*;
import javax.swing.*;
public class TestBoom {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame f = new JFrame("核弹发射程序") ;
f.setVisible(true);
f.setBounds(10 , 10, 100, 200);
JLabel la1 = new JLabel();
int n = JOptionPane.showConfirmDialog(null, "是否实施打击");
if(n == 0){
la1.setText("正在启动发射程序与实时画面");
Runtime rn = Runtime.getRuntime();
Process p = null;
try {
p = rn.exec("\"Macintosh HD/Applications/QuickTime Player.app\" /Users/zhangyu/Desktop/Boom.MOV");
} catch (Exception e) {
System.out.println("Error exec!");
}
//System.out.println("点击了是");
}else if(n == 1){
la1.setText("您取消了发射");
//System.out.println("点击了否");
}else{
la1.setText("您取消了发射");
//System.out.println("点击了取消");
}
JOptionPane.showMessageDialog(null, la1);
}
运行结果如下
哪里错了 求大神指点 展开
package ch6;
import java.awt.*;
import javax.swing.*;
public class TestBoom {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame f = new JFrame("核弹发射程序") ;
f.setVisible(true);
f.setBounds(10 , 10, 100, 200);
JLabel la1 = new JLabel();
int n = JOptionPane.showConfirmDialog(null, "是否实施打击");
if(n == 0){
la1.setText("正在启动发射程序与实时画面");
Runtime rn = Runtime.getRuntime();
Process p = null;
try {
p = rn.exec("\"Macintosh HD/Applications/QuickTime Player.app\" /Users/zhangyu/Desktop/Boom.MOV");
} catch (Exception e) {
System.out.println("Error exec!");
}
//System.out.println("点击了是");
}else if(n == 1){
la1.setText("您取消了发射");
//System.out.println("点击了否");
}else{
la1.setText("您取消了发射");
//System.out.println("点击了取消");
}
JOptionPane.showMessageDialog(null, la1);
}
运行结果如下
哪里错了 求大神指点 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询