我的程序是在主程序里面设计了一个按钮,点开按钮就会打开一个网页。
这个网页里面会显示我的应用程序的一些信息。我写一个JApplet的类,里面有一些参数是要用到我的程序的运行结果,然后再显示在html上。
于是我在我的主程序里面调用了这个JApplet类,希望每次都是一个新建的里面包含了主程序的参数网页。现在的问题是, 实际上我打开一个嵌入applet的网页的时候,这个网页只是装入了applet,但是这个JApplet类并不是我的主程序里面运行的得到了参数的类,
实际上每次打开的网页都是没有内容的同一个网页。高手们帮帮忙,怎样才能在我的主程序里面调用JApplet类动态的生成applet呢?

解决方案 »

  1.   

    这个是我写的JApplet的类,里面实际上需要用的参数都是主程序提供的。public class CourseViewer extends JApplet {    public Vector seqLs = new Vector();
        public Vector seqLo = new Vector();
        public void loViewer(String cn)
        {
            String courseFileName;
            courseFileName = cn;
            Onto courseOnto = new Onto(courseFileName);
            seqLs = courseOnto.getSeqLs();
            System.out.println(seqLs);
            for (int i = 0; i < seqLs.size(); i++) 
            {            seqLo = courseOnto.getSeqLo(seqLs.get(i).toString());
            }
        }
        public void init() {           Box box= Box.createVerticalBox();
               ButtonGroup group = new ButtonGroup();
               for(int i =0; i<seqLs.size();i++)
               {
                   JRadioButton button = new JRadioButton(seqLs.get(i).toString());
                   box.add(button);
                   group.add(button);
                   JLabel label =  new JLabel(seqLs.get(i).toString());
                     add(label);
               }
               
               add(box);    }
       public void start()
       {
       }
    }下面是我的主程序里面调用的代码,但是感觉没用啊,好像每次网页装载applet都是只读取JApplet类的内容而已,跟主程序没任何交流。
    我实际期望的是在主程序中得到参数,生成applet,然后网页在加载这个applet。private void courseHtml(java.awt.event.ActionEvent evt) {                            
     CourseViewer cv = new CourseViewer();
     cv.loViewer(fileNameOut3);
     cv.init();
     cv.start();
    //如何在这里能调用JApplet得到参数呢
        
        String   exe   =   "C:\\Program Files\\Internet Explorer\\iexplore.exe " + "C:\\Users\\memo\\Desktop\\final\\course\\build\\mainPage.html";   
       try{   
      Runtime   rt = Runtime.getRuntime();   
      rt.exec(exe);     
      }   
      catch(Exception   e)   
      {   
      }  
    }
      

  2.   

    还是说我的思路有问题呢?JApplet类只能加载一次,不能在主程序中调用?