Monday, March 26, 2018

How To Draw All shapes in java Program

This Program Is How To Draw Different Shapes In Java


package a;
import java.*;
import java.applet.*;
import java.awt.*;
import java.awt.color.*;
/*
 * <applet code="allshape.class" width=100 height=100>
 * </applet>
 * */
public class allshape extends Applet implements Runnable
{

String msg="moving Banner";
char cha;
boolean stopFlag=true;
Thread t=null;
public void start()
{
t=new Thread(this);
stopFlag=false;
t.start();
}
public void run()
{
for(;;)
{
try
{
repaint();
Thread.sleep(250);
cha=msg.charAt(3);
msg=msg.substring(1,msg.length());
}
catch(InterruptedException e)
{

}
}
}
public void stop()
{
stopFlag=true;
t=null;
}
public void paint(Graphics g)
{
g.drawLine(5, 100, 300, 100);
g.drawLine(5, 200, 300, 200);
g.drawLine(100, 5, 100, 300);
g.drawLine(200, 5, 200, 300);
g.drawOval(25, 30, 50, 50);
g.drawRect(125, 40, 60, 50);
g.setColor(Color.red);
g.fillRoundRect(210, 25, 80, 50, 25, 25);
g.fillOval(5, 125, 75, 40);
g.setColor(Color.black);
g.drawLine(200, 200, 100, 100);
g.drawArc(225, 125, 100, 100, 50, 150);

g.setColor(Color.red);
g.drawLine(15, 300, 75, 300);
g.drawLine(15, 300, 35, 250);
g.drawLine(35, 250, 75, 300);
g.setColor(Color.black);
g.drawString("vvp", 125, 250);
g.drawString(msg, 225, 250);


}
}

No comments:

Post a Comment

Generate Even Numbers in a Range In PHP.

$start = 1; $end = 20; for ($i = $start; $i <= $end; $i++) {     if ($i % 2 == 0) {         echo $i . " is even.<br>";   ...