基于Java的远程桌面监控源代码来源:熊哲的日志importjava.io.*;importjava.awt.Choice;importjava.awt.Dialog;importjava.awt.FlowLayout;importjava.awt.BorderLayout;importjava.awt.Font;importjava.awt.Color;importjava.net.Socket;importjava.net.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;booleanexistFile;FileOutputStreamfo;//*************************************1JMenuBarmenu=newJMenuBar();JMenumnuFile=newJMenu(文件);JMenuItemAddComputer=newJMenuItem(添加新主机);JMenuItemmnuFileExit=newJMenuItem(退出);//*************************************2JButtonAddcomputer=newJButton(隐藏主机);JLabelHost=newJLabel(选择主机);JPanelH_A=newJPanel();ChoiceAddress=newChoice();JLabelConnectIp=newJLabel(服务器IP地址);JTextFieldConnectIpText=newJTextField(14);//*************************************3DefaultMutableTreeNodeRoot=newDefaultMutableTreeNode(远程控制管理器);JTreetree=newJTree(Root);;JPopupMenupopM=newJPopupMenu();JMenuItemcy_load=newJMenuItem(下载);JMenuItemcy_delect=newJMenuItem(删除);JMenuItemcy_refurbish=newJMenuItem(刷新子项);JFileChooserJsave=newJFileChooser();JScrollPanetreePane=newJScrollPane();DefaultTreeCellRenderercellRenderer=null;DefaultMutableTreeNodenode1=null;DefaultTreeModeltreeModel;FileselectFile;//*************************************4SocketClientSocket=null;//声名一个套接字StringHostName=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;publicCtree(){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));//2Addcomputer.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));//popcy_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);//popcy_refurbish.addActionListener(this);cy_load.addActionListener(this);cy_delect.addActionListener(this);tree.addMouseListener(newHandleMouse(this));thi