about using icons
I am trying to display an icon in a window. The code is give below
publicclass LoginHandler{
JFrame mainWindow;
Container contentPane;
JPanel panel;
public LoginHandler()
{
//JFrame.setDefaultLookAndFeelDecorated( true );
createMainWindow();
addComponentsToMainWindow();
}
privatevoid createMainWindow()
{
mainWindow =new JFrame("Login" );
mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mainWindow.setExtendedState( JFrame.MAXIMIZED_BOTH );
mainWindow.setResizable(false );
mainWindow.setVisible(true );
}
privatevoid addComponentsToMainWindow()
{
contentPane = mainWindow.getContentPane();
panel =new JPanel();
panel.add(new JLabel(new ImageIcon("C:\\test\\DMS.gif" ) ) );
}
publicstaticvoid main( String [] args )
{
LoginHandler obj =new LoginHandler();
}
}
The icon to be display and the source file are both located in the same directory, still this code is not working. Please tell me what can be the possible reason.
When I display the the same icon using NetBeans GUI Builder same path is generated (for the icon) by the IDE, and the application works fine. But manual coding does not display any icon.
Thanks

