如何用JAVA语言实现计算机的重起和关机? 我知道关机Runtime.getRumtime.exec("RunDllEXE User.exe,exitwindow");别忘用TRY把他括起来 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请 Sunboyjava把详细的程序写出来好吗,谢谢了 哦 当然了,那天很忙 public class ExitWindows extends JFrame implements ActionListener { JButton exitWindows; public ExitWindows() { super("ExitWindows"); setSize(200,240); setDefaultCLoseOperation(JFrame.EXIT_ON_CLOSE); exitWindows = new JButton("关机"); exitWindows.AddactionListener(this); JPanel pane = new JPanel(); pane.add(exitWindows); setContentPane(pane); } public static void main(String[] args) { ExitWindows exit = new ExitWindows(); exit.show(); } public void actionPerformed(ActionEvent evt) { Runtime r = Runtime.getRuntime(); Process p = null; Object src = evt.getSource(); if(scr==exitWindows) { try{ r.exec("RUNDLL.EXIT user.exe,exitwindows"); p.waitFor(); } catch(Exception en) { System.out.printf(en.toString()); } } } } 请着重看TRY的处理,因为程序可能有错误,我在网吧上网。。最好理解 做成自己想要的格式 UP楼上写的没错~~~~~ 做一个BUTTON 然后引入超类 在BUTTON上做一个监听~~~~没错~~ super("ExitWindows");是怎么应用的???调用jframe吗public ExitWindows()是构造函数吗《------仁者见仁,智者见智------》 java中的方法可以不写返回值类型吗? 从map里面取值 求一个 String.replaceAll 的写法 关于项目大小的问题 求《java2图形设计卷二:swing》 rmi 的送分题(不知何解) 如何判断数据库中是否存在某个表??? 那里可以下载的到带搜索得JDK帮助文档(1.3,1.4都可) 这有个好网站 关于类中get方法返回值的问题 java如何实现删除文本文件的行 如何填充JCheckBox的颜色,用setBackground()也不行!
{
JButton exitWindows;
public ExitWindows()
{
super("ExitWindows");
setSize(200,240);
setDefaultCLoseOperation(JFrame.EXIT_ON_CLOSE);
exitWindows = new JButton("关机");
exitWindows.AddactionListener(this); JPanel pane = new JPanel();
pane.add(exitWindows); setContentPane(pane);
}
public static void main(String[] args)
{
ExitWindows exit = new ExitWindows();
exit.show();
}
public void actionPerformed(ActionEvent evt)
{
Runtime r = Runtime.getRuntime();
Process p = null; Object src = evt.getSource();
if(scr==exitWindows)
{
try{
r.exec("RUNDLL.EXIT user.exe,exitwindows");
p.waitFor();
}
catch(Exception en) {
System.out.printf(en.toString());
}
}
}
}
请着重看TRY的处理,因为程序可能有错误,我在网吧上网。。最好理解 做成自己想要的格式
是构造函数吗《------仁者见仁,智者见智------》