Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NetBeans IconImage  RSS feed

 
Ranganath s.Junpal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I have a small problem with setting the IconImage of the JFrame with Swings. I tried to Hard code it N also tried using the Properties window. But it was not successful.
The code i wrote is as follows
try{
this.setIconImage(Toolkit.getDefaultToolkit().getImage("/Pic/ir.png"));
}
catch(Exception e)
{
e.printStackTrace();
}

And my Second Problem is with the JPanel. I have extended the JPanel and overrided the method PaintCOmponent to draw the Image with it. When i add this JPanel with the JFrame Image is not at all visible.

The Code is as follows.
/*
* WPanel.java
*
* Created on July 5, 2006, 1:39 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package Components;
import java.awt.Graphics;
import java.awt.Toolkit;
import javax.swing.JPanel;
import java.net.URL;
import java.awt.Image;

/**
*
* @author Ranganath.S
*/
public class WPanel extends JPanel{
private Image img;
/** Creates a new instance of WPanel */
public WPanel()
{

URL iUrl=getClass().getResource("/Pics/welcome.jpg");
img = Toolkit.getDefaultToolkit().getImage(iUrl);

}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawImage(img,0,0,this);
}
}


Thank you
Regards
 
Nick Meverden
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!