JScrollPane with static background Image

Posted on 2007-07-25
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
    LVL 92

    Accepted Solution

    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

    also ensure your tree has opaque set to false
    LVL 17

    Expert Comment

    by:Dejan Pažin

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

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now