在 Java Eclipse 控制台中更改颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5757311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change color in java eclipse console
提问by randomUser56789
Is there any way to change text color in eclipse console?
I am not talking about when I go to options and change color from black to for example red.
I mean like when I launch my program and it executes code and at some point it changes color.
For example:
有没有办法在 eclipse 控制台中更改文本颜色?
我不是在谈论何时进入选项并将颜色从黑色更改为例如红色。
我的意思是当我启动我的程序并执行代码时,它会在某些时候改变颜色。
例如:
//code
if (a == 2)
//change text color to red and continue typing in red color
I am not talking about guis jframes etc. I am talking about Eclipse console.
我不是在谈论 guis jframes 等。我在谈论 Eclipse 控制台。
回答by VonC
Probably by using a different org.eclipse.ui.console.MessageConsoleStream, considering that:
可能通过使用不同的org.eclipse.ui.console.MessageConsoleStream,考虑到:
It is ssed to write messages to a message console.
A message console may have more than one stream connected to it.
Each stream may be displayed in a different color
ssed 将消息写入消息控制台。
一个消息控制台可能有多个连接到它的流。
每个流可以用不同的颜色显示
See this thread:
看到这个线程:
IOConsoleOutputStream
has asetColor(Color newColor)
, so I canMessageConsole.getInputStream().setColor(Color newColor)
for each type of message.
IOConsoleOutputStream
有一个setColor(Color newColor)
,所以我可以MessageConsole.getInputStream().setColor(Color newColor)
为每种类型的消息。