2010-09-08 40 views

Trả lời

4

Mẫu mã từ 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 vào liên kết trên để biết thêm chi tiết và cách tiếp cận.

18

Try ...

scala> Console.BLUE 
res0: java.lang.String = 

OK, tốt, văn bản đã đi màu xanh. Thật thà!

scala> Console.YELLOW_B 
res2: java.lang.String = 

Và bạn có thể thấy nền là, um, màu vàng.

7

Chỉ cần để mở rộng câu trả lời từ oxbow_lakes: trong scala 2.9.2 phiên dịch tôi đã in một cách rõ ràng chuỗi BLUE:

scala> println(Console.BLUE + " now it's really blue!") 
Các vấn đề liên quan