How to set icon in joptionpane title bar

Hi all,I like to set a icon in joptionpane title bar(to the top left of joptionpane)Is there any possible way to set it.Can anyone send me the code to set the icon
[191 byte] By [rose@rosea] at [2007-11-27 5:59:57]
# 1
Did you bother reading the documentation? http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html#JOptionPane(java.lang.Object,%20int,%20int,%20javax.swing.Icon)
rebola at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 2
All dialogs inherit the icon from the parent JFrame.
camickra at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 3

Hi

I ve tried this,but still i' m not getting icon in joptionpane title bar.

JOptionPane jp = new JOptionPane("Session Expired - Please Re Login" , JOptionPane.INFORMATION_MESSAGE , JOptionPane.WARNING_MESSAGE, ("logosmall.gif"));

JDialog dialog = jp.createDialog(parent, "Session Expired - Please Re Login");

((Frame)dialog.getParent()).setIconImage(("logosmall.gif").getImage());

dialog.setVisible(true);

can anyone help me.....

rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 4
Not sure, but I think the icon of the frame needs to be set before the dialog is created.
camickra at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 5
you need to include this line before it will showdialog.setResizable(true);now, if that works for you, go to javaranch and the other places you've posted thisand post a follow-up 'problem solved'
Michael_Dunna at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 6

hi.

My problem not yet solved.

I am getting the icon only in the message displaying region.

I need to get the icon in title bar of joptionpane.

even i added setresizable() too.

could anyone reply...... with proper solutions.

Remember i need to get the icon exactly in the title bar of joptionpane.

rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 7
> could anyone reply...... with proper solutions.you have the solution/syou need the ability to use them correctly
Michael_Dunna at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 8

All,

I am building an applet using swings extensions and the applet runs well with applet viewer, but when i run it in IE, for the first time its visible but from second time onwards the icons in applet are not visible.

I am trying to load atleast 30 images

using

ImageIcon line2Available=new ImageIcon(getClass().getResource("/com/citi/cti/images/line_circles/04pch_up_line2_04blue.gif"));

kindly help me in this regard

is there anyway i can make sure the images loads always

Suntosha at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 9
Hi,I ve used them correctly.But still i am not getting it.I am getting the icon only in the message displaying region not in the title bar.Could you plz send me the code with the snapshot of that code.
rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 10

hi!

try this out..

package com.ani;

import javax.swing.ImageIcon;

import javax.swing.JDialog;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import com.sun.java.swing.plaf.windows.WindowsIconFactory;

public class Sample_01

{

/**

* @param args

*/

public static void main(String[] args)

{

JFrame frm = new JFrame();

frm.setIconImage(new ImageIcon("C:\\Movies0.JPG").getImage());

frm.setBounds(100, 100, 100, 100);

frm.setVisible(true);

frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JOptionPane jp = new JOptionPane("Session Expired - Please Re Login" , JOptionPane.INFORMATION_MESSAGE , JOptionPane.WARNING_MESSAGE, WindowsIconFactory.getMenuArrowIcon());

JDialog dialog = jp.createDialog(frm, "Session Expired - Please Re Login");

dialog.setResizable(true);

dialog.setVisible(true);

}

}

change the image according to your specification.

regards

Aniruddha

Aniruddha-Herea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 11

Hi,

I am getting the icon in the frame that is present behind the joptionpane.

But i need to get the icon in the joptionpane's title bar not in the frame 's title bar.

http://java.sun.com/docs/books/tutorial/figures/uiswing/components/JOptionPaneMetal.png

http://java.sun.com/docs/books/tutorial/figures/uiswing/components/InformationalDialogMetal.png

I need to get the icon just before the title "Messasge".

Reply me.

rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 12
have you tried my program?
Aniruddha-Herea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 13
HiYes,I tried your program.But i am getting the icon in the frame that is present behind the joption pane.But my questionis i like to get the image in the joptionpane's title bar.....Still i am not getting it.
rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 14

hi,

http://java.sun.com/docs/books/tutorial/figures/uiswing/components/DialogIcon2Metal.png

Click this link.U ll get the image of joption pane.

Title of the joption pane is "Inane Warning".

I like to get the icon before this "inane warning."

can u send me the code.....

Did u got it ?

Kindly help me.......

