Change color of IOConsoleOutputStream [message #1723242] |
Fri, 12 February 2016 16:41 |
Alexandre Honorat Messages: 8 Registered: February 2016 |
Junior Member |
|
|
Hi everybody,
I want to print some text in a MessageConsole and I would like to color some parts of it.
I have tried to use the setColor method to change the MessageConsoleStream but it seems to not work. I guess my problem is more related to the usage of Device and Color, but I am not sure.
Here is the code I use to write to the console:
MessageConsoleStream mcs = mc.newMessageStream();
Color currentClr = mcs.getColor();
RGB red = new RGB(255, 0, 0);
//Device device = currentClr.getDevice();
Device device = Display.getDefault();
Color warningColor = new Color(device, red);
mcs.setColor(warningColor);
mcs.println("This text should be colored in red, right? But it isn't.");
mcs.setColor(currentClr);
As you can see I have tried two ways to get a device to pass to the Color constructor. The commented one throws a null pointer exception. And the current one prints text in black. Besides I don't need fancy colors, so if some basic ones (as red, yellow, etc) are predefined it is perfect for me.
Any ideas ? Thanks
|
|
|
|
Powered by
FUDForum. Page generated in 0.01920 seconds