title: JADE ContractNet and GUI problems
body: <p>I have some problems with use of <strong><em>ContractNet</em> (Interaction Protocol) and GUI</strong> with the use of <strong>JADE multiagent framework</strong>.</p>
  
  <p>In particular, in the override of <strong><em>handlePropose</em></strong> method.
  I know that my problem comes from the use of a GUI. Let me explain: </p>
  
  <blockquote>
    <p>My agent (Initiator) uses a first GUI and, after a click, the
    conversation begins with a second agent (Responder). According to the
    Protocol, the Initiator has thus sent a CFP to Responder. The agent
    Responder responds with a PROPOSE that contains different data.</p>
  </blockquote>
  
  <p>Since here, everything ok. Now... </p>
  
  <blockquote>
    <p>I wish that the agent Initiator, BEFORE returning a reply, may examine
    the data ... ie publish them on a JTable, for the user! The user will
    examine the proposal via GUI and will choose if to accept or not, by
    click on a button.</p>
    
    <ul>
    <li>If accept, the Initiator send ACCEPT_PROPOSAL.</li>
    <li>If not accept, the Initiator send REJECT_PROPOSAL.</li>
    </ul>
  </blockquote>
  
  <p>This should be done in the method <strong>handleProposal</strong>. This is my code:</p>
  
  <pre><code>@Override
  protected void handlePropose(final ACLMessage propose, final Vector acceptances) {
      try {
          System.out.println("Agent "+getLocalName()
              +": receive PROPOSE from "+propose.getSender().getLocalName());
  
          final ACLMessage reply = propose.createReply();
  
          Vector&lt;Goods&gt; goods = (Vector&lt;Goods&gt;) propose.getContentObject();
  
          // the JTable's GUI for visualize the list of data:
          final GoodsChoiceBox gcb = new GoodsChoiceBox(propose.getSender().getName(), goods);
  
          // the problem:
          gcb.getExecuteJButton().addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                 reply.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
                 System.out.println("Agent "+getLocalName()+": send ACCEPT PROPOSAL ");
                 acceptances.addElement(reply);
              }
          });
  
          // similar case, but for REJECT:
          // gcb.getAbortJButton().addActionListener(... bla bla
  
          gcb.setVisible(true);
  
      } catch (UnreadableException e){
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>..... But, obviously, does not work.</p>
  
  <p>In the Initiator agent, the ContractNet behaviour is aborted... so also handleInform, handleRefuse and handleFailure (for handle the answers) do not work.
  The Initiator's principal GUI is blocked. And other problems...</p>
  
  <p>Instead, if I do this (WITHOUT JButton, another GUI and ActionListener):</p>
  
  <pre><code>@Override
  protected void handlePropose(final ACLMessage propose, final Vector acceptances) {
      try {
          System.out.println("Agent "+getLocalName()
              +": received PROPOSE from "+propose.getSender().getLocalName());
          final ACLMessage reply = propose.createReply();
  
          Vector&lt;Goods&gt; goods = (Vector&lt;Goods&gt;) propose.getContentObject();
  
          // the JTable's GUI for visualize the list of data:
          final GoodsChoiceBox gcb = new GoodsChoiceBox(propose.getSender().getName(), goods);
  
          reply.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
          System.out.println("Agente "+getLocalName()+": ACCEPT PROPOSAL di "+propose.getSender().getLocalName());
          acceptances.addElement(reply);
  
      } catch (UnreadableException e){
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>.... <strong>works</strong>. </p>
  
  <p>I know that the problem is the ActionListener and its multithread nature.
  But I need the GUI there.</p>
  
  <p><strong>How can I fix?</strong></p>