-
How can an Image be made from a GUI Component like Button or Label ?
/*
Hi guys
i found following algorithm which can make an Image from the content of a component.
what i realy want to make happen here is i have drawn an ImageButton ( without image file) and i want that image face to be saved on an image file.
i tried to use this method but image goes complete black
any clue ? */
public static BufferedImage convertComponentToImage(Component c) {
Dimension size = c.getSize();
// Create a buffered image equal to the size of the component.
BufferedImage bufferedImage = new BufferedImage(size.width, size.height,BufferedImage.TYPE_INT_RGB);
// Get the graphics context of the image
Graphics bufferedGraphics = bufferedImage.createGraphics();
// Request the component to paint itself on to the image's graphics. This method would not work if the component is not yet visualized.
c.paint(bufferedGraphics);
return bufferedImage;
}
Similar Threads
-
Replies: 4
Last Post: 04-14-2006, 09:09 AM
-
Replies: 1
Last Post: 11-27-2001, 06:53 AM
-
By Robert C. Cain in forum VB Classic
Replies: 2
Last Post: 12-04-2000, 02:26 AM
-
By Robert C. Cain in forum VB Classic
Replies: 0
Last Post: 12-03-2000, 11:18 PM
-
Replies: 1
Last Post: 11-25-2000, 09:56 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks