Results 1 to 8 of 8
- 09-05-2010, 12:05 AM #1
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
- 09-05-2010, 12:20 AM #2
If the window is not showing, then the Robot class is no use.
An idea: Create a BufferedImage, get its graphics context and call the window's paint method to have it draw itself on your image.
- 09-05-2010, 12:42 AM #3
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
- 09-05-2010, 01:05 AM #4
Sorry, I don't have any examples.
- 09-05-2010, 05:15 PM #5
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
any ideas? I'm stumped.
- 09-05-2010, 05:17 PM #6
Have you tried what I suggested earlier:
Create a BufferedImage,
get its graphics context
call the window's paint method with the graphics to have it draw itself on your image.
Searching on this forum for new BufferedImage( found code examples for the first two steps.
The third step would be:
windowRef.paint(g); // for AWT
or
windowRef.paintComponent(g); // for swing
Now your buffered image contains what the window would have painted on the screen.
I don't know about the window's contained components. Try it and see what you getLast edited by Norm; 09-05-2010 at 05:21 PM.
- 09-07-2010, 04:51 AM #7
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
Okay, This is how i paint a component:
and here is how i call this method:Java Code:public static BufferedImage paintComponent(Graphics g) { BufferedImage grid = null; x.paintComponents(g); // paint background Graphics2D g2 = (Graphics2D)g; // we need a Graphics2D context int w = x.getWidth(); int h = x.getHeight(); grid = (BufferedImage)(x.createImage(w,h)); return grid; }
When I see the saved image, I see nothing but white. "x" refers to another window that is opened. What is happening?Java Code:Graphics g = x.getGraphics(); BufferedImage picImageArea = paintComponent(g); try { ImageIO.write(picImageArea, "png", new File("test.png")); } catch (IOException e1) { e1.printStackTrace(); }
- 09-07-2010, 12:59 PM #8
That is not the signature for the component's paintComponent method.Java Code:public static BufferedImage paintComponent(Graphics g) {
Are you intending to override the component's method?
What is x???Java Code:x.paintComponents(g); // paint background
I don't understand your code.What is happening?
How does it relate to what I suggested?
The three steps:
BufferedImage bi = new BufferedImage( ....);
Graphics g = bi.getGraphics();
windowRef.paint(g); // have the window paint itself on our image
Similar Threads
-
How to do a screen capture of content on web page/join 2 images
By raabie in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-27-2010, 01:02 PM -
DVB-T capture
By krato in forum Advanced JavaReplies: 0Last Post: 08-03-2010, 11:46 PM -
Using BufferedImage, WritableRaster etc. for making a "screen"
By ThemePark in forum Advanced JavaReplies: 0Last Post: 12-29-2009, 03:10 PM -
Need Help on Remote Host Screen Capture
By krishnaraoveera1294 in forum AWT / SwingReplies: 4Last Post: 03-13-2009, 10:56 PM -
Blank Screen while navigating from one screen to another
By mohana.krishna in forum Java ServletReplies: 0Last Post: 03-03-2009, 05:03 PM


LinkBack URL
About LinkBacks
Reply With Quote


Bookmarks