Link to home
Start Free TrialLog in
Avatar of itbeme
itbeme

asked on

Applet not an applet in browser?

I developed a swing applet that runs under MS J++.
I added to a webpage and Netscape brings up the message
"Applet GameFrame Exeption: java.lang.ClassCastException: GameFrame is not an applet"

GameFrame is the class that is loaded when program starts and has the main() function and the swing menu, JFrame layout and stuff.

IE brings up "exception: java.lang.IllegalArgumentException: adding a window to a container"

Here are some parts of class files that might be relevant

public class GameFrame extends JFrame
                      implements ActionListener, ItemListener
{


public static void main(String[] args)
     {
          GameFrame window = new GameFrame();
        window.setTitle("The Line Game");
          window.setResizable(false);
          window.pack();
          window.show();    
         
     }






public class LineGame extends JPanel implements MouseListener,
                                                MouseMotionListener
{


public LineGame ()
   {
        newgame();
        gamerunner();

           
      drawnItems = new Vector();
       compLines = new Vector();
       

      setBackground (Color.white);
      setMinimumSize (new Dimension(DRAWAREA, DRAWAREA));
      setPreferredSize (new Dimension(DRAWAREA, DRAWAREA));//DRAWAREA = 250
       setMaximumSize (new Dimension(DRAWAREA, DRAWAREA));


      addMouseListener (this);
      addMouseMotionListener (this);
   }

//I do not import java.applet.*; under Gameframe, if that makes a difference, and if it does I don't know the syntax to extend both JFrame and Applet.  Do I need to recode something or launch differently on web page?
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

You have made a JFrame, not a JApplet

A Frame is not an Applet

A Frame is a window, like IE, or Windows Explorer

An applet is embeddable indside things

> java.lang.ClassCastException: GameFrame is not an applet

Netscape don't lie (much) ;-)
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello?