aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes TextField & TextArea problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TextField & TextArea problem" Watch "TextField & TextArea problem" New topic
Author

TextField & TextArea problem

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am working on program that uses a text box to intally show text and another text box that allows the user to enter in the same text. Now if the user enters in somthing different in the input text box to the first text box the progran flags this as an error. This program in a nutshell is a 'Typing Teacher' program.
THE PROBLEM:
The problem is how do I show this error. What I want the text box to do is set the background colour to red BUT ONLY ON THE MISPELT WORD and not the entire text box.I know the alogorithim to do this its just making the text box highlight one word. I would be so, so grateful if some one could shed some light on this problem.
many thanx...
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
There are three methods that you'll need to use:
setSelectionStart()
setSelectionEnd()
setSelectionColor()
If you know where the word is in the string of text (and I understand from your post that you do), just set the selection start so that it's just before the word, and the selection end so that it's just after the word. Set the color you want the selection to be (this only needs to be done once for the whole JTextArea/Field), and you're good! .
Originally posted by John Howard:
I am working on program that uses a text box to intally show text and another text box that allows the user to enter in the same text. Now if the user enters in somthing different in the input text box to the first text box the progran flags this as an error. This program in a nutshell is a 'Typing Teacher' program.
THE PROBLEM:
The problem is how do I show this error. What I want the text box to do is set the background colour to red BUT ONLY ON THE MISPELT WORD and not the entire text box.I know the alogorithim to do this its just making the text box highlight one word. I would be so, so grateful if some one could shed some light on this problem.
many thanx...


There's nothing more dangerous than a resourceful idiot. ---Dilbert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TextField & TextArea problem
 
Similar Threads
How to remove selection of initialValue in JOptionPane
Show default text in PasswordTextBox.
how to implement an auto-suggest feature with Struts
Struts2 tree filter
YUI Autocomplete with XML and JSP