Changing the coffee cup Icon in Titlebar?

HI
I read all thrads about this but still dont get it working. I tried it 3 ways:
1:
ImageIcon pic = new ImageIcon("pic.gif");
this.setIconImage(pic.getimage());
I call this function in the constructor of the frame Object. Pic is in same folder as the class. Frame appears but NO icon is shown (just blue Titlebar)
2:
this.setIconImage( new ImageIcon( Classloader.getSystemResource("pic.gif")).getImage());
brings up a NULL pointer Error :(
3:
this.setIconImage(Toolkit.getDefaultToolkit().getImage(packetName + "pic.gif"));
where packetName is the full packet path.
this on e also gets me an NULL pointer Error.
I dont know what to do anymore. Please help! THanks!

2. this.setIconImage( new ImageIcon( Classloader.getSystemResource("pic.gif")).getImage());
This is the best thing to do if you don't know where your classes will be installed. Put your image in your classpath and you're done. If it didn't work for you then it may be because your class is in a package. Here's what I do:
setIconImage(new ImageIcon(this.getClass().getResource("/pic.gif").getImage());
Note the slash at the beginning of the file name. If my class is named com.hoser.SuperGUI, then it will be in a directory named .../something/com/hoser. I put the pic.gif file in the .../something directory, which would be one of the directories in my classpath, and the getResource() method finds it there.
If I left off the slash, then getResource() would be looking in my classpath for com/hoser/pic.gif, and in that case I would have to put the file into the .../something/com/hoser directory.

Similar Messages

  • How can we change the 'coffee cup' symbol

    sir/madam
    could you please tell me ,how can I change the coffee cup icon
    appeard at the left corner of the window to my own icon or image.

    public void JFrame.setIconImage(Image image)

  • How do I remove the coffee-cup icon in Windows's frames?

    Hi Java developers!!!
    I'd like to know if there's a way I can remove that small icon at the upper-left corner of an AWT Frame that
    appears on every window under Windows. As far as I know, there are licensing restrictions that won't let me
    distribute any program that use these copyright-protected icons/images in any program unless Sun
    explicitly tells me so. Ideas anyone?
    - Heriberto Delgado
    Sui Generis S.A.
    ([email protected])

    (Sorry for my bad english, I'm from Costa Rica.)
    Ok, let me explain it. Frame.setIconImage() gets rid of the coffee-cup icon in the frame, so that the old icon is
    not visible again in the application, thus it's not infringing any Sun-imposed copyrights on it's usage. That works
    when the application is run under Windows, and possibly other OSes. However, Windows is my only current
    development platform, and I don't know how my application will really look on other OSes, as
    Linux/Solaris/MacOS/etc., and I'm actually worried about if other Sun-proprietary icons/images will appear in my
    application when opened within these OSes, besides the coffee-cup icon. Should I be worried, or not?
    Again, thanks for your quick response!
    - Heriberto Delgado
    Sui Generis S.A.
    ([email protected])

  • How to change the java cup icon for all the JFrames?

    Hi,
    I would like to know if I can change the Java cup defult icon that appears in the upper left corner of the JFrames in one time, instead of setting the JFrame's icon in every created JFrame.
    Regards,
    Gabriel

    Then don't set the parent to null. If you don't want a parent, just set it to
    JOptionPane.showMessage(new IconFrame(), ...
    [\code]
    where IconFrame extends JFrame and sets the icon in it's constructor.  The optionpane will then use the icon from it's parent frame.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Change the coffe cup icon

    Do someone know how to chage the coffe cup icon"on the topleft" on the Jframe window?????

    yerJFrame.setIconImage (yerImage);Kind regards,
    Levi

  • Change Coffee cup icon on JDialog & JOptionPane

    I try to change the coffee cup icon on my JDialog and JOptionPane.
    My JDialog box does not load the Parent Icon (JFrame icon), and not even show a coffee cup icon.
    My JOptionPane would just show a coffee cup icon, eventhough its parent is the above JDialog with no icon.
    Is there anyone know how to fix this?
    I'd like show my icon on the JOptionPane instead of the coffee cup icon.
    And also to show my icon on the JDialog instead of nothing, not even a coffee icon.
    Any help is appreciated.
    CL

    Passing a parent with the desired icon to the JDialog/JOptionPane should solve your problem, however there is a bug in swing that prevents any icon from showing in the titlebar if a JDialog is made non-resizable (through a call to setResizable(false)).
    The bug adatabse says that this has been resolved but I am using jdk 1.3.1 and continue to have this problem.

  • How can I remove or replace the " Java coffee cup " icon ???

    I'd like to ask everybody some questions about the " Java coffee cup " icon
    doesn't JToolbar be able to pull out of Frame?
    but the JToolbar which was pulled out would have a little Java coffee cup icon
    just like JOptionPane,JDailog or JFrame.
    Is there any solution to remove this icon??
    equally....
    How can I remove or replace the little Java coffee cup icon of the title in
    JDialog or JOptionPane??
    Taking JFrame for instance, if I use "this.setIconImage(xxxxxxx);" then I can
    change the little Java coffee cup icon.
    but it seemed invalid to use it in JDialog.
    How can I solve it in JToorbar,JDailog and JOptionPane ???
    my e-mail : [email protected]

    this seems to be to most asked question at least in this forum.... only topped by the question about 'how to make an exe out of java apps' in the Java Programming Forum.
    Sorry, but is there anybody who has noticed those useful textboxes where it says 'Search'? I mean before there were computers one had to go to a library, ask somebody or perform extensive research until answers were found. Or one had to buy books only to find out the the other book he though about buying would have been better.
    Nowadays, simply type somthing like 'coffe cup' into a place where it is possible to do so and click into a region where it says 'Search' somewhere. Not even necessary to go to a froum like this and swamp it with the one trillionth version of this question, almost any search box might bring an answer (let it be right or not..).
    Although I have to admit that this instance is the most prosaic and least understandable one I have seen for long...
    Again sorry but I had to say that.

  • Changing the default sun icon

    When I create a JFrame it comes with the default sun icon (the coffee cup). Suppose I want to personalise my frame with my own icon. How do I change the icon.

    Don't know exactly but I think it has to do with java.awt.Frame.setIconImage()

  • How to change The Standard JOptionPane Icon?

    in this simple code
    i want to change the Standard JOptionPane icon to a different icon
    how could it be?
    thank you
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowEvent;
    import javax.sound.sampled.*;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import javax.swing.Icon;
    import java.awt.event.*;
      public class MyFrame extends JFrame 
    JLabel label=new JLabel("Hello");
      MyInner inner;
          MyFrame ()
            setupGUI();
        private void setupGUI()
           JFrame f =new JFrame();
        //   f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
           f.setTitle("Window Event");
            f.setSize(550,350);
            f.setResizable(false);
            f.setLayout(new BorderLayout());
            f.add("Center",label);
            f.show(true);
             inner=new  MyInner();
             f.addWindowListener(inner);
                   class MyInner extends WindowAdapter
           public void windowClosing(WindowEvent ee)
                         Toolkit tool = Toolkit.getDefaultToolkit();
                  tool.beep();
                      JOptionPane.showMessageDialog(null, "Nice Work! " );
                      System.exit(0);
          public  static void main(String[]args)
             MyFrame frame=new MyFrame ();
    }

    For instance:
        class MyInner extends WindowAdapter
            public void windowClosing(WindowEvent ee)
                Toolkit tool = Toolkit.getDefaultToolkit();
                tool.beep();
                JOptionPane.showMessageDialog(null, "Nice Work! ");
                ImageIcon myImageIcon = new ImageIcon("myPic.jpg"); // needs proper path here
                JOptionPane.showMessageDialog(null, "Better Work!", "Dang, I'm smart!", JOptionPane.ERROR_MESSAGE, myImageIcon);
                System.exit(0);
        }

  • How to change the node's icon in a tree when the node collapse or expand?

    how to change the node's icon in a tree when the node collapse or expand?

    Hi,
    You may need to use custom skin for that.
    -Arun

  • I would suggest a new feature:The possibilty to change the mouse pointer icon when you hover on an a

    I would suggest a new feature:The possibilty  to change the mouse pointer icon when you hover on an active link by any other one icon I select.

    Current Firefox versions have a feature called tear-off tabs.<br />
    You can detach a tab from the current window and open it in a new window by dragging a tab in the browser window.<br />
    You can drag that tab back to the tab bar in the original window to undo that detaching.
    bug489729 (Disable detach and tear off tab):
    * https://addons.mozilla.org/firefox/addon/bug489729-disable-detach-and-t

  • Change the java cup picture in the top left corner

    Does any one knows how to change the java cup picture in the top left corner of the frames and applets
    Thanks in advance

    Hi,
    I have the following code added and get this error:
    non-static method setIconImage(java.awt.Image) cannot be referenced from a static context
    private static void SetUpGUIApplication(){
            //This must be invoked before
            //creating the JFrame.  Native look and feels will be set here
            // Comment this out to see the differences
           FrmMain.setDefaultLookAndFeelDecorated(true);
            ImageIcon appIcon = new ImageIcon(getClass().getResource("resources/FLGCAN.ICO"));
            if (appIcon != null)
                    setIconImage(appIcon.getImage());
        }What does this mean when adding static verses non static?
    Thanks

  • Changing The Default Window Icons

    Is there a way to change the MDI Window Icon when the Form is run on the web. Changing the icon in client/server seems to work well with the following (attached d2kwutil.pll):
    declare
    a pls_integer;
    begin
    a := win_api_utility.get_active_window(false);
    win_api_session.change_mdi_icon(A,'newiconfilename',0);
    end;
    The problem with this is that it will always raise an error on the web because It cannot get the handle for the window (Frame) in Java. Is there a way to change the icon or am I just shooting in the dark. Any help would be appreciated.
    null

    hi sir
    my name OSAMA and wanna your help in changing MDI window
    i trying this code
    I am trying this code
    Declare
    hWin pls_integer := win_api_utility.get_active_window;
    Begin
    WIN_API_SESSION.CHANGE_MDI_ICON(hWin,'e:\e.ico',0);
    End;
    I have error
    frm-40734: internal error :pl-sql error occurred
    sorry but this is an urgent problem
    thank you sir
    osama

  • How can we change the default folder icon

    hi, is there anyway we can change the default folder icons of OS X?

    A quick search in these forums for folder icon brings up many hits, including this one: http://discussions.apple.com/thread.jspa?messageID=3792805

  • Changing the garbabe can icon

    Is there a way, short of finding the appropriate release of ResEdit, to change the garbage can icon in 9?

    Yes, Iconographer can be used to change the icons in the various system resources.
    In this case, the Trash icon resources are in the file named System in System Folder.
    If you were using ResEdit, you'd need to know the specific ones are in the icl8 and other associated icon resources, open that resource, then open the specific icon resource you want to alter.
    However, with Iconographer all you need do is use its Open item in the File menu, navigate to the file System and choose it. After a few seconds a scrollable list will appear showing all the icon resources in System. Scroll down to an item that you want to change, finding it visually or by ID#, double-click it, and it will be opened for you to tinker with. Saving it (File menu) will save any changes to the resource.
    The resource IDs for the Trash icons in the System file are -
    For the empty (nothing in it) icon:    -3993
    For the full (has stuff in it) icon:      -3984

Maybe you are looking for

  • Oracle Report Failing After Database Version Upgrade

    Hi, I have function code created in RDF file of oracle reports 10g as below- create or replace function clobblobtest (TMP_MID varchar2) return varchar is missed_text varchar2(1000) := ''; v_time_stamp date; v_end_time date; cursor c1(c_time_stamp in

  • I scanned a document and need to print. How do I do that?

    I scanned a document and I need to print it.  Where do I find it so I can print?

  • Tomcat Manual Deployment

    Hi, I'm trying to manually deploy a project (form, servlet, java class, jsp) but I put the project into ROOT folder. I think I'm wrong because when the form executes post method on the servlet Tomcat cannot find it and gives me Error HTTP 404(resourc

  • Portal Forms Perfomance

    I have developed several forms using 10.1.2 Portal. I have tried both a view based form and a table base form. Both the view based and the table based forms work but are very slow...I count 8 sec to comeback with results from the a simple table in th

  • I able to receive and send emails. however i cant read any incoming messages. pls contact me

    i can read incoming emails but it turn to be unreadable as follows : Theme :Exploring and Applying Prophetic Lessons in our Lives (Studies in = the Book of Daniel)=20 Messenger : Rev Dr Jack Sin=20 Message : An Earthly King exalts the Heavenly King (