Results 1 to 3 of 3
  1. #1
    gallathrijani is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Thumbs up Usage of THREADS IN APPLET

    Run it!

    import java.applet.*;
    import java.awt.*;
    /*<applet code="MyMessage" width=1120 height=537>
    </applet>*/
    public class MyMessage extends Applet implements Runnable
    {
    Thread t1;
    Color c;
    int i=-1,j,count=1,k,y=1,temp;
    public void init()
    {
    c=new Color(0,34,0);
    setBackground(c);
    c=new Color(255,255,170);
    setForeground(c);
    Font f=new Font("Britannic Bold",Font.ITALIC,30);
    setFont(f);
    }
    public void start()
    {
    t1=new Thread(this);
    t1.start();
    }
    public void paint(Graphics g1)
    {
    Graphics2D g=(Graphics2D)g1;
    g.setStroke(new BasicStroke(11));
    g.drawLine(120,187,120,380);
    g.drawLine(120,220,78,320);
    g.drawLine(120,220,175,250);
    g.drawLine(175,250,170,180);
    g.drawLine(120,380,80,500);
    g.drawLine(120,380,160,500);
    if(i>=711)
    {
    temp=i;
    i=711;
    }
    if(k==1)
    {
    g.drawLine(120+j,150+j,200+j,200+j);
    count++;
    j++;
    }
    else if(k==0)
    {
    g.drawLine(170-j,200-j,250-j,250-j);
    count--;
    j++;
    }
    g.drawOval(944-i,70,80,117);
    g.drawLine(984-i,187,984-i,380);
    g.drawLine(984-i,220,1024-i,330);
    g.drawLine(984-i,380,944-i,500);
    g.drawLine(984-i,380,1024-i,500);
    if(temp>=711)
    {
    i=temp;
    g.drawLine(273,220,160-y+5,130);
    g.drawOval(70,70+y,100-y,117);
    y++;
    if(i==834)
    g.drawString("SMOKING IS INJURIOUS TO HEALTH",550,200);
    }
    else
    {
    g.drawOval(70,70,100,117);
    g.drawLine(984-i,220,944-i,330);
    }
    g.drawString("SMOKER",60,50);
    }
    public void run()
    {
    repaint();
    for(j=1,i=0;i<=834;)
    {
    try
    {
    if(count==50)
    {
    j=1;
    k=0;
    }
    else if(count==1)
    {
    j=1;
    k=1;
    }
    repaint();
    t1.sleep(20);
    }catch(InterruptedException ie){}
    i=i+3;
    }
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Usage of THREADS IN APPLET

    Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    Did you have a question that you forgot to ask?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Default Re: Usage of THREADS IN APPLET

    Quote Originally Posted by DarrylBurke View Post
    Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    Did you have a question that you forgot to ask?

    db
    Thank you.

Similar Threads

  1. CPU usage without JNI
    By Eranga in forum Advanced Java
    Replies: 2
    Last Post: 12-13-2011, 02:25 AM
  2. Threads per Connection or Threads per Request
    By Felic in forum New To Java
    Replies: 4
    Last Post: 11-22-2011, 09:15 PM
  3. Popup usage: SwingWorker Threads?
    By Majin in forum AWT / Swing
    Replies: 1
    Last Post: 07-15-2011, 04:58 AM
  4. how to make an applet to creat threads in the server
    By paralax24 in forum Java Applets
    Replies: 0
    Last Post: 05-07-2011, 01:42 PM
  5. JProfiler 6.2.2 usage help
    By astrophyster in forum Advanced Java
    Replies: 0
    Last Post: 03-31-2011, 08:09 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
  •