Let's say I have a console app in Java that reads input from the user and then prints it back out (very basic)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
while(true) {
Scanner scanner = new Scanner(System.in);
String message = scanner.nextLine();
System.out.println(message);
}
}
}
Is it possible to make the text the user enters when typing a different colour when compared to the text that is printed out with System.out.println
?
For example if I ran that program in a console that defaults to white text on a black background the following would happen.
I would type "hello world" and it would show in red. When I press enter, it prints "hello world" in the default white.
As a bonus, is it possible to configure a background for the "hello world" when it is printed in red? This means that I can choose two contrasting colours in case a user has their console background at a default setting of red.
Thanks!