Button to minimize Client in V7.7

Hi guys,

The button script (thanks to adamaustin :thumb_left: ) that worked perfectly in V7.6 now fails to work in V7.7

from java.awt import Frame

win = system.gui.getParentWindow(event)
print "got it"
parent = win
while parent is not None:
   win = parent
   parent = win.getParent()
   print ("got another" if parent is not None else "TOP")
win.setState(Frame.ICONIFIED)

The Error that comes up

[quote]Traceback (most recent call last):
File “event:mousePressed”, line 7, in
java.lang.ClassCastException: com.inductiveautomation.ignition.client.launch.BootstrapSwingFS cannot be cast to javax.swing.JComponent

at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.hasCustomFunction(PyComponentWrapper.java:186)

at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.__findattr_ex__(PyComponentWrapper.java:113)

at org.python.core.PyObject.__getattr__(PyObject.java:923)

at org.python.pycode._pyx9.f$0(<event:mousePressed>:9)

at org.python.pycode._pyx9.call_function(<event:mousePressed>)

at org.python.core.PyTableCode.call(PyTableCode.java:165)

at org.python.core.PyCode.call(PyCode.java:18)

at org.python.core.Py.runCode(Py.java:1275)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:568)

at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:168)

at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:265)

at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)

at com.sun.proxy.$Proxy21.mousePressed(Unknown Source)

at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)

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$200(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$1.doIntersectionPrivilege(Unknown Source)

at java.security.ProtectionDomain$1.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$1.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)

java.lang.ClassCastException: java.lang.ClassCastException: com.inductiveautomation.ignition.client.launch.BootstrapSwingFS cannot be cast to javax.swing.JComponent

at org.python.core.Py.JavaError(Py.java:495)
at org.python.core.PyTableCode.call(PyTableCode.java:168)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:568)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:168)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:265)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at com.sun.proxy.$Proxy21.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
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$200(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$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.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$1.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)

Caused by: java.lang.ClassCastException: com.inductiveautomation.ignition.client.launch.BootstrapSwingFS cannot be cast to javax.swing.JComponent
at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.hasCustomFunction(PyComponentWrapper.java:186)
at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.findattr_ex(PyComponentWrapper.java:113)
at org.python.core.PyObject.getattr(PyObject.java:923)
at org.python.pycode._pyx9.f$0(event:mousePressed:9)
at org.python.pycode._pyx9.call_function(event:mousePressed)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
… 39 more

Ignition v7.7.0 (b2014071516)
Java: Oracle Corporation 1.7.0_67
[/quote]

Not sure if its a Java 8 issue?? :scratch:

Any guidance is appreciated.

Cheers

This looks like a bug in Ignition 7.7. You can get around this by using this code:

from javax.swing import JFrame
from org.python.core import Py
win = system.gui.getParentWindow(event)
while not isinstance(win,JFrame):   
   win = win.getParent()
javaWin = Py.tojava(win,JFrame)
javaWin.setState(JFrame.ICONIFIED)

This is fixed in 7.7.1-rc2

Cool, Thanks guys.