Javaでは、アクティブ化されたとき(wantCommand = trueの場合)、押したキーを読み取って文字列に追加し、Java.awt.Graphicsを使用して文字列を描画するアプリケーションを作成しています画面... 誰かがあなたが入力したものに文字列を取得するコードを手伝ってくれませんか(そして、あなたが入力していたものを台無しにした場合は削除することもできます)これが私がこれまでに持っているものです:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
public class slashCommand {
public static boolean wantCommand = false;
public static String commandLine = "kill";
public static String getText () {
//get the string in a for loop or something maybe
return commandLine;
}
public static void render(Graphics g) {
if (wantCommand) {
g.setColor(new Color(0, 0, 0, 130));
g.fillRect(Inventory.inv_bag[0].x - 100, Inventory.inv_bag[0].y + 116, Component.size.width, 10);
g.setColor(new Color(255, 255, 255));
g.setFont(new Font("Arial", Font.PLAIN, 10));
g.drawString("/ " + commandLine, Inventory.inv_bag[0].x - 69, Inventory.inv_bag[0].y + 125);
}
}
}