jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes Image Background in a Jlist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Image Background in a Jlist" Watch "Image Background in a Jlist" New topic
Author

Image Background in a Jlist

Kyle Kerlew
Greenhorn

Joined: Oct 10, 2013
Posts: 5
I was wondering if anyone could give me a sample of an image being displayed on the background of an entire Jlist


I've been trying to figure it out myself all day, but no prevail
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10519
    
    9

Welcome to the Ranch.

Kyle Kerlew wrote:I was wondering if anyone could give me a sample of an image being displayed on the background of an entire Jlist

Unfortunately, no. We do not hand out ready made code here. However, we can definitely help point you in the right direction. For that, you need to tell us what you tried, show us your SSCCE code and tell us where you are stuck.

One of the possible ways to achieve what you wish for is have the image painted as a background. Either the panel which holds the JList or the JList itself. All the other components on top of the panel need to be transparent (check out a method called setOpaque(boolean opaque)) for the image to show up.
Keep in mind, the JList itself will use a renderer to display the data. Also, typically the JList will be wrapped up in a JScrollPane and the scroll pane will eventually be added to the panel. This should help you figure out what all components are 'hiding' your image.
Check out http://www.coderanch.com/how-to/java/BackgroundImageOnJPanel to get an idea on how to draw an image as a background.
Also check out http://docs.oracle.com/javase/tutorial/uiswing/painting/ to understand how graphics work in Swing.
Your API docs will have a link to "How to use lists' This is a common feature to almost all the Swing components. Follow that link to get an understanding of renderers (among other things)

I would suggest you start off one step at a time.
1) Create a panel with the background image
2) Add the panel to the frame. Run the application, confirm the image is displayed.
3) Then start adding the list/scroll pane etc.

In the meanwhile I will move this thread over to the UI forums which is a more suitable forum for your question


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image Background in a Jlist