I am new to JAVA 2D, what is the good tutorial to follow to learn from basics to advance level. I want to draw rectangles having text in it. Thanks in advance
Asked
Active
Viewed 47 times
1 Answers
0
You will need to use JPanel api to achieve this. Refer the following sample:
public class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawRect(10/*x*/, 10/*y*/, 80/*width*/, 30/*hight*/);
g.drawString("TextToDraw", 25/*x*/, 25/*y*/);
}
}

Abhijeet Dhumal
- 1,799
- 13
- 24