108k views
4 votes
. Complete the code, drawing a line between points (100, 200) and (34, 67)

public void paint( Graphics g )

{

// your code goes here

}

1 Answer

5 votes

Answer:

The answer for the given question is given below:

public void paint( Graphics g )

{

g.drawLine(100, 200 ,34, 67);

}

Step-by-step explanation:

In this code we are using “drawLine” method to draw the line between the points

The graphics object “g” is to call the drawLine method .

The syntax of drawline method is given below

drawLine(int X1, int Y1, int X2, int Y2)

Where X1, Y1, X2, Y2 are the points in the x and y coordinate

Following are the full code of that program

import java.applet.Applet; // package of applet

import java.awt.Graphics; // package of awt

public class line1 extends Applet //inherit applet class

{

public void paint( Graphics g ) // paint method

{

g.drawLine(100, 200 ,34, 67); // drawline

}

}

It draw the corresponding line between the coordinate

User Ooransoy
by
6.3k points