🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7533

Re: Applet, JTree, setCursor problem

#7533
From: Torsten Welches
Date: Wed, 17 Jan 2001 10:13
96 lines
4354 bytes
Jim,

a TreeCellRenderer is only used to *paint* the nodes, it is not 
part of the JTree as a visual component. 
Tooltips work because JTree overrides getToolTipText appropriately. 

Torsten

"Jim H." <jgh@metafile.com> wrote:
>For 2+ days I have been trying to alter the cursor from the default to the
>wait and hand with no luck.
>
>I have an Applet with a JTree.  Some of the tree nodes may be clicked to
>issue a server request using a background thread.  I would like to display
>the hand cursor for these nodes.  And, while the server request is
>outstanding, I would like to display the wait cursor.  Otherwise, I want to
>display the default cursor for all the other tree nodes.
>
>I have set the component's (a JLabel) cursor using the following code:
>------------------------------------
>  public Component render(
>                           Component        dspComp            // The
>displayed component
>                         , JTree                  tree
>// The tree structure
>                         , DefaultMutableTreeNode node      // The current
>tree node
>                         , boolean                isSelected          // Is
>node selected
>                         , boolean                isExpanded        // Is
>folder expanded
>                         , boolean                isLeaf                 //
>Is node a leaf
>                         , int                        row
>// Row in the tree
>                         , boolean                hasFocus           // Does
>node have focus
>                         )
>  {
>      JLabel jLabel = (JLabel)super.render( dspComp      // The displayed
>component
>                                          , tree         // The tree
>structure
>                                          , node         // The current tree
>node
>                                          , isSelected   // Is node selected
>                                          , isExpanded   // Is folder
>expanded
>                                          , isLeaf       // Is node a leaf
>                                          , row          // Row in the tree
>                                          , hasFocus     // Does node have
>focus
>                                          );
>
>
>      Cursor jc =  Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR);
>
>      if  ( _nodeFailure )
>      {
>          jLabel.setIcon( _damagedIcon);
>          jLabel.setToolTipText( MSG_ERROR);
>      }
>      else if  ( isLoadInProgress() )
>      {
>          jLabel.setIcon( _notLoadedIcon);
>          jLabel.setToolTipText( MSG_LOADING);
>          if  ( hasFocus) jc = Cursor.getPredefinedCursor(
>Cursor.WAIT_CURSOR);
>      }
>      else if  ( !isLoadCompleted() )
>      {
>          jLabel.setIcon( _notLoadedIcon);
>          jLabel.setToolTipText( MSG_CLICK_TO_LOAD);
>          if  ( hasFocus) jc =  Cursor.getPredefinedCursor(
>Cursor.HAND_CURSOR);
>      }
>
>      jLabel.setCursor( jc);
>      return( jLabel);
>  }
>---------------------------------------------
>
>The tool-tips work great!  However, the cursor does not change!  Under the
>debugger and examining the jLabel, the cursor is changed.  But it just is
>not visually displayed.  Only the default cursor is shown.
>
>I have tried a mouse listener without success.  The above seems simple and
>straight forward, but ineffective.
>
>Any ideas?
>
>Thanks!
>
>
>
Technical Details
Message-ID: <3a657033$1_1@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!207.105.83.65
References: <3a635b19_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,fc00ca3aea35938b
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2001-01-17 02:14:03 PST
From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Sender: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Reply-To: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Subject: Re: Applet, JTree, setCursor problem
Newsgroups: borland.public.jbuilder.java.swing
X-User-Info: 193.158.55.74 193.158.55.74    
References:  <3a635b19_2@dnews> 
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3a657033$1_1@dnews>
Date: 17 Jan 2001 02:13:07 -0800
X-Trace: 17 Jan 2001 02:13:07 -0800, 207.105.83.65
Lines: 97
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!207.105.83.65