1

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

Holger
  • 285,553
  • 42
  • 434
  • 765
  • I don't really get what you are trying to accomplish with the runnable but it seems to be a bug you are not responsible for. Have you tried downloading the newest version of Java? – RecursiveExceptionException Jul 17 '16 at 18:55
  • when you click in the windows console it gets in a different mode, with esc you can get to the other again. i also recognized that problem but it is as designed. when the console is in this mode the thread gets stopped. – Henning Luther Jul 17 '16 at 18:57
  • I have downloaded the latest version of java. The runnable was for other things running in this project that were quickly discarded. That is a slimmed down version of my code, but the problem still remains if you just run that code. There's probably some silly flag that I have to add to make it run without that issue. – Michael Payne Jul 17 '16 at 18:58
  • 2
    @itzJanuary I assume you're joking about downloading the latest version of Java – OneCricketeer Jul 17 '16 at 18:59
  • Is there a way to disable this mode? I made a few simple c# programs like this, and the issue did not occur. – Michael Payne Jul 17 '16 at 19:00
  • @cricket_007 the application shouldn't crash when clicking in the console. What's your suggestion then? – RecursiveExceptionException Jul 17 '16 at 19:07
  • @cricket_007 Because QuickEdit mode crashing Java isn't a bug... – RecursiveExceptionException Jul 17 '16 at 19:08
  • Tip: run your code in an IDE, that way you aren't going to see OS related issues (as frequently) – OneCricketeer Jul 17 '16 at 19:10

1 Answers1

1

This has nothing to do with Java. You've entered QuickEdit mode. Press ENTER to leave it.
Here is how to disable it altogether.

Community
  • 1
  • 1
johnnyaug
  • 887
  • 8
  • 24