?
Solved

Realtime text in Java

Posted on 2003-03-15
6
Medium Priority
?
166 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:ghat1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 8145867
add a listender to the text field and update the display whenever the text entered changes.
0
 

Author Comment

by:ghat1
ID: 8145977
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?
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 8147993
Either:

1. add a keylistener to your canvas and process events accordingly, or

2. adding a transparent textfield to your canvas could work for entering the data, but then once the data is entered what to do then.

I think 1. is the way to go.
0
 

Expert Comment

by:CleanupPing
ID: 9058667
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.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9726494
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question