-
Icon Change in Leafnode of Jtree
How do I change the icon of the leafnode when clicking
on JTree Swing Component?
-
Re: Icon Change in Leafnode of Jtree
If you want to control how a tree node is displayed in a JTree, you need to
use a TreeCellRenderer class.
PC2
Saibal <sanmitsai@yahoo.com> wrote in message
news:3a1b9591$1@news.devx.com...
>
>
> How do I change the icon of the leafnode when clicking
> on JTree Swing Component?
>
>
-
Re: Icon Change in Leafnode of Jtree
The TreeCellRenderer class changes all the leaf-node icons
I only need to change a paticular leaf node icon when it will
be clicked.
"Paul Clapham" <pclapham@core-mark.com> wrote:
>If you want to control how a tree node is displayed in a JTree, you need
to
>use a TreeCellRenderer class.
>
>PC2
>
>Saibal <sanmitsai@yahoo.com> wrote in message
>news:3a1b9591$1@news.devx.com...
>>
>>
>> How do I change the icon of the leafnode when clicking
>> on JTree Swing Component?
>>
>>
>
>
-
Re: Icon Change in Leafnode of Jtree
<saibal sanmitsai> wrote in message news:3a1cfd99$1@news.devx.com...
>
> The TreeCellRenderer class changes all the leaf-node icons
> I only need to change a paticular leaf node icon when it will
> be clicked.
>
What do you mean by "when it will be clicked"? Do you want a different icon
to flash as you click, then the original icon to reappear when you lift your
finger from the mouse? Or do you want the different icon to appear on
selected nodes? The TreeCellRenderer can show a different icon for selected
nodes.
-
Re: Icon Change in Leafnode of Jtree
Yes I want the icon to changed when selected.
I am able to cahnge the icon for the nodes but
not the leaf-nodes(the nodes that do not have child).
"Paul Clapham" <pclapham@core-mark.com> wrote:
>
><saibal sanmitsai> wrote in message news:3a1cfd99$1@news.devx.com...
>>
>> The TreeCellRenderer class changes all the leaf-node icons
>> I only need to change a paticular leaf node icon when it will
>> be clicked.
>>
>What do you mean by "when it will be clicked"? Do you want a different
icon
>to flash as you click, then the original icon to reappear when you lift
your
>finger from the mouse? Or do you want the different icon to appear on
>selected nodes? The TreeCellRenderer can show a different icon for selected
>nodes.
>
>
>
-
Re: Icon Change in Leafnode of Jtree
saibal <sanmitsai@yahoo.com> wrote in message
news:3a208753$1@news.devx.com...
>
> Yes I want the icon to changed when selected.
> I am able to cahnge the icon for the nodes but
> not the leaf-nodes(the nodes that do not have child).
>
If you use a TreeCellRenderer, you have to implement a method that looks
like this:
getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
boolean expanded, boolean leaf, int row, boolean hasFocus)
Notice that it has a boolean parameter that tells you whether the node you
are rendering is selected or not. Use this parameter to decide what icon
you are going to display.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks