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

Similar Messages

  • How to set Icon on MenuItem

    How to set icon on MenuItem, but not in JMenuItem?

    saleemtol003 wrote:
    You are right.It's not possible to set icon on menuItem.
    I am talking about SystemTray in which I added PopupMenu with MenuItem.
    but I need MenuItem with icon.Is there another way to solve this problem?Nope, just because you're adding a PopupMenu to a TrayIcon does not change the fact that MenuItems cannot have icons.

  • How to set icon image in jstudio for my application

    Dear friends,
    I developed one application in jstudio.And need to set an special icon for my application.While i download my application in to mobile. The icon should be displayed in the mobile.To show my application as unique from other applications.But i dont know how to set an icon for my application. If any one find answer please reply as soon as possible.
    Thank you

    Java Studio Enterprise per se does not support creating applications for mobile devices. I gues you used NetBeans Mobility Pack for that. Therefore, please refer to http://mobility.netbeans.org/ for more information. Thanks.
    Here is a FAQ entry, which, as far as I understand answers your question: http://www.netbeans.org/kb/faqs/j2me-mobility.html#FaqJ2MESpecifyMidletIcon

  • How to set icon for .lnk on PPC

    I'm using the Mysaifu JVM and I would like to know how to set an icon of my choice for the shortcut file to my application (.lnk). Currently, the Mysaifu character shows up as the icon.
    On a previous post, I found out how to run my java application using the following text in my .lnk file:
    255#"\Program Files\Mysaifu JVM\jre\bin\jvm.exe" -Xhidevmwindow -Xmx5M -jar "\My Documents\DeliveryOrganizer.jar" DeliveryOrganizer
    Please help!!!
    Your help would be much appreciated!
    Thanks!

    I don't think you're going to have much luck modifying the original link, since the jvm.exe is what the link is pointing to. Windows Mobile is getting its icon from the jvm.exe, and not the DeliveryOrganizer jar file.
    However, you might look into creating a separate .lnk file, that then calls your original .lnk file that executes the jvm.exe. See if Windows Mobile allows you to modify the new .lnk file's properties...

  • How to Set icon/image programatically in ADF before page loads

    This is my UI:
    Depends on the condition i want to set icon/image programatically in my java code.Before page load im calling this method.
    So i couldnt take binding value also,it throws null pointer exception.Then i tried setting icon/image programatically.
    <af:commandImageLink text="settings" icon="#{bean.iconsettings}" binding="#{bean.bind}"> </af:commandImageLink>
    My bean:
    private RichIcon iconsettings;(its getters and setters)
    private void method(){                         // method
    if(cond){
    this.iconsettings="/images/20.jpg";   //trying to set icon in a string.but it throws me error that cannot set RichIcon to string.
    else
    this.iconsettings="/images/19.jpg";
    Could any one tell me how can i set icon/image in java code.Before page loads im performing all above said tasks.Please help.

    Well, you set the icon property to a bean method, which you have done. The bean method however need to have the signature
    public String getIconsetting()
    // your code returning hte path to the icon
    if(cond){
         return ="/images/20.jpg";   //trying to set icon in a string.but it throws me error that cannot set RichIcon to string.
    else {
         return ="/images/19.jpg";
    The bindproperty is not needed, remove it and remove the RichIcon Iconsettings too´as it's not needed to and is the wrong type anyway.
    Timo

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

  • Setting icon in JDialog

    Hi all
    I have a problem setting an icon in a JDialog. Now I know that JDialog's icon image will be the same as the icon image of its parent frame. Hence, setting the icon image of the parent frame which launches the JDialog will set the icon for the JDialog. But the problem lies here. It does not work the way it should. The JDialog is not getting the icon from the parent frame. Can somebody help me out with this problem? Is there any other way to set the icon for the JDialog explicitly - say something like a setIcon().
    Help will be really appreciated.
    Thanks.

    Hi,
    there is no setIcon(). There are some problems when your JDialog is not resizable and modal. Try some combinations with resizable and modal to find out whether thats the reason.
    Phil

  • How to set icon in JavaHelp frame?

    Hello everybody
    I'm using JavaHelp 2.0 for the first time and I have been told that it is possible to set the icon within the JavaHelp frame. Furthermore it should be possible to set the position of the help window.
    I used the following code within my Java class to start JavaHelp, as the help frame should appear, when the user clicks on "JavaHelp" within the "Help" menu:
        JMenu helpMenu = new JMenu("Help");
        try {
          URL hsURL = new File("javahelp/DbManager.hs").toURL();
          HelpSet hs = new HelpSet(null, hsURL);
          HelpBroker hb = hs.createHelpBroker();
          menuItem = new JMenuItem("JavaHelp");
          menuItem.addActionListener(new CSH.DisplayHelpFromSource(hb));
          helpMenu.add(menuItem);
        } catch (Exception e) {
        }My helpset is called "DbManager.hs" and here's the presentation section of it (of course the image "dbmanager.title.image" is defined within the map file):
      <!-- presentation -->
      <presentation default="true" displayviews="true" displayviewimages="false">
        <name>MainWindow</name>
        <size width="600" height="500" />
        <location x="200" y="200" />
        <title>Database Manager</title>
        <image>dbmanager.title.image</image>
      </presentation>When I start the JavaHelp it does not show the Icon and it does not set the size and location accordingly.
    I'd be very glad for any hint on what I might be overlooking.
    Thanks,
    Christian

    Hi,
    You need to specify the name of your presentation in the createHelpBroker call:
        JMenu helpMenu = new JMenu("Help");
        try {
          URL hsURL = new File("javahelp/DbManager.hs").toURL();
          HelpSet hs = new HelpSet(null, hsURL);
          HelpBroker hb = hs.createHelpBroker("MainWindow");
          menuItem = new JMenuItem("JavaHelp");Then it should work.
    Brendan

  • How to set icon for JTree

    hi,
    I have a JTree. For this JTree i have a DefaultJTreeCellRenderer.
    i have done like this
    JTree tree = new JTree();
    DefaultJTreeCellRenderer renderer = new DefaultJTreeCellRenderer();
    renderer.setOpenIcon(....);
    renderer.serCloseIcon(...);
    tree.setCellRenderer(renderer);but this is not working.
    how to change the icons of the node when i click
    thank you

    public class Test extends JFrame implements ActionListener {
         private static final long serialVersionUID = 1L;
         private JButton buttonCreate;
         private JTree tree;
         private DefaultMutableTreeNode defaultMutableTreeNode;
         private DefaultTreeModel defaultTreeModel;
         private int i;
         public Test() {
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              layoutComponents();
              setSize(400, 400);
              setLocationRelativeTo(null);
              setVisible(true);
         private void layoutComponents() {
              defaultMutableTreeNode = new DefaultMutableTreeNode("Root");
              defaultTreeModel = new DefaultTreeModel(defaultMutableTreeNode);
              tree = new JTree(defaultTreeModel);
              tree.setRootVisible(false);
              buttonCreate = new JButton("Create");
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(tree, BorderLayout.CENTER);
              getContentPane().add(buttonCreate, BorderLayout.SOUTH);
              DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
              ImageIcon icon_close = new ImageIcon("./images/project_closed.gif");
              ImageIcon icon_open = new ImageIcon("./images/project_opened.gif");
              renderer.setOpenIcon(icon_open);
              renderer.setClosedIcon(icon_close);
              tree.setCellRenderer(renderer);
              buttonCreate.addActionListener(this);
         public static void main(String[] args) {
              new Test();
         public void actionPerformed(ActionEvent e) {
              addElementToParent("Child" + i++);
         private DefaultMutableTreeNode addElementToParent(Object theChild) {
              return addElementToParent(defaultMutableTreeNode, theChild, true);
         private DefaultMutableTreeNode addElementToParent(DefaultMutableTreeNode theParent, Object theChild, boolean shouldBeVisible) {
              DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(theChild);
              if (theParent == null) {
                   theParent = defaultMutableTreeNode;
              defaultTreeModel.insertNodeInto(childNode, theParent, theParent.getChildCount());
              TreePath childTreePath = new TreePath(childNode.getPath());
              //          Make sure the user can see the lovely new node.
              if (shouldBeVisible) {
                   tree.scrollPathToVisible(childTreePath);
              tree.requestFocusInWindow();
              return childNode;
    }this is the code which i was trying to execute.
    here i want to explain you is
    when i click the node the icon should change to open_icon
    when i click the other node the previous node icon should change to close_icon
    how is this possible
    null

  • How to set icon to a file type??

    How to assign an icon to the application generated file?
    Thanks in advance.

    What GUI do you work with?
    I assume you want to see the icons in Windows. You will have to modify the registry, possibly by some native API call. Have a look at the MSDN library then.
    Hiran

  • How to set icon that fit(stretch) to JLabel?

    Let say i have aa image(w = 50, h = 50) and JLabel(w = 100, h = 100)
    how to fit the image to JLabel by JLabel.setIcon(image)?
    thx..

    Ooop... sorry u mean getScaledInstance right, by the way which the faster way to scale image? code 1 or code 2
    Code 1.
    public ImageIcon create_Thumbnail(ImageIcon img,int w , int h ){
            img = new ImageIcon(img.getImage().getScaledInstance(w, h, BufferedImage.SCALE_SMOOTH));
            return  img;
    }Code 2
        public ImageIcon create_Thumbnail(ImageIcon img,int w , int h ){
            BufferedImage bi;
            bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();     
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            g2.drawImage(img.getImage(), 0, 0, w, h, null);
            g2.dispose();
            return new ImageIcon(bi);
        }

  • 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 would like to know how to set the default view for the columns. Somewhere I read it could be done in by music icon under Library.  Can't find it.  Thanks

    "I would like to know how to set the default view for the columns that are shown in iTunes. Every time I open it, I have to either go to the options, or right-click to get the pop-up options, and delete "rating" and add "composer." I'd really like to just do it once and be done with it."  Somewhere I read you could do this by clicking on the Music icon under LIBRARY then arramge the columns.  Trouble is, I can't find a Musi Folder or icon in my user library.
    Any help would be appreiated.  OSX 10.9.2  iTunes version 11.1.5  Thanks!!! CW!

    From the iTunes menu bar try View>Show View Options.  Make sure what you want to see is checked and what you don't is unchecked.  You can do this (may need to do this) for any playlists, your main Library, etc.
    Good luck
    srb

  • How to set the minimum size of the JDialog.

    Hi Could any one tell me ,
    How to set the minimmum size of the JDailog.
    I am using the JDialog's setMinimumSize(...)
    But it is not working.....
    Regards -
    Vikas Kumar sahu

    That's pretty much all there is, although you could always add a componentlistener and manually not let the size go below your minimum.
    Or you could try overriding setSize...

  • How can we set icon to a tree table

    Hi ADF Experts,
    The below is regarding skinning of af:tree table component.
    How can we set icon to a tree table
    Below is the af:tree component. When I run the application I see all the parent and child nodes as folder icon. My question is how can set a file icon to the elements present inside a parent node.
      <af:treeTable value="#{pageFlowScope.MerchandizeTreeModel.productTreeModel}"
                                      id="tt1" var="row"
                                      rowSelection="multiple"
                                      horizontalGridVisible="false"
                                      verticalGridVisible="false">
                          <f:facet name="nodeStamp">
                            <af:column sortable="false" headerText=""
                                       rowHeader="true" id="c11" width="200">
                     <af:panelGroupLayout id="pgl0">
       <af:image source="/images/folder.png" shortDesc="foldericon"
                                id="i1"/>
                      <af:outputText value="#{row.groceryItems}" id="ot11"/>
    </af:panelGroupLayout>
                            </af:column>
                          </f:facet>
                        </af:treeTable>
    Thanks in advance,
    Animesh

    Hi Experts,
    I am having a tree table component in adf. I have set a folder image for the parent node. How can we set a document image for contents inside a parent node.
    Thanks,
    Biswa

Maybe you are looking for