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.
IndexProgramming Questions & HelpSyntax Questions › "Cannot find anything named 'MouseInfo'"
Page Index Toggle Pages: 1
"Cannot find anything named 'MouseInfo'" (Read 2330 times)
"Cannot find anything named 'MouseInfo'"
Mar 31st, 2010, 1:23am
 
For a little programm that makes removed frame windows movable again, i used MouseInfo.getPointerInfo().getLocation().x
in this threat.
http://processing.org/discourse/yabb2/num_1224367967.html
it seems to work fine for most of us, but i have some people who told me that they get the following error.

"Cannot find anything named 'MouseInfo'"
MouseInfo.getPointerInfo().getLocation().x-mX,


How could that be, do they use an old Java Version or what could be the problem, and any idea on how to solve it



Re: "Cannot find anything named 'MouseInfo'"
Reply #1 - Mar 31st, 2010, 2:05am
 
MouseInfo cames with Java 1.5, I don't think recent Processing sketches can run with Java 1.4. Can they
Ask these users what Java version they have. On Windows, for example, go to Control Panel > Java > About button (also displayed in the Java console, etc.).

Mmm, searching in Processing source, I see it is a compiler error, so that's for people running the sketch from the PDE, not from an applet or application, right
So I think the error comes with Processing 1.1: authors removed automatic import of Java AWT packages ("Changed how imports are handled in sketches. This may break some sketches that use java.xxx packages that aren't covered in the Processing reference." in list of revisions).

Just add:
import java.awt.MouseInfo;
at the start of your sketch.
Re: "Cannot find anything named 'MouseInfo'"
Reply #2 - Mar 31st, 2010, 3:08am
 
ahh, great. big thanks!
hope that helps.
Re: "Cannot find anything named 'MouseInfo'"
Reply #3 - Mar 31st, 2010, 5:34am
 
This has definitely to do with the changes done to the auto-import, but I think that was generally a very good thing. Previously, the entire java.awt package would be imported wholesale style and then started causing naming conflicts with other classes and libraries. For example, now with Processing 1.1 also handling Java 1.5 syntax, more people are likely to start using the Java Collections API more and start working with List's. So previously every time you wanted to use a List, you'd have to clarify which one to use since the class exists in both java.awt (a drop-down GUI widget) and java.util (a generic List-style collection interface). The AWT classes are hardly ever used by Processing folk and the new approach is much cleaner & flexible and the list of default imports can also be edited via the preferences.txt file...
Re: "Cannot find anything named 'MouseInfo'"
Reply #4 - Mar 31st, 2010, 8:00am
 
To add to toxi's points.. the fix is to add:

import java.awt.MouseInfo;

to the beginning of your sketch, and you should be fine. For the most part, I've limited the packages/classes that are imported by default to only things that we cover in the reference somewhere. That's not a strict rule, but it's the general way of things.
Re: "Cannot find anything named 'MouseInfo'"
Reply #5 - Mar 31st, 2010, 8:54am
 
thx toxi & ben, thats good to know.
i just have to keep that in mind
Page Index Toggle Pages: 1