Icon in the titlebar of a JDialog

Hey,
I'd like to put a small .gif Icon into the titlebar of a JDialog - is this possible?
Normally I use this with a JFrame - how's that with a JDialog?
this.setIconImage(new ImageIcon("myPackage/a-small-happy-face.gif").getImage());

I tried both possibilities now - unfortunately it didn't work out for me.
Perhaps I should have told you that I derived JDialog. My dialog class
is called DialogOptionSettings and it needs two other parameters (l and o).
I simply tried to forward "frame" and "true" in DialogOptionSettings ctor
to the base classes ctor.
It now works without problem, alas but also without icon...
          JFrame frame = new JFrame();
          frame.setIconImage(new ImageIcon("transform/face-icon-small-happy.gif").getImage());
          //Image img = Toolkit.getDefaultToolkit().getImage("transform/face-icon-small-happy.gif");
          //frame.setIconImage(img);
          dlgOptions = new DialogOptionSettings(frame,true, l, o); //true false for modal and frame is parent.

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

  • How can i change the icon in the top left of a jdialog

    how can i change the icon in the top left of a jdialog.
    thnkx in advance

    You cannot directly. If you have a jFrame (e.g.) with your own icon you can use one of the JDialog costructors using (Component owner, ... ). Then the dialog will display the same icon.

  • Changing the titlebar icon

    How can I change the default java icon shown in the titlebar of the java application?

    // Sets the icon for this fine application
    ImageIcon aII = new ImageIcon("images/logo.gif");
    this.setIconImage(aII.getImage());This does the trick in our application.
    / engegil

  • 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

  • Proxy Icon in TextEdit titlebar created HUGE file when dragged into Finder

    Hi everyone, Hope you can solve this mystery...
    I just noticed that the Titlebar of my TextEdit window has a small icon next to the filename (aka "Proxy icon").  I realized that it's draggable, so I decided to do little test to test it's functionality. 
    - I created a small file with one word in it "test" and saved it as "test file.rtf" in a subfolder under Documents; and
    - With the file still open, I dragged the Proxy Icon into a Finder window to the Desktop folder.
    When I looked for the file in Finder, I was shocked to see that:
    - It created a HUGE file...the original file is only 306 bytes in size, but the one I created by dragging shows 2.3 MB !
    - The dragged file also has the appearance of an "Alias" file b/c the Finder window show3s a document icon with a curved arrow next to the filename.
    Questions:
    1) Why would Maverick use an Alias symbol on a file that is clearly not an Alias based on it's size?
    2) Why is the file so much larger than the original?
    I searched online for answers but found none, so I thought I'd give this forum a try.
    btw - in case you're wondering, I did not open the dragged file b/c I didn't want to take any chances.
    Thanks in advance.
    C
    OSX Maverick
    Mac Mini (purchased new approx 6 months ago)

    You can avoid the hassle of the Terminal with this contextual menu add on: SymbolicLInker. It's just a right click away:

  • Display an icon(question,warning,etc.) inside JDialog(like in JOptionPane)

    Hello,
    because JOptionPane can't use a JPasswordField as the input component, I created a JDialog prompting the user for a password. Now I can't figure out how to show that nice look-and-feel style icon inside the dialog (the question mark that is shown when you use messageType=QUESTION_MESSAGE in JOptionPane). Shortly, this is what I have and this is what I want to get... I tried this:
    dlg.getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG)But it does nothing. Could you help me, please?
    Thank you
    Ondra

    Still it doesn't answer my question: how to display the LAF icon inside a JDialog.Huh?import javax.swing.*;
    public class OptionPanePassword {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new OptionPanePassword().makeUI();
       public void makeUI() {
          JLabel label =new JLabel("Enter Password: ");
          JPasswordField field = new JPasswordField(15);
          JPanel panel = new JPanel();
          BoxLayout layout = new BoxLayout(panel, BoxLayout.X_AXIS);
          panel.setLayout(layout);
          panel.add(label);
          panel.add(field);
          JOptionPane.showConfirmDialog(null, panel, "",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    }db

  • 'X' icon at the right corner of POPUP_TO_CONFIRM window

    Hi,
    I used POPUP_TO_CONFIRM to pop up a window, but when click the 'X' icon at the right corner, the window can not be closed, how to make this work?
    Thanks a lot.
    Best Regards,
    Stephanie

    if you enable the cancel button it will work
    CALL FUNCTION 'POPUP_TO_CONFIRM'
               EXPORTING
                    titlebar              = 'THis is for test'
                    text_question         = text-009
                    text_button_1         = 'Yes'
                    icon_button_1         = 'ICON_OKAY'
                    text_button_2         = 'No'
                    icon_button_2         = 'ICON_CANCEL'
                    default_button        = '2'
                    display_cancel_button = 'X'                 "If you enable this then it will work
                    start_column          = 25
                    start_row             = 6
               IMPORTING
                    answer                = v_ans.

  • How can I display icons on the bookmark bar?

    Does anyone know how to display a webpage's icon on the bookmark bar instead of the title? thanks!

    Use a JFrame not a JDialog.

  • Add a icon to jframe titlebar

    Hi all,
    I want to add an icon near the minimize, maximise, close icons in a JFrame titleBar.
    The new icon should be the one for "minimize application to tray" (so the icon with the dot)
    Any ideas? Thx very much!

        setIconImage (new ImageIcon ("location of your icon.jpg").getImage ());

  • When I drag and drop an icon from the address bar to the desktop is does creat the shortcut but will not display the website icon, only the firefox icon, how can I display website icons?

    When I drag and drop a website icon from the Forefox address bar to the desk top, the short cut is created but the icon that appears is the firefox Icon. I want to disply the icon from the website that the short cut refers to. I have checked all I can think of in my computer to no avail.

    You have to assign the favicon yourself to the desktop shortcut (right-click the shortcut: Properties) after you have dragged the link to the desktop.
    You can usually find the favicon in Tools >Page Info > Media and save the icon there.
    Otherwise use the main domain of the website and add favicon.ico (e.g. mozilla.com/favicon.ico ) to display the favicon in a tab and save that image to a folder.

  • How do I add the Displays icon to the Menu Bar?

    In prior OS on my iMac, I was able to add the Display icon to the Menu Bar, making it a quick fix to adjust the resolution.  That option no longer appears in the Display section of System Preferences.  I am using multiple displays.  Could that make any difference?  Any suggestions?

    http://displaymenu.milchimgemuesefach.de/about.html

  • How do I select which bluetooth speakers to play out of? My iPod connects to both kitchen and living room speakers. My old iPod had a selection icon on the now playing screen, but my new one doesn't.

    Hi,
    Our setup
    A new iPod Touch 5 with iOS 8.3.
    Living room speakers that use a Logitech Bluetooth Audio Adapter.
    Kitchen speakers that use an AmazonBasics Bluetooth 4.0 Audio Receiver.
    The iPod connects to both but always wants to play to the kitchen. To play in the living room, we have to unplug the power to the kitchen speakers. Bluetooth settings screen doesn't let you select between Bluetooth connections. All I seem to be able to do is forget the connection.
    We also have an old iPod Touch (not sure of the generation, but it has iOS 6.1.6). On that one, there is a little icon on the now playing screen that would open a little pull-down menu to let you select which Bluetooth connection to use for playing audio.
    I don't see the "select output" icon on the new now playing screen
    Jimmy
    PS the iPod seems very aggressive in connecting. I hear the living room speakers activate when my wife gets out of the car in the driveway. Then as she comes into the living room, the sound switches to the kitchen.

    Thanks, this was the clue I needed to figure it out.
    From Settings you can pull up Control Center.
    In Control Center you can enable "Access from within Apps" (also "Access from Lockscreen")
    Now when I'm playing music, I can swipe up from the bottom and a little control center window slides up. Neat - this is new since my old iPod. On this window, the name of the current Bluetooth connection appears. Tap on that, and a list of connected Bluetooth items appears. I just tap on the one I want to connect to and I am now playing through the speakers I want.
    Jimmy

  • Downloads of updates not saving, no prompts or icons in the Application folder-how do I ensure updates are saved?

    I am following the instructions to download v 6 but receive no prompt to move the Firefox icon to the applications folder. I have done that anyway, but it's not saving-the latest version is July 11. I then get reminders to update all the time-what am I doing wrong?
    I am working on a Mac laptop

    A lot of people panic when they see Photoshop displaying differently from other software. But that's normal and expected. Here's what happens:
    1. Photoshop is color managed and performs a document profile > monitor profile conversion when it displays. So whatever the document profile is, Photoshop will display correctly - unless you have CM policies set to "off" (...!)
    2. Other applications, including many web browsers, aren't color managed and will just send the file numbers directly to the display. This distinction is extremely important, because there will be a slight difference. Again, that's normal. Photoshop is right and the other apps are wrong.
    3. Without color management, it all hangs on how your monitor displays color. Most monitors are so close to sRGB that any sRGB file will display roughly correctly. This is why sRGB is the de facto web standard: it can live without color management. And that's why you should always convert web material to sRGB. Yes, that's the Edit > Convert to Profile option. You can also use Save For Web to do this if you check the appropriate boxes.

  • I just got my Ipad2 and have my email accounts set up.  When I go to the folder icon at the top of the page and click on Sent Items they disappear to somewhere.  How do you look at your sent items?

    I just got my Ipad2 and have my email accounts set up.  I have sent messages but when I go to the folder icon at the top right of the page and tap on SENT emails it makes the inbox email on the screen disappear.  How do you check your sent emails?  Thanks for your help.

    You can send over WiFi, but it sounds as if you need to setup your Gmail account, or did you do this already?

Maybe you are looking for