Computer Science, asked by aneeshasajeer1, 5 months ago

To type inside a Rectangle drawn in Draw you have to ------- *​

Answers

Answered by alviattu424
1

Explanation:

Use your Graphics2D object and call drawString(String str, int x, int y). Something like

g2d.drawRect(c, d, a, b);

g2d.drawString("Hi", (a+c)/2, (b+d)/2);

Note that the Javadoc specifies

Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the leftmost character is at position (x, y) in this graphics context's coordinate system.

so you would need to take into account the space the font takes on screen. Use FontMetrics for that.

Similar questions