The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Changing cursor in an Application/Applet

Posted by Mickael Feledyn on June 22, 2000 at 8:12 AM

> I am using Swing 1.0.3 with JDK 1.1.7(Visual Age 2)....
> I try to change the cursor to busy cursor when a button is pressed...IT doesn't work for the applet...but does work when it runs as an Application..
> Code:
> if (Context.getProperty("frame") == null)
> ((com.sun.java.swing.JApplet) Context.getProperty"applet")).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

> if (Context.getProperty("frame") != null)
> ((JFrame) Context.getProperty("frame")).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

>
> Here Context is a hashtable which has handles of both the applet and the JFrame in which the applet sits when running as an Application.

> Thanks much.

You can try this :
javax.swing.JOptionPane.getFrameForComponent(yourApplet).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
"javax.swing.JOptionPane.getFrameForComponent" is usefull for getting root frames :) .

Hope this helps.



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us