Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Red face Applet not working

    i had done a small applet program in which i want to move my alphabet A horizontally

    but i m getting an error like dis
    symbol : constructor Thread(priyas)
    location: class java.lang.Thread
    t=new Thread(this);

    my program is
    Java Code:
    import java.applet.*;
    import java.awt.*;
    /*
    <applet code=priyas width=500 height=500>
    </applet>
    */
    
    public class priyas extends Applet 
    {
      int x;int y;
      Thread t=null;
       
     
    
    public void run()
    {
    for(;;)
    {
     try
     {
      repaint();
     Thread.sleep(0);
            if(x<392)
             x++;
                    else
                    x=7;
    }
    
    catch(Exception e)
    {
    }
     }
    }
    
    
      public void init()
      {
       setBackground(Color.black);
       Font f=new Font("Comic Sans",Font.BOLD,32);
       setFont(f);
    t=new Thread(this);
       t.start();
      }
    
    
      public void paint(Graphics g)
      {
       g.setColor(Color.white);
        g.drawRect(4,178,72,10);
        g.drawRect(402,10,6,110);
        g.drawRect(254,310,10,379);
        g.drawRect(405,310,85,10);
       g.drawString("A",19,110);
       g.drawString("B",111,379);
       g.drawString("C",416,393);
        
         
        showStatus("Bouncing Alphabets");
      }
    }
    please try to help me out to perform this applet to work

  2. #2
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default

    i dont know what is the problem java forum people are not replying to my thread posted

  3. #3
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    As you are creating a Thread object in this class and overriding run method in he same class, you need to implement Runnable interface

    Java Code:
    import java.applet.*;
    import java.awt.*;
    /*
    <applet code=priyas width=500 height=500>
    </applet>
    */
    
    public class priyas extends Applet  implements Runnable
    {
      int x;int y;
      Thread t=null;
    
    
    
    public void run()
    {
    for(;;)
    {
     try
     {
      repaint();
     Thread.sleep(0);
            if(x<392)
             x++;
                    else
                    x=7;
    }
    
    catch(Exception e)
    {
    }
     }
    }
    
    
      public void init()
      {
       setBackground(Color.black);
       Font f=new Font("Comic Sans",Font.BOLD,32);
       setFont(f);
    t=new Thread(this);
       t.start();
      }
    
    
      public void paint(Graphics g)
      {
       g.setColor(Color.white);
        g.drawRect(4,178,72,10);
        g.drawRect(402,10,6,110);
        g.drawRect(254,310,10,379);
        g.drawRect(405,310,85,10);
       g.drawString("A",19,110);
       g.drawString("B",111,379);
       g.drawString("C",416,393);
    
    
        showStatus("Bouncing Alphabets");
      }
    }

  4. #4
    Join Date
    Mar 2009
    Posts
    51
    Rep Power
    0

    Default

    but my alphabets are just blinking but not moving

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by jyothi.priyanka View Post
    i dont know what is the problem java forum people are not replying to my thread posted
    I agree. The customer service here is terrible. I'm asking for a refund.

  6. #6
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    Thats a logical error, you should try yourself first. We are always here to help you.

Similar Threads

  1. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 12:54 PM
  2. Shape drawing applet not working...
    By evapisces in forum Java Applets
    Replies: 0
    Last Post: 11-17-2008, 11:46 PM
  3. Replies: 8
    Last Post: 05-28-2008, 07:00 AM
  4. Applet button not working
    By letmeoutofhere in forum Java Applets
    Replies: 9
    Last Post: 11-14-2007, 12:15 PM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 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
  •