# Cannot coerce value '2' into type: interface javax.swing.border.Border

**URL:** <https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [December 31, 2024, 6:40am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330 "2024-12-31T06:40:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anh\_Tran](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Anh\_Tran](https://forum.inductiveautomation.com/u/Anh_Tran)\
**Post date:** [December 31, 2024, 6:40am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/1 "2024-12-31T06:40:35Z")

</div>

"Cannot coerce value '2' into type: interface javax.swing.border.Border"

I tried using the expression for a border appear depending on a condition and I get the above error message. Any idea on how to avoid this error???

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 31, 2024, 9:13am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/2 "2024-12-31T09:13:09Z")

</div>

> [@Anh\_Tran](#):
>
> I tried using the expression for a border appear depending on a condition ,,,

Show us the expression. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<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 3, 2025, 5:46am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/3 "2025-01-03T05:46:14Z")

</div>

You can't use a number for a border. You must use the [toBorder() expression function](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/type-casting/toBorder).

---

<div class="post-metadata">

**Author:** ![Anh\_Tran](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Anh\_Tran](https://forum.inductiveautomation.com/u/Anh_Tran)\
**Post date:** [January 3, 2025, 9:30am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/4 "2025-01-03T09:30:02Z")

</div>

how do i include a tag in it? i seen several example with a tag in toBorder() expression function and tried but not working

---

<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 3, 2025, 10:26am UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/5 "2025-01-03T10:26:30Z")

</div>

What's the tag supposed to do? Can you give me a general description of the conditions, component, and desired border outcome?

---

<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 3, 2025, 1:21pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/6 "2025-01-03T13:21:47Z")

</div>

> [@Anh\_Tran](#):
>
> include a tag in it?

Make a custom property and bind the tag to that. Then use that property in the `toBorder()` expression.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 3, 2025, 2:27pm UTC](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/7 "2025-01-03T14:27:23Z")

</div>

Looks like you're trying to coerce `"2"` to a border instead of `2` but also [^](https://forum.inductiveautomation.com/t/cannot-coerce-value-2-into-type-interface-javax-swing-border-border/100330/3)
