为什么我无法查看前景颜色变化?

时间:2015-07-24 00:03:04

标签: java

Source code (There's many files, can't paste them all here)

GIF of what happens

我正在制作一个快速测试游戏,并正在制作新命令。我的一个命令“清晰”应该是有点花哨的首先让文字变暗,等待一段时间,然后然后清除它。

My Thread.sleep(1000),我用于“等待”,似乎阻止我看到文字变暗。我只是立刻挂了一秒钟,文字就消失了。我的做法有问题吗?

import java.awt.event.*;

public class Listener implements ActionListener {

Primaire runtime;

Listener(Primaire gRuntime) { runtime = gRuntime; }

public void actionPerformed(ActionEvent e) {

    if (e.getSource() == runtime.input) {
        String command = runtime.input.getText().toLowerCase();

        if (command.equals("look"))
        { runtime.say(runtime.moniteur.surroundings); }

        else if (command.equals("repeat"))
        { runtime.say(runtime.moniteur.levelInfo); }

        else if (command.equals("clear")) {

            try {
                runtime.input.setText("");
                runtime.output.setForeground(new java.awt.Color(80, 80, 80));
                Thread.sleep(1000);
                runtime.output.setText("");
                runtime.output.setForeground(new java.awt.Color(160, 160, 160));
            }   

            catch (InterruptedException ez) { }
        }

        else if (command.equals("")) {

        }

        else if (command.equals("")) {

        }

        runtime.input.setText("");
        runtime.input.requestFocus();
    }

}

}

0 个答案:

没有答案