Java 错误:未解决的编译问题
这是我的错误代码:Java 错误:未解决的编译问题,java,colors,Java,Colors,这是我的错误代码: Exception in thread "main" : TextAttributes cannot be resolved to a type TextAttributes cannot be resolved to a type Console cannot be resolved to a type at Font.main(Font.java:8) import java.awt.Color; import enigma.console.*; impor
Exception in thread "main" :
TextAttributes cannot be resolved to a type
TextAttributes cannot be resolved to a type
Console cannot be resolved to a type
at Font.main(Font.java:8)
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!");
}
}
不要注意这些评论,它们是错误的。问题不在于您的导入,而在于您的环境。如果在IDE中运行代码,请尝试清理环境。
我只是尝试在控制台中编译和运行您的代码,效果很好。您忘了在代码中导入相关类。您能说出它是哪一个吗?:/<代码>文本属性未导入,也未在导入的包中列出。对于
控制台
类也是如此。查看代码行,可能是您尚未导入的TextAttributes。如果您使用eclipse,请按Ctrl+shit+o组合键来组织imports.texttributes和控制台,如错误消息所示。在修复Eclipse中“Problems”视图中显示的所有错误之前,不要尝试执行代码。