Results 1 to 3 of 3
Thread: Image on a panel in java, how??
- 02-23-2011, 07:04 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
- 02-23-2011, 10:02 AM #2
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
try this:
1)create an image instance variable:
Image face;
2)load the image in the constructor of the panel:
face= new ImageIcon("image location on disk").getImage();
3) in the paintComponent method after you call super.painComponent(g), call the draw image method and give it as a first parameter face:
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(face,x,y,null) // x,y = position of image, null = imageobserver
}
hope this helps...Last edited by brigadier90; 02-23-2011 at 10:28 AM.
- 02-23-2011, 09:48 PM #3
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
Similar Threads
-
Set the background image for tabs for tabbed panel
By radhi in forum Java 2DReplies: 1Last Post: 10-24-2010, 08:25 PM -
How to change the background image of panel
By radhi in forum Java 2DReplies: 4Last Post: 10-14-2010, 08:18 AM -
How to display image in a panel with JFileChooser
By srisar in forum AWT / SwingReplies: 14Last Post: 10-11-2009, 06:06 PM -
How to set Image in Panel ?
By sudmitra in forum New To JavaReplies: 0Last Post: 09-12-2009, 10:07 PM -
add image on panel
By samiksha.goel in forum AWT / SwingReplies: 4Last Post: 08-02-2008, 07:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks