Package jade.gui

Class AclGui

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class AclGui
    extends JPanel
    The AclGui class extends the Swing JPanel class by adding all the controls required to properly edit/show the fields of an an ACL message compliant to the FIPA 97 specs.

    There are basically two ways of using the AclGui class.

    • Non Static Mode. As AclGui extends JPanel, an instance of AclGui can be directly added to whatever Container thus providing an easy way to permanently insert into a GUI a panel for the editing/display of an ACL message.
      The setMsg() and getMsg() methods can be used to display a given ACL message in the panel and to retrieve the ACL message currently displayed.
      The setEnabled() and setSenderEnabled() methods can be used to enable/disable modifications to all fields in the ACL message and/or the sender field respectively.
      E.g.
      This code creates an agent GUI with a panel (in the left part of the GUI) that displays each new message received by the agent .....
      AclGui acl;
      .....
      JFrame agentGui = new JFrame();
      agentGui.getContentPane().setLayout(new BorderLayout());
      acl = new AclGui();
      acl.setEnabled(false);
      agentGui.getContentPane().add("West", acl);
      .....
      Each time a new message is received (assuming the message has been stored in the msg variable of type ACLMessage) acl.setMsg(msg);
    • Static Mode. The AclGui class also provides the editMsgInDialog() and showMsgInDlg() static methods that pop up a temporary dialog window (including an AclGui panel and the proper OK and Cancel buttons) by means of which it is possible to edit and show a given ACL message.
      E.g.
      This code creates a button that allows the user to edit an ACL message by means of a temporary dialog window .....
      ACLMessage msg;
      .....
      JButton b = new JButton("edit");
      b.addActionListener(new ActionListener()
      {
      public void actionPerformed(ActionEvent e)
      {
      msg = AclGui.editMsgInDialog(new ACLMessage("", null);
      }
      } );
    Version:
    $Date$ $Revision$
    Author:
    Giovanni Caire - CSELT
    See Also:
    ACLMessage, Serialized Form
    • Method Detail

      • setMsg

        public void setMsg​(ACLMessage msg)
        Displays the specified ACL message into the AclGui panel
        Parameters:
        msg - The ACL message to be displayed
        See Also:
        getMsg()
      • getMsg

        public ACLMessage getMsg()
        Get the ACL message currently displayed by the AclGui panel
        Returns:
        The ACL message currently displayed by the AclGui panel as an ACLMessage object
        See Also:
        setMsg(ACLMessage msg)
      • setEnabled

        public void setEnabled​(boolean enabledFlag)
        Enables/disables the editability of all the controls in an AclGui panel (default is enabled)
        Overrides:
        setEnabled in class JComponent
        Parameters:
        enabledFlag - If true enables editability
        See Also:
        setSenderEnabled(boolean enabledFlag)
      • setSenderEnabled

        public void setSenderEnabled​(boolean enabledFlag)
        Enables/disables the editability of the sender field of an AclGui panel (default is enabled)
        Parameters:
        enabledFlag - If true enables editability
        See Also:
        setEnabled(boolean enabledFlag)
      • showMsgInDialog

        public static void showMsgInDialog​(ACLMessage msg,
                                           Frame parent)
        Pops up a dialog window including an editing-disabled AclGui panel and displays the specified ACL message in it.
        Parameters:
        m - The ACL message to be displayed
        parent - The parent window of the dialog window
        See Also:
        editMsgInDialog(ACLMessage msg, Frame parent)
      • editMsgInDialog

        public static ACLMessage editMsgInDialog​(ACLMessage msg,
                                                 Frame parent)
        Pops up a dialog window including an editing-enabled AclGui panel and displays the specified ACL message in it. The dialog window also includes an OK and a Cancel button to accept or discard the performed editing.
        Parameters:
        m - The ACL message to be initially displayed
        parent - The parent window of the dialog window
        Returns:
        The ACL message displayed in the dialog window or null depending on whether the user close the window by clicking the OK or Cancel button
        See Also:
        showMsgInDialog(ACLMessage msg, Frame parent)