← Back to team overview

sikuli-driver team mailing list archive

[Question #394139]: ExceptionInInitializerError being thrown when creating Screen instance

 

New question #394139 on Sikuli:
https://answers.launchpad.net/sikuli/+question/394139

Hello,

I am new to using sikuli and was able to create 1 project fairly easy with it but now I can't get it to work.  As soon as Screen s = new Screen(); is hit I get the following exception:


Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
	at ControlMeasureCreation.getCoordinates(ControlMeasureCreation.java:20)
	at Toolkit$18.actionPerformed(Toolkit.java:486)
	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.plaf.basic.BasicButtonListener.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$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)
Caused by: java.lang.IllegalThreadStateException: Cannot call method from the event dispatcher thread
	at java.awt.Robot.checkNotDispatchThread(Unknown Source)
	at java.awt.Robot.waitForIdle(Unknown Source)
	at org.sikuli.script.Mouse.move(Mouse.java:345)
	at org.sikuli.script.Mouse.move(Mouse.java:318)
	at org.sikuli.script.Mouse.init(Mouse.java:59)
	at org.sikuli.script.Screen.initScreens(Screen.java:89)
	at org.sikuli.script.Screen.<clinit>(Screen.java:58)
	... 38 more

Here is my code:

import org.junit.Before;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.junit.After;

public class ControlMeasureCreation {

	Toolkit t = new Toolkit();

	@Before
	public void setUp() {

	}

	public void getCoordinates(String coor) {

		Screen s = new Screen();

		Pattern p;

		try {

			p = new Pattern("images/CMCreation/add.png");
			s.find(p.similar(0.95f));
			s.click(p.similar(0.90f));// click add

			p = new Pattern("images/CMCreation/add.png");
			t.lblPassFail.setText("Pass");

		} catch (FindFailed e) {
			t.lblPassFail.setText("Fail");
		}

	}

	@After
	public void tearDown() {

		System.exit(0);

	}

}



I have been unable to find any fixes via google but this site keeps coming up so I'm hoping there is someone that could help me. 

Thank you.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.