Here you can find the source of buildImage(Component c)
Parameter | Description |
---|---|
c | non-null component |
public static Image buildImage(Component c)
//package com.java2s; //License from project: Apache License import java.awt.*; public class Main { /**/* w w w . j a va2 s.c o m*/ * create an image of the component * * @param c non-null component * @return */ public static Image buildImage(Component c) { Dimension size = c.getSize(); int width = (int) size.getWidth(); int height = (int) size.getHeight(); Image ret = c.createImage(width, height); if (ret != null) { Graphics g = ret.getGraphics(); Color background = c.getBackground(); if (background == null) background = Color.white; g.setColor(background); g.fillRect(0, 0, (int) size.getWidth(), (int) size.getHeight()); c.paint(g); } return ret; } }