当前位置:编程学习 > 网站相关 >>

Applet在web页面打开远程桌面前端测试代码

曾经用Applet在web页面打开远程桌面的前端测试代码,后台代码无法公开,仅作备忘。

RdpApplet.java:
[java] 
package com.elusiva.rdp.applet; 
 
import java.applet.Applet; 
import java.awt.BorderLayout; 
import java.awt.Color; 
import java.awt.Graphics; 
import java.awt.TextArea; 
import java.io.ByteArrayOutputStream; 
import java.io.FilterOutputStream; 
import java.io.IOException; 
import java.io.OutputStream; 
import java.io.PrintStream; 
import java.net.MalformedURLException; 
import java.net.URL; 
import java.util.ArrayList; 
import java.util.Iterator; 
import java.util.List; 
import java.util.Map; 
import java.util.StringTokenizer; 
 
import com.elusiva.rdp.Common; 
import com.elusiva.rdp.OrderException; 
import com.elusiva.rdp.RdesktopException; 
import com.elusiva.rdp.RdesktopSwing; 
 
public class RdpApplet extends Applet { 
    private final String rdpShellPath = "C:\\Program Files\\XXX\\Open Virtual Desktop\\rdpshell.exe"; 
    private RdpThread_2 rThread = null; 
    private String[] argArray = null; 
    private List<String> argList = new ArrayList<String>(); 
    TextArea aTextArea = null; 
    PrintStream aPrintStream  = null; 
   
   public void paint(Graphics g){ 
       g.setColor(new Color(0xFFFFFF)); 
       g.fillRect(0,0,g.getClipBounds().width,g.getClipBounds().height); 
       g.setColor(new Color(0x000000)); 
       int width = g.getFontMetrics().stringWidth("Launching isoft IVAPP Everywhere session..."); 
       int x = (int) (g.getClipBounds().getWidth() / 2) - (width/2); 
       int y = (int) (g.getClipBounds().getHeight() / 2); 
       if(!redirectOutput) g.drawString("Launching isoft IVAPP Everywhere session...", x, y); 
       width = g.getFontMetrics().stringWidth("Connect to Server..."); 
       x = (int) (g.getClipBounds().getWidth() / 2) - (width/2); 
       y = (int) (g.getClipBounds().getHeight() / 2) + 20; 
       if(!redirectOutput) g.drawString("Connect to Server...", x, y); 
   } 
    
   boolean redirectOutput = false; 
    
   public void init(){ 
       redirectOutput = isSet("redirectOutput"); 
       if(redirectOutput){ 
           aPrintStream = new PrintStream( new FilteredStream(new ByteArrayOutputStream() ) ); 
           System.setOut(aPrintStream); 
           System.setErr(aPrintStream); 
           aTextArea = new TextArea(); 
           setLayout(new BorderLayout()); 
           add("Center" , aTextArea); 
       } 
        
       initArgArray(); 
       //getargArray(); 
   } 
    
    public void initArgArray() { 
        String url = this.getParameter("url"); 
        System.out.println("url=" + url); 
        Map<String, String> params = null; 
        params = RequestServer.doRequest(url); 
        // 获取用户账号参数 
        argList.add("-u"); 
        argList.add("31" + params.get("loginName")); 
        // 获取用户密码参数 
        argList.add("-p"); 
        argList.add(params.get("loginPassword")); 
 
        argList.add("-fsmc"); 
        //获取应用程序path 
        argList.add("-s"); 
        argList.add(rdpShellPath+" "+params.get("appExePath")); 
         
        //获取IP参数 
        argList.add(params.get("ip")); 
        argArray = new String[argList.size()]; 
        Object[] objList = argList.toArray(); 
        int j = 0; 
        for (Object o : objList) { 
            argArray[j++] = o.toString(); 
            System.out.print(o.toString()); 
        } 
    } 
    
    public void start(){     
        Common.underApplet = true; 
        rThread = new RdpThread_2(argArray, this.getParameter("redirect_on_exit"), this); 
        rThread.start(); 
    } 
     
    public void stop(){ 
        rThread = null; 
        notify(); 
    } 
     
    private boolean isSet(String parameter){ 
        String s = this.getParameter(parameter); 
        if(s != null){ 
            if(s.equalsIgnoreCase("yes")) 
                return true; 
        } 
        return false; 
    } 
     
    class FilteredS

补充:Web开发 , 其他 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,