我有这个GUI程序,我试图基本上复制Windows CMD。由于我在这个程序中有很多功能,我决定将部分代码放在不同的类中。但它没有回应。Java没有从其他类的响应
if(command.size()<2 && command.size()>0) {
switch(command.get(0)) {
case "dt":
getDateTime a = new getDateTime();
a.Start();
break;
// other case(s) down below
}
}
这里是geDateTime类
public class getDateTime {
public static void Start() {
Terminal t = new Terminal();
try {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date date = new Date();
String s = dateFormat.format(date).toString();
t.print(s);
}catch(Exception e){ e.printStackTrace(); }
}
}
这里是打印();在主类...
public static void print(String s) {
Color c = Color.WHITE; // prints white text to JFrame
Style style = output.addStyle("Style", null);
StyleConstants.setForeground(style, c);
try{
document.insertString(document.getLength(), s, style);
}catch(Exception e){e.printStackTrace();}
}
现在,当我输入命令访问getDateTime类,程序冻结,我不能输入任何内容。但是,如果我只是把getDateTime类放入主类的void中,它就可以正常工作;但是这将会是一个问题,因为一些函数可能会有数百行代码,因此将所有内容都放到主类中。
程序死机时不会产生错误。
您可以在pastebin.com上添加终端类的代码吗?您是否尝试过使用调试器? – neowulf33
@ neowulf33 http://pastebin.com/7Z1WuMJF – Arc