Quantcast
Channel: web development helpdesk » image
Viewing all articles
Browse latest Browse all 10

How do I paint a tiled image, for example as a background of a panel?

$
0
0
The TexturePaint class can be used to achieve that. public void paintComponent(Graphics g) { if(paint == null) { try { // Create TexturePaint instance the first time int height = image.getHeight(this); int width = image.getWidth(this); bi = (BufferedImage) createImage(width, height); Graphics2D biG2d = (Graphics2D) bi.getGraphics(); biG2d.drawImage(image, 0, 0, Color.black, this); paint = new TexturePaint(bi, new […]

Viewing all articles
Browse latest Browse all 10

Trending Articles