Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Applet not an applet in browser?

Posted on 2003-03-04
Medium Priority
Last Modified: 2013-12-29
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");

public class LineGame extends JPanel implements MouseListener,

public LineGame ()

      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?
Question by:itbeme
  • 3
LVL 35

Expert Comment

ID: 8065715
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) ;-)
LVL 35

Accepted Solution

TimYates earned 100 total points
ID: 8065722
you want to extend either "Applet" (for AWT applet) or "JApplet" (for swing applet)

not JFrame
LVL 35

Expert Comment

ID: 8070481

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question