Setting icon in JDialog title bar.

Hi all,
Can u send me the code for setting the icon in the title bar of JDialog?
Currently i'm working on linux.
Is there any possible way to set it.

1) Swing related questions should be posted in the Swing forum.
2) Quit multi posting, you where given the answer yesterday when you originally posted this question.

Similar Messages

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

  • 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

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

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

  • How to set mouse listener for title bar of JFrame ?

    Hi, all
    How to we can set mouse listener for title bar of JFrame ?
    Please help

    Again, why did you not state this in your original
    question? Do we have to ask you every time what your
    actual requirement is?
    As I said in your last posting, if you don't give us
    the reuqirement in you question we can't help you.
    Sometimes your solution may be on the right track
    sometimes it isn't. We waste time guessing what your
    are trying to do if you don't give us the
    requirement.
    I gave you the answer in your other posting on this
    topic. The AWTEventListener can listen to events
    other than MouseEvents.
    The Swing tutorial has a list of most of the events.
    Pick the events you want to listen for:
    http://java.sun.com/docs/books/tutorial/uiswing/events
    /handling.htmlthe first, i am sory because my requirement not clear so that it wasted everybody time.
    The second, thank for your answer
    The third, AWTEvenListener do not support listener event on title bar
    but ComponentListener can know when we can change frame position.
    please see below that ComponentListener can handle action:
    public void componentHidden(ComponentEvent e) {
            displayMessage(e.getComponent().getClass().getName() + " --- Hidden");
        public void componentMoved(ComponentEvent e) {
            displayMessage(e.getComponent().getClass().getName() + " --- Moved");
        public void componentResized(ComponentEvent e) {
            displayMessage(e.getComponent().getClass().getName() + " --- Resized ");           
        public void componentShown(ComponentEvent e) {
            displayMessage(e.getComponent().getClass().getName() + " --- Shown");
        }Thanks for all supported your knowledge, you are great !

  • 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 set icon in JDialog

    In JFrame there is method setIconImage(Image) for setting image icon on title bar , but in case of JDialog how to it?

    In case you have not mentioned the owner of JDialog, java sets a hidden frame as its owner.Thefore you can set the icon on a JDialog dialog by
    ((java.awt.Frame)dialog.getOwner()).setIconImage(Image);
    Regards
    Shashi

  • Black and white and coulored icons in Gnome3 title bar

    Hello all,
    I wonder about icons in the Gnome3 title bar. I did'nt changed any related settings.
    I have an up to date physical installation and an up to date Virtual Box with beautiful black and white icons:
    Today I upgraded a clone of the Virtual Box machine. This machine was not updated since months. The icons are colored now.
    I thought all up to date installations should have the same theme and icons. Just for know, why they are different and where can I fix it?
    Last edited by wwn (2014-05-07 13:14:44)

    Don't export it as a .jpeg which is unsuitable for B&W images, blurring them as rgb files (not B&W).
    Better is .tiff (compressed B&W tiff are tiny) or 1 bit .gif.
    It is also possible that .pdf vector files might work but I haven't experimented with those.
    http://www.google.com.au/search?q=black+%26+white+vector+patterns&hl=en&client=s afari&rls=en&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=T0yYUNjqOKaTiAeqrYGwA Q&ved=0CCkQsAQ&biw=1138&bih=1272
    http://www.graphicswall.com/black-and-white-vector-patterns
    http://all-free-download.com/free-vector/black-and-white-vector-pattern.html
    http://www.freevector.com/category/patterns/
    http://vectorpatterns.co.uk/patterns-2/a-transparent-black-and-white-arrow-patte rn-set/
    http://pattern8.com/
    This is very retro lo-tech with unattractive results, which is why I guess Apple hasn't bothered with them.
    Peter

  • 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

Maybe you are looking for

  • How to check DFS replication status in windows 2008 r2 file server

    Hi, I have created File server DFS namespace between 2 windows 2008 R2 server. namespace mode is 2008. I have copied 3 TB data on file server 1. now it is getting replicated from file server 1 to file server 2. till now the data is not fully replicat

  • Event Alert in Oracle Application

    Hi all, Reqquirement- I am having one task custom form in that form we assign a task to our employee.when i assign a task on that form, mail alert should fire & mail should send to that employee. Query- When i save a record on my form alert get fired

  • KDE - Global keyboard shortcuts not working

    My global keyboard shortcuts have stopped working in KDE. When I try to open "Shortcuts and Gestures" in the System Settings, it freezes, and eventually needs to be terminated. Any ideas what could be causing this? I don't see any related recent upda

  • Flash and Flex swc... and a little bit of Blazeds

    i have created a flex library project that connects to a BlazeDS endpoint for consumer/producer communication... i have used action script rather than configure the config.xml file on the server...  heres a snip of the code... channelSet = new Channe

  • Compromise of the group

    Hi, I am supervisor of a group of vendors, and must view the agendas periodically. To view the agenda creating a group, but to work each user has to give me permission. How do I see the agendas, without the need to ask for each user that the permissi