I have following code:
canvas=new MembershipFunctionComponent(functions);
canvas.setPreferredSize(new Dimension((int)this.getWidth(), (int)this.getHeight()));
canvas.addMouseListener(canvas);
pane.add(canvas);
MembsershipFunctionComponent extends JComponent. Why is paintComponent method executed 2 times?
paintComponentcan get called at pretty much any time by the Swing framework. Examples of when this might happen:None of this should worry you – you should just write your code so that it doesn’t care how many times paintComponent is called.