You need to override the method paintComponent(Graphics g)
of JPanel and use drawImage()
on the Graphics object g
as in this example.
Also, check these two examples by @trashgod:
More Related Contents:
- Make a object when pressed follow mouse pointer, java [closed]
- How to have an interactive map in JFrame
- How to add an image to a JPanel?
- How to set a background picture in JPanel
- Simplest way to set image as JPanel background
- the images are not loading
- How to draw in JPanel? (Swing/graphics Java)
- .gif image doesn’t moves on adding it to the JTabbed pane
- Background image for a jPanel not working
- Why does calling dispose() on Graphics object cause JPanel to not render any components
- Having images as background of JPanel
- How to fit Image size to JFrame Size?
- Clicking on a drawn object
- Show an animated BG in Swing
- Difference between paint, paintComponent and paintComponents in Swing
- How does paintComponent work?
- JPanel repaint issue
- Displaying a histogram of image data
- Zoom box for area around mouse location on screen [closed]
- addKeyListener() doesn’t work for JPanel
- Spring behavior simulation
- Replacing JPanel with JPanel in a JFrame
- Saving a Java 2d graphics image as .png file
- Infinite background for game
- Slide JPanel Content in a JForm on Java
- Java Container remove method not working correctly
- How to add an image to a JFrame title bar?
- How do I resize images inside an application when the application window is resized?
- Image resizing and displaying in a JPanel or a JLabel without loss of quality
- Can I add a component to a specific grid cell when a GridLayout is used?