How to use colours in console output in Scala or Java?
Try...
scala> Console.BLUE
res0: java.lang.String =
OK, well, the text has gone blue. Honest!
scala> Console.YELLOW_B
res2: java.lang.String =
And you can see the background is, um, yellow.
Sample code from JavaWorld
import java.awt.Color;
import enigma.console.*;
import enigma.core.Enigma;
public class Main
{
    public static void main(String[] args)
    {
        TextAttributes attrs = new TextAttributes(Color.BLUE, Color.WHITE);
        s_console.setTextAttributes(attrs);
        System.out.println("Hello World!");
    }
    private static final Console s_console;
    static
    {
        s_console = Enigma.getConsole("Hellow World!");
    }
}
Visit the above link for more details and approaches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With