Java Draw Image drawImage(Graphics graphics, Component comp, Image image)

Here you can find the source of drawImage(Graphics graphics, Component comp, Image image)

Description

draw Image

License

Open Source License

Declaration

public static void drawImage(Graphics graphics, Component comp, Image image) 

Method Source Code


//package com.java2s;
import java.awt.*;

public class Main {
    public static void drawImage(Graphics graphics, Component comp, Image image) {
        Dimension d = comp.size();
        // Dimension d = comp.getSize();
        graphics.setColor(comp.getBackground());
        graphics.fillRect(0, 0, d.width, d.height);
        graphics.drawImage(image, (d.width - image.getWidth(null)) / 2, (d.height - image.getHeight(null)) / 2,
                null);/*from   ww  w  .  j  ava2  s.c  o m*/
    }
}

Related

  1. drawImage(BufferedImage originalImage, BufferedImage scaledImage, int width, int height)
  2. drawImage(BufferedImage srcImg, BufferedImage img2Draw, int w, int h)
  3. drawImage(BufferedImage target, Point targetPoint, BufferedImage source)
  4. drawImage(final Graphics2D graphics, final Image image, final Rectangle rectangle)
  5. drawImage(Graphics g, BufferedImage im, Rectangle dst, Rectangle src)
  6. drawImage(Graphics2D g, BufferedImage image, int x, int y)
  7. drawImage(Graphics2D g2d, BufferedImage image, Rectangle dispArea)
  8. drawImage(Image image, Dimension windowSize, Graphics graphics)
  9. drawImage(Image image, Graphics g, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)