Home Answers Viewqa Java-Beginners setbackground image to JFrame

 
 


shweta
setbackground image to JFrame
1 Answer(s)      3 years and a month ago
Posted in : Java Beginners

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 Pages:
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
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
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
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
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
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 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
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
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.
Browse an image
java.awt.event.*; public class UploadImage extends JFrame { Image img; JTextField...Browse an image  hi................ i want to browse an image from..."); PreparedStatement psmnt = connection.prepareStatement("insert into images(image) values
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
AWT Image
, 110, 100, 20); } public static void main(String s[]) { final JFrame frame = new JFrame("Show Triangle"); final JPanel p = new
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
how to reset JFrame
how to reset JFrame  how to reset JFrame
image effects - Java Beginners
image effects  hey can u help me in loadin an image file... that will show you image crop effect: import java.sql.*; import java.awt.... java.awt.image.FilteredImageSource; public class Upload extends JPanel { BufferedImage image; Image img
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
Image Processing Java
); } /* * This method just create a JFrame to display the image. Closing the window... title,RenderedImage image) { JFrame f = new JFrame(title...Image Processing Java  Using This Code I Compressed A JPEG Image
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
Image Selection - Swing AWT
Image Selection  Hi, I need to provide the image selection facility... click on any item, the image of that item should be selected as done in windows...*; public class DisplayImage extends JFrame { JLabel promptLabel; JTextField
Getting image pixel values
Getting image pixel values  how to get image pixels values on mouse... GetPixels extends JPanel { BufferedImage image; JLabel[] labels; public GetPixels(BufferedImage image) { this.image = image
Regarding Image in Swings
Regarding Image in Swings  Hi, I have some requireemnt like when i click on the button in frame,it wil display the image.....plz do the needful...; import java.awt.image.BufferedImage; public class DisplayImage { JFrame f
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
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
Display Image in Java
;new JFrame("Display image");   Panel panel = ... Display Image in Java       This example takes an image from the system and displays
Display Image on JDesktopPane
!= null) { JFrame f = new JFrame(); f.setTitle("Display Image From...Display Image on JDesktopPane In this section, you will learn how to retrieve an image from  the database and display it on the JDesktopPane. You can see
ZodiacSign with an image - Java Beginners
JLabel(icon); JPanel p=new JPanel(); p.add(label1); p.add(label2); JFrame f=new JFrame(); f.add(p); f.setVisible(true); f.setSize(400,100); } } Thanks
displaying image in awt - Java Beginners
ActionListener{ JFrame fr = new JFrame ("Image loading program Using awt"); Label... ImagePanel("D:/Sunset.jpeg"); JFrame frame = new JFrame("Image Frame...displaying image in awt  Hi All, I have downloaded the code
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
Set Transparent Background Image
Set Transparent Background Image Swing components not only allow you to change... to your frame or other components by setting the transparent background image on the frame. Here we are going to give the transparent effect to the image
image cannot be saved - Java Beginners
image cannot be saved  In the following program when we click on the menu item import, we can show any image on the panel but when we click on save the image is not drawn on the desired location.......please check the following

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.