⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handlemouse.java

📁 基于TCP/IP的远程控制访问程序 可以对远程的计算机惊醒控制管理!
💻 JAVA
字号:
import java.util.StringTokenizer;
import java.awt.Component;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import javax.swing.tree.TreePath;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.JOptionPane;
 //弹出菜单事件
class HandleMouse implements MouseListener
 {
 	Ctree c;
 	boolean twoPath=false;
 	TreePath currentPath=null;
 	public HandleMouse(Ctree c)
 	 {
 	 	this.c=c;
 	 }

 	public void mouseClicked(MouseEvent e)
 	 {
 	    currentPath=c.tree.getSelectionPath();
 	    
 	    //取得当前节点
 	    c.node1 = (DefaultMutableTreeNode)(currentPath.getLastPathComponent());
        boolean noRootChild;  //判断是否是主机节点
        noRootChild=!(c.node1.getParent()==c.node1.getRoot());
          if(e.getClickCount()==2&&!noRootChild)    //双击主机节点,加载数据
            {
            	 boolean reload=true;
                 StringTokenizer strHP=new StringTokenizer(c.node1.toString(),":");//(String)c.node1.getUserObject()与c.node1.toString()等价,为取得节点名称
 	             String HN=strHP.nextToken();
 	             int IPP=Integer.parseInt(strHP.nextToken());
 	           //System.out.println("startPort is "+c.startPort);
                 if(c.startPort)//已经有加载的主机
                  {
                    if(c.HostName.equals(HN)&&(c.IPPort==IPP))
                       reload=false;
                  }
                 if(reload)
                  {
                    c.HostName=HN;
                    c.IPPort=IPP;
                    if(c.startPort)
                     {
                        c.quit();
                     }
              //      TreePath parentPath = c.tree.getSelectionPath();

              //      c.node1 = (DefaultMutableTreeNode)(parentPath.getLastPathComponent());
                 //   System.out.println(c.node1);
                    c.connect();
                  }
            }
 	    else if(e.getClickCount()==2&&!(c.node1.getChildCount()>0)&&!c.node1.isRoot())
 	     {
 	 	    {
 	 	 	 	 try
 	 	 	  	  {
               	   DefaultMutableTreeNode node2=null;
               	   c.out.println("addClientTree");
              	   c.out.flush();
               	   c.out.println(String.valueOf(currentPath));
                   c.out.flush();
               	   String s=new String("");
               	   String F_ornot=new String("");
               	   s=c.in.readLine();
               	   //node2=new DefaultMutableTreeNode(s);
               	   //System.out.println(s);
               	   if(s.equals("&isFile&"))
               	    {
               	    	String filepath=c.in.readLine();
               	    	System.out.println(filepath);
               	    	int parameter=JOptionPane.showConfirmDialog(null,
               	    	"打开或运行 "+filepath,"打开["+c.HostName+"]",JOptionPane.YES_NO_OPTION);
               	    	if(parameter==0)
               	    	 {
               	    	    c.out.println("&execute&");
               	    	    c.out.flush();
               	    	 }
               	    	else
               	    	 {
               	    	    c.out.println("&inexecute&");
               	    	    c.out.flush();
               	    	 }                  	    	 	    
               	    	s=c.in.readLine();
               	    }	
                	 while(!s.equals("&&over&&"))
                	  {
                 	 	F_ornot=c.in.readLine();
                 	 //	System.out.println(F_ornot);
                 	 	if(node2==null)
                 	 	{
                 	 	   if(F_ornot.equals("directory"))
                 	 	      node2=new DefaultMutableTreeNode(s);
                 	 	   else 
                 	 	      node2=new DefaultMutableTreeNode(s,false);  
                 	 	 c.node1.add(node2);
                 	    }
                 	    else if(F_ornot.equals("directory"))
                 	 	  {
                 	          c.node1.add(new DefaultMutableTreeNode(s,true));
                 	 	    //  System.out.println(F_ornot+" add directory");
                 	 	  }                 	 	
                 	 	else //if(F_ornot.equals("file"));
                 	 	  {
                 	          c.node1.add(new NodeInformation(s,false));
                 	        //  System.out.println(F_ornot+" add file");
                 	      }                   	 	
                 	 	s=c.in.readLine(); 
                	  }
                   if(node2!=null)  
                     c.tree.scrollPathToVisible(new TreePath(node2.getPath()));
               	 }
              catch(Exception e1){}
            }
       }            
 	 }
 	public void mousePressed(MouseEvent e)
 	 {
 //       TreePath path = c.tree.getPathForLocation(e.getX(),e.getY());
 //       c.tree.setSelectionPath(path);	
 	 }
 	public void mouseEntered(MouseEvent e){}
 	public void mouseExited(MouseEvent e){}
 	public void mouseReleased(MouseEvent e)
 	 {
 	 	if(e.isPopupTrigger())
 	 	 c.popM.show((Component)e.getSource(),e.getX(),e.getY());
 	 }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -