How to replace the icon in the title bar and minimized window

I am not sure if this is a Swing question. But since nobody answered it in the Java Programming forum, let me place it here:
I would like to set my own icon in the title bar and in the minimized window of my java application, replacing the java coffee cup icon.
I am using:
frame.setIconImage(new ImageIcon("image.gif").getImage())
as was suggested previously in the Java Programming forum at:
http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5212059
This does create the icon in both places. However, it only works when I run the program from JBuilder 2006. It doesn't work if I run the program from the .jar or the .exe file.
How can I make it work for my .jar and .exe file?
Please help! Thanks!

It doesn't work if I run the program from the .jar...working example for a .jar
import javax.swing.*;
import java.awt.*;
class Testing
  public void buildGUI()
    JFrame f = new JFrame();
    Image img;
    try
      java.net.URL url = new java.net.URL(getClass().getResource("Save.gif"), "Save.gif");//correct capitalization required
      if (url != null)
        img = javax.imageio.ImageIO.read(url);
        f.setIconImage(img);
    catch(Exception e){}//do nothing - default will display
    f.setSize(200,200);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new Testing().buildGUI();
}

Similar Messages

  • How to set an icon in title bar and minimized window

    I would like to set my own icon in the title bar and in the minimized window of my java application, replacing the java coffee cup icon.
    I am using:
    frame.setIconImage(new ImageIcon("image.gif").getImage())
    as was suggested previously in this forum at:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=5212059
    This does create the icon in both places. However, it only works when I run the program from JBuilder 2006. It doesn't work if I run the program from the .jar or the .exe file.
    How can I make it work for my .jar and .exe file?
    Please help! Thanks!

    BrigitAnanya wrote:
    This is urgent! What? Replacing an icon is urgent? That's ridiculous.
    Can anyone tell me how I can replace Sun's Java Icon?The way you were already told. Only if you aren't going to put the icon in your current working directory, don't write code that assumes the icon is in your current working directory.

  • Since installing 4.0.1 I can't right click on the Icon in my task bar and have Firefox give me the option of "close and save" the tabs. Only let's me know I'm about to close multiple tabs. How do I get "save and close" back?

    Before installing 4.0.1 I could right click on the Firefox icon on my computer's taskbar and hit close window. It would then give me the option to "save tabs and quit" or "close all tabs."
    Now it just alerts me that I'll be closing multiple tabs.
    It was convenient to be able to close Firefox and open it with all of the tabs in place. There is nothing more irritating than having multiple tabs lost because your computer did an update overnight and restarted. Also it was helpful when you wanted to run a tun-up or cleaner that asked you close out of your browser for optimum result's.
    How do I get "save and quit" back?
    Thanks

    Firefox now always stores the old session, and you can access it by going to the History menu and selecting "Restore Previous Session"
    If you want Firefox to display the message to save the session, it can be turned back on by changing some preferences.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # Locate the preference '''browser.tabs.warnOnClose''', if its value is set to '''false''', double-click on it to change its value to '''true'''
    # Repeat this for these 3 preferences '''browser.warnOnQuit''', '''browser.warnOnRestart''' and '''browser.showQuitWarning'''
    If you always open the last set of tabs, an alternative approach is this:
    # Click the orange Firefox button, then select options to open the options window
    # Go to the General panel
    # Change the setting "When Firefox starts" to "Show my windows and tabs from last time"

  • Different icon for Frame's title bar and alt tab

    I have been using Frame.setIconImage to supply the image icon for the title bar and (on Windows, the <alt><tab> image). The trouble is there is only one image for both but one is usually small 16x16 and the other is usually large 32x32. What I have been doing is creating an image that is 32x32 but scales back to 16x16 and still looks good.
    The trouble is it is tricky to create graphics like that. I wondered is there a way to specify one image for the title bar and another image for the <alt><tab> image?
    thanks,
    Ian

    Has anyone encountered this problem before? Is there
    a solution? Or can anyone say definitivly that
    specifying the title bar icon and the <alt><tab> icon
    separately is not possible?Sorry- you can't do it. Windows apps can do this easily because they use a .ico that can contain both the 16x16 and 32x32.
    There are a couple of hacks I tried once, trying to swap icons based on events, but they are horrible hacks and don't work well enough to use. Your choices are as follows:
    1. Use a 16x16 .gif as your icon and have it look good in the upper left hand corner of your frame but horrible during alt-tab,
    or
    2. Use a 32x32 .gif and have it look poorly in the upper left hand corner of your frame but good during most other times.
    I'd choose #1.
    (The reason behind all of this is Java does a much worse job of resizing your icon than you could do yourself with a little work in Paint Shop Pro.)

  • Off-screen title bar and menu

    I have a dual monitor setup, where the monitors have different resolution. I usually open documents on the larger screen, but if I open a second document it opens on the smaller screen with title bar and main menu off-screen. Is it any way I can anchor new windows to the top of the screen instead of the bottom?

    parish_chap wrote:
    V.K. wrote:
    parish_chap wrote:
    Unfortunately, as with Expose, the Prefs window disappears when I activate Spaces.
    I don't quite understand what you mean. do you mean that the system preferences window moves off screen when you enable spaces? when you enter spaces view (F8 is the default shortcut) you should see all windows in all spaces on all monitors. is this not working?
    It isn't displayed, i.e. it disappears. Remember this is a MS app and appears to follow the semantics of modal dialogues in Windows, i.e. they aren't "real" windows. They are a PITA in Windows as it's possible to hide them with another window and they are a pain to find - they don't appear in window lists and you can't Alt-TAB to them.
    oh, yes, I forgot about that. I know that MS office Spaces integration was supposed to be fixed in Snow Leopard but I guess that didn't happen with MSN messenger. that's probably also the reason those apple scripts you tried didn't work.
    Looking at this from a different angle, where are window positions likely to be saved as the position is retained across reboots. Is it the OS that handles this, or the app itself?
    the window positions of an application are stored in the preference file of that application in /users/username/library/preferences. if you quit an application, delete its preference file and relaunch it then it should display on the default screen with default values. however, some apps (like Mail) keep important data in their preference files and deleting them will wipe that data.
    Thanks. As you said about Mail, MSN Messenger stores all its data in their, e.g. account details, and the plist file is binary, but a quick Google revealed plutil so I converted it to XML, edited it in vi, and converted back to binary +et voilà+ it worked!!
    The window position was 0, -56 so I just changed it to 0, 56
    that will of course, do it.
    Thanks for your help!
    you are welcome.

  • How to add an icon in the title bar,next to the maximize and minimize icons

    I need to add an icon ( help icon; ?) in the JInternalFrame� title bar. Anyone could help me????
    Thanks

    have you get the answer ?? on how you add an icon to the title bar?? ...
    if you do please inform me..
    thanks

  • How add a new icon in the title bar?

    does anyone know how to change the default "java icon" that appears on the title bar of a Window (in an application Frame)?

    Hi,
    use the method public void setIconImage(Image) in Frame (inherited by JFrame).
    best regards

  • Changing the icon in the title bar

    How can I go about changing the Icon in the title bar that goes next to the title?

    setIconImage(Image image) for JFrame.
    setFrameIcon(Icon icon) for JInternalFrame.
    Take a look at the API.

  • If for some reason u have the icon in your task bar (the one with 2 arrows pointing in a circle) just go into mobile me pref...click sync...and uncheck box show status in menu bar.  My question is, I do not have this option. How do I get the sync to stop

    "if for some reason u have the icon in your task bar (the one with 2 arrows pointing in a circle) just go into mobile me pref...click sync...and uncheck box show status in menu bar."
    I do not have the option box to "show status in menu bar"
    I tried the free for a little while Mobile me, and didn't use it, so cancled. I cannot get the sync status roundabout arrows out of my status bar. AND, they keep trying to sync.
    Another issue related with this is that during the time that I tried out Mobile me, I had my ical alarm set to go off every 2 hours. NOW my computer has an ical  pop-up every 2 hours. I cannot find how to stop it.
    Another issue, Yahoo is trying to sync with my computer and I have no idea why or where that one came from.
    Can anyone out there help me please. 

    "if for some reason u have the icon in your task bar (the one with 2 arrows pointing in a circle) just go into mobile me pref...click sync...and uncheck box show status in menu bar."
    I do not have the option box to "show status in menu bar"
    I tried the free for a little while Mobile me, and didn't use it, so cancled. I cannot get the sync status roundabout arrows out of my status bar. AND, they keep trying to sync.
    Another issue related with this is that during the time that I tried out Mobile me, I had my ical alarm set to go off every 2 hours. NOW my computer has an ical  pop-up every 2 hours. I cannot find how to stop it.
    Another issue, Yahoo is trying to sync with my computer and I have no idea why or where that one came from.
    Can anyone out there help me please. 

  • How do I stop my MacBook clearing the icons off the desktop when I switch off

    How do I stop my MacBook clearing the icons off the desktop when I switch off the machine?

    Hi Matt
    After I create say a word document, file it on my desktop and then shut down my machine. The next time I open up the MacBook the file icon has been removed from the desktop. I can still retrieve the file in a folder labeled with the month I created it. But why has the OS removed it from the desktop and how can I stop it happening?
    It happens to alias icons as well!
    Regards

  • How can i disable '+' icon in the toolbar

    Hi,
    I have one requirement i.e i want to disable '+' button[File-->New] in the toolbar.This button creates a record when i click on this.
    My block(Updatable block) should allows updations and insertions so i can't make insert_allowed and update_allowed property to "NO".I tried with
    APP_SPECIAL2.ENABLE('FILE.NEW',PROPERTY_OFF); but the + icon is still enabled when i write above code.
    How can i disable '+' icon in the toolbar
    Thanks in advance,

    This is eBusiness-related, maybe ask your question in the EBusiness-forum, maybe here OA Framework

  • How can I remove icons from the Finder sidebar?  Were transferred when I set up laptop from my desktop computer.  Tried dragging off but that didn't work.

    How can I remove icons from the Finder sidebar?  Transferred info from my Mac Pro desktop computer (using target mode) and there were folder icons on the Mac Pro Finder sidebar that are now on the MacBook Finder sidebar, even though these folders do not exist on the MacBook.  Tried to drag them off, which is the usual way to get rid of folders that the user adds to the sidebar (as opposed to those that can be added via the Customize Toolbar dropdown menu) but was unsuccessful.  I then unchecked all of the Customize Toolbar menu items and the folder icons still remained.  What else can I do?

    Did you hold the Command (Apple) key while dragging them off the sidebar? That usually makes them go *poof*.

  • How to set the icon for the entire application with JFrame.setIconImage

    I set the icon on the main frame using JFrame.setIconImage(). The icon is shown properly in the main frame.
    If more JFrames are opened from the main frame, the newly opened JFrames also show the icon.
    However if JDialogs are opended, in some cases the icon set on the main frame is shown and in other cases the coffee cup.
    What is JFrame.setIconImage() expected to do? Setting the icon for a single JFrame or the entire application?
    How can I set the icon for the entire application?
    How can I set the icon for JDialogs?
    Thank you

    In order for your dialogs to use the same icon as the frame, you must parent the dialogs to the frame which has the custom icon.
    See the following thread for more information: http://forum.java.sun.com/thread.jsp?forum=57&thread=362542
    cheers,
    Greg

  • I synced my Ipod to itunes now i can only double click the icons on the screen it seems that the swiping feature has been disabled, how do I get it back to normal? I've restored it but nothing has changed

    I synced my Ipod to itunes now I can only double tap the icons on the screen, it seems that the swipeing feature has somehow been disabled, Is there a way i could fix it or get it back to normal?

    Hi there,
    It sounds like you may have an accessibility feature called VoiceOver enabled. Take a look at the article below for more information on how to use VoiceOver as well as how to disable it.
    iPod nano (6th generation and later): How to use VoiceOver
    http://support.apple.com/kb/ht4317
    -Griff W.

  • How do I change the order of the icons on the top right hand corner?

    Hi,
    I was wondering how to change the order for the icons at the top of the screen. I selected the option of not showing the battery status bar in the energy saver section. However, when I decided to add it back to the top, the order changed. This may sound strange but is there any way to get it back in the correct order.
    Thanks

    1) Hold down the command key and drag them around.
    2) Open System Preferences/Accounts Login Items and change the order they load.

