Skip to content
Snippets Groups Projects
Commit 11f59aad authored by Dallin Nickel (djn011)'s avatar Dallin Nickel (djn011)
Browse files

Created the action class with the ability to simulate button presses

parent 449e5212
No related branches found
No related tags found
3 merge requests!36Base system,!34Test gitignore,!33Base system
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
package model;
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
public class Action extends Hotkey{
/**
* Robot which simulates user key presses
*/
Robot robot;
/**
* Constructs an immutable hotkey.
*
* @param keyCode The virtual keycode of the hotkey.
* @param id The unique ID of the hotkey.
* @param modifier The modifier of the hotkey.
*/
public Action(int keyCode, int id, Modifier modifier) throws AWTException {
super(keyCode, id, modifier);
this.robot = new Robot();
}
/**
* Simulates the pressing of the buttons specified by modifier and keycode
*/
public void press(){
robot.keyPress(this.getModifier().val());
robot.keyPress(this.getKeyCode());
robot.keyRelease(this.getModifier().val());
robot.keyRelease(this.getKeyCode());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment