Write a program to paint the off-screen buffer in swings

Answer

To paint the off-screen buffer in swings requires the paint component that is using an image allowing easy to create set of images and its components in different states. This image that is stored, remain useful for automated regression testing that is also known as the golden image approach that is used to compare the images with the current and old images that uses the last stable build of the image. The code that displays it is as follows:

JButton b = new JButton("Image buffer");
button.setSize(100, 50);
// This set the initial size of the image.
BufferedImage image = new BufferedImage(b.getWidth(), b.getHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
button.paint(g);
ImageIO.write(image, "png", new File("image.png"));

All swing Questions

Ask your interview questions on swing

Write Your comment or Questions if you want the answers on swing from swing Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---