Are any methods available to set an image as background in a JFrame
?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class BackgroundImageJFrame extends JFrame
{
JButton b1;
JLabel l1;
public BackgroundImageJFrame() {
setSize(400,400);
setVisible(true);
setLayout(new BorderLayout());
JLabel background=new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful_design.png"));
add(background);
background.setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am a button");
background.add(l1);
background.add(b1);
}
public static void main(String args[])
{
new BackgroundImageJFrame();
}
}
check out the below link
http://java-demos.blogspot.in/2012/09/setting-background-image-in-jframe.html