If you have played Runescape, you know at the bottom how yuo can enter text in and It would send it to everyone in the game. And it shows the text that other people say below it. How do I accomplish this in my applet? I have tryed keyTyped, but you can erase using backspace ect. And I've Tried using JTextField, but then I can't controle my character. Any Ideas?

Designate a specific key as the "say" key. Then, whenever that key is pressed, set a flag in your key listening class to true. In your keypressed method, check if that flag is set to true, and if it is, send all the keystrokes recieved to a string that will appear on the screen. When the user presses enter, turn your "say" flag back off. You can see this type of behavior in many professional games and it's easy to implement.

I ment, how do I do a box, and still have my gui images behind it. ALSO implement things like backspace, unless you can use JTextField. The only problem with using jtext field is that the controels get messed up, so maby I need to look into the JTextField class more. But, if I do use JTextField, how do I get it to be transparent, so my GUI image can show behind it?

You'll probably need to make a custom component to get the transparency you want. What do you mean by the JTextField making your controls not work? Is it a focus issue, (the text field is taking all the key input and therefore the keys you've specified to control your character aren't being listened to by the game)? Or do you mean that adding the text field to your game is making your gui not appear correctly?

I've tried making a custom component, through lsitening for Character keys instead of the other keys. And it worked. Except I don't know how to code the backspace, to erase the last character. I tried to sue JTextFiedl but, what the problem is, is what you explained. the text field is taking al lthe key input. I looekd up the class/api, but couldn't find anything on making it unfocused. Also, JTextfield is drawn under my GUI, which is drawn in update(). So when every I type, the gui flikers, and I can't see what I'm writing.

Is there any other way to accomplish this? www.miragesource.com ... I'm trying to immatate this. Its written in VB6, thats how they do it, they have controels with all sorts of fancy stuff, but I don't have enoguh money fro vb6, and I'd rather have cross platform and more powerfull thing. If you can help me easier in lvie chat, my AIM is tr00p3er, and my MSN is ryancapote@hotmail.com

If I were in your situation, I would render the text box completely myself, instead of trying to use existing Java components to do the job. While JTextField is very nice for non-game applications, it really isn't meant for what you'd like to do. By actively rendering your text box like whatever else is on your screen, you can have absolute control over where it appears and even give it some transparency if you want to get fancy. Like I said before, designate a "say" key that will send all your key strokes to your text box. To implement back space, all you need to do is get the key code of the KeyEvent that is passed into the keyPressed(KeyEvent) method and check if it is equal to KeyEvent.BACK_SPACE, and then delete the apropriate character from the String in your text box. Here's what I'm thinking:

As for transparency, you could go with a JTextField and use setOpaque(false). This should make it completely transparent.

If you want to have partial opacity (to reduce the contrast of the game content underneath), a custom component will be much easier than JTextField.

In theory you should be able to set a background color with a semitransparent alpha value (such as new Color(255,0,0,128) for a semitransparent red). However, I just tried to do that and it failed - the text field suddenly shows lots of repaint artifacts.

As for the key events, you could do the following: Whenever your game loop gets a KeyEvent and you want that to be processed by the JTextField, retrieve the ActionMap key for that event from the InputMap, then retrieve the Action from the ActionMap and execute the Action:

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org