We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Lost cursor() (Read 1075 times)
Lost cursor()
Apr 3rd, 2010, 9:34am
 
When I invokelater for a jfilechooser, I loose the ability to control the cursor.  Anyone know how to get it back?  Doubleclick to test this code.

Code:
import javax.swing.JFileChooser;
final JFileChooser fc = new JFileChooser();

void draw() {
 cursor(WAIT);
}

void mouseClicked() {
 if (mouseEvent.getClickCount() == 2) {
   javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
 try{
   int returnVal = fc.showOpenDialog(null);

   if (returnVal == JFileChooser.APPROVE_OPTION) {
File[] openfiles = fc.getSelectedFiles();
   }
 }
 catch(Exception e) {
   javax.swing.JOptionPane.showMessageDialog(null, e);
 }
}
   });
 }
}
Re: Lost cursor()
Reply #1 - Apr 4th, 2010, 9:42pm
 
Tested on P5 1.1, OS X 10.6.2, Java 1.5.
No Cursor problem here.
Re: Lost cursor()
Reply #2 - Apr 5th, 2010, 1:26am
 
For the record, I could reproduce the issue with Windows XP Pro SP3, Java 1.6.0_18, Processing 1.1. The cursor is WAIT over the sketch's surface but go back to normal cursor as long as the JFileChooser is opened.
I have no idea why it does that...

I tried to set the cursor on the frame, in the thread body, but it changes nothing.
Re: Lost cursor()
Reply #3 - Apr 5th, 2010, 5:36am
 
My platform is OSX 10.6.3, had the same issue on OSX 10.6.2 & 10.6.1, and as far as I recall 10.5.x.

After you close (select or cancel) the Jfilechooser, the cursor should return to the wait in this sketch, but it doesn't.  After launching the file chooser, we lose control to set the cursor.
Re: Lost cursor()
Reply #4 - May 6th, 2010, 5:51pm
 
Figured it out...
Basically, if you create a JDialog (e.g. using JOptionPane.showMessage())
without a non-null, visible parent, then your custom cursors will not be
respected. You must have a non-null, visible parent for the dialog.

So I just replaced "null" with "frame".

import javax.swing.JFileChooser;
final JFileChooser fc = new JFileChooser();

void draw() {
cursor(WAIT);
}

void mouseClicked() {
if (mouseEvent.getClickCount() == 2) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try{
int returnVal = fc.showOpenDialog(frame); //Note the "frame" here instead of "null"

if (returnVal == JFileChooser.APPROVE_OPTION) {
File[] openfiles = fc.getSelectedFiles();
}
}
catch(Exception e) {
javax.swing.JOptionPane.showMessageDialog(null, e);
}
}
});
}
}
Page Index Toggle Pages: 1