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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:11:12+00:00 2026-06-10T11:11:12+00:00

I am having trouble with ImageIcon().GetImage() The strange thing is, is that it sometimes

  • 0

I am having trouble with ImageIcon().GetImage()

The strange thing is, is that it sometimes works and shows me the window with the maps on it, and other times it doesn’t. It also works on other computers flawlessly but not on mine!

I have tried everything, reinstalling Java, reinstalling IntelliJ, also disabling my firewall, but to no avail. I have also written a similar program in C# which works perfectly, which leads me to believe it isn’t a permissions error. I have also tested it on a basic Windows XP system with an on board graphics card which also works perfectly.

Here is my code:

public class main {

public static void main(String[] args) {
    System.out.println("Running main..");
    try
    {
        URL url = new URL("http://maps.googleapis.com/maps/api/staticmap?center=-33.80382155278416,18.567184266922002&zoom=17&size=1024x1024&maptype=hybrid&sensor=false&format=png&key=AIzaSyCVnp9iTXRSS3ZE5FjzF7uNZavazWhLko4");
        Image img=new ImageIcon(url).getImage();
        System.out.println("INFO :"+img);
        new ImageFrame(img);

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

public static class ImageFrame extends JFrame{

    public ImageFrame(Image img){

        setPreferredSize(new Dimension(540, 480));
        setaImg(img);
        ImagePanel somePanel = new ImagePanel(540, 480);
        add(somePanel);
        setVisible(true);
    }

    private Image aImg;

    public Image getaImg() {
        return aImg;
    }

    public void setaImg(Image aImg) {
        this.aImg = aImg;
    }

    public class ImagePanel extends JPanel{

        public ImagePanel(int width, int height){
            setPreferredSize(new Dimension(width, height));
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(getaImg(), 0, 0, null); // see javadoc for more info on the parameters
        }
    }



}

 }

I have ran it through the step through debugger and it stops at this line:

Image img=new ImageIcon(url).getImage();

But with no error, it just hangs forever.

I am totally confused as to why it isn’t working on my system, and only my system. Any help would be GREATLY appreciated.

  • 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-06-10T11:11:14+00:00Added an answer on June 10, 2026 at 11:11 am

    Works fine for me

    enter image description here

    Google’s not blocking you are they? From memory you have something like 10,000 queries a day or something.

    Try downloading the URL manually using the InputStream (URL.openStream()) and see if you’re getting some kind of response other than an image binary.

    UPDATED

    After investigation, found to be a problem with Java 7 and IPv6 as documented here Downloading files using Java randomly freezes

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

Sidebar

Related Questions

Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with an .htaccess file on WAMP. Works on the live server, but
Having trouble with this -- a couple of other related posts out there, but
I am having trouble inserting an image on top of a paint method that
Having trouble with iterator. It need to iterate over ArrayList and find any other
Having trouble with MKAnnotation. Have a custom pinview and works fine for the first
Having trouble and not sure how to proceed with debug. Found a question that
having trouble with a double component uipicker, everything shows up and it fills with
Having trouble with query results. The getSales() function works great the first time it
Having trouble with a horizontal scroll bar that pops up. My page is set

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.