I need to get the image from the title bar of the JDialog. Is there any way to get the image from the JDialog, there is no getIconImage() method, i tried getIconImages() but it doesnt works.
Such window decorations are typically the provenance of the host platform's window manager. The image may be platform specific. You can use this handy tool to browse the icons available in a given look & feel.
UIManager has a getIcon() method you might wanna look into that...
check this thread for some examples and valid keys for getIcon
As a hack, you might be able to create your own image using the Robot class. The Screen Image class might help you out.
What happened when you tried to use getIconImages()
? Using the following code, I was able to set the icon for a dialog, show the dialog, and then get that icon back out and do something almost-useful with it:
final JDialog dlg = new JDialog();
dlg.setIconImage((new ImageIcon("C:/icon.jpg")).getImage());
dlg.setVisible(true);
System.out.println("Height = " + dlg.getIconImages().get(0).getHeight(null));
System.out.println("Width = " + dlg.getIconImages().get(0).getWidth(null));
This correctly printed out the height and width of the icon that I had set by calling setIconImage()
.
Or, are you trying to find out information about an icon in a dialog (or frame) when no custom icon has been set?