OO Programming with Java


Drawing 2D

Now, an extension is proposed by Graphics2D with Shape elements:

public void paint(Graphics g) { 
  //g.drawRect(10,10,280,180) 
  Graphics2D g2 = (Graphics2D)g;
  // reification
  Shape s  = new RoundRectangle2D.Double(10,10,280,180,20,20); 
  g2.draw(s);
  g2.setFont(new Font("Purisa", Font.CENTER_BASELINE & Font.ITALIC, 30));
  g2.drawString("Java is fun !", 65, 105);
}

11 - 12