// Shutdown Or Restart PC Swing
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
public class SR extends JFrame implements ActionListener
{
JFrame f;
JButton b1,b2;
public SR()
{
f=new JFrame();
b1=new JButton("Shutdown");
b1.addActionListener(this);
b2=new JButton("Restart");
b2.addActionListener(this);
f.add(b1);
f.add(b2);
f.setLayout(new FlowLayout());
f.setSize(300,300);
f.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
try
{
Runtime r=Runtime.getRuntime();
if(ae.getSource()==b1)
{
r.exec("shutdown -s -t 5");
}
else if(ae.getSource()==b2)
{
r.exec("shutdown -r -t 5");
}
}
catch(Exception e)
{
}
}
public static void main(String args[])
{
new SR();
}
}