setbackground image to JFrame

setbackground image to JFrame

how to setbackground image to JFrame.
View Answers

April 22, 2010 at 12:11 PM

Hi Friend,

Try the following code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TransparentBackgroundImage
{
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Window win = e.getWindow();
win.setVisible(false);
win.dispose();
System.exit(0);
}
} );
JPanel panel=new JPanel(new GridLayout(2,2)){
ImageIcon image = new ImageIcon( "C:/rose.jpg" );
public void paint( Graphics g ) {
Dimension d = getSize();
for( int x = 0; x < d.width; x += image.getIconWidth() )
for( int y = 0; y < d.height; y += image.getIconHeight() )
g.drawImage( image.getImage(), x, y, null, null );
super.paint(g);
}
};
JLabel l1=new JLabel("Name");
JLabel l2=new JLabel("Address");
JTextField text=new JTextField(20);
JTextField text1=new JTextField(20);
panel.setOpaque(false);
text.setOpaque(false);
text1.setOpaque(false);
panel.add(l1);
panel.add(text);
panel.add(l2);
panel.add(text1);
frame.add( panel );

frame.pack();
frame.show();
}
}

Thanks









Related Tutorials/Questions & Answers:
setbackground image to JFrame - Java Beginners
setbackground image to JFrame   how to setbackground image to JFrame... TransparentBackgroundImage { public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener( new WindowAdapter() { public
insert image in JFrame - Development process
= new JFrame("Display image"); Panel panel = new ShowImage...insert image in JFrame  how to insert a image in JFrame.please... Panel { BufferedImage image; public ShowImage() { try
Advertisements
Java Image On JFrame Title
How to set Image On JFrame In this section, you will learn how to set an image on JFrame title using Java program. For this, we have created an object...() that will load the specified image and the method setIconImage() of JFrame class
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
jframe
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
how to add scrollbar to JFrame
i add my panel to scrollpane and then add that scrollpane to JFrame than...; /*********************************************************/ ImageIcon img; JLabel create,change,image,your,can; JComboBox cb...=getContentPane(); setBackground(Color.white); img=new ImageIcon("googletitle.gif
how to add scrollbar to JFrame
i add my panel to scrollpane and then add that scrollpane to JFrame than...; /*********************************************************/ ImageIcon img; JLabel create,change,image,your,can; JComboBox cb...=getContentPane(); setBackground(Color.white); img=new ImageIcon("googletitle.gif
how to add scrollbar to JFrame
i add my panel to scrollpane and then add that scrollpane to JFrame than...; /*********************************************************/ ImageIcon img; JLabel create,change,image,your,can; JComboBox cb...=getContentPane(); setBackground(Color.white); img=new ImageIcon("googletitle.gif
how to add scrollbar to JFrame
i add my panel to scrollpane and then add that scrollpane to JFrame than...; /*********************************************************/ ImageIcon img; JLabel create,change,image,your,can; JComboBox cb...=getContentPane(); setBackground(Color.white); img=new ImageIcon("googletitle.gif
how to add scrollbar to JFrame
i add my panel to scrollpane and then add that scrollpane to JFrame than...; /*********************************************************/ ImageIcon img; JLabel create,change,image,your,can; JComboBox cb...=getContentPane(); setBackground(Color.white); img=new ImageIcon("googletitle.gif
how to reset JFrame
how to reset JFrame  how to reset JFrame
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
jframe background color not showing
jframe background color not showing  jframe background color is not showing. please suggest.   Just add the background color to JPanel and then add it to JFrame. For example .. JFrame myFrame = new JFrame(); JPanel
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask... and sub menu(employee). in Form Login(jFrame) have username(textfield1) and password(passwordfield1), in Menu(jframe) have Menu employee(jMenu),creaby(jlabel1
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir thanks a lot for your reply... this public class PrintExample extends JFrame implements ActionListener { public...() { setBackground(Color.white); Font font = new Font("Serif", Font.PLAIN, fontSize
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... PrintExample extends JFrame implements ActionListener { public static void main...() { setBackground(Color.white); Font font = new Font("Serif", Font.PLAIN
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... PrintExample extends JFrame implements ActionListener { public static void main...() { setBackground(Color.white); Font font = new Font("Serif", Font.PLAIN
JFRAME - Java Beginners
javax.swing.*; import java.awt.event.*; public class MenuExample extends JFrame
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
image scrolling
should be diplayed on jframe Example : similar to image viewer...image scrolling  Hi My reqvirements are as below Input is the address of a folder containing images Output should be a jframe displying first
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir i am doing a project so i am working in netbeans i have to print a JFrame it contains Labels and few textboxfields so i want to take the whole JFrame contents for printing so would you
loading image - Swing AWT
loading image  give me a source code to add any wallpaer of my PC as a background image to jpanel on a jframe
Move Image in Java Swing
; BufferedImage image; ShowCanvas() { setBackground(Color.white); setSize...How to Move Image in Java Swing In this section, you will learn how to move an image using mouse. For this purpose, we have specified an image and using
image embadding - Java Beginners
image embadding  sir how to put images in JFrame/JPanel  Hi... class DisplayImage extends JPanel{ private BufferedImage image; public DisplayImage() { try { image
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
image scrolling
image scrolling  A brief description of scrolling image
Image Steganography
Image Steganography  SOURCE CODE FOR IMAGE STEGANOGRAPHY
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my... an object for it.my java code is public class submit { JFrame frame; JTextArea text1; void form() { frame=new JFrame("details you have entered are"); JPanel
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built... in the first Jframe to another JLabel in the other JFrame.Can you please help me,how...*; import java.awt.event.*; class PassData extends JFrame { JTextField text
how to draw a table on jframe in java - Java Beginners
how to draw a table on jframe in java  how to draw a table on jframe in java?  Hi friend, import java.awt.*; import... scrollPane = new JScrollPane(table); JFrame frame = new JFrame
Java Spring Desktop application with multiple classes and jframe
and classes...How to close one Jframe from another..Please tell... First jframe...;This is not disposing Jframe2** t.dispo(); } Second Jframe package... extends JFrame { /** Creates new form Touchscreen */ public Touchscreen
image format
image format  what are the different format available in image
image format
image format  what are the different format available in image
browse image
java.awt.image.*; import java.awt.event.*; public class UploadImage extends JFrame { Image...browse image  how to browse the image in image box by browse button and save image in database by save button by swing   import java.sql.
browse image
java.awt.image.*; import java.awt.event.*; public class UploadImage extends JFrame { Image...browse image  how to browse the image in image box by browse button and save image in database by save button by swing   import java.sql.

Ads