Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners setbackground image to JFrame
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shweta
setbackground image to JFrame
1 Answer(s)      4 years and 8 months ago
Posted in : Java Beginners


how to setbackground image to JFrame.

Advertisement
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
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
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
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 - 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
image
image  how to add the image in servlet code
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 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
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
Advertisements
 

 

 

DMCA.com