public class MyPanel { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; . . . } }
public MyPanel() { setPreferredSize(new Dimension(width, height)); . . . }