We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, where are instructions for importing a library from java to processing? I can only info on importing contributed libraries, and I have no idea how to manually load from java jdk (or indeed to find the library I'm looking for.) The libray I'm looking for is robot.awt.
I've searched 3 books, google, and here, which normally would be enough to find this; I may not be searching using the right terms. Please note, I am a beginner at processing, so I hope you will be patient.
Answers
The easiest way to do it is to just drag the
.jar
file into the Processing editor.Shameless self-promotion: here is a guide on using libraries in Processing.
I just saw that you mention
robot.awt
. Do you mean theRobot
class? If so that's not a library, that comes standard in Java. All you have to do is import it.https://Docs.Oracle.com/javase/9/docs/api/overview-summary.html#JavaSE
java.desktop
:https://Docs.Oracle.com/javase/9/docs/api/java.desktop-summary.html
java.desktop
, we find packagejava.awt
:https://Docs.Oracle.com/javase/9/docs/api/java/awt/package-summary.html
java.awt
, we find the class Robot:https://Docs.Oracle.com/javase/9/docs/api/java/awt/Robot.html
java.awt
, we use the keyword commandimport
like this:import java.awt.Robot;
https://Processing.org/reference/import.html
No shame in a bit of self promotion, KevinWorkman! 'Do you mean the Robot class? If so that's not a library, that comes standard in Java. All you have to do is import it.' Ah, yes, I meant class. Looking for the right word might have helped... So I need to simply write :- import java.awt.Robot into the editor window, and its done??
Okay, I get a 'windows firewall message', ticked something to make it go away, then a small window with a grey square in it appears; the letter 's' is visible on the window, obscured by the max/min buttons. Does this mean I have imported robot class?
Can you please post a MCVE?
Importing a class doesn't actually do anything, other than tell the compiler what you mean when you write
Robot
in your code. You have to call the functions in theRobot
class to tell it to do something.https://forum.processing.org/two/search?Search=robot
Kf
As I understand it, an MCVE for what I typed would simply be import java.awt.Robot; Thats all I typed, then hit return. I'll see if I can make a robot object and get it to do something.
Okay, I ran gotoloops code here:-https://forum.processing.org/two/discussion/15674/speed-of-screenshots. I works, so I guess I now have robot class working. Thanks all.