Hello Friends
The code below has no error at compile time.
But while executing, it does not show the icon at the left hand top corner of the frame, where a java cup icon is originally shown.
I want to replace it with my icon.
- import java.io.*;
-
import javax.swing.*;
-
import java.awt.*;
-
import java.util.*;
-
-
class Error1
-
{
-
-
public JPanel contentPane()
-
{
-
JPanel panel=new JPanel();
-
JLabel label=new JLabel("This is a frame with its own Icon.");
-
panel.add(label);
-
-
-
return panel;
-
-
}
-
-
private static void createGui()
-
{
-
-
-
JFrame frame=new JFrame("Error");
-
frame.setDefaultLookAndFeelDecorated(false);
-
Error1 obj=new Error1();
-
frame.setContentPane(obj.contentPane());
-
frame.setVisible(true);
-
frame.setSize(new Dimension(650,100));
-
frame.setResizable ( false );
-
frame.setLocation(50,50);
-
-
// frame.setIconImage(getFDImage());
-
Image icon = Toolkit.getDefaultToolkit().getImage("D:\\error.bmp");
-
frame.setIconImage(icon);
-
}
-
/*protected static Image getFDImage()
-
{
-
java.net.URL imgURL = Error.class.getResource("D:\\error.bmp");
-
if (imgURL != null)
-
{
-
return new ImageIcon(imgURL).getImage();
-
} else
-
{
-
return null;
-
}
-
}*/
-
public static void main(String args[])
-
{
-
SwingUtilities.invokeLater(new Runnable() {public void run() {createGui(); }});
-
}
-
}