How might I call java functions without having to use 'import <x>' in each function
Afficher commentaires plus anciens
I am using the java robot class to simulate events in an .m file To use this, I must call: 'import java.awt.*' and 'import java.awt.event.*'
From this, I make a robot: rob=Robot;
Now, I can call events with the robot using things like rob.keyPress(KeyEvent.VJ_K) rob.keyRelease(KeyEvent.VJ_K)
I want to be able to use this java robot in subfunctions, however the robot's member functions are not accessible if I call the subfunctions from within my original function. the program only works 'correctly' if I call 'import java.awt.*' 'import java.awt.event.*'
inside each subfunction. I want to be able to pass my robot into subfunctions, how might I do this without calling 'import' for each one and rendering my program horribly slow..?
Réponses (1)
David Young
le 8 Juin 2011
0 votes
"import" has no effect on the speed of a Java program. The statement only tells the compiler where to find classes so that it can do type-checking etc.
Catégories
En savoir plus sur Call Java from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!