Skip to content

Commit

Permalink
Fixed accuracy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stringflow committed Feb 8, 2019
1 parent 50d46f5 commit 45df77a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/flowtimer/timers/VariableTimer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package flowtimer.timers;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
Expand Down Expand Up @@ -43,7 +46,7 @@ public VariableTimer(FlowTimer flowtimer) {
submitButton.setBounds(285, 26, 80, 22);
submitButton.setEnabled(false);
submitButton.addActionListener(e -> {
long passedTime = flowtimer.getTimerLabelUpdateThread().getTimerLabelCallback().getTime(flowtimer.getTimerStartTime());
long passedTime = (System.nanoTime() - flowtimer.getTimerStartTime()) / 1_000_000;
long offsets[] = { getVariableOffset() - passedTime };
int interval = intervalComponent.getComponent().getValue();
int numBeeps = numBeepsComponent.getComponent().getValue();
Expand All @@ -53,6 +56,20 @@ public VariableTimer(FlowTimer flowtimer) {
submitButton.setEnabled(false);
});

// Click submit button when enter is hit while editing the frame text field
frameComponent.getComponent().addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
}

public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
submitButton.doClick();
}
}
});

frameComponent.add(this);
fpsComponent.add(this);
offsetComponent.add(this);
Expand Down

0 comments on commit 45df77a

Please sign in to comment.