Setting an icon in the title bar of a JFrame...

Hi,
how do I set an image (icon) in the title bar of a JFrame (in the top left corner)?
In JInternalFrame there is a method
public void setFrameIcon(Icon icon)to set an image in the title bar of this internal frame - but in a JFrame I didn't find any method like this...
Thanks in advance
- Stephan

Thanks ICE, that works for me...
this.setIconImage(new ImageIcon("img\\foo.jpg").getImage());- Stephan

Similar Messages

  • Set an icon in the title bar.

    Hello,
    i am unable to set an icon before the title in the title bar.
    i am using jdk1.4.
    could someone plz tell me how to do this.
    i have tried the setFrameIcon method...but it only works for internal frames...not for JFrame.
    By default it is the tea cup and saucer icon( well, that is what it is right?)...how can i replace this with my own icon?

    Try this,
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image icon = kit.getImage("myicon.gif");
    setIconImage(icon);

  • 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();
    }

  • Changing icon in the title bar

    Hi all,
    I've seen that applications like NetBeans have custom icons in the title bar of the application (instead of the standard Java Cup). How can I do the same? (i.e. customize the icon).
    Thanks in advance!

    One issue to be aware on Windows is that the icon you set is used both on the title bar (16x16) and when you <alt> <tab> between apps (32x32 or 48x48 on XP). This means that if you create a 16x16 icon it will look kind of chunky when you <alt><tab>. At work we get our art department to create a 48x48 icon that scales down to 16x16 well, a non trival task.
    IL

  • Odd action using the icon in the title bar of image in psCS5--???????

    i use imac, lion.
    by accident, i discovered that, clicking on and dragging the icon at the left of the title bar (actually within the title bar to left of file name),  i can sometimes open the
    image in ACR,  as hosted by BRIDGE (which is not running. i do not use bridge).
    sometimes the image will be duplicated following this dragging of icon, the new duplicate lying atop the image of the background layer, in the same window, and shows the diagonal bars awaiting resizing. if i just click the ("checkmark")  in the options bar to accept this new layer,  or, if i  press enter, i am looking at a new layer, which is a duplicate of the background layer. this new layer is a "SMART OBJECT", and functions as such.
    this happens only with JPG and TIF files, not with RAW.  i have ACR prefs set to open all supported jpg and tif files.
    i should note that none of this occurs if the image has been edited in any way. in fact, after any edit the icon in the title bar is not movable.
    i am having some difficulty describing a simple and quick process. i don't know if this is a bug, a feature, or the result of too much RED BULL!  i Just reread post and it does seem delusional.
    can anyone help?

    it seems to work with or without the shift key.
    I work with OS 10.6.8 and you are right that it works without shift, too.
    My surmise is that the title bar’s icon of non-dirty files (files that have no History steps save the Open-step or have just been saved) behaves like the file’s icon in the Finder as the behaviour seems to be exactly like a drag-and-drop from the Finder (as a Smart Object if set in the Photoshop > Preferences > General > Place or Drag Raster Images as Smart Objects, not if set otherwise) and works across files, too.
    I don’t think I had noticed that previously, but that behaviour may well be fully intentional.

  • Disabling close 'X' icon in the title bar of JDialog

    I found that JDialogs by default come up with the close 'X' icon. The only manipulation that can be done is by setting the DefaultCloseOperation.
    Is there some way I can avoid showing that icon on the title bar?
    My JDialog already has a 'Close' button and I have written an action listener for it. I dont want to listen to WindowEvents as well.

    JDialog d = new JDialog((Frame)c, true);
    d.setSize(400,300);
    d.setUndecorated(true);
    d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);That bit of code seems to get rid of the title bar entirely and cause a MetalLookAndFeel dragging bar without an X to appear.
    Let me know if this is a satisfying solution
    My full test code followsimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DyalogTest extends JFrame
       public DyalogTest()
          super("Dialog Test");
          setSize(500, 400);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container c = getContentPane();
          c.setLayout(new FlowLayout());
          JButton b = new JButton("Initiate Dialog");
          b.addActionListener(new ActionListener()
             public void actionPerformed(ActionEvent e)
                Component c = SwingUtilities.getRoot((Component)e.getSource());
                JDialog d = new JDialog((Frame)c, true);
                d.setUndecorated(true);
                d.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
                JButton b = new JButton("Dispose");
                b.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
                      Component c = SwingUtilities.getRoot((Component)e.getSource());
                      JDialog d = (JDialog)c;
                      d.setVisible(false);
                      d.dispose();
                d.getContentPane().setLayout(new FlowLayout());
                JPanel p = new JPanel();
                p.setPreferredSize(new Dimension(400,300));
                p.setBorder(BorderFactory.createTitledBorder("Vanilla Dialog"));
                p.add(b);
                d.setContentPane(p);
                d.pack();
                d.setVisible(true);
          c.add(b);
       public static void main(String[] args)
          new DyalogTest().setVisible(true);
    }

  • Placing an Icon in the Title bar.

    Hello,
    i am unable to set an icon before the title in the title bar.
    i am using jdk1.4.
    could someone plz tell me how to do this.
    i have tried the setFrameIcon method...but it only works for internal frames...not for JFrame.
    By default it is the tea cup and saucer icon( well, that is what it is right?)...how can i replace this with my own icon?

    setIconImage ( new ImageIcon ( "image.gif" ).getImage () );
    put "image.gif" in the same directory as the .class

  • 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

  • Displaying an icon in the title bar of a web page

    Hi Friends,
    Pls temme how 2 display a given icon in the title bar of a web - page, i mean in the title bar of the web - browser which loads the page.
    Thanks in advance,
    Kottayam Achayan

    Hi Friends,
    Pls temme how 2 display a given icon in the title bar
    of a web - page, i mean in the title bar of the web -
    browser which loads the page.
    Thanks in advance,
    Kottayam AchayanIn web.xml, you can use the <icon> element to specify the image to be used.
        <icon>
            <small-icon><!-- Specify a 16X16 GIF or JPG --></small-icon>
            <large-icon><!-- Specify a 32X32 GIF or JPG --></large-icon>
        </icon>Hope this helps.
    Annie.

  • 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.

  • Volume icon in the Title Bar of my Treo 800w?!

    I don't know completely how to explain this, but here it goes:
    I have a Palm Treo 800w for Sprint. Yesterday, I looked at my phone (that I've had for 3-4 months now) and noticed a symbol that I've never seen in Title Bar on the right-hand side. It was an icon for volume, except it provided more(and simpler) options for volume. When you click on it, it showed the volume levels you could choose, but you could also select On, Off, or Vibrate. I went to look at the icons provided in the User Guide, but it wasn't any of them. ALSO, this icon in the Title Bar replaced where my battery icon usually would go.
    Anyways, my phone died, and when I turned it back on, it resumed to normal and didn't show the icon anymore. I like that icon, so I looked all around on my phone and read the user guides, but found NOTHING! Please help me if you can!
    Megan
    Post relates to: Treo 800w (Sprint)

    Sometimes after you use the media player (and under other equally unpredictable circumstances) the volume/speaker icon replaces the battery icon. I don't think I've ever clicked it, so I don't know whether it's functions are duplicative of an equally convenient icon.
    Since most people are much more concerned about their battery life, every post I have seen here on this was a complaint about the change rather than a request for it.
    Anyway, I don't think there is any built-in way for users to change the icons on that bar. There might be third party software or registry edits to do it; that would require more research.

  • Embedding HTML in the Title Bar of a JFrame

    Hi Folks,
    I have a simple question. Do you know I can I employ an HTML-enabled script in the title bar of a JFrame? I would like to make use of the subscript tag in HTML <sub>, yet it didn't work out:
    public class MyFrame extends JFrame{
    super("<html>KPC<sub>V.10</sub></html>");
    }I don't know what I am doing wrong, but the title appears with the HTML tags, not in the way I would like it to be formatted. What would you suggest?
    Regards,

    The frame title is (typically) set in a native OS frame, which is not controlled by Java.
    Perhaps if you tell Java to let the L&F control the frame decorations it might work, but probably not, as it would probably just try to mimic what the OS does anyway, which is to not support HTML.
    So basically, you can't.

  • Changing the logo in the Title Bar of a JFrame

    How do I change the logo in the left hand corner of the Title Bar of a JFrame window.

    Hi Sverigeterje
    Thanks.
    That's very neat. All done with one line of code, as opposed to the two lines of code I found in an answer (dated Jan 8, 2001) from Alexander Smirnov in response to a similar question (dated Sep 16, 2000) from Shawn Barker. (http://forums.java.sun.com/thread.jsp?forum=31&thread=49970 - Jan 8, 2001)
    ImageIcon image = new ImageIcon("CustomIcon.gif");
    this.setIconImage(image.getImage());
    Once again many thanks.
    George (aka cyberking1)

  • Displaying our own icon at the title bar of a frame.

    Hai,
    How do i display an Icon of my choice at the title bar of a frame or a dialog box.
    Thank you.

    Thank you shahidjava for the kind reply,
    I tried your code as follows but I'am getting an exception saying "wrong number of arguments in the method.".
    Can you please help this out.
    import java.awt.*;
    import java.awt.event.*;
    public class testIcon extends Frame
         public testIcon()
         setVisible(true);
         setTitle("mohammad afzal....!");
         setBounds(100,100,200,200);
         getIconImage("afzal.gif");
         public static void main(String args[])
         testIcon ti=new testIcon();
    }

  • 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

