Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capturing JPanel with data as an image

Posted on 2002-06-12
2
Medium Priority
?
267 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 400 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

721 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