Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Problems using SwingWorker for JTree node rendering

Thread view: 
Christian Sauer - 26 Jan 2004 12:08 GMT
Hi all,

i am implementing a cell renderer for a JTree which displays a set of nodes.
The nodes in turn represent local or remote (ftp, http, etc) files.
in order to check whether or not each file is reachable or not i use
an url connection. since this operation may be very time consuming
(when rendering lots of nodes) i use a SwingWorker3 which does
this asynchronously. the color of the nodes label will be changed then
according to the connection state of the checked file (red = not reachable,
green = ok)

everything is perfect except the fact, that changing the label color
does not work. the 'setForeground' method is called, but nothing
happens although the swing worker is running in the swing GUI thread.

does somebody has an explanation for this?
thanks for any hint :o)

BTW: i recognized that even animated GIFs do not work, when
being used to render (a part ) of a tree node ...

cheers,
chris
Christian Kaufhold - 26 Jan 2004 17:52 GMT
> i am implementing a cell renderer for a JTree which displays a set of nodes.
> The nodes in turn represent local or remote (ftp, http, etc) files.
[quoted text clipped - 8 lines]
> does not work. the 'setForeground' method is called, but nothing
> happens although the swing worker is running in the swing GUI thread.

Renderers are assumed to be stateless.

Only if the data changes will they be re-queried for an updated re-
presentation of the item they show.

Therefore, reachability of a file must be made a property of the node
in the TreeModel, which the fires nodeChanged-events when it changes.

Christian
Christian Sauer - 27 Jan 2004 07:31 GMT
Hoi christian,

the renderer itself is stateless, i know...

but the renderer creates for each rendered node an own panel containing
two labels: one with the icon and text and one with the state text. the last
one is the component of which the color should be changed according to
the files state.

cheers,
chris

> > i am implementing a cell renderer for a JTree which displays a set of nodes.
> > The nodes in turn represent local or remote (ftp, http, etc) files.
[quoted text clipped - 18 lines]
>
> Christian
Christian Kaufhold - 27 Jan 2004 13:01 GMT
Hello!

> but the renderer creates for each rendered node an own panel containing
> two labels: one with the icon and text and one with the state text. the last
> one is the component of which the color should be changed according to
> the files state.

It is still stateless. No matter how these components change later does
not matter, only their state directly after getXXXComponent.
(A renderer should probably also not create components for each node
but reuse the same once for all).

[snip reverse-time-ordered quote]

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.