import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
public class ShowGridLayout extends JFrame {
public ShowGridLayout() {
Container container = getContentPane();
container.setLayout(new GridLayout(3, 3, 4, 4));
JButton regeditButton = new JButton("regedit.exe----注册表");
regeditButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "regedit";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(regeditButton);
JButton winmsdButton = new JButton("winmsd-------系统信息");
winmsdButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "winmsd";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(winmsdButton);
JButton calcButton = new JButton("calc-------启动计算器");
calcButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "calc";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(calcButton);
JButton notepadButton = new JButton("notepad----打开记事本");
notepadButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "notepad";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(notepadButton);
JButton progButton = new JButton("progman----程序管理器");
progButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "progman";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(progButton);
JButton shutdownButton = new JButton("tsshutdn-----关机命令");
progButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "rononce /c -p";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(shutdownButton);
}
public static void main(String[] args) {
ShowGridLayout frame = new ShowGridLayout();
frame.setTitle("快速命令1.0");
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
public class ShowGridLayout extends JFrame {
public ShowGridLayout() {
Container container = getContentPane();
container.setLayout(new GridLayout(3, 3, 4, 4));
JButton regeditButton = new JButton("regedit.exe----注册表");
regeditButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "regedit";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(regeditButton);
JButton winmsdButton = new JButton("winmsd-------系统信息");
winmsdButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "winmsd";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(winmsdButton);
JButton calcButton = new JButton("calc-------启动计算器");
calcButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "calc";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(calcButton);
JButton notepadButton = new JButton("notepad----打开记事本");
notepadButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "notepad";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(notepadButton);
JButton progButton = new JButton("progman----程序管理器");
progButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "progman";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(progButton);
JButton shutdownButton = new JButton("tsshutdn-----关机命令");
progButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try {
String cmdStr = "rononce /c -p";
Runtime.getRuntime().exec(cmdStr);
} catch (IOException e) {
}
}
});
container.add(shutdownButton);
}
public static void main(String[] args) {
ShowGridLayout frame = new ShowGridLayout();
frame.setTitle("快速命令1.0");
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}