Results 1 to 3 of 3

Thread: Applets

  1. #1
    MBD
    MBD is offline Member
    Join Date
    Sep 2011
    Location
    Sale, Cheshire
    Posts
    10
    Rep Power
    0

    Default Applets

    Hi, I get a ClassNotFound Exception each time I try to run this applet, is it because I have added the applet code to the code source file rather than creating a separate html file? any help would be appriciated, thanks. MBD.

    Java Code:
    import java.awt.*;
    import java.applet.*;
    
    <applet code="Banner" width=300 height=50>
    </applet>
    
    
    public class Banner extends Applet implements Runnable {
    	String msg = " Java Rules the Web ";
    	Thread t;
    	boolean stopFlag;
    	
    
    public void init() {			// Initialize t to null.
    	t = null;
    	}
    
    
    public void start() {			// Start the thread.
    	t = new Thread(this);
    	stopFlag = false;
    	t.start();
    	}
    
    
    public void run() {			// Entry point for thr Thread
    	char ch;			// that runs the Banner.
    	for( ; ; ) {			// Display Banner.				
    	   try {
    	      repaint();
    	      Thread.sleep(250);
    	      ch = msg.charAt(0);
    	      msg = msg.substring(1, msg.length());
    	      msg += ch;
    	      if(stopFlag)
    		break;
    	      } catch(InterruptedException exc) { }
    	   }
    	}
    
    
    public void stop() {			// Pause the Banner.
    	stopFlag = true;
    	t = null;
    	}
    
    
    public void paint(Graphics g) {		// Display the Banner.
    	g.drawString(msg, 50, 30);
    	}
       }

  2. #2
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Applets

    Applets is not my strong side but where is the main method?
    Anyway there is a section for Java Applets

  3. #3
    ozyhale is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Applets

    Applets dont have a main method :D use the init() method instead

Similar Threads

  1. Applets
    By rdjava in forum Advanced Java
    Replies: 2
    Last Post: 01-27-2011, 12:07 AM
  2. New to Applets
    By Psyclone in forum Java Applets
    Replies: 8
    Last Post: 02-28-2010, 04:00 AM
  3. I need help with Applets
    By ProgrammingPup in forum Advanced Java
    Replies: 1
    Last Post: 12-22-2009, 08:07 PM
  4. Can't see any Applets
    By pyr0chem in forum Java Applets
    Replies: 9
    Last Post: 12-17-2008, 04:24 AM
  5. applets on mac what´s going on?
    By willemjav in forum Java Applets
    Replies: 6
    Last Post: 04-19-2008, 07:03 PM

Posting Permissions

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