This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TextField for a translator

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic