浏览器没装JRE插件,不需Tomcat应该也能运行才对。

解决方案 »

  1.   

    applet不需要在tomcat下面运行啊,在html里面就可以用了,新建立一个.html的文件,然后把编译过后的.class加载在里面就可以了,另外用 appletviewer.exe就可以运行applet文件了
      

  2.   

    现在能播放了,但是applet不能自动刷新,播放时要最小化再显示才能看到播放的图像。
      

  3.   


    public class PinjuanApplet extends Applet implements
    ControllerListener
    {
      private boolean isStandalone = false;
      Player player;
      Component visualcom, controlcom;
      boolean playType;
      String currentDirectory;
      JPanel jPanelVideo = new JPanel();
       JPanel jPanelCont=new JPanel();
      BorderLayout borderLayout2 = new BorderLayout();
      BorderLayout borderLayout1 = new BorderLayout();
      JButton jb=new JButton("播放");
      int record=0;
      public PinjuanApplet() {
      }
      public void init() {
        try {      jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      private void jbInit() throws Exception {
        this.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setVisible(true);
        this.setBackground(new Color(0,0,0));
        playType=false;
        jPanelVideo.setToolTipText("视频窗口");
        jPanelVideo.setVerifyInputWhenFocusTarget(true);
        jPanelVideo.setLayout(borderLayout2);
        jb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              jbAction(e);
            }}
    );
          jb1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              jb1Action(e);
            }}
    );
        jb.setSize(200,30);
        jPanelCont.add(jb);
        this.add(jPanelVideo, BorderLayout.CENTER);
        this.add(jPanelCont,BorderLayout.SOUTH);
      }
      public void jbAction(ActionEvent e)
      {
        playType=true;
        record=0;
        boFangControl();
      }
      public void boFangControl() {
        int kid;
        Vector mtype=new Vector();
        Vector mcontent=new Vector();
        mtype.add(new Integer(1));
        mtype.add(new Integer(5));
        mtype.add(new Integer(1));
        if(record>=mtype.size()) return;
          int flag = ( (Integer) mtype.elementAt(record)).intValue();
            if (flag == 1) {
              //showText((String) mcontent.elementAt(record));
              showText("意思xxxxx");
            }
            if (flag == 4 || flag == 5) {
              showMedia();
            }
      }
      public void showText(String show)
      {
        record++;
        repaint();
        TextArea tarea=new TextArea(show,5,20);
        jPanelVideo.add(tarea, BorderLayout.CENTER );
        jPanelVideo.show();
        this.add(jPanelVideo, BorderLayout.CENTER);
        repaint();
        try{
          Thread.sleep(30000);
        }catch(Exception ex){}
        jPanelVideo.remove(tarea);
        boFangControl();
      }
      public void showMedia()
      {
        record++;
        String s2="1.mpg";
        if (player != null)
          player.close();
        try {
          player = Manager.createPlayer(new MediaLocator
                                        ("file:/"+"d:/"+s2));
        }
        catch (java.io.IOException e2) {
          System.out.println(e2);
          return;
        }
        catch (NoPlayerException e2) {
          System.out.println("不能找到播放器.");
          return;
        }
        if (player == null) {
          System.out.println("无法创建播放器.");
          return;
        }
        player.addControllerListener ( this );
        player.prefetch();  }
      public void controllerUpdate (ControllerEvent e)
      {
    // 调用player.close()时ControllerClosedEvent事件出现。
    // 如果存在视觉部件,则该部件应该拆除(为一致起见,
    // 我们对控制面板部件也执行同样的操作)
        if (e instanceof ControllerClosedEvent) {
          if (visualcom != null) {
            jPanelVideo.remove(visualcom);
            visualcom = null;
          }
          if (controlcom != null) {
            jPanelVideo.remove(controlcom);
            controlcom = null;
          }
          return;
        }
        if (e instanceof EndOfMediaEvent) {
          if(player!=null)
            player.close();
          if (visualcom != null) {
          jPanelVideo.remove(visualcom);
          visualcom = null;
        }
        if (controlcom != null) {
          jPanelVideo.remove(controlcom);
          controlcom = null;
        }
        //this.remove(jPanelVideo);
        boFangControl();
          return;
        }
        if (e instanceof PrefetchCompleteEvent) {
          player.start();
          return;
        }
          if (e instanceof RealizeCompleteEvent) {
          visualcom = player.getVisualComponent();
          if (visualcom != null)
            jPanelVideo.add(visualcom, BorderLayout.CENTER );
          controlcom = player.getControlPanelComponent();
       if (controlcom != null)
         jPanelVideo.add(controlcom, BorderLayout.SOUTH );
         //this.add(jPanelVideo,BorderLayout.CENTER);
          repaint();
        }
      }}
      

  4.   

    放到网页中要有java虚拟机才能正常显示,你装了吗?