Re: Drawing Icons



On Feb 28, 5:35 pm, Daniel Pitts
<newsgroup.spamfil...@xxxxxxxxxxxxxxxxxxx> wrote:
Jason Cavett wrote:
I am working on a tree cell renderer (currently, extends
DefaultTreeCellRenderer) and I want to be able to "draw" the icons as
I need them. Here's an explanation of what I mean.

If the tree is displaying a node and the node is in its default state,
I want this:
[Icon]

If the tree is displaying a node and the node is "opened":
[Icon]

If the tree is displaying a node and the node is "opened" and has a
note attached:
[Icon{n}]

Basically, I want to be able to draw what I need (on the fly) so I can
build up the icon. I do realize I could just create every possible
icon and display the right one depending on the state of the
underlying node, but that seems to be very inefficient, especially as
I add more nodes.

Hopefully this message makes sense. Can anybody provide any insight?

You can create an Icon for every state that node can have (which looks
like three from here). You should create an image (for example a png
image) for those states, and then use ImageIcon()

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

That's what I was doing originally. However, due to new requirements
the number of icons are going to at least double. Additionally, since
the application will (most likely) be skinned in the future, I don't
want to have to make 6 times the amount of icons. It *should* be
easier to just build each icon as I need it. And, it works (see my
other posts), except for the fact that the text is overtop the icon
within the JTree and I can't figure out how to shift it over. (This
seeemingly happened automatically when I was using an ImageIcon.)
.



Relevant Pages

  • Re: How do I write an ImageIcon object into a file on my computer?
    ... private static String[] getMimeArray{ ... throws IOException, Exception { ... Download the icon to a ".ico" icon ... image from HTTP and display it within my JPanel as an ImageIcon type, ...
    (comp.lang.java.help)
  • Re: JTree-Icons dynamisch =?iso-8859-1?Q?einf=E4rben?=
    ... > Oder ein ImageIcon bauen, ... > private Color mBackground = Color.white; ... public class BackgroundIcon implements Icon { ... wurde weis durch den ImageObserver wo das war und so ...
    (de.comp.lang.java)
  • Re: How do I write an ImageIcon object into a file on my computer?
    ... How do you write to a new file anything, like String content or Image ... image from HTTP and display it within my JPanel as an ImageIcon type, ... It's not really an icon as Windows understands it, ... @param urlPath the String url path ...
    (comp.lang.java.help)
  • Re: Mice on stamps.
    ... would that be an explanation why Czech Pharmacology have the humble ... mouse as their Icon? ...
    (rec.collecting.stamps.discuss)
  • Re: Mice on stamps.
    ... would that be an explanation why Czech Pharmacology have the humble ... mouse as their Icon? ...
    (rec.collecting.stamps.discuss)