Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using GlassPanel for Cursor Feedback  RSS feed

 
Dave Rivera
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I simply want to show a WAIT_CURSOR while my long-running task is going on.
The following snippets of code, to test the technique, do not get the job done. The cursor shape does not change.
Any ideas why?
Does the fact that this is executed in the ActionPerformed() method for a menu item make a difference?
Thanks.
<CODE>
. . . .
{
Thread mgrThread = new Thread(new Runnable() {
public void run() {
int j=0;
for (int i=0; i < 2000;i++)
{
j+=1;
System.out.println(" "+j);
Thread.yield();
}
}});
// end of thread
MyGlassPane glassPane = new MyGlassPane();
setGlassPane(glassPane);
glassPane.setVisible(true); //before worker thread
mgrThread.start();
try {
mgrThread.join();
}
catch (InterruptedException ie) {}
glassPane.setVisible(false); //after worker thread
}
. . . . .
class MyGlassPane extends JPanel {
public MyGlassPane() {
addKeyListener(new KeyAdapter() { });
addMouseListener(new MouseAdapter() { });
super.setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}
</CODE>
[This message has been edited by Dave Rivera (edited May 11, 2001).]
[This message has been edited by Dave Rivera (edited May 11, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!