Friday, 6 May 2022

B) Write a java program in multithreading using applet for drawing flag.


DOWNLOAD    "Slip2Q2"


TO RUN CODE 
STEP 1    javac Slip2Q2.java
STEP 2    appletviewer Slip2Q2.java

CODE:

import java.applet.Applet;
import java.awt.*;

/**
* Created by : Amar Ghugare
* created on : 20-05-2022 18:16
* Purpose of class :
* Write a java program in multithreading
* using applet for drawing flag.
*/
public class Slip2Q2 extends Applet implements Runnable{
Thread t = null;
public void paint(Graphics g){

for (int i = 450;i >= 100; i-=10){
g.drawLine(100,400,100,i);
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
for(int i = 100; i <=300;i+=10){
g.drawLine(100,100,i,100);
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
for(int i = 100; i<=250;i+=10){
g.drawLine(300,100,300,i);
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
for(int i = 300; i >=100;i-=10){
g.drawLine(250,250,i,250);
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
}
g.setColor(new Color(255,153,5));
g.fillRect(100, 100, 200, 50);

g.setColor(new Color(255,255,255));
g.fillRect(100, 150, 200, 50);


g.setColor(new Color(19,136,8));
g.fillRect(100, 200, 200, 50);

g.setColor(Color.BLACK);
g.drawRect(100, 100, 200, 150);

g.drawLine(0, 450, 500, 450);
g.setColor(Color.BLUE);
g.drawArc(175,150,50,50,0,360);

}
public void start() {
t = new Thread( this );
t.start();
}
@Override
public void run() {
repaint();
}
}
/*
<applet code="Slip2Q2.class" width="500" height="500">
</applet>
*/

No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...