Hi I am creating a java desktop application where I am drawing rectangle. I want to write some text inside rectangle.
How can I achieve this?
Here is my code:
class DrawPanel extends JPanel {
private void doDrawing(Graphics g) {
int a=90;
int b=60;
int c=10;
int d=15;
ArrayList<Graphics2D> g1 = new ArrayList<Graphics2D>();
for(int i=0;i<=9;i++){
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(new Color(212, 212, 212));
g2d.drawRect(c, d, a, b);
d+=65;
}
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
doDrawing(g);
}
}