rose@rosea at 2007-7-12 16:37:19 > top of Java-index,Desktop,Core GUI APIs...
# 15
see in my program, i am using WindowsIconFactory.getMenuArrowIcon() in joptionpane , you may replace that as well..it is running in my machine as expected....regardsAniruddha
Aniruddha-Herea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 16
R u there Aniruddha?
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 17

Hi

public class Sample_01

{

/**

* @param args

*/

public static void main(String[] args)

{

JFrame frm = new JFrame();

frm.setIconImage(new ImageIcon("tree.wait.gif").getImage());

frm.setBounds(100, 100, 100, 100);

frm.setTitle("Hi");

frm.setVisible(true);

frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JOptionPane jp = new JOptionPane("Session Expired - Please Re Login" , JOptionPane.INFORMATION_MESSAGE , JOptionPane.WARNING_MESSAGE, WindowsIconFactory.getMenuArrowIcon());

JDialog dialog = jp.createDialog(frm, "Session Expired - Please Re Login");

dialog.setResizable(true);

dialog.setVisible(true);

}

}

This is the code i worked.

But its not working for me......

I am not even getting the icon in the frame itself....

I apologize that in my previous replies i said that i am getting the icon in the frame but not in joptionpane....

But there is no icon in frame itslef......

rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 18
hi!the image you are trying to get is relative, try giving absolute address. and make sure that tree.wait.gif is available in your application root.regardsAniruddha
Aniruddha-Herea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 19
Hi,The image is available in my application.But i am not getting the icon in the frame itslef.......Kindly help me.I also tried with absolute address,But still i am not getting it...
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 20

Hi,

Refer to the code...

public class Sample_01

{

/**

* @param args

*/

public static void main(String[] args)

{

JFrame frm = new JFrame();

//frm.setIconImage(new ImageIcon("tree.wait.gif").getImage());

frm.setIconImage(new ImageIcon("./img/securitymanager.gif").getImage());

System.out.println("Image>" + frm.getIconImage());

frm.setBounds(100, 100, 200, 300);

frm.setTitle("Hi");

frm.setVisible(true);

frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JOptionPane jp = new JOptionPane("Session Expired - Please Re Login" , JOptionPane.INFORMATION_MESSAGE , JOptionPane.WARNING_MESSAGE, WindowsIconFactory.getMenuArrowIcon());

//JDialog dialog = jp.createDialog(frm, "Session Expired - Please Re Login");

//dialog.setResizable(true);

//dialog.setVisible(true);

}

}

Even with this code i am not getting the icon in the frame.....

But when i use frm.getIconImage(), it prints -- Image>sun.awt.image.ToolkitImage@66848c,which is a non null value....

Kindly reple me

rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 21
R u there Aniruddha?
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 22
hi!frm.setIconImage(new ImageIcon("./img/securitymanager.gif").getImage()); is also relative. just for testing can you display this image in a jlabel? or can you just provide the entire directory path like C:\xxx\pp.png ?try this...
Aniruddha-Herea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 23

Hi,

I am working in Linux.

I ve set like this.

frm.setIconImage(new ImageIcon("/home/vidhya/workspace/Others/src/demos/img").getImage());

System.out.println("Image>" + frm.getIconImage());

But still am not getting the icon.

But it prints "Image>sun.awt.image.ToolkitImage@66848c",non- null value

wat to do....

Y i am not getting the icon?/

rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 24
Hifrm.setIconImage(new ImageIcon("/home/vidhya/workspace/Others/src/demos/img/securitymanager.gif").getImage());I tried this.Now i am getting the icon in the frame.But not in joptionpane......Kindly help me
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 25
R u there Aniruddha?
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 26
hello,i do not have linux now in my machine, so i can't test. but i guess if your frame is getting the image then your joption pane also should get the image if it is set resizable true.....sorry friend......
Aniruddha-Herea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 27
HiI am geeting it in frame but not in joptionpane....Anyhow if u find it using linux reply me without fail.Thank you very much.....
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 28
HiCan u tell me the usage of WindowsIconFactory.getMenuArrowIcon()?help me....
rose@rosea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...
# 29
hi,that is nothing but a static factory calss which provides a ready-made icon for any testing purpose, i guess BasicIconFactory.getMenuArrowIcon() will be available on all os....regardsAniruddha
Aniruddha-Herea at 2007-7-21 21:40:08 > top of Java-index,Desktop,Core GUI APIs...