madkit.gui

## Class ConsoleAgent

- java.lang.Object
- - madkit.kernel.AbstractAgent
  - - madkit.gui.ConsoleAgent

- All Implemented Interfaces:
    java.lang.Comparable<AbstractAgent>

      public class ConsoleAgent
      extends AbstractAgent

  This agent displays standard out and err prints in its GUI. This agent is useful when the application is not launched from a command line or an IDE so that the console is not directly visible.
  Since:
    MaDKit 5.0.0.14
  Version:
    0.91
  Author:
    Fabien Michel

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class madkit.kernel.AbstractAgent

      `AbstractAgent.ReturnCode, AbstractAgent.State`

  - ### Field Summary

    - ### Fields inherited from class madkit.kernel.AbstractAgent

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConsoleAgent()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `end()` This method corresponds to the last behavior which is called by the MaDKit kernel.
    `void` | `setupFrame(javax.swing.JFrame frame)` Called when the default GUI mechanism is used upon agent creation.

    - ### Methods inherited from class madkit.kernel.AbstractAgent

      `activate, broadcastMessage, broadcastMessageWithRole, bucketModeCreateGroup, bucketModeRequestRole, checkAgentAddress, compareTo, createGroup, createGroup, createGroup, createGroupIfAbsent, createGroupIfAbsent, createGroupIfAbsent, createGUIOnStartUp, destroyCommunity, destroyGroup, destroyRole, executeThisAgent, executeThisAgent, executeThisAgent, getAgentAddressIn, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getDistantAgentWithRole, getExistingCommunities, getExistingGroups, getExistingRoles, getKernelAddress, getLogger, getMadkitConfig, getMadkitProperty, getMadkitProperty, getMyGroups, getMyRoles, getName, getNetworkID, getOrganizationSnapShot, getReplyTo, getServerInfo, getSimpleNetworkID, getState, hasGUI, hashCode, hasRole, isAlive, isCommunity, isGroup, isKernelOnline, isMadkitPropertyTrue, isMessageBoxEmpty, isRole, killAgent, killAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchNode, launchXmlAgents, leaveGroup, leaveRole, nextMessage, nextMessage, nextMessages, proceedEnumMessage, purgeMailbox, receiveMessage, reload, requestRole, requestRole, sendMessage, sendMessage, sendMessageWithRole, sendMessageWithRole, sendReply, sendReplyWithRole, setLogLevel, setMadkitProperty, setMadkitProperty, setName, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ConsoleAgent

          public ConsoleAgent()

  - ### Method Detail

    - #### setupFrame

          public void setupFrame(javax.swing.JFrame frame)

      Description copied from class: `AbstractAgent`
      Called when the default GUI mechanism is used upon agent creation. This provides an empty frame which will be used as GUI for the agent. The life cycle of the frame is automatically managed: the frame is disposed when the agent is terminated. Some menus are available by default. Default code is only one line: `frame.add(new IOPanel(this));`. Default settings for the frame are:
      - width = 400
      - height = 300
      - location = center of the screen
      - a JMenuBar with: `MadkitMenu`, `AgentMenu` and `AgentLogLevelMenu`
      Overrides:
        `setupFrame` in class `AbstractAgent`
      Parameters:
        `frame` - the default frame which has been created by MaDKit for this agent.
      See Also:
        `OutputPanel`

    - #### end

          protected void end()

      Description copied from class: `AbstractAgent`
      This method corresponds to the last behavior which is called by the MaDKit kernel. This call occurs when a threaded agent normally exits its live method or when the agent is killed. Usually a good place to release taken resources or log what has to be logged. It has to be noted that the kernel automatically takes care of removing the agent from the organizations it is in. However, this cleaning is not logged by the agent. Therefore it could be of interest for the agent to do that itself.

      Here is a typical example:

           @Override
           protected void end()
           {
                  AbstractAgent.ReturnCode returnCode = leaveRole("a community", "a group", "my role");
                  if (returnCode == AbstractAgent.ReturnCode.SUCCESS){
                          if(logger != null)
                                  logger.info("I am leaving the artificial society");
                  }
                  else{
                          if(logger != null)
                                  logger.warning("something wrong when ending, return code is "+returnCode);
                  }
                  if(logger != null)
                          logger.info("I am done");
                  }
           }

      Overrides:
        `end` in class `AbstractAgent`

Fabien Michel, Olivier Gutknecht, Jacques Ferber - November 18 2014