我知道关机
Runtime.getRumtime.exec("RunDllEXE User.exe,exitwindow");别忘用TRY把他括起来

解决方案 »

  1.   

    请 Sunboyjava把详细的程序写出来好吗,谢谢了
      

  2.   

    哦   当然了,那天很忙 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的处理,因为程序可能有错误,我在网吧上网。。最好理解 做成自己想要的格式 
                
                                         
                     
     
                         
                    
                                     
      

  3.   

    UP楼上写的没错~~~~~ 做一个BUTTON 然后引入超类 在BUTTON上做一个监听~~~~没错~~
      

  4.   

    super("ExitWindows");是怎么应用的???调用jframe吗public ExitWindows()
    是构造函数吗《------仁者见仁,智者见智------》