Maybe you are looking for

  • ERROR IN RELEASING A BILLING DOCUMENT

    Hi all, when i am releasing a billing document to finance in T.code- VF02, I am getting the following error message though i have done all the tax related settings in tax proceedure and assigned the same to country : Error:- Tax code in procedure ZTA

  • I payed for vip on an app once but it did not specify about annual payments could I get my money back that they have taken ?

    the app smule didn't specify that when I bout vip it would take annual payments, it is taken money out with me knowong and i want the money back into my account would this be possible ? I'm very upset about this and I would like apple to have a look

  • Quicktime believes a newer version of Quicktime is installed

    My iTunes wasn't working properly and I also found that Quicktime was another program that wasn't seeming to work. Because of this, I decided to remove Quicktime from my computer and then reinstall it. However, when I tried to open the installer, I w

  • Changing the cast member of a sprite

    Hi, I have the following code so that when a user clicks on a shape (acting as a button), it changes the cast member of an existing sprite called "base" on the stage to an image cast member called "Italian Lira". However the code does not work, any s

  • Battery questions for MacBook Air 11 inch

    I generally have my MBA 11 inch connected to the power supply during the day and therefore it shows 100% when I close the lid at the end of the day. After overnight the battery shows 95% or less when I open in the morning. Is this normal ? Clearly no