package elte.java2_utikalauz5.java2d; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.*; /** peldaprogram a TexturePaint hasznalatara. @link.forrásfájl {@docRoot}/../data/java2d/src Mintak.java @link.letöltés {@docRoot}/../data/java2d Mintak.jar @since Java 2 Útikalauz programozóknak */ class Mintak extends Canvas { /** Verziószám */ private final static long serialVersionUID = 15L; public void paint (Graphics g) { Graphics2D g2 = (Graphics2D) g; BufferedImage bi = new BufferedImage (4, 4, BufferedImage.TYPE_INT_RGB); Graphics2D gbi = bi.createGraphics(); gbi.setColor (Color.white); gbi.fillRect (0, 0, 4, 4); gbi.setColor (Color.red); gbi.fillOval (0, 0, 4, 4); Rectangle2D teglalap = new Rectangle2D.Float (0.0f, 0.0f, 4.0f, 4.0f); TexturePaint tp = new TexturePaint (bi, teglalap); g2.setPaint (tp); g2.fillRect (10, 10, 150, 200); } public static void main (String[] args) { Frame f = new Frame (); f.add (new Mintak ()); f.addWindowListener ( new WindowAdapter () { public void windowClosing (WindowEvent e) { System.exit (0); } } ); f.setSize (300, 300); f.setVisible (true); } }