Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

There are a lot of resources on this already but I just can't seem to get it to work. What am I doing wrong? The jar file is at:

http://www.alexandertechniqueatlantic.ca/multimedia/AT-web-presentation-imp.jar

And the code I am using to embed is:

<APPLET ARCHIVE="multimedia/AT-web-presentation-imp.jar" 
        CODE="ImpViewer.class" 
        WIDTH=100% 
        HEIGHT=100%>
</APPLET>

The test page I am using is at:

http://www.alexandertechniqueatlantic.ca/test.php

When I download the jar it runs fine, so I am certain the problem is only with the html embedding. Pleas help!

Also, I get the following error:

java.lang.ClassCastException: ImpViewer cannot be cast to java.applet.Applet

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
95 views
Welcome To Ask or Share your Answers For Others

1 Answer

java.lang.ClassCastException: ImpViewer cannot be cast to java.applet.Applet

The 'applet' is not an applet.

BTW - nice UI. Like the way the red splash fades in to the 'Welcome Introductory Workshop' page. Very smooth.

Launch it from a link using Java Web Start (& please don't try and cram such a beautiful UI into a web page).


If the client insists on the GUI being crammed into a web site then (slap them for me &) try this hack.

/*
<APPLET 
    ARCHIVE="AT-web-presentation-imp.jar" 
    CODE="ImpViewerApplet" 
    WIDTH=720 
    HEIGHT=564>
</APPLET>
*/
import java.awt.*;
import java.applet.*;
import java.util.*;

public class ImpViewerApplet extends Applet {

    public void init() {
        setLayout(new BorderLayout());
        Window[] all = Window.getWindows();
        ArrayList<Window> allList = new ArrayList<Window>();
        for (Window window : all) {
            allList.add(window);
        }
        String[] args = {};
        ImpViewer iv = new ImpViewer(); 
        iv.main(args);

        all = Window.getWindows();
        for (Window window : all) {
            if (!allList.contains(window) && window.isVisible()) {
                if (window instanceof Frame) {
                    Frame f = (Frame)window;
                    Component[] allComp = f.getComponents();
                    Component c = f.getComponents()[0];
                    f.remove(c);
                    f.setVisible(false);
                    add(c);
                    validate();
                }
            }
        }
    }
}

The emphasis is on the word 'hack'.

  1. The Frame will flash onto screen before disappearing.
  2. It will only work at 720x564 px, unlike the java.awt.Frame which was resizable to any size. But then, your '100%' width/height was being a bit optimistic anyway. Some browsers will honour those constraints, others will not.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...