Hi,I'm a beginner to Java. Can anyone help me? I want to know how a textField to be displayed above a image(like acting as the background of that textField).

You can use a small panel that displays an image as a container for your controls. Something like this

class ImagePanel extends JPanel {
    Image img;
    
    public ImagePanel(){
        super();
        
        img = loadImage("whatever.file");
    }
    
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if(img != null) {
            g.drawImage(img, 0, 0, this);
        }
    }
    
    public Image loadImage(File f) {
        Image image = getToolkit().getImage(f.getPath());        
        return image;
    }
}

Add your text field to that panel.

Thanks for your help,Ezzaral. But I already solved my problem, still I appreciated your code above.

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.