软著V1根据Java的远程桌面监控源代码交底.docx

上传人:b****8 文档编号:23888858 上传时间:2023-05-21 格式:DOCX 页数:28 大小:20.87KB
下载 相关 举报
软著V1根据Java的远程桌面监控源代码交底.docx_第1页
第1页 / 共28页
软著V1根据Java的远程桌面监控源代码交底.docx_第2页
第2页 / 共28页
软著V1根据Java的远程桌面监控源代码交底.docx_第3页
第3页 / 共28页
软著V1根据Java的远程桌面监控源代码交底.docx_第4页
第4页 / 共28页
软著V1根据Java的远程桌面监控源代码交底.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

软著V1根据Java的远程桌面监控源代码交底.docx

《软著V1根据Java的远程桌面监控源代码交底.docx》由会员分享,可在线阅读,更多相关《软著V1根据Java的远程桌面监控源代码交底.docx(28页珍藏版)》请在冰豆网上搜索。

软著V1根据Java的远程桌面监控源代码交底.docx

软著V1根据Java的远程桌面监控源代码交底

基于Java的远程桌面监控源代码

importjava.io.*;

importjava.awt.Choice;

importjava.awt.Dialog;

importjava.awt.FlowLayout;

importjava.awt.BorderLayout;

importjava.awt.Font;

importjava.awt.Color;

import.Socket;

import.InetAddress;

importjavax.swing.*;

importjava.awt.event.ActionListener;

importjava.awt.event.ActionEvent;

importjava.awt.event.WindowAdapter;

importjava.awt.event.WindowEvent;

importjava.awt.event.KeyAdapter;

importjava.awt.event.KeyEvent;

importjavax.swing.tree.DefaultMutableTreeNode;

importjavax.swing.tree.DefaultTreeCellRenderer;

importjavax.swing.tree.DefaultTreeModel;

importjavax.swing.tree.TreePath;

importjavax.swing.tree.TreeNode;

importjava.awt.Image;

importjavax.swing.ImageIcon;

importjava.awt.Toolkit;

publicclassmidClient

{

   publicstaticvoidmain(String[]args)throwsIOException

   {

       try{

               UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

          }

       catch(Exceptione1){}

       newCtree();

   }

}

 

