I\'ve a class which extends JPanel. I overwrote protected void paintComponent(Graphics g).
JPanel
protected void paintComponent(Graphics g)
There is a variable which has to be recalculate
Here's what I use (where CoordinatePlane is a JPanel):
I'm not an expert
public CoordinatePlane() { setBackground(Color.WHITE); this.addComponentListener(new ComponentAdapter(){ public void componentResized(ComponentEvent e) { //YOUR CODE HERE } }); }