# java.awt.Paint error on vision window open in designer

**URL:** <https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054>\
**Category:** Ignition\
**Created:** [February 20, 2018, 4:37pm UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054 "2018-02-20T16:37:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 20, 2018, 4:37pm UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/1 "2018-02-20T16:37:33Z")

</div>

Whenever I open a vision window(with objects on it) in the designer I receive the following error.

I am not certain what is causing it any guidance on where to look would be greatly appreciated.

```auto
java.lang.ClassCastException: Unable to create new interface java.awt.Paint. java.awt.Paint
	at com.inductiveautomation.ignition.common.TypeUtilities$DefaultClassInitializer.createNew(TypeUtilities.java:1663)
	at com.inductiveautomation.ignition.common.TypeUtilities.getInitValueForClass(TypeUtilities.java:1613)
	at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.setQValue(AbstractPropertyAdapter.java:216)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.setQValue(SimpleBoundTagAdapter.java:245)
	at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.updateValue(AbstractPropertyAdapter.java:262)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.notifyTagChanged(SimpleBoundTagAdapter.java:498)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.tagChanged(SimpleBoundTagAdapter.java:487)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager$TagChangeListenerProxy.tagChanged(DatasourceTagManager.java:1108)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager.subscribe(DatasourceTagManager.java:299)
	at com.inductiveautomation.ignition.client.sqltags.impl.ClientTagManagerImpl.subscribe(ClientTagManagerImpl.java:422)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.startup(SimpleBoundTagAdapter.java:140)
	at com.inductiveautomation.factorypmi.application.binding.DefaultInteractionController.startupAdapters(DefaultInteractionController.java:332)
	at com.inductiveautomation.factorypmi.application.FPMIWindow.startup(FPMIWindow.java:348)
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace$DesigntimeWindowOpener.openWindow(WindowWorkspace.java:3575)
	at com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace.openWindow(WindowWorkspace.java:1333)
	at com.inductiveautomation.factorypmi.designer.workspace.StartupPanel$ResourceThumbnail.onClick(StartupPanel.java:339)
	at com.inductiveautomation.factorypmi.designer.workspace.StartupPanel$ThumbnailButton$1.mouseClicked(StartupPanel.java:244)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.9.3 (b2017060210)
Java: Oracle Corporation 1.8.0_74

```

---

<div class="post-metadata">

**Author:** ![abiesbiogas](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@abiesbiogas](https://forum.inductiveautomation.com/u/abiesbiogas)\
**Post date:** [July 13, 2018, 8:20am UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/2 "2018-07-13T08:20:12Z")

</div>

Hi Irose 🙂,  
did you solve the problem?  
I have the same message and in my opinion is due to a bad conversion from string to color when reading the color value from a tag (string) to assigni it to a component field property, as FillColor.

first error message:

```auto
ClassCastException: Unable to create new interface java.awt.Paint. java.awt.Paint

Ignition v7.9.8 (b2018053113)
Java: Oracle Corporation 1.8.0_172

```

second and following error messages:

```auto
ClassCastException: Cannot coerce string value '-1' into a color

Ignition v7.9.8 (b2018053113)
Java: Oracle Corporation 1.8.0_172

```

---

<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:** [July 13, 2018, 12:22pm UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/3 "2018-07-13T12:22:59Z")

</div>

Tag bindings typically deliver an integer -1 on startup, no matter what they really are, until the first poll for tag values returns. Prior to that first poll, the datatype is unknown, so even datasets and other types will get the -1. Consider using the `toColor()` expression function instead of relying on implicit string-to-color conversion, then you can wrap it in the `try()` function to catch this phenomenon.

---

<div class="post-metadata">

**Author:** ![abiesbiogas](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@abiesbiogas](https://forum.inductiveautomation.com/u/abiesbiogas)\
**Post date:** [July 16, 2018, 1:35pm UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/4 "2018-07-16T13:35:21Z")

</div>

> Tag bindings typically deliver an integer -1 on startup

thank you pturmel 👍 that was sufficent to manage all the possible cases

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 16, 2018, 5:38pm UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/5 "2018-07-16T17:38:04Z")

</div>

Thanks for the information pturmel, however, not all of my displays have component scripting on them, and as far as I can tell it doesn’t matter which window I open. There is some tag scripting in the project, but, as far as I understand these scripts should not occur until following startup. Please correct me if I am wrong.

Thanks,

---

<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:** [July 17, 2018, 2:12am UTC](https://forum.inductiveautomation.com/t/java-awt-paint-error-on-vision-window-open-in-designer/17054/6 "2018-07-17T02:12:16Z")

</div>

This is more a problem with tag binding than scripting. It only impacts scripts to the extent that the affected properties have propertyChange scripts.
