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.ClassCastExcepti on: 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.IllegalArgumentE xception: 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?
I added to a webpage and Netscape brings up the message
"Applet GameFrame Exeption: java.lang.ClassCastExcepti
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.IllegalArgumentE
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello?
A Frame is not an Applet
A Frame is a window, like IE, or Windows Explorer
An applet is embeddable indside things
> java.lang.ClassCastExcepti
Netscape don't lie (much) ;-)