I have a simple java console application that prints out a string as if someone were typing it. It works fine, except for when I click into the console window. The cell that I clicked on turns white, and the thread stops executing. Image of said occurrence
Here is a sample of my code:
public class Main {
public static void main(String[] args) {
String text = "Welcome to the terminal.";
boolean newLine = true;
new Runnable() {
@Override
public void run() {
for (int i = 0; i < text.length(); i++) {
System.out.print(text.substring(i, i + 1));
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (newLine) {
System.out.println("");
}
}
}.run();
}
}
Windows 10 may have something to do with it. I don't know. I have tried removing the Runnable part, but it does the same thing. Thanks for your help. <3