Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-15-2009, 03:30 PM
Member
 
Join Date: Mar 2009
Posts: 34
Rep Power: 0
jyothi.priyanka is on a distinguished road
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
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-15-2009, 03:42 PM
Member
 
Join Date: Mar 2009
Posts: 34
Rep Power: 0
jyothi.priyanka is on a distinguished road
Default
i dont know what is the problem java forum people are not replying to my thread posted
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-15-2009, 04:17 PM
Senior Member
 
Join Date: Dec 2008
Posts: 164
Rep Power: 2
dswastik is on a distinguished road
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

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");
  }
}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-15-2009, 05:04 PM
Member
 
Join Date: Mar 2009
Posts: 34
Rep Power: 0
jyothi.priyanka is on a distinguished road
Default
but my alphabets are just blinking but not moving
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-15-2009, 10:15 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,487
Rep Power: 8
Fubarable is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-16-2009, 09:18 AM
Senior Member
 
Join Date: Dec 2008
Posts: 164
Rep Power: 2
dswastik is on a distinguished road
Default
Thats a logical error, you should try yourself first. We are always here to help you.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling another applet on click of button in one applet niteshwar.bhardwaj Java 2D 1 02-19-2009 01:54 PM
Shape drawing applet not working... evapisces Java Applets 0 11-18-2008 12:46 AM
Java mail problem(working in intranet,but not working in iternet) sundarjothi Advanced Java 8 05-28-2008 08:00 AM
Applet button not working letmeoutofhere Java Applets 9 11-14-2007 01:15 PM
Applet, To center text and To open I engage in a dialog in an Applet Marcus Java Applets 4 06-08-2007 07:15 AM


All times are GMT +2. The time now is 05:17 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org