[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


JScrollPane with static background Image

Posted on 2007-07-25
Medium Priority
Last Modified: 2008-02-01
Hi all

I have a JPanel with BG image on it.
I used the getViewport().setView(iPanel); in order to put the panel inside the JScrollPane.
Now I want the bg Image to saty in it place and not to move when the user scrolls. ( the JPanel cotains a JTree )

Question by:aquasw
  • 2
LVL 92

Accepted Solution

objects earned 1500 total points
ID: 19565374
you'll need to subclass JViewport and paint your image in the subclass'es paintComponent() method. Then set that as your scroll panes viewport

LVL 92

Expert Comment

ID: 19565388
also ensure your tree has opaque set to false
LVL 17

Expert Comment

by:Dejan Pažin
ID: 19565922

Take a look at this example, the only difference is, it shows JTextArea instead of a JTree:


Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question