Very simple question: I have a class which extends from java Robot class, however I have an error in my IDE (netbeans), that I haven't handled the AWTException for the my class. how can I fix this?
My class is like this:
public class KeyBoard extends Robot{
}
Constructors of the class java.awt.Robot
throw an AWTException
that requires mandatory handling. So, to solve the problem, declare the constructor of your class to throw an AWTException
.
public class KeyBoard extends Robot{
public KeyBoard throws java.awt.AWTException{
//constructor body.
}
//other methods.
}
For more information, you can read the documentation of the Robot class here.