Link to home
Start Free TrialLog in
Avatar of ghat1
ghat1

asked on

Realtime text in Java

Hi,
I have written a drawing applet (somewhat like paintbrush). I would like to add real-time text typing to it i.e. the user should be able to click anywhere on the screen and type text on it character by character and see it simultaneously.

Currently, I am using a seperate dialog box that lets the user type in the text in a textfield, and the whole string is displayed on the string at a mouseclick using Graphics.drawString.

Any help is greatly appreciated.

Thanks,
Brian
Avatar of Mick Barry
Mick Barry
Flag of Australia image

add a listender to the text field and update the display whenever the text entered changes.
Avatar of ghat1
ghat1

ASKER

I want to remove the dialog box completely. The user should be able to click at any location on the applet screen and begin typing at that coordinate (I dont care about the font). It would be nice to have a blinking cursor too...but thats wishful thinking. I tried calling drawstring on every keyTyped event, but enabling backspace in this case would require redrawing the entire applet.

Is there a way to add a transparent JTextfield upon every mousePressed at that coordinate?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ghat1:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept objects' comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer