例如,我有扩展 JPanel 的 A 类,我想将它的 Graphics2D 传递给 B 类。如果我对 B 类中的那个 Graphics2D 实例进行操作,它会在 A 类上绘制吗?
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
...
b.doSomePainting(g2d);
...
}
例如,我有扩展 JPanel 的 A 类,我想将它的 Graphics2D 传递给 B 类。如果我对 B 类中的那个 Graphics2D 实例进行操作,它会在 A 类上绘制吗?
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
...
b.doSomePainting(g2d);
...
}