package elte.java2_utikalauz5.java2d; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; /** peldaprogram a vagas hatarainak kijeloleset mutatja be. @link.forrásfájl {@docRoot}/../data/java2d/src Vagas.java @link.letöltés {@docRoot}/../data/java2d Vagas.jar @since Java 2 Útikalauz programozóknak */ class Vagas extends Canvas { /** Verziószám */ private final static long serialVersionUID = 15L; public void paint (Graphics g) { Graphics2D g2 = (Graphics2D) g; int w = getSize ().width; int h = getSize ().height; Ellipse2D e = new Ellipse2D.Float (w / 4.0f, h / 4.0f, w / 2.0f, h / 2.0f); g2.setClip (e); g2.setColor (Color.blue); g2.fillRect (0, 0, w, h); Rectangle2D teglalap = new Rectangle2D.Float (w / 2.0f, h / 2.0f, w / 2.0f, h / 2.0f); g2.clip (teglalap); g2.setColor (Color.green); g2.fillRect (0, 0, w, h); } public static void main (String[] args) { Frame f = new Frame (); f.add (new Vagas ()); f.addWindowListener ( new WindowAdapter () { public void windowClosing (WindowEvent e) { System.exit (0); } } ); f.setSize (300, 300); f.setVisible (true); } }