Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java g、 从字符串[]中提取字符串_Java_String_Draw_Arrays - Fatal编程技术网

Java g、 从字符串[]中提取字符串

Java g、 从字符串[]中提取字符串,java,string,draw,arrays,Java,String,Draw,Arrays,我尝试从字符串[]中绘制字符串。这个代码似乎不起作用。应该是某种聊天系统。。我还想知道,这是一个好的还是坏的方式,使聊天系统?例如,是否有更好的方法“清空”零件 导入java.awt.Graphics; 导入javax.swing.ImageIcon; 公共类聊天系统{ 公共静态布尔值ChatOpen=false; 公共静态高度=400; 公共静态宽度=400; 公共静态字符串[]LastWords; 公共静态字符串[]UpdateWords; 公共静态布尔值为空=真; 公共静态void som

我尝试从字符串[]中绘制字符串。这个代码似乎不起作用。应该是某种聊天系统。。我还想知道,这是一个好的还是坏的方式,使聊天系统?例如,是否有更好的方法“清空”零件

导入java.awt.Graphics;
导入javax.swing.ImageIcon;
公共类聊天系统{
公共静态布尔值ChatOpen=false;
公共静态高度=400;
公共静态宽度=400;
公共静态字符串[]LastWords;
公共静态字符串[]UpdateWords;
公共静态布尔值为空=真;
公共静态void someonespeak(字符串字){

对于(int x=0;x为什么不创建一个包含“普通”组件的聊天系统,比如文本的JTextArea?o.o从来没有听说过这种组件xD谢谢..也许我应该试试那个...)谢谢注意,如果你画了一个空字符串,就什么也没有画出来-它不会像你预期的那样覆盖任何现有的像素。@minisurma如果你画的是Swing,我建议你看看这个,菜单可以被看作是所有组件的概览:)@Jack是的,这就是我想要的:D
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));
    }
}
}