Display an image in a JTree

A

Aaron Fude

Hi,

Is it possible to display an image in the node of a JTree?

I am not talking about little icon, but rather the "content" of the tree.

Thanks,

Aaron
 
A

Aaron Fude

Daniel said:
Can you be more specific? I can think of at least two meanings to what
you ask.

A common practice would be to have a JTree that shows a list of
files/folders, and when you click on a file, a different panel shows the
contents of that file. This is fairly easy to do. Look into
TreeSelectionListener for hints on how to do this.

The other thing I can think of, is that you want your TreeCellRenderer
to actually render an image, which might change the size of the tree
node considerably. This is also fairly easy. Look into
TreeCellRendered for hints on this approach.

If you meant something else, please feel free to explain more precisely
what you want. It would be even more helpful to see also what you've
tried and how it failed you (see http://sscce.org)
I want the second! - and I posted a question that I ran into about
controlling the size of the image. Java only shows a small portion of it
(that would have fit in the default size label).

Thanks in advance!

Aaron
 
D

Daniel Pitts

Aaron said:
I want the second! - and I posted a question that I ran into about
controlling the size of the image. Java only shows a small portion of it
(that would have fit in the default size label).

Thanks in advance!

Aaron
Now is the appropriate time to post an SSCCE, that way we can determine
how you are attempting it, and what might be broken about it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top