0906130204-廖浩伟-操作系统安全课程设计报告(8)

2019-08-31 14:48

操作系统安全课程设计报告-0906130204-廖浩伟

3.14进程选项卡按钮时间处理

public void actionPerformed(ActionEvent args) {

if(args.getActionCommand().equals(\结束进程(E)\)){ if (pTable.getSelectedRow() != -1) {

if (pTable.getValueAt(pTable.getSelectedRow(), 0) != null) {

// Toolkit.getDefaultToolkit().beep(); String pname =

pTable.getValueAt(pTable.getSelectedRow(), 0) .toString();

pname = pname.replace(\, \); pname = pname.trim();

int n = JOptionPane.showConfirmDialog(this, \确定要结束进程\ + pname

+ \吗?\, \确认对话框\, JOptionPane.YES_NO_OPTION);

if (n == JOptionPane.YES_OPTION) { try {

String kill = \ + pname

+ \;

Runtime.getRuntime().exec(kill); } catch (Exception ex) { }

JOptionPane.showMessageDialog(this, pname + \被杀掉了!\, \消息\,

JOptionPane.WARNING_MESSAGE);

} } } else

JOptionPane.showMessageDialog(this, \没有选中项!\, \消息\,

JOptionPane.WARNING_MESSAGE);

}else if(args.getActionCommand().equals(\新建任务(N)\)){

JFrame newjf = new JFrame(\创建新任务\); newjf.setSize(400, 250);// 设置大小

// newjf.setLocationRelativeTo(null);// 设置窗体显示在屏幕中央

newjf.setResizable(false);// 设置禁止改变窗体大小 newjf.setDefaultCloseOperation(2);

- 34 -

操作系统安全课程设计报告-0906130204-廖浩伟

newjf.getContentPane().setBackground(Color.WHITE); newjf.setLayout(null);

//创建字体

Font font = new Font(\微软雅黑\,Font.PLAIN,12);

JLabel msg = new JLabel(\将根据您所输入的名称,为您打开相应的程序。\);

msg.setBounds(45, 30, 320, 20); msg.setFont(font); newjf.add(msg);

JLabel jl_open = new JLabel(\打开(O):\); jl_open.setBounds(10,80,45,20); jl_open.setFont(font); newjf.add(jl_open);

JTextField jtf_open = new JTextField(); jtf_open.setFont(font);

jtf_open.setBounds(60,80,300,20); newjf.add(jtf_open);

JPanel south = new JPanel(); south.setBounds(0,150,400,100); south.setLayout(null);

JButton jbt_ok = new JButton(\确定\); jbt_ok.setFont(font);

jbt_ok.setBounds(180, 18, 80, 28);

JButton jbt_exit = new JButton(\取消\); jbt_exit.setFont(font);

jbt_exit.setBounds(280, 18, 80, 28);

ActionListener al = new ActionListener() {

// 事件处理方法

public void actionPerformed(ActionEvent e) {

if(e.getActionCommand().equals(\确定\)) {

//运行新程序 try {

String exeCmd = jtf_open.getText().trim(); String startCmd = \process call create \+exeCmd;

- 35 -

操作系统安全课程设计报告-0906130204-廖浩伟

}

}

Runtime.getRuntime().exec(startCmd);

} catch (IOException eee) {

// TODO Auto-generated catch block eee.printStackTrace(); System.out.println(\);

} }

else if(e.getActionCommand().equals(\取消\)) {

newjf.dispose(); } } };

jbt_ok.addActionListener(al); jbt_exit.addActionListener(al); south.add(jbt_ok); south.add(jbt_exit); newjf.add(south);

newjf.setVisible(true);

3.15Main函数

public static void main(String[] a) throws Exception { try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

} catch (Exception e) { }

new dFrame(); } }

- 36 -

操作系统安全课程设计报告-0906130204-廖浩伟

四、成果展示

4.1进程展示功能

- 37 -

操作系统安全课程设计报告-0906130204-廖浩伟

4.2进程结束功能

- 38 -


0906130204-廖浩伟-操作系统安全课程设计报告(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:在线考试系统毕业论文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: