JPanel backround question

I would like to use a picture as a background for a JPanel. But I would also like to put a JScrollpane in the JPanel. Can I have both of those at the same time? Thanx

[173 byte] By [GooNa] at [2007-11-27 11:00:19]
# 1

Put the JPanel in the JScrollPane.

I'm not sure if setting a JScrollPane's opacity to "false" allows it to show through, but it's worth a try.

Joe

Message was edited by:

Joe_h

Joe_ha at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 2

I would like the scrollpane to be smaller than the picture

GooNa at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 3

> I would like the scrollpane to be smaller than the

> picture

JScrollPane.setSize(smaller than picture);

Navy_Codera at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 4

my problem is that the scrollpane does not show up at all. I'm putting the picture on the jpanel in the paint method, is that wrong?

GooNa at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 5

> my problem is that the scrollpane does not show up at

> all. I'm putting the picture on the jpanel in the

> paint method, is that wrong?

after adding the jpanel to the scrollpane

add the scrollpane in the parent component.

e.g. JFrame, JWindow... etc..

Yannixa at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 6

In the future, Swing related questions should be posted in the Swing forum.

You can search the Swing forum for this solution. This question is asked all the time. "background image" would be the common search keywords.

camickra at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...
# 7

What I'm trying to do is have a JPanel of size 10 by 10, put a 10 by 10 pitcure in it as a background, then in the middle I want to put a 5 by 5 scrollpane with other stuff in it.

GooNa at 2007-7-29 12:28:53 > top of Java-index,Java Essentials,Java Programming...