dont know the why this modified JTextField did not show up..help me out

import java.awt.*;
import javax.swing.*;
public class JBgtextfield extends JTextArea{

	public void paint(Graphics g)
	{
	setOpaque(false);
	ImageIcon ic=new ImageIcon("image1.png");
	Image i=ic.getImage();
	g.drawImage(i,0,0,this);
	super.paint(g);
	}
}

i then created an instance of this class and added it to a panel in init() method. but it didnt show up?

Do you mean the text field didn't show up, or it did show up but the image was missing? If you paint a small colored rectangle instead of the image does that work?

yes image didnt show up!!! text field appears

is the image found in the same directory or in the right path?

new ImageIcon(...) is famous for not throwing any exceptions when it fails to find the file; it's just empty. JLabel is happy to accept null for its image icon, so the final result is no image and no error messages. We see that quite often in DaniWeb "help!" posts.
Use the exists() method of the File class with the path/name of the file to confirm that your program can find the file.

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.