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 6380903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:19:39+00:00 2026-05-25T02:19:39+00:00

I have a JFrame in which I am using Graphics2D to draw a VolatileImage

  • 0

I have a JFrame in which I am using Graphics2D to draw a VolatileImage using this tutorial. I have mainly copied the code to see how it works, but have slightly edited it for my game. I am running my computer with two screens.

The problem arises when I drag the window of the game onto the other screen which the window did not originally appear on. The window goes grey and no graphics are shown on screen, even the simple rectangles I have drawn with the Graphics2D. This only happens when I call for the draw method of the volatileimage as shown in the tutorial.

I believe it may have something to do with this…

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();

…but I am not sure.

Any help would be greatly appreciated. It would also be interesting to know if VolatileImage is the way I should be going for my game or if BufferedImage or something else is a better method for performance and frame rate.

  • 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-25T02:19:40+00:00Added an answer on May 25, 2026 at 2:19 am

    Yes, you are correct. VolatileImage is device-specific. From “The VolatileImage API User Guide” you can read:

    A VolatileImage is device-specific: if you created a VolatileImage with one
    GraphicsDevice, you might not be able to copy that VolatileImage to another
    GraphicsDevice. For this reason, you need to call validate before attempting to copy the
    VolatileImage.

    and

    If the code is IMAGE_INCOMPATIBLE then the VolatileImage is not
    compatible with the current GraphicsConfiguration. This
    incompatibility can occur if the image was created with one
    GraphicsConfiguration and then drawn into another. For example,
    in a multiple-monitor situation, the VolatileImage exists is
    associated with a particular GraphicsConfiguration. Copying that
    image onto a different GraphicsConfiguration could cause
    unpredictable results.
    To correct this problem, you need to create a
    new VolatileImage that is compatible with the current
    GraphicsConfiguration

    When dragging your frame to another screen device you need to check the result from the VolatileImage.validate(gc) method of your and recreate the image to the new device. Note that there are cases when you cannot create a VolatileImage, in those cases you need to fall back on another Image implementation like BufferedImage.

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

Sidebar

Related Questions

I have a JFrame inside of which is a jpanel that im using as
I have written a java applet which opens a JFrame (so when run in
I have a JFrame. This JFrame contains a JButton. I click the JButton and
This one's a tough one - I have a JFrame that generates JTextFields. When
I have a JFrame which has 3 JPanels in GridBagLayout .. Now, when I
This is my first time using a JFrame. I can't get the window to
Scenario: I have one JFrame and JPanel added to that JFrame . on this
I have a JComboBox object in my JFrame which behaves exactly as expected. However,
I have a non-GUI thread that starts a JFrame using java.awt.EventQueue.invokeLater(new Runnable() { public
I have created a simple Java application which has a JFrame and few JButtons.

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.