Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7077543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:26:11+00:00 2026-05-28T06:26:11+00:00

I am currently making a fullscreen game and I want to be able to

  • 0

I am currently making a fullscreen game and I want to be able to take some screenshots.
I have found this little code snippet:

BufferedImage image = 
new Robot().createScreenCapture(new Rectangle(w.getX(), w.getY(),w.getWidth(),w.getHeight()));

ImageIO.write(image, "jpg", new File("C:\\Users\\Kaizer\\Desktop\\", "ScreenShot"             + counter + ".jpg"));

I know it doesnt look pretty, but it makes a screenshot, but from my desktop, and not my actual fullscreen game. The Windows screenshots does the same.

I know there is something I overlooked, but I can’t figure it out for the life of me.

By the way: this code is run when the player presses the F11 button. It is not its own method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:26:11+00:00Added an answer on May 28, 2026 at 6:26 am

    If you wrote your game with Swing or AWT, instead of using Robot, you can do the following:

    private static void captureImage(Component c, String fileName)
            throws IOException {
        BufferedImage img = new BufferedImage(c.getWidth(), c.getHeight(),
                BufferedImage.TYPE_INT_RGB);
        c.paint(img.getGraphics());
    
        ImageIO.write(img, "jpg", new File(fileName + ".jpg"));
    }
    

    Note: Depending on the Component you’re using, it may or may not need to be visible. But seeing as you’re taking a picture from a game, I’m pretty sure that won’t matter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently making a little game with a countdown timer. I use an NSTimer,
I'm currently making a webpage and I have run in to some problems with
I am currently making a lot of use of code like this in order
I am currently making an Opencart site. And I want to something a little
I am currently making a template in Django that renders some forms. I have
I'm I'm currently making a wpf c# app. I have some storyboards which animate
I'm planning on making a game and want the window to have 3 different
Im currently making an app and am having some difficulty, here is the code:
Currently making a global volunteer site, and the webpages will more or less have
I'm currently making an application with Backbone.js and some JQuery libraries. Today I work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.