String []中的g.drawstring字符串

时间:2013-12-10 16:48:45

标签: java string draw arrays

我尝试从String []中绘制字符串。这段代码似乎不起作用。它应该是聊天系统的一部分..我也想知道这是不是好的或坏的方式来建立聊天系统?例如,是否有一些更好的方法来“清空”部分?

import java.awt.Graphics;

import javax.swing.ImageIcon;

public class ChatSystem {
public static boolean ChatOpen = false;
public static int ChatHeight = 400;
public static int ChatWidth = 400;
public static String[] LastWords;
public static String[] UpdateWords;
public static boolean empty = true;

public static void SomeOneSpoke(String words){
    for(int x = 0; x<5;x++){
    LastWords[x] = UpdateWords[x];
    LastWords[x+1] = UpdateWords[x];
    LastWords[x] = words;
    }
}

public static void GameText(String words){
    for(int x = 0; x<5;x++){
    LastWords[x] = UpdateWords[x];
    LastWords[x+1] = UpdateWords[x];
    LastWords[x] = words;
    }
}

public void draw(Graphics g) {
    if(empty == true){
        for(int x=0;x<5;x++){
        LastWords[x] = "";  
        }
    }
        g.drawImage(new ImageIcon("pictures/interfaces/Interface1.png").getImage(), 0, Screen.myHeight-ChatHeight, ChatWidth, ChatHeight, null);
        for(int x=0;x<5;x++){
        g.drawString(LastWords[x], 15, (Screen.myHeight-20)-(x*30));
    }
}
}

0 个答案:

没有答案