[英]fillOval and correct use of paintComponent in actionListener
我想在paintComponent
之外使用fillOval
; 例如, actionListener
fillOval
:
public void mouseReleased(MouseEvent e) {
int r = Math.max((maxx - minx) / 2, (maxy - miny) / 2);
int nr = (int) Math.sqrt(2 * Math.pow(r, 2));
int newx = minx - (nr - r);
int newy = miny - (nr - r);
iterator.add(new Object[] { newx, newy, nr, g2.getColor() });
// remember
paintComponent(g2);
}
我不确定paintComponent(g2)
是否正确。
在paintComponent(g2)中,我不确定是否正确。
直接调用paintComponent
永远是不正确的。 此方法由Swing绘画堆栈负责调用此方法。 使用repaint
repaint();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.