Results 1 to 2 of 2
Thread: Usage of THREADS IN APPLET
- 10-30-2012, 05:45 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
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;
}
}
}
- 10-30-2012, 08:16 PM #2
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?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
CPU usage without JNI
By Eranga in forum Advanced JavaReplies: 2Last Post: 12-13-2011, 02:25 AM -
Threads per Connection or Threads per Request
By Felic in forum New To JavaReplies: 4Last Post: 11-22-2011, 09:15 PM -
Popup usage: SwingWorker Threads?
By Majin in forum AWT / SwingReplies: 1Last Post: 07-15-2011, 04:58 AM -
how to make an applet to creat threads in the server
By paralax24 in forum Java AppletsReplies: 0Last Post: 05-07-2011, 01:42 PM -
JProfiler 6.2.2 usage help
By astrophyster in forum Advanced JavaReplies: 0Last Post: 03-31-2011, 08:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks