How might I call java functions without having to use 'import <x>' in each function
显示 更早的评论
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..?
回答(1 个)
David Young
2011-6-8
0 个投票
"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.
类别
在 帮助中心 和 File Exchange 中查找有关 Call Java from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!