Java-Applets

Applets Applets are small java programs that run inside a web browser. The byte code for an applet is stored as part of a web page that is made available on a web server. When we download such a web page, the applet contained in it is also downloaded and executed by the web browser. … Read more…

Java-Lines

Lines The simplest shape we can draw with the Graphics class is a line. The drawLine( ) method takes two pair of coordinates, (x1, y1) and (x2, y2) as arguments and draws a line between them. Program Program Source  import java.applet.Applet; import java.awt.Graphics; public class Javaapp extends Applet { public void paint(Graphics g) { g.drawLine(10,10,100,10); … Read more…

Java-Rectangles

drawRect We can draw a rectangle using the drawRect( ) method. This method takes four arguments. The first two represent the x and y coordinates of the top left corner of the rectangle, and the remaining two represent the width and the height of the rectangle. fillRect We can draw a solid box by using … Read more…

Java-Circle and Color

Circle The Graphics class does not have any method for circles or ellipses. However, the drawOval( ) method can be used to draw a circle or an ellipse. Ovals are just like rectangles with overly rounded corners. The drawOval( ) method takes four arguments, the first two represent the top left corner of the oval … Read more…

5

Java-Arcs

Arcs An arc is a part of an oval. In fact, we can think of an oval as a series of arcs that are connected together in an orderly manner. The drawArc( ) designed to draw arcs takes six arguments. The first four are the same as the arguments for drawOval( ) method and the … Read more…

Java-Simple Animation

Program Program Source import java.applet.Applet; import java.awt.Graphics; public class Javaapp extends Applet { public void paint(Graphics g) { int a=100,b=100,c=10,d=10; for(int i=0;i<15;i++) { try{ Thread.sleep(1000); }catch(InterruptedException ex){} g.drawRect(a, b, c, d); a-=5; b-=5; c+=10; d+=10; } } }