1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/* Draw Line in Applet Window Example This java example shows how to draw lines in an applet window using drawLine method of Graphics class. */ /* <applet code="DrawLineExample" width=200 height=200> </applet> */ import java.applet.Applet; import java.awt.Graphics; public class DrawLineExample extends Applet{ public void paint(Graphics g){ /* * to draw line in an applet window use, * void drawLine(int x1,int y1, int x2, int y2) * method. * * This method draws a line between (x1,y1) and (x2,y2) * coordinates in a current color. */ //this will draw a line between (10,10) and (50,50) coordinates. g.drawLine(10,10,50,50); //draw vertical line g.drawLine(10,50,10,100); //draw horizontal line g.drawLine(10,10,50,10); } } |
Example Output
thank for the guidance of draw layout keep teaching guyzzzzz thanks
thanks guys for the guidance of drawLine
Thank you for explaining, though I don’t really understand.