Is it possible to call repaint() inside the main()?I have tried the code below.But its not working
public mypanel()
{
initComponents();
repaint(100,150,40,40);
}
protected void paintComponent(final Graphics g)
{
final Graphics2D g2 = (Graphics2D)jLabel2.getGraphics();
g2.drawRect(100,150,40,40);
}
//above code doesnt provide any output
private void formMouseClicked(java.awt.event.MouseEvent evt)
{
repaint(100,150,40,40)
}
this code draws the rectangle.But I want to draw it when the program execution starts.Please help to solve this(rect
angle drawn on an image placed in jLabel).