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

2019-08-31 14:48

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

}

}

ex.printStackTrace(); } finally { try {

serv.getInputStream().close(); } catch (Exception e) { e.printStackTrace(); } }

this.serviceCount = i;

3.5系统属性数据结构接口

package 进程管理与监控;

public interface IMonitorService {

public MonitorInfoBean getMonitorInfoBean() throws Exception; }

3.6绘图点数据结构

package 进程管理与监控;

public class XY {

public int x1,y1,x2,y2; }

3.7主类

package 进程管理与监控;

- 14 -

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

import java.awt.*;

import java.awt.event.*; import java.io.IOException; import java.io.OutputStream; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; import java.util.Vector;

import javax.swing.*;

import javax.swing.border.Border;

import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; import javax.swing.event.*; import javax.swing.table.*;

import com.sun.management.OperatingSystemMXBean;

public class dFrame extends JFrame implements ActionListener {

//选项卡

JTabbedPane jtp; JPanel process_tab; JPanel service_tab; JPanel function_tab; //显示进程的表格

JTable pTable = new JTable(); //显示服务的表格

JTable sTable = new JTable(); //中间面板

JPanel mainpanel;

final Vector pb = new Vector(5); final Vector sb = new Vector(5); //进程信息面板

JLabel process_num; //获取系统基础信息所需

MonitorServiceImpl m = new MonitorServiceImpl(); IMonitorService service = new MonitorServiceImpl();

MonitorInfoBean monitorInfo = service.getMonitorInfoBean(); OperatingSystemMXBean os = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); //图标偏移量

- 15 -

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

static int move = 0; //折线图所需的数据

static List X_memory_record = new ArrayList(); static List Y_memory_record = new ArrayList(); static List D_memory_record = new ArrayList(); static List X_cpu_record = new ArrayList(); static List Y_cpu_record = new ArrayList(); static List D_cpu_record = new ArrayList();

JPanel p_memory_record; JPanel p_cpu_record; JPanel p_cpu_used; JPanel p_memory_used;

//记录前一次cpu数据 int temp_cpu_x = 370; int temp_cpu_y = 140;

dFrame() throws Exception {

setTitle(\任务管理器\); setSize(545, 580);

this.setDefaultCloseOperation(3); this.setLayout(null);

this.getContentPane().setBackground(Color.BLACK); //加菜单栏 MenuBar();

//加选项卡以及中间内容 setTab(); //加图标

Image img = (new

ImageIcon(\)).getImage(); this.setIconImage(img);

this.setVisible(true); }

3.8选项卡部分

//选项卡布局

public void setTab() throws Exception{

jtp = new JTabbedPane(JTabbedPane.TOP);

process_tab = new JPanel();

- 16 -

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

}

process_tab.setLayout(null); ProcessTab();

service_tab = new JPanel(); //service_tab.setLayout(null); ServiceTab();

function_tab = new JPanel(); function_tab.setLayout(null); FunctionTab();

process_tab.setBackground(Color.WHITE); service_tab.setBackground(Color.WHITE); function_tab.setBackground(Color.WHITE);

jtp.add(\进程 \,process_tab); jtp.add(\服务 \,service_tab); jtp.add(\性能 \,function_tab);

mainpanel = new JPanel();

mainpanel.setBounds(-5, 20, 540, 500); mainpanel.add(jtp);

this.getContentPane().add(mainpanel);

southPanel();

3.9菜单栏部分

//菜单栏

public void MenuBar(){

JMenuBar JMB = new JMenuBar();

String [] arrayMenu = {\文件(F) \,\选项(O) \,\查看(V) \,\帮助(H) \};

String [][] arrayItem = {

{\新建任务(N)\,\退出任务管理器(X)\},

{\前端显示(A)\,\使用时最小化(M)\,\最小化隐藏(H)\}, {\立即刷新(R)\,\更新速度(U)\,\选择列(S)\},

{\任务管理器帮助主题(H)\,\关于任务管理器(A)\}};

for(int i=0;i

- 17 -

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

{

JMenu Menu = new JMenu(arrayMenu[i]); for(int j=0;j

JMenuItem item = new JMenuItem(arrayItem[i][j]); Menu.add(item); }

JMB.add(Menu); }

JMB.setBounds(0,0,545,20);

this.getContentPane().add(JMB); }

public void southPanel(){

JPanel southpan = new JPanel(); southpan.setLayout(null);

process_num = new JLabel(

\进程数: \+m.processCount+\+ \使用率:

\+(int)(os.getSystemCpuLoad()*100)+\+\+ \物理内存:

\+(int)(((float)monitorInfo.getUsedMemory()/(float)monitorInfo.getTotalMemorySize())*100)+\); //设置字体

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

process_num.setBounds(5, 0, 520, 25); southpan.add(process_num);

southpan.setBounds(0, 520, 530, 25); this.getContentPane().add(southpan);

//更新UI,否则每次刷新时进程数等信息不会改变 this.process_num.updateUI(); }

3.10进程选项卡

//进程选项卡

public void ProcessTab() throws Exception {

- 18 -


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

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

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

马上注册会员

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