How to Set Transperent Background Image to Jpanel

Ads
 

How to Set Transperent Background Image to Jpanel

Sir ,How to set Background Image to Jpanel.
View Answers

April 12, 2010 at 2:55 PM

Hi Friend,

Try the following code:

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

public class TransparentBackgroudImage
{
public static void main(String[] args) {
JFrame frame = new JFrame("Table");
frame.addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Window win = e.getWindow();
win.setVisible(false);
win.dispose();
System.exit(0);
}
} );

JTextArea area=new JTextArea(15,4){

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);
}
};

area.setOpaque(false);

JScrollPane sp = new JScrollPane( area );
frame.getContentPane().add( sp );

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

Thanks

Ads









Related Tutorials/Questions & Answers:
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
set background image in javafx
set background image in javafx  Hi, How to add backgroung image in javafx integrated with jswing
Advertisements
how to use a image in background in your application form?
how to use a image in background in your application form?  how to use a image in background in your application form
How to set pdf background color.
How to set pdf background color. In this example, you will see how to set back ground color of pdf in struts2.  index.jsp <html> <...;/title></head> <body> <p>Background of file
UIToolBar background image
UIToolBar background image  Hi, How to set background image of UIToolBar? Give me code for adding UIToolBar's background image. Thanks
How to set the Gradient Color as a background color for Java Frame?
How to set the Gradient Color as a background color for Java Frame?  How to set the Gradient Color as a background color for Java Frame
How to add image in panel as background in net beans IDE?
How to add image in panel as background in net beans IDE?  How to add image in panel as background in net beans IDE
how to create menubar and the below background color/image in java swing
how to create menubar and the below background color/image in java swing  how to create menubar and the below background color/image in java swing
UITableView Background Image
UITableView Background Image  How to set an image as a background of UITableView in iPhone SDK   I think, we can't
How to add background image to div using CSS?
How to add background image to div using CSS
UITextField Background Image
UITextField Background Image  How can i set a background image... below.. on how to set the uitextfield leftview image.. - (void)viewDidLoad... a Background Image on UITextField - (void)viewDidLoad { [super viewDidLoad
UIButton background image
UIButton background image  Hi, How to create uibutton with background image? Thanks
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
Background image UIBarButtonItem
Background image UIBarButtonItem  i wanted to add a background image to my UIBarButtonItem.. that i created into .xib in my iPhone application.   Set the background image to UIBarButtonItem UIBarButtonItem *btn
UIView Background Image
UIView Background Image  HI, Please let's know how to add background image to a view? Thanks   Hi You can use the following code...:@"myimage.png"]]; Read more at UIView Image Background Tutorial page. Thanks
UITableViewCell background image
iPhone application. I have to add the background image to UITableViewCell. Please tell me how to add UITableViewCell background image. Thanks   Hi, Here is the code example of UITableViewCell background using image. UIView
uinavigationcontroller background image
a background image to uinavigationcontroller... the Background Image to it as given below‚?¶ #import <UIKit/UIKit.h> #import <...uinavigationcontroller background image  I wants to add a background
How to change background, change background
How to change background       This example will teach you to change background of any object... a picture to change background. Selection: Make selection by the Magic wand tool
Change JPanel background color from mouse entered/exit event
Change JPanel background color from mouse entered/exit event  I have a JPanel with a grid layout and I populated it with anonymous JPanels to it be like tiles on a game board. I added a mouse entered event to all the added
How to design a background, design a background, a background
How to design a background     ... how to design a background by this example. New File: Take a new file. Choose color: First set the foreground and background color. Clouds: Go to Filter menu
ModuleNotFoundError: No module named 'aldryn-background-image'
: No module named 'aldryn-background-image' How to remove the ModuleNotFoundError: No module named 'aldryn-background-image' error? Thanks   ...ModuleNotFoundError: No module named 'aldryn-background-image'  Hi
ModuleNotFoundError: No module named 'aldryn-background-image'
: No module named 'aldryn-background-image' How to remove the ModuleNotFoundError: No module named 'aldryn-background-image' error? Thanks   ...ModuleNotFoundError: No module named 'aldryn-background-image'  Hi
ModuleNotFoundError: No module named 'django-background-image'
: No module named 'django-background-image' How to remove the ModuleNotFoundError: No module named 'django-background-image' error? Thanks   ...ModuleNotFoundError: No module named 'django-background-image'  Hi
Set Background Colors and Images in HTML
Set Background Colors and Images in HTML       The  background colors can be set... to set a background color in HTML. In this Tutorial, the code describe you
Setting a Background image for UITableView in iPhone & iPad application.
at background. So, to wrap up my question is short ..... i need to set an image...Setting a Background image for UITableView in iPhone & iPad application. ... the UITableView using set backgroundcolor. But my requirement is bit different ..i wanted
background
background  how to add image as background to a frame
How to draw in jPanel? swing/graphics Java
How to draw in jPanel? swing/graphics Java  How to draw in jPanel? (swing/graphics Java
UIImageView set Image URL
UIImageView set Image URL  Show image by URL   UIImageView set image url Create NSURL object and add the Image URL to it. Create NSData... to it by imageWithData: method Finally, you can add UIImage to Image view. Find
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so.......?? thanku and second question how to attach calender jar file in jtextfield using
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so.......?? thanku and second question how to attach calender jar file in jtextfield using
jpanel
jpanel  hello sir, i made one jpanel inside the frame and made the button inside the panel.. wrote the only second panel code other class file.. so.......?? thanku and second question how to attach calender jar file in jtextfield using

Ads