Maybe you are looking for

  • New columns in Enjoy Preq (ME51N/ME52N/ME53N) overview ALV

    Hi all, I want to add some new columns in the overview subscreen of the Enjoy Purchase Requisition transactions (ME21N/ME22N/ME23N). I've added some fields on item level of the PReq, via the enhancement MEREQ001 (in the Customer include CI_EBANDB). I

  • Can I easily match Pantone colors using Illustrator?

    Hi all, I run a small invitation supply company. Our primary design tool up until now has been Photoshop Elements. We recently purchased a $6000 printer from Xerox which is the 'gold standard' for graphic arts and Pantone approved. We also have a pan

  • Charts of CR2008 not working in CR2011

    Hello everyone, I have a problem with Crystal Reports. I created reports with CR 2008 wich worked fine and looked as they should, but when I open the same report in CR2011 the charts are looking really bad. For instance a bar chart in CR2008 has a no

  • Price from Pur Info record not picking up

    Hi All, We have a requirement to pick Price from Purchasing Info record for Standard Cost estimate (CK11N/CK40N). The purchase info record has been created and price maintained in both u201CNet Priceu201D and u201CEffective Priceu201D fields in info

  • Tool bars missing advisor says 'hold key down - What KEY???

    My tool bars went missing, so I went to help. The advise said this is a 'new' feature [who needs this???] It also said I could restore the tool bars that I didn't ask to lose by holding 'the key' down and pressing V T etc at the same time. But, My ke