Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: window icon

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default window icon

    Hi everyone, I need to set an image to the window of my application
    I've heard it is this way

    frame.setIconImage(new ImageIcon(imgURL).getImage());

    but not working, I know setIconImage needs an Image as a parameter, but I don't know how to create it because nowhere it asks for the location of my image

    another question:is the window icon (in the upper-left) the same as the task bar icon, or do I have to set two differents sized icons?

    thanks!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: window icon

    The imgURL parameter is the location of the image. What have you been using instead? Recommended reading: How to Make Frames (Main Windows) (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: window icon

    the java tutorials website is down
    I changed imgUrl with "/resources/icon.png" but when I run it, it doesnt shows up, thought maybe png format wasnt supported but neither is gif, so I think there is something wrong with the code.
    meanwhile I want to add copy-to-clipboard functionality to a JMenuItem, I tried something with setAction and DefaultEditorKit.copyAction but can't figure it out, any ideas?

    thanks kevin

    ADDED: java tutorials website's up

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: window icon

    What happens if you use the full path?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: window icon

    how do I put the full path? like "C:\Users\user\Documents\NetBeansProjects\project\ src\resources\img.png" ? I tried creating an Image object and thus, set the image to the frame but didnt work because cant create an Image object.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: window icon

    Yeah, that looks like a full path.

    Unfortunately, if you want more help, you're going to have to post an SSCCE (which in your case should only be a few lines) so I can see exactly what you're trying to do.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member
    Join Date
    Sep 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: window icon

    ok problem solved, the absolutepath was C: so I need to move my icon to C:\resources\icon.gif or put the full path
    thanks!

Similar Threads

  1. Craating non active window ,and inputing to the non active window.
    By java-beginner in forum Java Theory & Questions
    Replies: 0
    Last Post: February 25th, 2011, 10:13 PM
  2. Moving Icon in gridlayout SWING
    By Loodistobilo in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 24th, 2010, 07:59 PM
  3. How to place icon on a picture base on (x,y) axis
    By FaintSmile in forum Java Theory & Questions
    Replies: 1
    Last Post: July 13th, 2010, 07:27 AM
  4. [SOLVED] I cant load the icon!!!!
    By chronoz13 in forum AWT / Java Swing
    Replies: 12
    Last Post: January 22nd, 2010, 03:52 AM
  5. Icon change and lib folder problem
    By LeonLanford in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 21st, 2009, 03:00 AM