三天没人应啊!!!!这是csdn吗?....................斑长大人呢。

解决方案 »

  1.   

    选择文件名可以用
    <object id="fileDialog" width="0px" height="0px" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
    </object>
    <textarea id=TxtBody style="background-color:#EEEEEE;width:100%;height:100">无标题</textarea>
    <br>
    <input type=button value=加载 onclick="loadDoc()">
    <input type=button value=保存 onclick="saveDoc()">
    <script>
    function loadDoc()
    {
    fileDialog.CancelError=true;
        try{
        fileDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt";
         fileDialog.ShowOpen();
        var fso=new ActiveXObject("Scripting.FileSystemObject");
        var reading=1;
        var f=fso.OpenTextFile(fileDialog.filename,reading);
        //window.confirm(f);
        var r=f.ReadAll();
        f.close();
        TxtBody.value=r;
        }catch(e){}
    }
    function saveDoc()
    {
    fileDialog.CancelError=true;
       try{
       fileDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt";
       fileDialog.ShowSave();
       var fso=new ActiveXObject("Scripting.FileSystemObject");
       var f=fso.CreateTextFile(fileDialog.filename,true);
       f.write(TxtBody.value);
       f.Close();
       }
       catch(e){}
    }
    </script>
    </body>
      

  2.   

    Applet是在客户端运行的,需要从服务器下载
    用<Applet>标签就可以自动下载发布Applet
    零:打包
    jar -cvf *.jar *
    一:数字签名Key
    keytool -genkey -alias DigitalTitanKey -keystore DigitalTitanStore
    ?
    DigitalTitan
    ?
    DigitalSky
    ?
    DigitalSky
    ?
    CityBy
    ??
    CN
    ?
    Y
    ?
    password
    二:数字签名
    jarsigner -keystore DigitalTitanStore *.jar DigitalTitanKey
      

  3.   

    给你个例子
    package Excel;import java.io.*;
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    import java.applet.*;
    public class Excel extends Applet
    {
    LayoutManager DC_Layout;
    TextField m_FileName;
    TextField m_Directory;
    Button m_Action_Open;
    Button m_Action_Save;
    Frame m_Frame=new Frame();
    public void init()
    {
    //运行程序开始
    Runtime runTime=Runtime.getRuntime();
    Process process;
    try
    {
    process=runTime.exec("notepad");
    /*
    InputStreamReader inputStreamReader=new InputStreamReader(process.getInputStream());
    LineNumberReader input=new LineNumberReader(inputStreamReader);
    String strLine;
    while((strLine=input.readLine())!=null)
    {
    JOptionPane.showMessageDialog(this,strLine);
    }
    */
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(this,e.getMessage());
    }
    finally
    {
    //JOptionPane.showMessageDialog(this,"Finally...");
    }
    //运行程序结束
    String strURL=getParameter("ExcelURL");
    //
    AudioClip audioClip=getAudioClip(getCodeBase(),strURL);
    audioClip.play();
    audioClip.stop();
    audioClip.loop();
    //
    //play(getCodeBase(),strURL);
    //
    setBackground(Color.white);
    DC_Layout=new FlowLayout(FlowLayout.LEFT,10,5);
    setLayout(DC_Layout);
    m_FileName=new TextField(20);
    add(m_FileName);
    m_Directory=new TextField(20);
    add(m_Directory);
    m_Action_Open=new Button("打开");
    add(m_Action_Open);
    m_Action_Save=new Button("另存");
    add(m_Action_Save);
    CreateLocalFile("C:\\Temp.txt");
    ReadURL(strURL);
    }
    public boolean action(Event e,Object arg)
    {
    if(e.target instanceof Button)
    {
    if("打开".equals(e.arg))
    {
    FileDialog fileDialog=new FileDialog(m_Frame,"打开什么文件?");
    fileDialog.setFile("*.doc");
    fileDialog.setDirectory(".");
    fileDialog.show();
    String strOpenFile;
    if((strOpenFile=fileDialog.getFile())!=null)
    {
    m_FileName.setText(strOpenFile);
    m_Directory.setText(fileDialog.getDirectory());
    try
    {
    this.getAppletContext().showDocument(new java.net.URL("javascript:window.open('','','channelmode');"));
    }
    catch(Exception error)
    {}
           }
    else
    {
            m_FileName.setText("取消");
    m_Directory.setText("");
    }
    return true;
    }
    if("另存".equals(e.arg))
    {
    FileDialog fileDialog=new FileDialog(m_Frame,"另存什么文件?");
    fileDialog.setFile("*.doc");
    fileDialog.setDirectory(".");
    fileDialog.show();
    String strSaveFile;
    if((strSaveFile=fileDialog.getFile())!=null)
    {
    m_FileName.setText(strSaveFile);
    m_Directory.setText(fileDialog.getDirectory());
           }
    else
    {
            m_FileName.setText("取消");
    m_Directory.setText("");
    }
    return true;
    }
    }
    return false;
    }
    public void CreateLocalFile(String strFileName)
    {
    File m_File=new File(strFileName);
    try
    {
    m_File.createNewFile();
    JOptionPane.showMessageDialog(this,"成功创建本地文件...");
    }
    catch(Exception error)
    {
    JOptionPane.showMessageDialog(this,error.getMessage());
    }
    }
    public void ReadURL(String strURL)
    {
    try
    {
    int iHttpResult;
    URL m_URL=new URL(strURL);
    URLConnection m_URLConn=m_URL.openConnection();
    m_URLConn.connect();
    HttpURLConnection m_HttpConn=(HttpURLConnection)m_URLConn;
    iHttpResult=m_HttpConn.getResponseCode();
    if(iHttpResult!=HttpURLConnection.HTTP_OK)
    JOptionPane.showMessageDialog(this,"无法连接...");
    else
    {
    int iFileSize=m_URLConn.getContentLength();
    InputStreamReader m_Reader=new InputStreamReader(m_URLConn.getInputStream());
    char[] Buffer=new char[2048];
    int iNum=0;
    while(iNum>-1)
    {
    iNum=m_Reader.read(Buffer);
    if(iNum<0)break;
    //JOptionPane.showMessageDialog(this,new String(Buffer,0,iNum));
    }
    m_Reader.close();
    }
    }
    catch(Exception e)
    {
    JOptionPane.showMessageDialog(this,e.getMessage());
    }
    }
    }
      

  4.   

    Applet可以象activex那样一次安装,多次使用???怎么做?
      

  5.   

    谢谢各位!!!
    我说的二星是两个小三角即可。可能误会了。
    可否请问一下gjd111686(数字金刚),
    那个applet可以做到用JavaScript控制吗?
    可否给个例子?
    多谢了。
      

  6.   

    控件弹出一个选择本地文件的对话框,让用户选择文件?
    弹出这个对话框不用怎么麻烦吧?
    用<input type=File Name="FileName" >不就可以弹出来了嘛。
    自己想要实现的功能说明一下,象applet Activex之类普通用户怎么会愿意运行,
    谁知道里面会不会有病毒
      

  7.   

    自己想要实现不仅选择文件,而且可以选择多个文件,还可以选择目录。怎么用applet实现?数字签名我己经试成功了。就是同意签名后,applet可以读本地的文件系统。
    但没有办法实现以下功能:1:运行时让applet隐藏起来,然后用JavaScript来调用applet,如让applet弹出一个对话框,提示用户选择文件等。
    2:applet很大时,在页面提示一个安装进度条,也没法实现。如何做?请各位指点。再次说明:
            小弟大意,我指的两星指两个小三角。
            请各位帮助。
      

  8.   

    Applet不可能的。已经被ms的浏览器视为不安全的了。
      

  9.   

    applet当然可以由javascript来控制!
    给applet赋一个name或id,然后就可以调用它的方法了,例如
    <applet name="a">
    ...<script>
    function f(){
      document.all.a.method();
    }
    </script>
      

  10.   

    <applet name="aaa">
    ...<script>
    function f(){
      document.all.aaa.method();
    }
    </script>
    applet中的方法必须声名为public