Graphics
도 모두 Graphics2D
에 포함되어있는 경우 왜 기본값이 Graphics2D
이 아니겠습니까?
거의 모든 그림을 재정의하여 Graphics2D
개체를 캐스팅/만들 것 같습니다.왜 Swing은 'Graphics2D'가 아닌 'Graphics'를 기본으로합니까?
@Override
public void paintComponent(Graphics paramGraphics){
super.paintComponent(paramGraphics);
Graphics2D g = (Graphics2D) paramGraphics.create();
// RenderingHints etc.
}
모든 그래픽이 실제로 Graphics2D로 보장되는 것은 아닙니다. 예, 그렇습니다. 화면에 그려 넣으면 믿습니다. 그러나 인쇄하는 경우 항상 그렇지 않을 수도 있습니다. –