aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes TextField for a translator 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 for a translator" Watch "TextField for a translator" New topic
Author

TextField for a translator

Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
Hi there

I am busy writing some translation software for my company and I have run into one requirement from the boss that I am having trouble implementing.

Basically, I am stripping the values out of define statements out of php files and displaying these in textfields in a table. Now, there are pieces in the strings that the user must translate and there are pieces that the translator must leave alone. This is stuff like html formatting and references to other variables. So I want these bits to be in the textfield, but the user cannot edit them. And to go further, I don't want the user to see the exact code, I want them to see a little gray box in the textfield so that the user knows that there is a piece here that must not be translated.

For example in the english value it is:
Rachel is my name.<br> Hello!

On screen I want to show the user (where the _ are boxes)
Rachel is my name._ Hello!

And in the text area for the user to translate it must show
_

So that the user knows to type before and after the box, so that I can preserve the formatting.

Could anyone help me in getting a little gray box in a text field or is there some better approach that I am missing?

Many kind regards,
Rachel
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
I'm not sure if this is possible, but can you put all the bits of text that are to be editable textboxes and the non-editable bits in JLabels or non-editable textfields ? I think that would be easiest.

If you want textboxes that are only part editable you need to write a DocumentFilter. This will help.
You can make your non-editable text appear grey by using the setParagraphAttributes method and the Style & StyleConstants class.

I think the former of these approaches will be much easier.
hth D.
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
DocumentFilter NOOOO!! I've been putting that off for as long as possible!!

Maybe that textfield label combination will work. Maybe i'll make it into a little panel that I shove into the table's cell. Thank goodness it's Friday and I don't actually have to implement this today. But thanks for the suggestions. I'm going to go with this one first and try the DocumentFilter as a last resort.

Thank you once again Almighty Don for saving Rachel from swinging into danger.

May you have a super weekend!
Rachel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TextField for a translator