Form Icons (JDialog et al) JDK1.2

I would like to know how to change the application icons in JDialogs and JOptionPanes.

I always have the coffee icon displayed. JFrame derivatives have a setIconImage member, while the JDialog and JOptionPane derivatives do not.

Is there a way to change the default so that all the corner icons are removed.

I am using JDK1.2.
(I know that not all windowing environments have this corner icon, but we are using ms windows most of the time.)
LVL 1
cmainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

expertmbCommented:
hi,
 
   this code will help u,
import java.applet.*;
import java.applet.Applet;
import java.lang.*;
import java.awt.*;
import java.awt.Toolkit;
import java.awt.Image;
import java.awt.Frame;
import java.lang.String;
import java.lang.Boolean;
import java.util.Date;
import java.util.StringTokenizer;
import java.io.*;
import java.lang.Thread;
 
public class imagetest extends Frame implements Runnable
{
Image img = null;
Thread kicker, kicker2;

public void run() {
        String  name;

        // get the thread's name
        name = new String(Thread.currentThread().getName());
        System.out.println("NAME: " + name);
        if (name.equals("kicker"))
        {
                Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                while (kicker != null) {
                        // do Icon Animation
                        doicon();
                        setIcon();
                }
        }
        else
        {
                while (kicker2 != null) {
                        try {
                                kicker2.sleep(1000);
                        } catch (InterruptedException e) {}
                        kicker = null;
                        System.out.println("Thread kicker stopped");
                        try {
                                kicker2.sleep(1000);
                        } catch (InterruptedException e) {}
                        startkicker();
                }
        }
}

public void startkicker() {
        if (kicker == null) {
                kicker = new Thread(this);
                kicker.setName("kicker");
                kicker.start();
                System.out.println("Thread kicker started");
        }
        if (kicker2 == null) {
                kicker2 = new Thread(this);
                kicker2.setName("kicker2");
                kicker2.start();
                System.out.println("Thread kicker2 started");
        }
}

public void paint (Graphics g) {
        startkicker();
}


// iconimage when animation stops
public void setIcon()
{

        MediaTracker tracker = new MediaTracker(this);
        img = Toolkit.getDefaultToolkit().getImage("C:\\JBuilder3\\java\\jre\\lib\\images");
        tracker.addImage(img, 0);
 
        try {
                tracker.waitForID(0);
        } catch (InterruptedException e) {
                return;
          }
 
        setIconImage(img);
}

// Icon Animation
public void doicon() {
        String file, dum, name;

        file = new String("C:\\JBuilder3\\java\\jre\\lib\\images\\");
      name = new String(file + "win32_CopyDrop32x32.gif");
        for (int i=0; i<18; i++)
        {
                //System.out.println("doicon" + i);
                MediaTracker tracker = new MediaTracker(this);
                //dum = new String(file + i);
                //name = new String(dum + ".gif");
                //System.out.println("FILE: " + name);
                img = Toolkit.getDefaultToolkit().getImage(name);
                tracker.addImage(img, i);
 
                try {
                        tracker.waitForID(i);
                } catch (InterruptedException e) {
                        return;
                  }
               
                setIconImage(img);

                try {
                        kicker.sleep(100);
                } catch (InterruptedException e) {}
        }
}



public imagetest()
{
        super("Imagetest");
        //display 2 images
        add("West",new loadimage("images\\win32_CopyDrop32x32.gif"));
        add("Center",new loadimage("images\\win32_LinkDrop32x32.gif"));

        pack();
        resize(preferredSize());

        //This is needed for setting the iconimage.
        // Don't know why, but if you remove it the icon will not be displayed
        MediaTracker tracker = new MediaTracker(this);
        img = Toolkit.getDefaultToolkit().getImage("images\\win32_MovDrop32x32.gif");
        tracker.addImage(img, 0);
 
        try {
                tracker.waitForID(0);
        } catch (InterruptedException e) {
                return;
          }
 
        setIconImage(img);
        startkicker();
      setSize(400,300);
      setVisible(true);
//        show();
}

 
public static void main (String args[])
{
// was used for JDK beta 2
//                try {
//                        System.setSecurityManager(new EmptySecurityManager());
//                } catch (SecurityException e) {
//                        System.out.println("Caught SecurityException trying to set Security manager");
//                }
        new imagetest();
}

}
 
 
class loadimage extends Canvas {
 
        Image img = null;

        public loadimage(String pic) {
                MediaTracker tracker = new MediaTracker(this);
 
                img = Toolkit.getDefaultToolkit().getImage(pic);
 
                tracker.addImage(img, 0);
 
                try {
                        tracker.waitForID(0);
                } catch (InterruptedException e) {
                        return;
                }
 
                if (img != null)  {
                        int width = img.getWidth(this);
                        int height = img.getHeight(this);
                        resize(width, height);
                        show();
                }
        }
 
        public void paint(Graphics g) {
                if (img != null)
                        g.drawImage(img, 0, 0, this);
        }
 
}
 
  mb...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.