?
Solved

Applet not an applet in browser?

Posted on 2003-03-04
3
Medium Priority
?
224 Views
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");
          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?
0
Comment
Question by:itbeme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 35

Expert Comment

by:TimYates
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) ;-)
0
 
LVL 35

Accepted Solution

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

not JFrame
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8070481
Hello?
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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