Results 1 to 4 of 4
  1. #1
    paulious is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default Converting netbeans app to applet

    Hi, i'm writing a tictactoe game for uni course and am trying to implement it in a browser to run as an applet. The Java console produces there errors..

    ava.lang.ClassCastException: gui.Frame cannot be cast to java.applet.Applet
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassCastException: gui.Frame cannot be cast to java.applet.Applet


    I have changed the closeonexitprocedure to none, this was causing a problem with security violation. I believe my problem now is that i need to extend my frame class with Applet, but not quite sure how :( Any help would be great, i'll post only a section of my code as i think the problem lies with defining the class inheritence.

    package gui;

    import javax.swing.*;

    import logic.*;
    import java.applet.Applet;


    public class Frame extends javax.swing.JFrame
    {
    boolean playerOne = true;
    private Facade facade;
    int p1score = 0;
    int p2score = 0;

    private boolean[ ][ ] clicked;
    /** Creates new form Frame */
    public Frame() {

    initComponents();
    setLocation(100,100);
    setSize(400, 300);

    facade = new Facade();

    clicked = new boolean[ 3 ][ 3 ];

    for( int row = 0; row < 3; row++ )
    {
    for( int column = 0; column < 3; column++ )
    {
    clicked[ row ][ column ] = false;
    }
    }



    }

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    You cannot do this. As error message says JFrame cannot convert into an Applet. Implement your code in an Applet. Since you are working on NetBeans it's so easy.

  3. #3
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Once you have it working as an applet, convert it to something vaguely useful, like Javascript. Applets are so last century

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by fishtoprecords View Post
    Once you have it working as an applet, convert it to something vaguely useful, like Javascript. Applets are so last century
    I know this is not related question here. So I'm not expecting to hang on for a long discussion.

    Is there any simple way to do this conversion lol?

Similar Threads

  1. converting jar to .class or .java
    By marmara95 in forum New To Java
    Replies: 12
    Last Post: 10-06-2012, 10:49 PM
  2. Converting a Collection to an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:44 PM
  3. Converting URL to URI
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 10:15 AM
  4. Converting a byte[] into Sound
    By savage82 in forum Advanced Java
    Replies: 1
    Last Post: 11-21-2007, 11:57 PM
  5. help with converting to JApplet
    By Simmy in forum AWT / Swing
    Replies: 2
    Last Post: 08-09-2007, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •