Stop Button
This commit is contained in:
@ -62,28 +62,39 @@ public class Controller_Frontend {
|
||||
@FXML
|
||||
private Label intconLabel;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private Button stepButton;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private Button autoRunGUI;
|
||||
|
||||
@FXML
|
||||
private Button stopButton;
|
||||
|
||||
|
||||
|
||||
|
||||
private volatile boolean isAutoRunActive = true;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private void stopAutoRun(ActionEvent event) {
|
||||
|
||||
isAutoRunActive = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private void autoRunGUI(ActionEvent event) {
|
||||
if (!isAutoRunActive) {
|
||||
isAutoRunActive = true;
|
||||
}
|
||||
Thread autoRunThread = new Thread(() -> {
|
||||
try {
|
||||
while (DataRegister.getPC() < prog.length) {
|
||||
while (DataRegister.getPC() < prog.length && isAutoRunActive){
|
||||
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
@ -92,7 +103,7 @@ public class Controller_Frontend {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
Thread.sleep(200); // Millisekunden
|
||||
Thread.sleep(200); //Verzögerungszeit in Millisekunden
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
@ -100,9 +111,12 @@ public class Controller_Frontend {
|
||||
});
|
||||
autoRunThread.setDaemon(true);
|
||||
autoRunThread.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private void stepintoButton(ActionEvent event) throws IOException {
|
||||
if (lstContentListView.getItems().isEmpty()) {
|
||||
@ -295,6 +309,7 @@ public class Controller_Frontend {
|
||||
|
||||
lstContentListView.getStylesheets().add(Objects.requireNonNull(getClass().getResource("styles.css")).toExternalForm());
|
||||
autoRunGUI.setOnAction(this::autoRunGUI);
|
||||
stopButton.setOnAction(this::stopAutoRun);
|
||||
}
|
||||
|
||||
private static void setTRISbuttons(ToggleButtonGroup[] allButtons) {
|
||||
|
||||
Reference in New Issue
Block a user