Suppose below is my code :
public void paintComponent( Graphics g )
{
graphics2D = (Graphics2D)g;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setPaint(Color.white);
graphics2D.fillRect(0, 0, getSize().width, getSize().height);
graphics2D.setColor(Color.black);
}
and graphics2D is global variable declared like :
private Graphics2D graphics2D;
Now, how can I access g to draw lines from other methods?
When I'm accessing graphics2D, it's showing that NullPointerException.
and please also brief me about the Graphics g thing.