How can I set a icon image on JDialog's title bar?
Created May 4, 2012
Sandip Chitale You can't... at least not directly.
The dialog may not have a title bar in some windowing environments...atleast that has been the given rationale behind the lack of such a feature
Starting JDK 1.1.7 a resizable dialog will inherit the icon of the owner frame. Owner frame is the one passed in the Dialog's CTOR.
If you want to allow a different icon for your dialog from that of your main application frame then you could always create a dummy frame, set the icon on it using the frame.setIconImage(Image); and pass it in the Dialog's CTOR. The dummy frame is never shown.
This has implications in term of -
- Modality of the Dialog
- Automatic showing/hiding of Dialog when your main application frame is shown/hidden. You can always get around it by listeneing to ComponentEvents on the application frame and showing and hiding the dialog apropriately.