Question: In java I'm making an application that, when activated (if wantCommand = true), it will read what ever key you press it reads and adds it to a string, and then using Java.awt.Graphics, it draws the string to the screen... Can someone help me with the code to getting the String to what you type (and possibly a deleting also in case you messed up what you were typing)
Here is what I have so far:

```
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);
        }
    }
}

```

Answer: 
You appear to have a long way to go. You need:

* Most importantly a GUI, preferably Swing and not AWT, so that your key presses and String drawing have an application to interact with and display data from.
* A KeyListener attached to a component that has focus. Note that I don't think that Key Bindings would work well for this.
* An JPanel with an overridden `paintComponent(Graphics g)` method.
Try to register a keyPressed event listener to the GUI; the event tells which key got pressed which you can pass around

```
private void formKeyPressed(java.awt.event.KeyEvent evt)                                
{                                    
   System.out.println(evt.getKeyChar());
}         

```