From b3182076fca55898685558915eb470c547c0caee Mon Sep 17 00:00:00 2001 From: Aidan Ross Date: Tue, 2 May 2023 12:54:52 +0000 Subject: These two classes are used to create a gui with 4 lanes and buttons that activate when you press the keys d,f,h, and j --- KeyDetection.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 KeyDetection.java (limited to 'KeyDetection.java') diff --git a/KeyDetection.java b/KeyDetection.java new file mode 100644 index 0000000..429665a --- /dev/null +++ b/KeyDetection.java @@ -0,0 +1,27 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package cs; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +public class KeyDetection extends AbstractAction +{ + long timeStart = System.currentTimeMillis(); + private char key; + public KeyDetection(char ch){ + key = ch; + } + + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + int time = (int)((System.currentTimeMillis()-timeStart)); + System.out.println(key + ": " + time); + } + +} -- cgit v1.2.3