Java Utililty Methods JDialog Icon

List of utility methods to do JDialog Icon

Description

The list of methods to do JDialog Icon are organized into topic(s).

Method

voidjdialog$setIconImage(JDialog dlg, Image image)
jdialoset Icon Image
try {
    Method e = dlg.getClass().getMethod("setIconImage", new Class[] { Image.class });
    e.invoke(dlg, new Object[] { image });
} catch (Exception var3) {
    var3.printStackTrace();
voidsetDialogIcon(JDialog dialog, InputStream imageInputStream)
Set the icon if a dialog.
try {
    dialog.setIconImage(ImageIO.read(imageInputStream));
} catch (IOException | NullPointerException e) {
    System.out.println("Failed to set window icon.");
voidsetDialogIcon(JDialog dlg)
Set the Icon for an dialog
try {
    Image image = ImageIO.read(dlg.getClass().getResourceAsStream("icon.png"));
    Class cls = Dialog.class;
    java.lang.reflect.Method m = cls.getMethod("setIconImage", new Class[] { Image.class });
    m.invoke(dlg, new Object[] { image });
} catch (Throwable e1) {
voidsetIconImage(JDialog j, Image b)
A hack into the JDK 6.0 Window class, written for backwards compatibility Shows an icon in the top corner of Dialog windows
try {
    Class.forName("java.awt.Window").getDeclaredMethod("setIconImage", new Class[] { java.awt.Image.class })
            .invoke(j, b);
} catch (Exception e) {
voidsetWindowIcon(JDialog jd)
set Window Icon
ImageIcon frameIcon = getDefaultFrameIcon();
if (frameIcon != null)
    jd.setIconImage(frameIcon.getImage());