Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Realtime text in Java

Posted on 2003-03-15
6
Medium Priority
?
167 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
5 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

564 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