# Java: Graphics2D

The javax.swing.Graphics2D class of Java 2 supports many more graphics operations than the Graphics class. For example,

## Graphics2D additional features

- Aliasing
- Shapes
- Affine transformations (scaling, rotation, skewing)
- [list many others, this is only a rough beginning]

## Graphics objects are Graphics2D objects

The Graphics object that is passed to `paintComponent` is really a Graphice2D object in Java 2, so it may quickly be downcast to Graphics2D to make additional methods available. For example

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        // Use g2 for all following operations
        g2.drawLine(...);