Article View: borland.public.jbuilder.java.swing
Article #7510Applet, JTree, setCursor problem
From: Jim H.
Date: Mon, 15 Jan 2001 20:18
Date: Mon, 15 Jan 2001 20:18
83 lines
4045 bytes
4045 bytes
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:
<3a635b19_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!208.226.57.227Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,fc00ca3aea35938b,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2001-01-15 12:24:07 PST Reply-To: "Jim H." <jgh@metafile.com> From: "Jim H." <jgh@metafile.com> Newsgroups: borland.public.jbuilder.java.swing Subject: Applet, JTree, setCursor problem Date: Mon, 15 Jan 2001 14:18:18 -0600 Lines: 86 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 208.226.57.227 Message-ID: <3a635b19_2@dnews> X-Trace: 15 Jan 2001 12:18:33 -0800, 208.226.57.227 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!208.226.57.227