【发布时间】:2012-01-25 21:51:15
【问题描述】:
如果所有Graphics 也包含在Graphics2D 中,为什么它们不默认为Graphics2D?
我似乎几乎总是在我所有的绘画覆盖中投射/创建一个Graphics2D 对象。
@Override
public void paintComponent(Graphics paramGraphics){
super.paintComponent(paramGraphics);
Graphics2D g = (Graphics2D) paramGraphics.create();
// RenderingHints etc.
}
【问题讨论】:
-
并非所有图形实际上都保证是 Graphics2D。是的,就是这样,我相信如果你在屏幕上绘图,但如果你在打印它,它可能(我相信)并不总是这样。
标签: java swing graphics graphics2d