Cizo89
12 years agoFrequent Contributor
Problem with custom JPopupMenu
Hi,
I would like to create a Popup Menu in SoapUI, using the method showPopup in class UISupport.
I have my compiled jar in ext folder, correctly created actions xml file in actions folder, but while trying to invoke it in SoapUI I'm receiving this error message:
Here is my code:
Thanks for help
Regards,
Marek
I would like to create a Popup Menu in SoapUI, using the method showPopup in class UISupport.
I have my compiled jar in ext folder, correctly created actions xml file in actions folder, but while trying to invoke it in SoapUI I'm receiving this error message:
Wed Sep 25 15:51:42 BST 2013:ERROR:java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)
at java.awt.Component.getLocationOnScreen(Unknown Source)
at com.eviware.soapui.support.UISupport.showPopup(UISupport.java:570)
at com.eviware.soapui.support.UISupport$showPopup.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at Framework.SyncAction.perform(SyncAction.groovy:28)
at com.eviware.soapui.support.action.swing.SwingActionDelegate.actionPerformed(SwingActionDelegate.java:89)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(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)
Here is my code:
package Framework
import com.eviware.soapui.model.ModelItem;
import com.eviware.soapui.support.UISupport
import com.eviware.soapui.support.action.support.AbstractSoapUIAction
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.border.BevelBorder;
import java.awt.Point
class SyncAction extends AbstractSoapUIAction{
public SyncAction(){
super( "Synchronize project", "Sync the project with actual resources, scripts and DataSources" )
}
public void perform( ModelItem target, Object param ){
JPopupMenu popup = new JPopupMenu("Test Popup Menu")
JMenuItem item = new JMenuItem("TestItem")
item.setHorizontalTextPosition(JMenuItem.RIGHT)
popup.add(item)
popup.setBorder(new BevelBorder(BevelBorder.RAISED))
UISupport.showPopup(popup, UISupport.createEmptyPanel(100, 100, 100, 100), new Point())
}
}
Thanks for help
Regards,
Marek