# Formatted Text Field put text on top left corner in vision

**URL:** <https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715>\
**Category:** General Discussion\
**Tags:** vision, ignition81\
**Created:** [January 18, 2023, 6:58am UTC](https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715 "2023-01-18T06:58:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [January 18, 2023, 6:58am UTC](https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715/1 "2023-01-18T06:58:00Z")

</div>

Hi Guys,

Hope I can get your help.

It is possible to put text in the top left corner of the formatted text field. Currently, I’m using the vision modules so it is possible to do that?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 18, 2023, 9:40am UTC](https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715/2 "2023-01-18T09:40:46Z")

</div>

The FormattedTextField inherits from the [JFormattedTextfield](https://javax.swing.JFormattedTextField) and JTextField classes. Consequently, it doesn't word wrap, and it doesn't have any vertical alignment methods. Expanding it to a height that is greater than one row of text only creates the illusion of a textArea. While it is probably possible to mess with the UI/Layout in some way to create the effect you are after, the end result would still only be the illusion of a text area.

Therefore, I feel that rather than go through all the trouble of forcing the text to vertically align, the simplest approach would be to create the illusion of vertical alignment by nesting a formatted text field into a container with the same background color. The horizontal alignment could be set to LEFT, and textfield could be positioned at the top of the container. Then by simply removing the border of the text field and putting a border around the container, we will have effectively created a text area that doesn't word wrap and has all the features of a FormattedTextField.

**Here is a code example that produces effect described effect:**

```auto
from javax.swing import BorderFactory
formattedTextField = event.source.parent.getComponent('Container').getComponent('Formatted Text Field')
formattedTextField.setHorizontalAlignment(formattedTextField.LEFT)
border = BorderFactory.createEmptyBorder()
formattedTextField.setBorder(border)

```

**Here is the result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/528a0379bafed67ee594f249e119a4352a5c0f7c.png)

* * *

**Here are the container settings:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/b/3b56de8b364d03c9df01ca9fdc5f747439962469.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/73dd206b30c16947ae0267c1c1aa2c037c1cb68a.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 18, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715/3 "2023-01-18T13:27:06Z")

</div>

Perhaps you should just use a text area. Hmm?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [January 18, 2023, 2:09pm UTC](https://forum.inductiveautomation.com/t/formatted-text-field-put-text-on-top-left-corner-in-vision/68715/4 "2023-01-18T14:09:19Z")

</div>

I was curious about the reasons behind this style choice, but I imagined that there must be something that can be done by a formattedTextField that can't be easily done with a text area.