classCtreeextendsJFrameimplementsActionListener

 {

   booleandisConnect=false;

   booleanpassOk=true;

     booleanstartPort=false;

     booleanDialogApp=false;

     boolean existFile;

     FileOutputStreamfo;

     //*************************************1

     JMenuBarmenu=newJMenuBar();

     JMenu   mnuFile=newJMenu("文件");

      JMenuItemAddComputer =newJMenuItem("添加新主机");

      JMenuItemmnuFileExit =newJMenuItem("退出");

      //*************************************2

      JButtonAddcomputer=newJButton("隐藏主机");

      JLabelHost=newJLabel("选择主机");

      JPanelH_A=newJPanel();

      ChoiceAddress=newChoice();

      JLabelConnectIp=newJLabel("服务器IP地址");

     JTextFieldConnectIpText=newJTextField(14);

     //*************************************3

     DefaultMutableTreeNodeRoot=newDefaultMutableTreeNode("远程控制管理器");

      JTreetree=newJTree(Root);;

   JPopupMenupopM=newJPopupMenu();

   JMenuItem  cy_load=newJMenuItem("下载");

   JMenuItem  cy_delect=newJMenuItem("删除");

   JMenuItem  cy_refurbish=newJMenuItem("刷新子项");   

   JFileChooserJsave=newJFileChooser();

   JScrollPanetreePane=newJScrollPane();

   DefaultTreeCellRenderercellRenderer=null;

   DefaultMutableTreeNodenode1=null;

   DefaultTreeModeltreeModel;

   FileselectFile;

      //*************************************4

   SocketClientSocket=null;//声名一个套接字

     String HostName=null;

     intIPPort=0;

   PrintWriterout=null;

     BufferedReaderin=null;

 

      //子窗口按钮

      DialogAddHost=null;

      JTextFieldComputer=null;

      JTextFieldPort1=null;

   JButtonok=newJButton("确定");

    JButtoncancel=newJButton("取消");

 

   Dialoglisten     =null;

   JPasswordFieldpassw  =newJPasswordField(10);

   JButtonok1       =newJButton("确认");

   JButtoncancel1   =newJButton("取消");

 

     FileinputFile=newFile("d:

/");

      File[]list=inputFile.listRoots();

      intJrate=0;

      intfinish=0;

   intByteNum; 

   StringfileName;

   booleancopy=false;

 

      public Ctree()

       {

         this("远程管理器");

       }

      publicCtree(StringTitle)

       {

           super(Title);

        Imagetitlephone=Toolkit.getDefaultToolkit().createImage("./icons/client.gif");

        this.setIconImage(titlephone);          

       this.setSize(600,500);

         this.setJMenuBar(menu);

       tree.setShowsRootHandles(true);

       setFont();

        addWindows();

       // tree.setEditable(false);

         ConnectIpText.setEditable(false);

 

         addListen();

         try

          {

              FileAdressFile=newFile("HostAddress.txt");

           if(!

AdressFile.exists())

            {

                AdressFile.createNewFile();

            }   

             FileReaderreadIn=newFileReader(AdressFile);

             BufferedReaderbufin=newBufferedReader(readIn);

             StringchoiceList=null;

            Stringaddress,port;

             while((choiceList=bufin.readLine())!

=null)

              {

                   Root.add(newDefaultMutableTreeNode(choiceList));

                  Address.add(choiceList);

              }

             bufin.close();

             readIn.close();

             this.setVisible(true);

           }

           catch(ExceptionE){}

    }

//******************************设置字体

   publicvoidsetFont()

    {       

        mnuFile.setFont(newFont("宋体",Font.PLAIN,12));

        AddComputer.setFont(newFont("宋体",Font.PLAIN,12));

        mnuFileExit.setFont(newFont("宋体",Font.PLAIN,12));

        //2

        Addcomputer.setFont(newFont("宋体",Font.PLAIN,13));

        Host.setFont(newFont("宋体",Font.PLAIN,13));

        Address.setFont(newFont("宋体",Font.PLAIN,13));

        ConnectIp.setFont(newFont("宋体",Font.PLAIN,13));

        ConnectIpText.setFont(newFont("宋体",Font.PLAIN,13));

        //pop

       cy_load.setFont(newFont("宋体",Font.PLAIN,12));

       cy_delect.setFont(newFont("宋体",Font.PLAIN,12));

       cy_refurbish.setFont(newFont("宋体",Font.PLAIN,12));

    }       

//******************************加入窗口容器   

      publicvoidaddWindows()

       {

         mnuFile.add(AddComputer);

         mnuFile.addSeparator();

         mnuFile.add(mnuFileExit);

         menu.add(mnuFile);

         H_A.add(Addcomputer);

           H_A.add(Host);

           H_A.add(Address);

           H_A.add(ConnectIp);

           H_A.add(ConnectIpText);

           tree.setRowHeight(21);

       tree.setCellRenderer(newEnhancedTreeCellRenderer());

       cellRenderer=(DefaultTreeCellRenderer)tree.getCellRenderer();

 

       cellRenderer.setFont(newFont("宋体",Font.PLAIN,14));

       cellRenderer.setBackgroundNonSelectionColor(Color.white);

       cellRenderer.setBackgroundSelectionColor(Color.blue);

       cellRenderer.setBorderSelectionColor(Color.yellow);

       cellRenderer.setTextNonSelectionColor(Color.black);

       cellRenderer.setTextSelectionColor(Color.white);      

        getContentPane().add(newJScrollPane(tree),BorderLayout.CENTER);

         popM.add(cy_load);

         popM.add(cy_delect);

       popM.addSeparator();      

         popM.add(cy_refurbish);        

         tree.add(popM);

         //*****************

         getContentPane().add(H_A,BorderLayout.NORTH);

     }

       //****************************监听信息

    publicvoidaddListen()

     {

         AddComputer.addActionListener(this);

         mnuFileExit.addActionListener(this);

 

         Addcomputer.addActionListener(this);

 

           //pop

           cy_refurbish.addActionListener(this);

           cy_load.addActionListener(this);

           cy_delect.addActionListener(this);

           tree.addMouseListener(newHandleMouse(this));

           this.addWindowListener(newWinAdptClient(this));

 

         //AddHost中的Button监听

         ok.addActionListener(this);

         cancel.addActionListener(this);

         //listen中的Button监听

         ok1.addActionListener(this);

         cancel1.addActionListener(this);

     }

/**********************************监听事件代码******************************/

 publicvoidactionPerformed(ActionEvente)

  {

    if(e.getSource()==AddComputer)

      {

         dialog();

      }

     elseif(e.getSource()==Addcomputer)

      {

           if(this.startPort)

            {

              if(e.getActionCommand()=="隐藏主机")

               {

                  out.println("hideServer");

                  out.flush();

                  Addcomputer.setActionCommand("显示主机");

                  Addcomputer.setName("显示主机");

                  Addcomputer.updateUI();

               }

              else

               {

                  out.println("appearServer");

                  out.flush();

                  Addcomputer.setActionCommand("隐藏主机");

                  Addcomputer.setName("隐藏主机");

                  Addcomputer.updateUI();

               }    

            }               

      }

     elseif(e.getSource()==mnuFileExit)

      {

         saveInit();

         quit();

         this.dispose();

         System.exit(0);

      }

     elseif(e.getSource()==cy_refurbish)

      {

         update();

      }      

     elseif(e.getSource()==cy_load)

      {//要把文件路径给传过去

        connectThreadstar=newconnectThread(this);

        star.start();

      }

     elseif(e.getSource()==cy_delect)

     {

        try

         {

           intparameter=JOptionPane.showConfirmDialog(null,

              "是否删除文件"+String.valueOf(tree.getSelectionPath()),"删除["+HostName+"]",JOptionPane.YES_NO_OPTION); 

          if(parameter==0)

            {              

                 Stringstr=String.valueOf(tree.getSelectionPath());

                 out.println("&delect&");

                 out.flush();

           //      System.out.println(str);

                 out.println(str);

                 out.flush();

                 str=in.readLine();

                 if(str.equals("1"))

                  {

                         treeModel=(DefaultTreeModel)tree.getModel();

                       TreePathtreepath=tree.getSelectionPath();

                       if(treepath!

=null)

                        {

                            DefaultMutableTreeNodeselectionNode=(DefaultMutableTreeNode)

                          treepath.getLastPathComponent();

                           TreeNodeparent

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1