Hey,
I created an JFrame GUI for my Strategy and want to create an Order when I press a button. But for some reason the order creation wont work when I put it into my ActionListener. My ActionListener works fine and the Order creation also works when i put it somewhere else, as for example directly into my onStart method. I only get problems when I put the Order creation into my Action Listener. The program will start but when I press the button I get this error message:
com.dukascopy.api.JFException: Incorrect thread
at com.dukascopy.api.impl.connect.validation.OrderValidator.validateOrderParameters(OrderValidator.java:115)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:116)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:262)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:267)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:272)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:282)
at com.dukascopy.api.impl.connect.JForexEngineImpl.submitOrder(JForexEngineImpl.java:287)
at singlejartest.Strategy$MeinHandler.actionPerformed(Strategy.java:70)
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$400(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 ActionListener:
private class MeinHandler implements ActionListener{
@Override
public void actionPerformed(ActionEvent event){
if(event.getSource()==buybtn)
{
try {
order = engine.submitOrder("Order" + System.currentTimeMillis(), Instrument.EURUSD, OrderCommand.BUY, 0.001);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Can somebody tell me what the problem is and how to fix it?