Solved

Capturing JPanel with data as an image

Posted on 2002-06-12
2
261 Views
Last Modified: 2006-11-17
Hello,

We have some content on a JPanel
As part of our project requirements we have to :
1. Capture this JPanel as an image. How do we do this ?

2. The JPanel has a scroll bar. Is there any way we can capture the entire content (even that beyond the scrollbar) as an image ?
This has to be implemented in Java. If anyone has worked on this could you please provide a solution for achieving the same.

Thanks in advance,
0
Comment
Question by:hariharann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 7074909
Create an image the same size as your panel, then simply pass the Graphic context associated with the image to the panels paint method:

panel.paint(image.getGraphics());

The image will then contain the contents of the entire panel.
0
 
LVL 92

Expert Comment

by:objects
ID: 7077297
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question