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
Solved

Capturing JPanel with data as an image

Posted on 2002-06-12
2
260 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
  • 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

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 76
spring jars download 1 35
passing enum to a method 3 17
American Express @Work site and Java 4 19
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…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

840 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