hi all. I want to ch ange my jframe's icon(cup of coffee).
i chkd the forum but that's what i m doing...
here's my code:

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AppStarter dialog = new AppStarter(new javax.swing.JFrame(), true);
                dialog.setLocationRelativeTo(null);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
               [B] dialog.setIconImage(new ImageIcon("untitled.gif").getImage());[/B]
                dialog.setTitle("Welcome user.");
                dialog.setVisible(true);
            }
        });
        System.out.println("Exit code here");
    }

I m using netbeans , jdk 6.
untitled.gif is in the same package where the AppStarter class is.
It doesnt change the image...
Thanks..

Could we see the "AppStarter" code. At least the constructor, and the setIconImage method (if you have overridden it).

Hi.This is my constructor..
initcomponents() is auto generated by netbeans.

public AppStarter(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        Oracle_Connector dbc = new  Oracle_Connector();
        S = dbc.make_ORACLE_conn();
    }

thanks.

So, I assume "AppStarter" extends JDialog? And, I assume you are wanting to cahnge the Image on the title bar, and or task bar?

Also, in this case, it is JDialog's Icon, not JFrame's Icon, as you won't have a JFrame here.

Also, try using the setIconImages method and pass it a List containing the same image several times. I.E.

Image i = new ImageIcon("untitled.gif").getImage();
    dialog.setIconImages(Arrays.asList(new Image[] { i, i, i, i, i, i }));

Just a WAG, as I haven't tried changing the Icons, myself, in a very long time.

hi masijade...I tried ur suggestion, it still doesnt work...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.