Display an image in a JTree

Discussion in 'Java' started by Aaron Fude, Nov 27, 2009.

  1. Aaron Fude

    Aaron Fude Guest

    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
    Aaron Fude, Nov 27, 2009
    #1
    1. Advertising

  2. Aaron Fude

    Aaron Fude Guest

    Daniel Pitts wrote:
    > Aaron Fude wrote:
    >> 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

    >
    > 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
    Aaron Fude, Nov 27, 2009
    #2
    1. Advertising

  3. Aaron Fude

    Daniel Pitts Guest

    Aaron Fude wrote:
    > Daniel Pitts wrote:
    >> Aaron Fude wrote:
    >>> 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

    >>
    >> 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

    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.
    Daniel Pitts, Nov 28, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UWluZG9uZyBaaGFuZw==?=

    display image after the image downloaded

    =?Utf-8?B?UWluZG9uZyBaaGFuZw==?=, Mar 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    315
    =?Utf-8?B?UWluZG9uZyBaaGFuZw==?=
    Mar 2, 2004
  2. Sam
    Replies:
    1
    Views:
    493
    Thomas Weidenfeller
    Jun 18, 2004
  3. groupie

    Display the jTree

    groupie, Jul 7, 2007, in forum: Java
    Replies:
    3
    Views:
    531
    Mark Space
    Jul 8, 2007
  4. jumpz
    Replies:
    3
    Views:
    605
    Jean-Baptiste Nizet
    Nov 12, 2007
  5. Rasikow Gnaniyar

    Display XML in JTree

    Rasikow Gnaniyar, Mar 12, 2008, in forum: Java
    Replies:
    1
    Views:
    878
    RedGrittyBrick
    Mar 12, 2008
Loading...

Share This Page